如何通过Spring检查OpenLdap PasswordPolicy相关的错误和操作属性?

时间:2015-04-08 19:59:54

标签: java spring spring-security openldap spring-ldap

我们正在使用spring-security 3.2.3版本在我们的应用程序中验证和访问OpenLdap。我有问题通过Spring上下文访问PPolicy属性和错误。它是PasswordPolicyAwareContext。

<bean id="contextSource  class="org.springframework.security.ldap.ppolicy.PasswordPolicyAwareContextSource">
<constructor-arg value="${ldap.url}" />     
<property name="password" value="${ldap.password}" />   
<property name="userDn" value="${ldap.userDN}" />
</bean>

<bean id="springSecurityLdapTemplate"  class="org.springframework.security.ldap.SpringSecurityLdapTemplate">
<constructor-arg ref="contextSource"/>
</bean>
<bean id="userDetailsContextMapper" class="LdapUserProfilePopulator"/>
  • 在我的Service类中,我使用:

    进行身份验证

    AuthenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userid,password));

  • 当出现错误例如Password_Expired时,Account_Locked会抛出异常。

  • 为了检查帐户是否被锁定等,我检查异常是否是org.springframework.security.authentication.LockedException等的实例

问题:

  1. 我们如何优雅地检查PPolicy错误并使用PasswordPolicyErrorStatus?

  2. 此外,我们如何访问OpenLdap操作属性,包括pwdMaxAge,pwdExpireWarning?我已经扩展了-LdapUserDetailsMapper来将LdapContext属性映射到我的User对象,但是我无法处理ldap中的操作属性。

  3. 真正感谢这方面的任何反馈/指示! 谢谢!


    我执行了以下操作来处理特定的ldap错误: http://forum.spring.io/forum/spring-projects/security/115236-why-passwordpolicyawarecontextsource-doesn-t-throw-exception-for-expired-passwords

    即扩展了PasswordPolicyAwareContextSource.java并处理了异常。 我发布这样以防万一其他人正在寻找类似的问题可以受益。 如果其他人有更好的处理方式,请发布。 谢谢!

0 个答案:

没有答案
相关问题