1
我可以绑定到嵌入式LDAP服务器我的本地机器上,使用下列豆:如何配置Spring Security PasswordComparisonAuthenticator
<b:bean id="secondLdapProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<b:constructor-arg>
<b:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<b:constructor-arg ref="contextSource" />
<b:property name="userSearch">
<b:bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<b:constructor-arg index="0" value="ou=people"/>
<b:constructor-arg index="1" value="(uid={0})"/>
<b:constructor-arg index="2" ref="contextSource" />
</b:bean>
</b:property>
</b:bean>
</b:constructor-arg>
<b:constructor-arg>
<b:bean class="com.company.security.ldap.BookinLdapAuthoritiesPopulator">
</b:bean>
</b:constructor-arg>
</b:bean>
然而
,当我尝试多次不能在一个糟糕的凭据PasswordComparisonAuthenticator认证事件:
<b:bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<b:constructor-arg>
<b:bean
class="org.springframework.security.ldap.authentication.PasswordComparisonAuthenticator">
<b:constructor-arg ref="contextSource" />
<b:property name="userDnPatterns">
<b:list>
<b:value>uid={0},ou=people</b:value>
</b:list>
</b:property>
</b:bean>
</b:constructor-arg>
<b:constructor-arg>
<b:bean class="com.company.security.ldap.BookinLdapAuthoritiesPopulator">
</b:bean>
</b:constructor-arg>
</b:bean>
通过调试,我可以看到,在认证方法从ldif文件拿起DN,但随后尝试比较密码,但是,它的使用LdapShaPasswordEncoder(默认的),其中通单词在文件中以明文存储,并且这是认证失败的地方。
这里的认证管理器bean引用首选认证豆:
<authentication-manager>
<authentication-provider ref="ldapAuthProvider"/>
<authentication-provider user-service-ref="userDetailsService">
<password-encoder hash="md5" base64="true">
<salt-source system-wide="secret"/>
</password-encoder>
</authentication-provider>
</authentication-manager>
在一个侧面说明,我是否设置ldapAuthProvider口令编码器,以明文或者只是留空,似乎它不使一个区别。任何帮助将不胜感激。
感谢