Tuesday, September 17, 2013

Programmatically Accessing ADF Security Context to Obtain Information About Users and Roles

Is ADF security turned on?
if (ADFContext.getCurrent().getSecurityContext().isAuthorizationEnabled())

Is the user logged on?
public boolean isAuthenticated() {
  return ADFContext.getCurrent().getSecurityContext().isAuthenticated();

Who is the user?
public String getCurrentUser() {
  return ADFContext.getCurrent().getSecurityContext().getUserName();

Is the user in a specified role?
public boolean isUserInRole(String role) {
  return ADFContext.getCurrent().getSecurityContext().isUserInRole(role);

1 comment: