10.4.1.2.BindAuthenticator
这个类org.springframework.security.providers.ldap.authenticator.BindAuthenticator实现了绑定认证策略。它只是尝试对用户进行绑定。

10.4.1.3.PasswordComparisonAuthenticator
这个类org.springframework.security.providers.ldap.authenticator.PasswordComparisonAuthenticator实现了密码比较认证策略。
10.4.1.4.活动目录认证
除了标准LDAP认证以外(绑定到一个DN),活动目录对于用户认证提供了自己的非标准语法。
上面讨论的bean必须连接到服务器。它们都必须使用SpringSecurityContextSource,这个是Spring LDAP的一个扩展。除非你有特定的需求,你通常只需要配置一个DefaultSpringSecurityContextSource bean,这个可以使用你的LDAP服务器的URL进行配置,可选项还有管理员用户的用户名和密码,这将默认用在绑定服务器的时候(而不是匿名绑定)。参考Spring LDAP的AbstractContextSource类的Javadoc获得更多信息。
通常,比简单DN匹配越来越复杂的策略需要在目录里定位一个用户入口。这可以使用LdapUserSearch的一个示例,它可以提供认证者实现,比如让他们定位一个用户。提供的实现是FilterBasedLdapUserSearch。
10.4.3.1.FilterBasedLdapUserSearch
这个bean使用一个LDAP过滤器,来匹配目录里的用户对象。这个过程在javadoc里进行过解释,在对应的搜索方法,。就如那里解释的,搜索过滤条件可以通过方法指定。对于这个类,唯一合法的参数是{0},它会代替用户的登录名。
在成功认证用户之后,LdapAuthenticationProvider会调用配置好的LdapAuthoritiesPopulator bean,尝试读取用户的授权集合。这个DefaultLdapAuthoritiesPopulator是一个实现类,它将通过搜索目录读取授权,查找用户成员所在的组(典型的这会是目录中的groupOfNames或groupOfUniqueNames入口)。查看这个类的Javadoc获得它如何工作的更多信息。
典型的配置方法,使用到像我们这在里讨论的这些bean,就像这样:
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://monkeymachine:389/dc=springframework,dc=org"/>
<property name="userDn" value="cn=manager,dc=springframework,dc=org"/>
<property name="password" value="password"/>
</bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userDnPatterns">
<list><value>uid={0},ou=people</value></list>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource"/>
<constructor-arg value="ou=groups"/>
<property name="groupRoleAttribute" value="ou"/>
</bean>
</constructor-arg>
</bean>
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-24626-3.html
人家是主战舰艇里的其中一舰