Example usage for org.apache.shiro.authc SimpleAuthenticationInfo getCredentialsSalt

List of usage examples for org.apache.shiro.authc SimpleAuthenticationInfo getCredentialsSalt

Introduction

In this page you can find the example usage for org.apache.shiro.authc SimpleAuthenticationInfo getCredentialsSalt.

Prototype

public ByteSource getCredentialsSalt() 

Source Link

Document

Returns the salt used to hash the credentials, or null if no salt was used or credentials were not hashed at all.

Usage

From source file:com.ning.billing.server.security.KillbillJdbcRealm.java

License:Apache License

@Override
protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken token)
        throws AuthenticationException {
    final SimpleAuthenticationInfo authenticationInfo = (SimpleAuthenticationInfo) super.doGetAuthenticationInfo(
            token);//  w  w  w. j  a  va  2s .c o  m

    // We store the salt bytes in Base64 (because the JdbcRealm retrieves it as a String)
    final ByteSource base64Salt = authenticationInfo.getCredentialsSalt();
    authenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(Base64.decode(base64Salt.getBytes())));

    return authenticationInfo;
}

From source file:me.buom.shiro.realm.jdbc.HmacJdbcRealm.java

License:Apache License

protected void beforeAssertCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
    SimpleAuthenticationInfo authInfo = (SimpleAuthenticationInfo) info;

    Object oldCredentials = authInfo.getCredentials();
    Object stringToSign = hmacBuilder.buildStringToSign((HmacToken) token);
    authInfo.setCredentials(stringToSign);

    if (log.isDebugEnabled()) {
        log.debug("oldCredentials: {}", oldCredentials);
        log.debug("credentials: {}", authInfo.getCredentials());
        log.debug("credentialsSalt: {}", authInfo.getCredentialsSalt().toHex());
    }/*from  w w  w. ja  v  a  2 s . c  o m*/
}

From source file:org.killbill.billing.server.security.KillbillJdbcTenantRealm.java

License:Apache License

@Override
protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken token)
        throws AuthenticationException {
    final SimpleAuthenticationInfo authenticationInfo = (SimpleAuthenticationInfo) super.doGetAuthenticationInfo(
            token);//from  ww w. j a v  a2 s  .  c o m

    // We store the salt bytes in Base64 (because the JdbcRealm retrieves it as a String)
    final ByteSource base64Salt = authenticationInfo.getCredentialsSalt();
    final byte[] bytes = Base64.decode(base64Salt.getBytes());
    // SimpleByteSource isn't Serializable
    authenticationInfo.setCredentialsSalt(new SerializableSimpleByteSource(bytes));

    return authenticationInfo;
}