use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImpl method permissionRoles.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<String> permissionRoles(Permission perm) throws SecurityException {
String methodName = "permissionRoles";
assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OBJECT_NULL);
checkAccess(CLS_NM, methodName);
Permission pe = permP.read(perm);
List<String> retVals;
if (pe != null && CollectionUtils.isNotEmpty(pe.getRoles())) {
retVals = new ArrayList<>(pe.getRoles());
} else {
retVals = new ArrayList<>();
}
return retVals;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImpl method findRoleConstraints.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<RoleConstraint> findRoleConstraints(User user, Permission permission, RoleConstraint.RCType rcType) throws SecurityException {
String methodName = "findRoleConstraints";
assertContext(CLS_NM, methodName, user, GlobalErrIds.USER_NULL);
assertContext(CLS_NM, methodName, permission, GlobalErrIds.PERM_NULL);
checkAccess(CLS_NM, methodName);
// find roles this permission is authorized for
Permission pe = permP.read(permission);
Set<String> authorizedRoles = authorizeRoles(pe.getRoles());
// find role constraints for the user and the permission's pa set
return userP.findRoleConstraints(authorizedRoles, user, rcType, pe.getPaSets());
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrImpl method permissionUsers.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<String> permissionUsers(Permission perm) throws SecurityException {
String methodName = "permissionUsers";
assertContext(CLS_NM, methodName, perm, GlobalErrIds.PERM_OPERATION_NULL);
checkAccess(CLS_NM, methodName);
Permission pe = permP.read(perm);
List<String> retVals;
if (pe != null && CollectionUtils.isNotEmpty(pe.getUsers())) {
retVals = new ArrayList<>(pe.getUsers());
} else {
retVals = new ArrayList<>();
}
return retVals;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrRestImpl method updatePermission.
/**
* {@inheritDoc}
*/
@Override
public Permission updatePermission(Permission perm) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".updatePermission");
Permission retPerm;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(perm);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerm = (Permission) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerm;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrImplTest method addPASetToPermission.
public static void addPASetToPermission(String msg, String paSetName, String obj, String[] op) throws SecurityException {
LogUtil.logIt(msg);
AdminMgr adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
Permission pop = PermTestData.getOp(obj, op);
pop.setPaSetName(paSetName);
adminMgr.updatePermission(pop);
LOG.debug("addPASetToPermission name [" + paSetName + "] successful");
}
Aggregations