Weblogic Portal Authorization – Get and Check User’s Roles
| Posted by watashii | Filed under Java, Programming, WebThe Authorization class provides runtime methods for security policies and roles checks. The following code fragment obtains the set of roles the logged-in user belongs to. Note the user must be authenticated first, see Authentication class.
String entAppName = ApplicationHelper.getNonVersionedAppName();
String webAppName = ApplicationHelper.getWebAppName(request);
EnterpriseRoleResource resource = new EnterpriseRoleResource(entAppName,webAppName,EntitlementConstants.P13N_ROLE_POLICY_POOL,"");
Map userRoles = Authorization.getRoles((P13nResource) resource);
if (Authorization.isUserInRole("Admin", userRoles)) {
return true;
}
Global and Enterprise Application roles are obtained using EnterpriseRoleResource. For Global, Enterprise, and Web Application roles, use WebappRoleResource.
com.bea.p13n.security.Authentication
Related Posts:
- Weblogic Portal – Create Streaming Desktop Page Definition Error
- Using JSF 1.2 on Oracle Workshop for Weblogic (Portal 10.3)
- Reading Portlet Preferences in Weblogic Portal
- Start & Stop Weblogic Without Username & Password
- Encrypt Passwords With Weblogic Server
Tags: authentication, authorization, portal, roles, weblogic