我想通过 ldap 使用身份验证领域。这工作正常。其次,我想将我的应用程序的 UserRoles 存储在 Roles 表中,这也很好。(下面的示例,带有聚合领域)
但我不知道如何获得这两个角色。来自 LDAP 和我的 Roles 表的角色放在一起。
我错过了什么?
<security-domain name="securtiyDomain" default-realm="my-realm" permission-mapper="default-permission-mapper">
<realm name=jdbc-realm" role-decoder="from-roles-attribute"/>
</security-domain>
<security-realms>
<aggregate-realm name="my-realm" authentication-realm="ldap-realm" authorization-realms="jdbc-realm ldap-realm"/>
<jdbc-realm name="jdbc-realm">
<principal-query .... >
<attribute-mapping>
<attribute to="roles" index="1"/>
</attribute-mapping>
</principal-query>
</jdbc-realm>
<ldap-realm name="ldap-realm" dir-context="ldap-connection" direct-verification="true">
<identity-mapping ...>
<attribute-mapping>
<attribute from="cn" to="Roles" .../>
</attribute-mapping>
<user-password-mapper from="userPassword"/>
</identity-mapping>
</ldap-realm>
<simple-role-decoder name="from-roles-attribute" attribute="roles"/>