use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class GroupMgrImpl method assign.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public Group assign(Group group, String member) throws SecurityException {
String methodName = "assign";
assertContext(CLS_NM, methodName, group, GlobalErrIds.GROUP_NULL);
checkAccess(CLS_NM, methodName);
ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId);
String dn;
if (group.getType() == Group.Type.ROLE) {
Role inRole = new Role(member);
inRole.setContextId(group.getContextId());
Role role = reviewMgr.readRole(inRole);
dn = role.getDn();
// Validate SSD constraints
SDUtil.getInstance().validateSSD(group, role);
} else {
User inUser = new User(member);
inUser.setContextId(group.getContextId());
User user = reviewMgr.readUser(inUser);
dn = user.getDn();
}
return groupP.assign(group, dn);
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class GroupMgrImpl method loadUserDn.
private void loadUserDn(User inUser) throws SecurityException {
ReviewMgr reviewMgr = ReviewMgrFactory.createInstance(this.contextId);
User outUser = reviewMgr.readUser(inUser);
inUser.setDn(outUser.getDn());
}
use of org.apache.directory.fortress.core.model.User in project directory-fortress-core by apache.
the class ReviewMgrImpl method assignedRoles.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<UserRole> assignedRoles(User user) throws SecurityException {
String methodName = "assignedRoles";
assertContext(CLS_NM, methodName, user, GlobalErrIds.USER_NULL);
checkAccess(CLS_NM, methodName);
User ue = userP.read(user, true);
return ue.getRoles();
}
use of org.apache.directory.fortress.core.model.User 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.core.model.User in project directory-fortress-core by apache.
the class DelReviewMgrRestImpl method assignedUsers.
/**
* {@inheritDoc}
*/
@Override
public List<User> assignedUsers(AdminRole role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".assignedUsers");
List<User> retUsers;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED_ADMIN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retUsers = response.getEntities();
// do not return a null list to the caller:
if (retUsers == null) {
retUsers = new ArrayList<>();
}
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retUsers;
}
Aggregations