Spring Security Ldap记住我不工作

时间:2012-08-15 20:06:47

标签: spring spring-ldap

我有一个使用spring security 3.0的应用程序。该应用程序使用我公司的Active目录进行登录。我从网上的例子中借用了一些代码,现在我能够成功执行绑定。但记住我的功能不起作用。更具体地说,我可以登录应用程序但是当我关闭浏览器并打开应用程序时,它会再次重定向到登录页面。任何人都可以告诉我我的配置有什么问题。

的security.xml

<http path-type="regex" use-expressions="true" auto-config="true">  
      <form-login 

      login-page="/Login.html" 

      login-processing-url="/j_spring_security_check" 

      default-target-url="/home.html" 

      authentication-failure-url = "/Login.html?login_error=1"        

 />

<logout logout-success-url="/Login.html" invalidate-session="true"
        delete-cookies="JSESSIONID" />

  <intercept-url pattern="\A/Login\Z" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
  <intercept-url pattern="\A/(?!Login).*\Z" access="isAuthenticated()" />

  <remember-me key="_spring_security_remember_me" token-validity-seconds="3600" user-service-ref="ldapUserDetailsService"/>

</http>


<authentication-manager alias="authenticationManager">
    <authentication-provider ref="ldapAuthProvider"/>
</authentication-manager>

<beans:bean class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" id="ldapAuthProvider">
    <beans:constructor-arg ref="ldapBindAuthenticator"/>
    <beans:property name="userDetailsContextMapper" ref="ldapUserDetailsContextMapper"/>
</beans:bean>

<beans:bean class="org.springframework.security.ldap.DefaultSpringSecurityContextSource" id="ldapServer">
    <!-- MS Active Directory -->
    <beans:constructor-arg value="ldap://hostname/DC=myCompany,DC=com"/>
    <beans:property name="userDn" value="CN=user,OU=Users,DC=mycompany,DC=com"/>
    <beans:property name="password" value="xxxxxx"/>
</beans:bean>

<beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator" id="ldapBindAuthenticator">
    <beans:constructor-arg ref="ldapServer"/>
    <beans:property name="userSearch" ref="ldapSearchBean"/>
</beans:bean>

<beans:bean class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch" id="ldapSearchBean">

    <beans:constructor-arg value="OU=Users"/>
    <beans:constructor-arg value="(sAMAccountName={0})"/>
    <beans:constructor-arg ref="ldapServer"/>
</beans:bean>


<beans:bean class="org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper" id="ldapUserDetailsContextMapper"/>

<beans:bean id="ldapUserDetailsService" class="org.springframework.security.ldap.userdetails.LdapUserDetailsService">
        <beans:constructor-arg index="0">
            <beans:ref local="ldapSearchBean" />
        </beans:constructor-arg>
    </beans:bean>   



<!-- Bean used for LDAP querying. -->
<beans:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <beans:constructor-arg ref="ldapServer" />
</beans:bean>

<beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler" id="expressionHandler"/>

0 个答案:

没有答案