Can't retrieve user roles

江枫思渺然 提交于 2019-12-12 18:24:37

问题


I am trying to return a list of roles back to a mobile client device from the WL server

In the createIdentity method of my LoginModule I added the following code

HashMap<String, Object> customAttributes = new HashMap<String, Object>();
customAttributes.put("AuthenticationDate", new Date());

Set<String> groups = new HashSet<String>();
groups.add("Managers");
groups.add("Users");

UserIdentity identity = new UserIdentity(loginModule, USERNAME, "Fred Flintstone", groups, customAttributes, PASSWORD);

The display Name "Fred Flintstone" gets returned to the mobile device, the custom attributes get returned, but the group information seems to get lost somewhere.

I get the following displayed in the mobile device logs

"BasicAuthRealm":{"userId":"user1","attributes":{"AuthenticationDate":"Thu Nov 14 22:39:35 EST 2013"},"isUserAuthenticated":1,"displayName":"Fred Flintstone"},"WL-Authentication-Success":{"BasicAuthRealm":{"userId":"user1","attributes":{"AuthenticationDate":"Thu Nov 14 22:39:35 EST 2013"},"isUserAuthenticated":1,"displayName":"Fred Flintstone"}},

I am running WL 6.0.0.1 Enterprise edition and running against a Liberty server v8.5.5.0

Any ideas?


回答1:


The groups object is not sent back to the client after the user successfully authenticates. The only parts of the UserIdentity object that are sent back are the name, displayName, and the attributes. I do not know the reason that the groups aren't sent back. Perhaps the objects purpose was only meant for the server and was never intended to be used by the client.

The unfortunate but easy workaround is to add any information you need to know about your group to your attributes object.



来源:https://stackoverflow.com/questions/19976915/cant-retrieve-user-roles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!