Interview Questions

Spring Security LDAP Configuration

Spring Security LDAP Configuration

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans <a href="http://www.springframework.org/schema/beans/spring-beans.xsd
" title="http://www.springframework.org/schema/beans/spring-beans.xsd
">http://www.springframework.org/schema/beans/spring-beans.xsd
</a>                        <a href="http://www.springframework.org/schema/security" title="http://www.springframework.org/schema/security">http://www.springframework.org/schema/security</a> <a href="http://www.springframework.org/schema/security/spring-security.xsd
" title="http://www.springframework.org/schema/security/spring-security.xsd
">http://www.springframework.org/schema/security/spring-security.xsd
</a>                        <a href="http://www.springframework.org/schema/context
" title="http://www.springframework.org/schema/context
">http://www.springframework.org/schema/context
</a>       <a href="http://www.springframework.org/schema/context/spring-context.xsd">

" title="http://www.springframework.org/schema/context/spring-context.xsd">

">http://www.springframework.org/schema/context/spring-context.xsd">

</a>    <global-method-security pre-post-annotations="enabled" />  
   
    <http pattern="/rest/login" security="none"/>  
    <http pattern="/rest/signup" security="none"/>

    <http  pattern="/rest/**" entry-point-ref="restAuthenticationEntryPoint" create-session="stateless">
         
        <custom-filter before="FORM_LOGIN_FILTER" ref="appAuthenticationFilter"/>
       
    </http>
   
    <authentication-manager alias="authenticationManager">
            <ldap-authentication-provider
                user-search-base="ou=serviceAccounts,dc=test,dc=com"
                user-search-filter="(uid={0})"
               
                >
            </ldap-authentication-provider>
    </authentication-manager>
   
   

  <ldap-server url="ldap://ldap3.com:389" manager-dn="uid=TomcatReadAdmin,ou=ouAdmins,dc=test,dc=com"
  manager-password="wIaH3IYw"/>
 
 
   
   
       
        <beans:bean id="appAuthenticationSuccessHandler"
                class="com.test.common.security.AppAuthenticationSuccessHandler">
               
        </beans:bean>
       
        <beans:bean id="restAuthenticationEntryPoint"
                class="com.test.common.security.RestAuthenticationEntryPoint">
               
       
               
         <beans:bean id="appAuthenticationFilter" class="com.test.common.security.AppAuthenticationFilter">  
        <beans:property name="authenticationManager" ref="authenticationManager" />
        <beans:property name="authenticationSuccessHandler" ref="appAuthenticationSuccessHandler" />  
    </beans:bean>
   
    </beans:beans>