In ADF Security object and role information can be found out using the below code anytime using the java code
User Name Information
ADFContext adfCtx = ADFContext.getCurrent();
SecurityContext secCntx = adfCtx.getSecurityContext();
String user = secCntx.getUserPrincipal().getName();
String loggedInUserName = secCntx.getUserName();
Role Information
ADFContext adfCtx = ADFContext.getCurrent();
SecurityContext secCntx = adfCtx.getSecurityContext();
String[] Roles = secCntx.getUserRoles()
Role Information check
You can use below logic to check if user have a role which you want to check, like if you want to enable a button if user have have manager Role.
public boolean checkIsUserInRole(String roleName){
return
(FacesContext.getCurrentInstance().getExternalContext().isUserInRole(roleName));
}
No comments:
Post a Comment