Thursday, January 19, 2012

ADF 11G : How to handle with User & Role Programatically?


public String getUserName(){

return ADFContext.getCurrent().getSecurityContext().getUserName().toUpperCase();
}

----
public boolean isUserInRole(String role){

return ADFContext.getCurrent().getSecurityContext().isUserInRole(role);
}

---- print the roles of the current user


for ( String role : ADFContext.getCurrent().getSecurityContext().getUserRoles() ) {

System.out.println("role "+role);

}  
-- Check Valid User   public boolean isAuthenticated() {

return ADFContext.getCurrent().getSecurityContext().isAuthenticated();

}