use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.
the class AdminMgrImpl method addAscendant.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public void addAscendant(Role childRole, Role parentRole) throws SecurityException {
String methodName = "addAscendant";
assertContext(CLS_NM, methodName, parentRole, GlobalErrIds.PARENT_ROLE_NULL);
setEntitySession(CLS_NM, methodName, parentRole);
assertContext(CLS_NM, methodName, childRole, GlobalErrIds.CHILD_ROLE_NULL);
// make sure the child role is already there:
Role role = new Role(childRole.getName());
role.setContextId(this.contextId);
role = roleP.read(role);
role.setContextId(this.contextId);
RoleUtil.getInstance().validateRelationship(childRole, parentRole, false);
roleP.add(parentRole);
// Use cRole2 to update ONLY the parents attribute on the child role and nothing else:
Role cRole2 = new Role(childRole.getName());
cRole2.setParents(role.getParents());
cRole2.setParent(parentRole.getName());
cRole2.setContextId(this.contextId);
setAdminData(CLS_NM, methodName, cRole2);
roleP.update(cRole2);
RoleUtil.getInstance().updateHier(this.contextId, new Relationship(childRole.getName().toUpperCase(), parentRole.getName().toUpperCase()), Hier.Op.ADD);
}
use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.
the class AuditMgrImpl method searchAdminMods.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<Mod> searchAdminMods(UserAudit uAudit) throws SecurityException {
String methodName = "searchAdminMods";
assertContext(CLS_NM, methodName, uAudit, GlobalErrIds.AUDT_INPUT_NULL);
checkAccess(CLS_NM, methodName);
if (StringUtils.isNotEmpty(uAudit.getUserId())) {
ReviewMgr rMgr = ReviewMgrFactory.createInstance(this.contextId);
User user = rMgr.readUser(new User(uAudit.getUserId()));
uAudit.setInternalUserId(user.getInternalId());
}
return auditP.searchAdminMods(uAudit);
}
use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.
the class DelAdminMgrImpl method updateRole.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public AdminRole updateRole(AdminRole role) throws SecurityException {
String methodName = "updateRole";
assertContext(CLS_NM, methodName, role, GlobalErrIds.ARLE_NULL);
setEntitySession(CLS_NM, methodName, role);
AdminRole re = admRP.update(role);
// search for all users assigned this role and update:
List<User> users = userP.getAssignedUsers(role);
if (CollectionUtils.isNotEmpty(users)) {
final AdminMgr aMgr = AdminMgrFactory.createInstance(this.contextId);
for (User ue : users) {
User upUe = new User(ue.getUserId());
setAdminData(CLS_NM, methodName, upUe);
List<UserAdminRole> uaRoles = ue.getAdminRoles();
UserAdminRole chgRole = new UserAdminRole();
chgRole.setName(role.getName());
chgRole.setUserId(ue.getUserId());
chgRole.setOsPSet(role.getOsPSet());
chgRole.setOsUSet(role.getOsUSet());
uaRoles.remove(chgRole);
ConstraintUtil.copy(re, chgRole);
uaRoles.add(chgRole);
upUe.setUserId(ue.getUserId());
upUe.setAdminRole(chgRole);
aMgr.updateUser(upUe);
}
}
return re;
}
use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.
the class DelAdminMgrImpl method addAscendant.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation(operationName = "addAscendantOU")
public void addAscendant(OrgUnit child, OrgUnit parent) throws SecurityException {
String methodName = "addAscendantOU";
assertContext(CLS_NM, methodName, parent, GlobalErrIds.ORG_PARENT_NULL);
VUtil.assertNotNull(parent.getType(), GlobalErrIds.ORG_TYPE_NULL, CLS_NM + "." + methodName);
setEntitySession(CLS_NM, methodName, parent);
assertContext(CLS_NM, methodName, child, GlobalErrIds.ORG_CHILD_NULL);
// ensure the child OrgUnit exists:
OrgUnit newChild = ouP.read(child);
if (parent.getType() == OrgUnit.Type.USER) {
UsoUtil.getInstance().validateRelationship(child, parent, false);
} else {
PsoUtil.getInstance().validateRelationship(child, parent, false);
}
ouP.add(parent);
newChild.setParent(parent.getName());
newChild.setContextId(this.contextId);
ouP.update(newChild);
if (parent.getType() == OrgUnit.Type.USER) {
UsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
} else {
PsoUtil.getInstance().updateHier(this.contextId, new Relationship(child.getName().toUpperCase(), parent.getName().toUpperCase()), Hier.Op.ADD);
}
}
use of org.apache.directory.fortress.annotation.AdminPermissionOperation in project directory-fortress-core by apache.
the class DelAdminMgrImpl method addDescendant.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public void addDescendant(AdminRole parentRole, AdminRole childRole) throws SecurityException {
String methodName = "addDescendantRole";
assertContext(CLS_NM, methodName, parentRole, GlobalErrIds.ARLE_PARENT_NULL);
assertContext(CLS_NM, methodName, childRole, GlobalErrIds.ARLE_CHILD_NULL);
setEntitySession(CLS_NM, methodName, childRole);
// ensure the parent AdminRole exists:
admRP.read(parentRole);
AdminRoleUtil.validateRelationship(childRole, parentRole, false);
childRole.setParent(parentRole.getName());
admRP.add(childRole);
AdminRoleUtil.updateHier(this.contextId, new Relationship(childRole.getName().toUpperCase(), parentRole.getName().toUpperCase()), Hier.Op.ADD);
}
Aggregations