use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class ReviewMgrImpl method findRoles.
/**
* {@inheritDoc}
*/
@Override
@AdminPermissionOperation
public List<String> findRoles(String searchVal, int limit) throws SecurityException {
String methodName = "findRoles";
VUtil.assertNotNull(searchVal, GlobalErrIds.ROLE_NM_NULL, CLS_NM + "." + methodName);
checkAccess(CLS_NM, methodName);
Role role = new Role(searchVal);
role.setContextId(this.contextId);
return roleP.search(role, limit);
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class RoleDAO method unloadDescendants.
/**
* @param le
* @param sequence
* @param contextId
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Graphable unloadDescendants(Entry le, long sequence, String contextId) throws LdapInvalidAttributeValueException {
Role entity = new ObjectFactory().createRole();
entity.setSequenceId(sequence);
entity.setName(getAttribute(le, ROLE_NM));
entity.setParents(getAttributeSet(le, GlobalIds.PARENT_NODES));
return entity;
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class RoleP method removeOccupant.
/**
* Remove the User dn occupant attribute from the OrganizationalRole entity in ldap. This method is called by AdminMgrImpl
* when the User is being deleted.
*
* @param userDn contains the userId targeted for attribute removal.
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @throws SecurityException in the event of DAO search error.
*/
void removeOccupant(String userDn, String contextId) throws SecurityException {
List<String> list;
try {
list = rDao.findAssignedRoles(userDn, contextId);
for (String roleNm : list) {
Role role = new Role(roleNm);
role.setContextId(contextId);
deassign(role, userDn);
}
} catch (FinderException fe) {
String error = "removeOccupant userDn [" + userDn + "] caught FinderException=" + fe;
throw new SecurityException(GlobalErrIds.ROLE_REMOVE_OCCUPANT_FAILED, error, fe);
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class RoleP method addOccupant.
/**
* Add the User dn occupant attribute to the OrganizationalRole entity in ldap. This method is called by AdminMgrImpl
* when the User is being added.
*
* @param uRoles contains a collection of UserRole being targeted for assignment.
* @param userDn contains the userId targeted for addition.
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @throws SecurityException in the event of DAO search error.
*/
void addOccupant(List<UserRole> uRoles, String userDn, String contextId) throws SecurityException {
if (CollectionUtils.isNotEmpty(uRoles)) {
for (UserRole uRole : uRoles) {
Role role = new Role(uRole.getName());
role.setContextId(contextId);
assign(role, userDn);
}
}
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class AdminMgrRestImpl method updateRole.
/**
* {@inheritDoc}
*/
@Override
public Role updateRole(Role role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".updateRole");
Role retRole;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRole = (Role) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRole;
}
Aggregations