Example usage for org.apache.shiro.authc.credential HashingPasswordService hashPassword

List of usage examples for org.apache.shiro.authc.credential HashingPasswordService hashPassword

Introduction

In this page you can find the example usage for org.apache.shiro.authc.credential HashingPasswordService hashPassword.

Prototype

Hash hashPassword(Object plaintext) throws IllegalArgumentException;

Source Link

Document

Hashes the specified plaintext password using internal hashing configuration settings pertinent to password hashing.

Usage

From source file:waffle.shiro.AbstractWaffleRealm.java

License:Open Source License

/**
 * Builds the authentication info./*  w  w  w .  ja  v  a2  s.com*/
 *
 * @param token
 *            the token
 * @param principal
 *            the principal
 * @return the authentication info
 */
private AuthenticationInfo buildAuthenticationInfo(final UsernamePasswordToken token, final Object principal) {
    AuthenticationInfo authenticationInfo;
    final HashingPasswordService hashService = this.getHashService();
    if (hashService != null) {
        final Hash hash = hashService.hashPassword(token.getPassword());
        final ByteSource salt = hash.getSalt();
        authenticationInfo = new SimpleAuthenticationInfo(principal, hash, salt,
                AbstractWaffleRealm.REALM_NAME);
    } else {
        final Object creds = token.getCredentials();
        authenticationInfo = new SimpleAuthenticationInfo(principal, creds, AbstractWaffleRealm.REALM_NAME);
    }
    return authenticationInfo;
}