如何在Websphere 8.5 JAAS中向“主题”添加角色/组?

时间:2019-07-12 07:44:32

标签: websphere jaas

我在Websphere 8.5中具有LDAP身份验证,并且需要将LDAP组映射到LoginModule中数据库中的组。 现在,我陷入了如何将组添加到“主题”的问题?

例如,我担任下一个角色:                            

我尝试在LoginModule.commit函数中添加下一个值,但是它不起作用:

subject.getPrincipals().add(new WSPrincipalImpl("customRealm/my_role"));
subject.getPrincipals().add(new WSPrincipalImpl("some_role"));
subject.getPrincipals().add(new WSPrincipalImpl("some_role@customRealm"));
subject.getPrincipals().add(new WSPrincipalImpl("my_role"));
subject.getPrincipals().add(new WSPrincipalImpl("customRealm/my_role"));
subject.getPublicCredentials().add(new WSCredentialImpl("defaultWIMFileBasedRealm", "admin", "1", "group:defaultWIMFileBasedRealm/cn=Admin,ou=Group,dc=rbs,dc=test,dc=local", "user:defaultWIMFileBasedRealm/cn=admin,ou=Users,dc=rbs,dc=test,dc=local", new ArrayList<>(Arrays.asList("some_role@customRealm", "some_role")), new ArrayList<>(Arrays.asList("group:customRealm/some_role"))));

对于检查用户角色,我使用FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role)

1 个答案:

答案 0 :(得分:0)

我看到您已经在WSCredential中添加了一个组;您可以将多个组指定为列表。 您不能将组直接添加到主题。

此外,我看到您在WSPrincipalImpl中添加了角色;这些角色实际上是主体名称。

此致

勒特