org.apache.shiro.authc
Class SimpleAuthenticationInfo

java.lang.Object
  extended by org.apache.shiro.authc.SimpleAuthenticationInfo
All Implemented Interfaces:
Serializable, AuthenticationInfo, MergableAuthenticationInfo

public class SimpleAuthenticationInfo
extends Object
implements MergableAuthenticationInfo

Simple implementation of the MergableAuthenticationInfo interface that holds the principals and credentials.

Since:
0.9
Author:
Jeremy Haile, Les Hazlewood
See Also:
AuthenticatingRealm, Serialized Form

Field Summary
protected  Object credentials
          The credentials verifying the account principals.
protected  PrincipalCollection principals
          The principals identifying the account associated with this AuthenticationInfo instance.
 
Constructor Summary
SimpleAuthenticationInfo()
          Default no-argument constructor.
SimpleAuthenticationInfo(Object principal, Object credentials, String realmName)
          Constructor that takes in a single 'primary' principal of the account and its corresponding credentials, associated with the specified realm.
SimpleAuthenticationInfo(PrincipalCollection principals, Object credentials)
          Constructor that takes in an account's identifying principal(s) and its corresponding credentials that verify the principals.
 
Method Summary
 boolean equals(Object o)
          Returns true if the Object argument is an instanceof SimpleAuthenticationInfo and its principals are equal to this instance's principals, false otherwise.
 Object getCredentials()
          Returns the credentials associated with the corresponding Subject.
 PrincipalCollection getPrincipals()
          Returns all principals associated with the corresponding Subject.
 int hashCode()
          Returns the hashcode of the internal principals instance.
 void merge(AuthenticationInfo info)
          Takes the specified info argument and adds its principals and credentials into this instance.
 void setCredentials(Object credentials)
          Sets the credentials that verify the principals/identity of the associated Realm account.
 void setPrincipals(PrincipalCollection principals)
          Sets the identifying principal(s) represented by this instance.
 String toString()
          Simple implementation that merely returns principals.toString()
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

principals

protected PrincipalCollection principals
The principals identifying the account associated with this AuthenticationInfo instance.


credentials

protected Object credentials
The credentials verifying the account principals.

Constructor Detail

SimpleAuthenticationInfo

public SimpleAuthenticationInfo()
Default no-argument constructor.


SimpleAuthenticationInfo

public SimpleAuthenticationInfo(Object principal,
                                Object credentials,
                                String realmName)
Constructor that takes in a single 'primary' principal of the account and its corresponding credentials, associated with the specified realm.

This is a convenience constructor and will construct a PrincipalCollection based on the principal and realmName argument.

Parameters:
principal - the 'primary' principal associated with the specified realm.
credentials - the credentials that verify the given principal.
realmName - the realm from where the principal and credentials were acquired.

SimpleAuthenticationInfo

public SimpleAuthenticationInfo(PrincipalCollection principals,
                                Object credentials)
Constructor that takes in an account's identifying principal(s) and its corresponding credentials that verify the principals.

Parameters:
principals - a Realm's account's identifying principal(s)
credentials - the accounts corresponding principals that verify the principals.
Method Detail

getPrincipals

public PrincipalCollection getPrincipals()
Description copied from interface: AuthenticationInfo
Returns all principals associated with the corresponding Subject. Each principal is an identifying piece of information useful to the application such as a username, or user id, a given name, etc - anything useful to the application to identify the current Subject.

The returned PrincipalCollection should not contain any credentials used to verify principals, such as passwords, private keys, etc. Those should be instead returned by getCredentials().

Specified by:
getPrincipals in interface AuthenticationInfo
Returns:
all principals associated with the corresponding Subject.

setPrincipals

public void setPrincipals(PrincipalCollection principals)
Sets the identifying principal(s) represented by this instance.

Parameters:
principals - the indentifying attributes of the corresponding Realm account.

getCredentials

public Object getCredentials()
Description copied from interface: AuthenticationInfo
Returns the credentials associated with the corresponding Subject. A credential verifies one or more of the principals associated with the Subject, such as a password or private key. Credentials are used by Shiro particularly during the authentication process to ensure that submitted credentials during a login attempt match exactly the credentials here in the AuthenticationInfo instance.

Specified by:
getCredentials in interface AuthenticationInfo
Returns:
the credentials associated with the corresponding Subject.

setCredentials

public void setCredentials(Object credentials)
Sets the credentials that verify the principals/identity of the associated Realm account.

Parameters:
credentials - attribute(s) that verify the account's identity/principals, such as a password or private key.

merge

public void merge(AuthenticationInfo info)
Takes the specified info argument and adds its principals and credentials into this instance.

Specified by:
merge in interface MergableAuthenticationInfo
Parameters:
info - the AuthenticationInfo to add into this instance.

equals

public boolean equals(Object o)
Returns true if the Object argument is an instanceof SimpleAuthenticationInfo and its principals are equal to this instance's principals, false otherwise.

Overrides:
equals in class Object
Parameters:
o - the object to compare for equality.
Returns:
true if the Object argument is an instanceof SimpleAuthenticationInfo and its principals are equal to this instance's principals, false otherwise.

hashCode

public int hashCode()
Returns the hashcode of the internal principals instance.

Overrides:
hashCode in class Object
Returns:
the hashcode of the internal principals instance.

toString

public String toString()
Simple implementation that merely returns principals.toString()

Overrides:
toString in class Object
Returns:
principals.toString()


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.