for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
package unicon.matthews.admin;
import java.util.Collection;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
public class AdminUserAuthenticationToken extends AbstractAuthenticationToken {
private static final long serialVersionUID = 1L;
private final Object principal;
principal
private Object credentials;
credentials
public AdminUserAuthenticationToken(Object principal, Object credentials) {
super(null);
this.principal = principal;
this.credentials = credentials;
setAuthenticated(false);
}
public AdminUserAuthenticationToken(Object principal, Object credentials,
Collection<? extends GrantedAuthority> authorities) {
super(authorities);
super.setAuthenticated(true); // must use super, as we override
@Override
public Object getCredentials() {
return this.credentials;
public Object getPrincipal() {
return this.principal;
public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
if (isAuthenticated) {
throw new IllegalArgumentException(
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
super.setAuthenticated(false);
public void eraseCredentials() {
super.eraseCredentials();
credentials = null;