package com.pollex.pam.security.token; import com.pollex.pam.business.web.vm.OtpAccount; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.core.SpringSecurityCoreVersion; import org.springframework.util.Assert; public class OtpAuthenticationToken extends AbstractAuthenticationToken { private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; private transient 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; } }