Example usage for org.springframework.security.authentication UsernamePasswordAuthenticationToken getCredentials

List of usage examples for org.springframework.security.authentication UsernamePasswordAuthenticationToken getCredentials

Introduction

In this page you can find the example usage for org.springframework.security.authentication UsernamePasswordAuthenticationToken getCredentials.

Prototype

public Object getCredentials() 

Source Link

Usage

From source file:org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider.java

/**
 * Creates the final {@code Authentication} object which will be returned from the
 * {@code authenticate} method./*from w  w w  .  ja  v a2s  .co  m*/
 *
 * @param authentication the original authentication request token
 * @param user the <tt>UserDetails</tt> instance returned by the configured
 * <tt>UserDetailsContextMapper</tt>.
 * @return the Authentication object for the fully authenticated user.
 */
protected Authentication createSuccessfulAuthentication(UsernamePasswordAuthenticationToken authentication,
        UserDetails user) {
    Object password = useAuthenticationRequestCredentials ? authentication.getCredentials()
            : user.getPassword();

    UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(user, password,
            authoritiesMapper.mapAuthorities(user.getAuthorities()));
    result.setDetails(authentication.getDetails());

    return result;
}

From source file:org.springframework.security.ldap.authentication.LdapAuthenticationProvider.java

/**
 * Creates the final <tt>Authentication</tt> object which will be returned from the <tt>authenticate</tt> method.
 *
 * @param authentication the original authentication request token
 * @param user the <tt>UserDetails</tt> instance returned by the configured <tt>UserDetailsContextMapper</tt>.
 * @return the Authentication object for the fully authenticated user.
 */// w  ww.j  a v  a 2s.  c  o m
protected Authentication createSuccessfulAuthentication(UsernamePasswordAuthenticationToken authentication,
        UserDetails user) {
    Object password = useAuthenticationRequestCredentials ? authentication.getCredentials()
            : user.getPassword();

    UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(user, password,
            user.getAuthorities());
    result.setDetails(authentication.getDetails());

    return result;
}

From source file:shionn.blog.security.AuthenticationProvider.java

private String encodePassword(UsernamePasswordAuthenticationToken token, User user) {
    String passphrase = new SimpleDateFormat("yyyyMMdd").format(user.getCreated()) + token.getCredentials()
            + salt;/*  w  w  w. j a v  a 2s. c  om*/
    String encoded = DigestUtils.sha512Hex(passphrase);
    logger.info(encoded);
    return encoded;
}