package com.pollex.pam.security.token;
|
|
import com.pollex.pam.web.rest.vm.OtpAccount;
|
import org.springframework.security.authentication.AbstractAuthenticationToken;
|
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.SpringSecurityCoreVersion;
|
import org.springframework.util.Assert;
|
|
import java.util.Collection;
|
|
public class OtpAuthenticationToken extends AbstractAuthenticationToken {
|
|
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
|
private final OtpAccount principle;
|
private String credentials;
|
|
public OtpAuthenticationToken(OtpAccount principle, String credentials) {
|
super(null);
|
this.principle = principle;
|
this.credentials = credentials;
|
setAuthenticated(false);
|
}
|
|
@Override
|
public String getCredentials() {
|
return this.credentials;
|
}
|
|
@Override
|
public OtpAccount getPrincipal() {
|
return this.principle;
|
}
|
|
@Override
|
public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
|
Assert.isTrue(!isAuthenticated,
|
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
|
super.setAuthenticated(false);
|
}
|
|
@Override
|
public void eraseCredentials() {
|
super.eraseCredentials();
|
this.credentials = null;
|
}
|
}
|