Class SimpleCredentialsMatcher
- All Implemented Interfaces:
CredentialsMatcher
- Direct Known Subclasses:
HashedCredentialsMatcher
Object.equals comparison.
Hashing comparisons (the most common technique used in secure applications) are not supported by this class, but
instead by the HashedCredentialsMatcher.
- Since:
- 0.9
- See Also:
-
Field Summary
Fields inherited from class org.apache.shiro.lang.codec.CodecSupport
PREFERRED_ENCODING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandoCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) This implementation acquires thetoken's credentials (viagetCredentials(token)) and then theaccount's credentials (viagetCredentials(account)) and then passes both of them to theequals(tokenCredentials, accountCredentials)method for equality comparison.protected booleanReturnstrueif thetokenCredentialsargument is logically equal to theaccountCredentialsargument.protected ObjectReturns theaccount's credentials.protected ObjectReturns thetoken's credentials.Methods inherited from class org.apache.shiro.lang.codec.CodecSupport
isByteSource, objectToBytes, objectToString, toBytes, toBytes, toBytes, toBytes, toBytes, toBytes, toBytes, toChars, toChars, toString, toString, toString
-
Constructor Details
-
SimpleCredentialsMatcher
public SimpleCredentialsMatcher()
-
-
Method Details
-
getCredentials
Returns thetoken's credentials.This default implementation merely returns
authenticationToken.getCredentials()and exists as a template hook if subclasses wish to obtain the credentials in a different way or convert them to a different format before returning.- Parameters:
token- theAuthenticationTokensubmitted during the authentication attempt.- Returns:
- the
token's associated credentials.
-
getCredentials
Returns theaccount's credentials.This default implementation merely returns
account.getCredentials()and exists as a template hook if subclasses wish to obtain the credentials in a different way or convert them to a different format before returning.- Parameters:
info- theAuthenticationInfostored in the data store to be compared against the submitted authentication token's credentials.- Returns:
- the
account's associated credentials.
-
equals
Returnstrueif thetokenCredentialsargument is logically equal to theaccountCredentialsargument.If both arguments are either a byte array (byte[]), char array (char[]) or String, they will be both be converted to raw byte arrays via the
toBytesmethod first, and then resulting byte arrays are compared viaArrays.equals(byte[],byte[]).If either argument cannot be converted to a byte array as described, a simple Object
equalscomparison is made.Subclasses should override this method for more explicit equality checks.
- Parameters:
tokenCredentials- theAuthenticationToken's associated credentials.accountCredentials- theAuthenticationInfo's stored credentials.- Returns:
trueif thetokenCredentialsare equal to theaccountCredentials.
-
doCredentialsMatch
This implementation acquires thetoken's credentials (viagetCredentials(token)) and then theaccount's credentials (viagetCredentials(account)) and then passes both of them to theequals(tokenCredentials, accountCredentials)method for equality comparison.- Specified by:
doCredentialsMatchin interfaceCredentialsMatcher- Parameters:
token- theAuthenticationTokensubmitted during the authentication attempt.info- theAuthenticationInfostored in the system matching the token principal.- Returns:
trueif the provided token credentials are equal to the stored account credentials,falseotherwise
-