Example usage for org.springframework.security.ldap.authentication LdapAuthenticationProvider setUserDetailsContextMapper

List of usage examples for org.springframework.security.ldap.authentication LdapAuthenticationProvider setUserDetailsContextMapper

Introduction

In this page you can find the example usage for org.springframework.security.ldap.authentication LdapAuthenticationProvider setUserDetailsContextMapper.

Prototype

public void setUserDetailsContextMapper(UserDetailsContextMapper userDetailsContextMapper) 

Source Link

Document

Allows a custom strategy to be used for creating the UserDetails which will be stored as the principal in the Authentication returned by the #createSuccessfulAuthentication(org.springframework.security.authentication.UsernamePasswordAuthenticationToken,org.springframework.security.core.userdetails.UserDetails) method.

Usage

From source file:io.gravitee.management.idp.ldap.authentication.LdapAuthenticationProviderConfigurer.java

private LdapAuthenticationProvider build() throws Exception {
    BaseLdapPathContextSource contextSource = getContextSource();
    LdapAuthenticator ldapAuthenticator = createLdapAuthenticator(contextSource);

    LdapAuthoritiesPopulator authoritiesPopulator = getLdapAuthoritiesPopulator();

    LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProviderProxy(
            ldapAuthenticator, authoritiesPopulator);
    SimpleAuthorityMapper simpleAuthorityMapper = new SimpleAuthorityMapper();
    simpleAuthorityMapper.setPrefix(rolePrefix);
    simpleAuthorityMapper.afterPropertiesSet();
    ldapAuthenticationProvider.setAuthoritiesMapper(simpleAuthorityMapper);
    if (userDetailsContextMapper != null) {
        ldapAuthenticationProvider.setUserDetailsContextMapper(userDetailsContextMapper);
    }//  ww  w . j  a va 2  s.c  o m
    return ldapAuthenticationProvider;
}