use of org.pentaho.platform.api.engine.IAclEntry in project pentaho-platform by pentaho.
the class PentahoBasicAclVoter method hasAccess.
public boolean hasAccess(final IPentahoSession session, final IAclHolder holder, final int mask) {
Authentication auth = getAuthentication(session);
// If we're not authenticated, default to no access and return.
if (auth == null) {
return false;
}
// admins can do anything they want!
if (isPentahoAdministrator(session)) {
return true;
}
IAclEntry[] effectiveAcls = getEffectiveAcls(session, holder);
if ((effectiveAcls == null) || (effectiveAcls.length == 0)) {
return false;
}
for (IAclEntry element : effectiveAcls) {
IPentahoBasicAclEntry acl = (IPentahoBasicAclEntry) element;
if (acl.isPermitted(mask)) {
return true;
}
}
return false;
}
use of org.pentaho.platform.api.engine.IAclEntry in project pentaho-platform by pentaho.
the class PentahoUserOverridesVoter method getEffectiveAcls.
@Override
public IAclEntry[] getEffectiveAcls(final IPentahoSession session, final IAclHolder holder) {
Authentication auth = getAuthentication(session);
// User is un-authenticated. Return no access controls.
if (auth == null) {
return null;
}
IAclEntry[] objectAcls = super.getEffectiveAcls(session, holder);
if (objectAcls == null) {
return null;
}
Object principal = auth.getPrincipal();
String userName = null;
if (principal instanceof UserDetails) {
userName = ((UserDetails) principal).getUsername();
} else {
userName = principal.toString();
}
for (IAclEntry element : objectAcls) {
// First, search for the user name in the objectAcls. If it's there,
// then that
// overrides anything else. It's the only acl returned.
IPentahoBasicAclEntry entry = (IPentahoBasicAclEntry) element;
String recipient = entry.getRecipient().toString();
// ACL.
if (recipient.equals(userName)) {
return new IAclEntry[] { entry };
}
}
// settings.
return objectAcls;
}
use of org.pentaho.platform.api.engine.IAclEntry in project pentaho-platform by pentaho.
the class PentahoAllowAllAclVoter method getEffectiveAcls.
public IAclEntry[] getEffectiveAcls(final IPentahoSession session, final IAclHolder holder) {
// Returns all the ACLs on the object which indicates that the
// user has all the necessary acls to access the object.
List allAcls = holder.getEffectiveAccessControls();
IAclEntry[] acls = new IAclEntry[allAcls.size()];
acls = (IAclEntry[]) allAcls.toArray(acls);
return acls;
}
use of org.pentaho.platform.api.engine.IAclEntry in project pentaho-platform by pentaho.
the class PentahoBasicAclVoter method getEffectiveAcl.
public PentahoAclEntry getEffectiveAcl(final IPentahoSession session, final IAclHolder holder) {
// First, get all the ACLs on the object that apply to the user.
IAclEntry[] effectiveAcls = getEffectiveAcls(session, holder);
PentahoAclEntry entry = new PentahoAclEntry();
entry.setMask(IPentahoAclEntry.PERM_NOTHING);
// indicates their access.
if ((effectiveAcls != null) && (effectiveAcls.length > 0)) {
int[] allAcls = new int[effectiveAcls.length];
for (int i = 0; i < effectiveAcls.length; i++) {
allAcls[i] = ((IPentahoAclEntry) effectiveAcls[i]).getMask();
}
entry.addPermissions(allAcls);
return entry;
} else {
return entry;
}
}
use of org.pentaho.platform.api.engine.IAclEntry in project pentaho-platform by pentaho.
the class PentahoBasicAclVoter method getEffectiveAcls.
public IAclEntry[] getEffectiveAcls(final IPentahoSession session, final IAclHolder holder) {
Authentication auth = getAuthentication(session);
if (auth == null) {
// No user, so no ACLs.
return null;
}
List allAcls = holder.getEffectiveAccessControls();
IAclEntry[] acls = new IAclEntry[allAcls.size()];
acls = (IAclEntry[]) allAcls.toArray(acls);
PentahoGrantedAuthorityEffectiveAclsResolver resolver = new PentahoGrantedAuthorityEffectiveAclsResolver();
IAclEntry[] resolvedAcls = resolver.resolveEffectiveAcls(acls, auth);
return resolvedAcls;
}
Aggregations