Class BasicUserDetailsContextMapper

java.lang.Object
com.appiancorp.suiteapi.common.spring.security.BasicUserDetailsContextMapper
All Implemented Interfaces:
org.springframework.security.ldap.userdetails.UserDetailsContextMapper

public class BasicUserDetailsContextMapper extends Object implements org.springframework.security.ldap.userdetails.UserDetailsContextMapper
This class implements very basic conversion from a Spring LDAP DirContextOperations bean to a UserDetails bean. The user data is simply retrieved by invoking the configured UserDetailsService with the given username. Conversion from UserDetails to a DirContextAdapter is not supported.

Sample XML configuration:


<bean id="userDetailsContextMapper" class="com.appiancorp.suiteapi.common.spring.security.BasicUserDetailsContextMapper">
  <constructor-arg ref="myUserDetailsService"/>
</bean>
<bean id="myUserDetailsService" class="com.example.security.auth.MyUserDetailsService"/>
  • Constructor Details

    • BasicUserDetailsContextMapper

      public BasicUserDetailsContextMapper(org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
      Creates a new instance with the given UserDetailsService which will be used to retrieve the user data when mapUserFromContext(DirContextOperations, String, Collection) is invoked.
  • Method Details

    • mapUserFromContext

      public org.springframework.security.core.userdetails.UserDetails mapUserFromContext(org.springframework.ldap.core.DirContextOperations ctx, String username, Collection<? extends org.springframework.security.core.GrantedAuthority> authority)
      Invokes the configured userDetailsService with the given username. The passed-in granted authorities are ignored and the ones set by UserDetailsService are used instead.
      Specified by:
      mapUserFromContext in interface org.springframework.security.ldap.userdetails.UserDetailsContextMapper
    • mapUserToContext

      public void mapUserToContext(org.springframework.security.core.userdetails.UserDetails user, org.springframework.ldap.core.DirContextAdapter ctx)
      Specified by:
      mapUserToContext in interface org.springframework.security.ldap.userdetails.UserDetailsContextMapper
    • getUserDetailsService

      protected org.springframework.security.core.userdetails.UserDetailsService getUserDetailsService()
    • toString

      public String toString()
      Overrides:
      toString in class Object