public SmsAuthenticationToken(Object principal, Collection<? extends GrantedAuthority> authorities) { super(authorities); this.principal = principal; super.setAuthenticated(true); // must use super, as we override }
/** * Copies the authentication details from a source Authentication object to a * destination one, provided the latter does not already have one set. * * @param source source authentication * @param dest the destination authentication object */ private void copyDetails(Authentication source, Authentication dest) { if ((dest instanceof AbstractAuthenticationToken) && (dest.getDetails() == null)) { AbstractAuthenticationToken token = (AbstractAuthenticationToken) dest; token.setDetails(source.getDetails()); } }
@Override public void eraseCredentials() { super.eraseCredentials(); credentials = null; } }
@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; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; }
@Override public String toString() { return "[" + super.toString() + ", attributes : " + attributes + "]"; } }
@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 int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; } }
@Override public String toString() { StringBuilder sb = new StringBuilder(super.toString()); String className = this.originalAuthentication == null ? null : this.originalAuthentication.getName(); sb.append("; Original Class: ").append(className); return sb.toString(); } }
/** * This constructor should only be used by <code>AuthenticationManager</code> or * <code>AuthenticationProvider</code> implementations that are satisfied with * producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>) * authentication token. * * @param principal * @param credentials * @param authorities */ public UsernamePasswordAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { super(authorities); this.principal = principal; this.credentials = credentials; super.setAuthenticated(true); // must use super, as we override }
/** * Copies the authentication details from a source Authentication object to a * destination one, provided the latter does not already have one set. * * @param source source authentication * @param dest the destination authentication object */ private void copyDetails(Authentication source, Authentication dest) { if ((dest instanceof AbstractAuthenticationToken) && (dest.getDetails() == null)) { AbstractAuthenticationToken token = (AbstractAuthenticationToken) dest; token.setDetails(source.getDetails()); } }
@Override public void eraseCredentials() { super.eraseCredentials(); } }
@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 int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append(" Assertion: ").append(this.assertion); sb.append(" Credentials (Service/Proxy Ticket): ").append(this.credentials); return (sb.toString()); } }
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); }
/** * Default implementation returns the user authentication associated with the auth token, if the token is provided. Otherwise, the consumer authentication * is returned. * * @param request The request that was successfully authenticated. * @param authentication The consumer authentication (details about how the request was authenticated). * @param authToken The OAuth token associated with the authentication. This token MAY be null if no authenticated token was needed to successfully * authenticate the request (for example, in the case of 2-legged OAuth). * @return The authentication. */ public Authentication createAuthentication(HttpServletRequest request, ConsumerAuthentication authentication, OAuthAccessProviderToken authToken) { if (authToken != null) { Authentication userAuthentication = authToken.getUserAuthentication(); if (userAuthentication instanceof AbstractAuthenticationToken) { //initialize the details with the consumer that is actually making the request on behalf of the user. ((AbstractAuthenticationToken) userAuthentication).setDetails(new OAuthAuthenticationDetails(request, authentication.getConsumerDetails())); } return userAuthentication; } return authentication; } }
@Override public void eraseCredentials() { super.eraseCredentials(); credentials = null; } }
@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; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + this.keyHash; return result; } }