org.acegisecurity.adapters
Class AbstractAdapterAuthenticationToken

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

public abstract class AbstractAdapterAuthenticationToken
extends AbstractAuthenticationToken
implements AuthByAdapter

Convenience superclass for AuthByAdapter implementations.

Version:
$Id: AbstractAdapterAuthenticationToken.java,v 1.5 2005/11/17 00:55:49 benalex Exp $
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)
           
 GrantedAuthority[] getAuthorities()
          Set by an AuthenticationManager to indicate the authorities that the principal has been granted.
 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.acegisecurity.providers.AbstractAuthenticationToken
getDetails, getName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.acegisecurity.Authentication
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

setAuthenticated

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

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

isAuthenticated

public boolean isAuthenticated()
Always returns true.

Specified by:
isAuthenticated in interface Authentication
Returns:
DOCUMENT ME!

getAuthorities

public GrantedAuthority[] getAuthorities()
Description copied from interface: Authentication
Set by an AuthenticationManager to indicate the authorities that the principal has been granted. Note that classes should not rely on this value as being valid unless it has been set by a trusted AuthenticationManager.

Specified by:
getAuthorities in interface Authentication
Returns:
the authorities granted to the principal, or null if authentication has not been completed

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.

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

equals

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


Copyright © 2004-2005 Acegi Technology Pty Limited. All Rights Reserved.