use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImpl method rolePermissionAttributeSets.
/**
* {@inheritDoc}
*/
@Override
public List<PermissionAttributeSet> rolePermissionAttributeSets(Role role, boolean noInhertiance) throws SecurityException {
Map<String, PermissionAttributeSet> permAttributeSets = new HashMap<String, PermissionAttributeSet>();
// look through all permissions in the role
List<Permission> permissions = this.rolePermissions(role, noInhertiance);
for (Permission perm : permissions) {
if (CollectionUtils.isNotEmpty(perm.getPaSets())) {
for (String paSetName : perm.getPaSets()) {
if (!permAttributeSets.containsKey(paSetName)) {
PermissionAttributeSet paSet = new PermissionAttributeSet(paSetName);
paSet.setContextId(this.contextId);
PermissionAttributeSet permAttributeSet = permP.read(paSet);
permAttributeSets.put(paSetName, permAttributeSet);
}
}
}
}
return new ArrayList<>(permAttributeSets.values());
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImpl method authorizedPermissionRoles.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public Set<String> authorizedPermissionRoles(Permission perm) throws SecurityException {
Set<String> authorizedRoles;
String methodName = "authorizedPermissionRoles";
assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OPERATION_NULL);
checkAccess(CLS_NM, methodName);
// Pull the permission from ldap:
Permission pe = permP.read(perm);
// Get all roles that this permission is authorized for:
authorizedRoles = authorizeRoles(pe.getRoles());
return authorizedRoles;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class Manageable method checkAccess.
/**
* Every Fortress Manager API (e.g. addUser, updateUser, addRole, ...) will perform authorization on behalf of the
* caller IFF the {@link AuditMgrImpl#adminSess} has been set before invocation.
*
* @param className contains the class name.
* @param opName contains operation name.
* @throws org.apache.directory.fortress.core.SecurityException
* in the event of data validation or system error.
*/
protected final void checkAccess(String className, String opName) throws SecurityException {
if (this.adminSess != null) {
Permission perm = new Permission(className, opName);
perm.setContextId(this.contextId);
AdminUtil.checkAccess(this.adminSess, perm, this.contextId);
}
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class Manageable method setEntitySession.
/**
* Set A/RBAC session on entity and perform authorization on behalf of the caller if the {@link #adminSess} is set.
*
* @param className contains the class name.
* @param opName contains operation name.
* @param entity contains {@link org.apache.directory.fortress.core.model.FortEntity} instance.
* @throws org.apache.directory.fortress.core.SecurityException
* in the event of data validation or system error.
*/
protected final void setEntitySession(String className, String opName, FortEntity entity) throws SecurityException {
entity.setContextId(this.contextId);
if (this.adminSess != null) {
Permission perm = new Permission(className, opName);
perm.setContextId(this.contextId);
AdminUtil.setEntitySession(this.adminSess, perm, entity, this.contextId);
}
}
Aggregations