Spring Security Framework

org.springframework.security.adapters
Class AbstractAdapterAuthenticationToken

java.lang.Object
  extended by org.springframework.security.providers.AbstractAuthenticationToken
      extended by org.springframework.security.adapters.AbstractAdapterAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, AuthByAdapter, Authentication
Direct Known Subclasses:
PrincipalSpringSecurityUserToken

public abstract class AbstractAdapterAuthenticationToken
extends AbstractAuthenticationToken
implements AuthByAdapter

Convenience superclass for AuthByAdapter implementations.

Version:
$Id$
Author:
Ben Alex
See Also:
Serialized Form

Constructor Summary
protected AbstractAdapterAuthenticationToken()
           
protected AbstractAdapterAuthenticationToken(String key, GrantedAuthority[] authorities)
          The only way an AbstractAdapterAuthentication should be constructed.
 
Method Summary
 boolean equals(Object obj)
           
 int getKeyHash()
          Returns the hash code of the key that was passed to the constructor of the AuthByAdapter implementation.
 boolean isAuthenticated()
          Always returns true.
 boolean isUserInRole(String role)
          Iterates the granted authorities and indicates whether or not the specified role is held.
 void setAuthenticated(boolean ignored)
          Setting is ignored.
 
Methods inherited from class org.springframework.security.providers.AbstractAuthenticationToken
getAuthorities, getDetails, getName, hashCode, setDetails, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.security.Authentication
getAuthorities, getCredentials, getDetails, getPrincipal
 
Methods inherited from interface java.security.Principal
getName, hashCode, toString
 

Constructor Detail

AbstractAdapterAuthenticationToken

protected AbstractAdapterAuthenticationToken()

AbstractAdapterAuthenticationToken

protected AbstractAdapterAuthenticationToken(String key,
                                             GrantedAuthority[] authorities)
The only way an AbstractAdapterAuthentication should be constructed.

Parameters:
key - the key that is hashed and made available via getKeyHash()
authorities - the authorities granted to this principal
Method Detail

equals

public boolean equals(Object obj)
Specified by:
equals in interface Principal
Overrides:
equals in class AbstractAuthenticationToken

getKeyHash

public int getKeyHash()
Description copied from interface: AuthByAdapter
Returns the hash code of the key that was passed to the constructor of the AuthByAdapter implementation. The implementation should convert the value to a hash code at construction time, rather than storing the key itself.

Specified by:
getKeyHash in interface AuthByAdapter
Returns:
the hash code of the key used when the object was created.

isAuthenticated

public boolean isAuthenticated()
Always returns true.

Specified by:
isAuthenticated in interface Authentication
Overrides:
isAuthenticated in class AbstractAuthenticationToken
Returns:
DOCUMENT ME!

isUserInRole

public boolean isUserInRole(String role)
Iterates the granted authorities and indicates whether or not the specified role is held.

Comparison is based on the String returned by GrantedAuthority.getAuthority().

Parameters:
role - the role being searched for in this object's granted authorities list
Returns:
true if the granted authority is held, or false otherwise

setAuthenticated

public void setAuthenticated(boolean ignored)
Setting is ignored. Always considered authenticated.

Specified by:
setAuthenticated in interface Authentication
Overrides:
setAuthenticated in class AbstractAuthenticationToken
Parameters:
ignored - DOCUMENT ME!

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.