Package org.apache.shiro.authc
Interface AuthenticationInfo
-
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
Account,MergableAuthenticationInfo,SaltedAuthenticationInfo
- All Known Implementing Classes:
SimpleAccount,SimpleAuthenticationInfo
public interface AuthenticationInfo extends Serializable
AuthenticationInforepresents a Subject's (aka user's) stored account information relevant to the authentication/log-in process only. It is important to understand the difference between this interface and theAuthenticationTokeninterface.AuthenticationInfoimplementations represent already-verified and stored account data, whereas anAuthenticationTokenrepresents data submitted for any given login attempt (which may or may not successfully match the verified and stored accountAuthenticationInfo). Because the act of authentication (log-in) is orthogonal to authorization (access control), this interface is intended to represent only the account data needed by Shiro during an authentication attempt. Shiro also has a parallelAuthorizationInfointerface for use during the authorization process that references access control data such as roles and permissions. But because many if not mostRealms store both sets of data for a Subject, it might be convenient for aRealmimplementation to utilize an implementation of theAccountinterface instead, which is a convenience interface that combines bothAuthenticationInfoandAuthorizationInfo. Whether you choose to implement these two interfaces separately or implement the oneAccountinterface for a givenRealmis entirely based on your application's needs or your preferences.Please note: Since Shiro sometimes logs authentication operations, please ensure your AuthenticationInfo's
toString()implementation does not print out account credentials (password, etc), as these might be viewable to someone reading your logs. This is good practice anyway, and account credentials should rarely (if ever) be printed out for any reason. If you're using Shiro's default implementations of this interface, they only ever print the accountprincipals, so you do not need to do anything additional.- Since:
- 0.9
- See Also:
AuthorizationInfo,Account
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectgetCredentials()Returns the credentials associated with the corresponding Subject.PrincipalCollectiongetPrincipals()Returns all principals associated with the corresponding Subject.
-
-
-
Method Detail
-
getPrincipals
PrincipalCollection getPrincipals()
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 currentSubject. The returned PrincipalCollection should not contain any credentials used to verify principals, such as passwords, private keys, etc. Those should be instead returned bygetCredentials().- Returns:
- all principals associated with the corresponding Subject.
-
getCredentials
Object getCredentials()
Returns the credentials associated with the corresponding Subject. A credential verifies one or more of theprincipalsassociated 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 theAuthenticationInfoinstance.- Returns:
- the credentials associated with the corresponding Subject.
-
-