@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } if (obj instanceof RememberMeAuthenticationToken) { RememberMeAuthenticationToken test = (RememberMeAuthenticationToken) obj; if (this.getKeyHash() != test.getKeyHash()) { return false; } return true; } return false; }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { throw new AuthenticationServiceException("Cannot authenticate " + authentication); } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; }
private Authentication getAuthentication() { UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( "Principal", "Credentials"); authentication.setDetails("127.0.0.1"); return authentication; }
/** * Creates the server-side authentication request object. */ protected Authentication createAuthenticationRequest(String principal, String credentials) { return new UsernamePasswordAuthenticationToken(principal, credentials); } }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { return authenticationManager.authenticate(authentication); }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (supports(authentication.getClass())) { return authentication; } else { throw new AuthenticationServiceException("Don't support this class"); } }
private Authentication createAuthenticatedPrincipal() { TestingAuthenticationToken authentication = new TestingAuthenticationToken(this.principalName, "password"); authentication.setAuthenticated(true); return authentication; }
/** * Verify (via {@link AuthenticationTrustResolver}) that the given authentication is not anonymous. * @param authentication to be checked * @return <code>true</code> if not anonymous, otherwise <code>false</code>. */ private boolean isNotAnonymous(Authentication authentication) { return !authTrustResolver.isAnonymous(authentication); }
@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } if (obj instanceof AnonymousAuthenticationToken) { AnonymousAuthenticationToken test = (AnonymousAuthenticationToken) obj; if (this.getKeyHash() != test.getKeyHash()) { return false; } return true; } return false; }
@Override public void eraseCredentials() { super.eraseCredentials(); credentials = null; } }
/** * Checks the {@code credentials}, {@code principal} and {@code details} objects, * invoking the {@code eraseCredentials} method on any which implement * {@link CredentialsContainer}. */ public void eraseCredentials() { eraseSecret(getCredentials()); eraseSecret(getPrincipal()); eraseSecret(details); }
@Override public String toString() { return "[" + super.toString() + ", attributes : " + attributes + "]"; } }
public TestingAuthenticationToken(Object principal, Object credentials, List<GrantedAuthority> authorities) { super(authorities); this.principal = principal; this.credentials = credentials; setAuthenticated(true); }
/** * This constructor can be safely used by any code that wishes to create a * <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()} * will return <code>false</code>. * */ public UsernamePasswordAuthenticationToken(Object principal, Object credentials) { super(null); this.principal = principal; this.credentials = credentials; setAuthenticated(false); }
/** * Constructor. * * @param key to identify if this object made by an authorised client * @param principal the principal (typically a <code>UserDetails</code>) * @param authorities the authorities granted to the principal * @throws IllegalArgumentException if a <code>null</code> was passed */ public AnonymousAuthenticationToken(String key, Object principal, Collection<? extends GrantedAuthority> authorities) { this(extractKeyHash(key), principal, authorities); }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { ((TestingAuthenticationToken) authentication).setDetails(resultDetails); return authentication; }
private Authentication getAuthentication() { UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( "Principal", "Credentials"); authentication.setDetails("127.0.0.1"); return authentication; }
private Authentication createAuthenticatedPrincipal() { TestingAuthenticationToken authentication = new TestingAuthenticationToken(this.principalName, "password"); authentication.setAuthenticated(true); return authentication; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; } }