use of org.apache.directory.fortress.core.SecurityException 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.SecurityException in project directory-fortress-core by apache.
the class RoleUtil method loadGraph.
/**
* Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
* using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing role hierarchies.
*/
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
Hier inHier = new Hier(Hier.Type.ROLE);
inHier.setContextId(contextId);
LOG.info("loadGraph initializing ROLE context [{}]", inHier.getContextId());
List<Graphable> descendants = null;
try {
descendants = roleP.getAllDescendants(inHier.getContextId());
} catch (SecurityException se) {
LOG.info("loadGraph caught SecurityException={}", se);
}
Hier hier = HierUtil.loadHier(contextId, descendants);
SimpleDirectedGraph<String, Relationship> graph;
graph = HierUtil.buildGraph(hier);
roleCache.put(getKey(contextId), graph);
return graph;
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrRestImpl method addInheritance.
/**
* {@inheritDoc}
*/
@Override
public void addInheritance(Role parentRole, Role childRole) throws SecurityException {
VUtil.assertNotNull(parentRole, GlobalErrIds.PARENT_ROLE_NULL, CLS_NM + ".addInheritance");
VUtil.assertNotNull(childRole, GlobalErrIds.CHILD_ROLE_NULL, CLS_NM + ".addInheritance");
FortRequest request = RestUtils.getRequest(this.contextId);
RoleRelationship relationship = new RoleRelationship();
relationship.setParent(parentRole);
relationship.setChild(childRole);
request.setEntity(relationship);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ADDINHERIT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrRestImpl method removePermissionAttributeFromSet.
/**
* {@inheritDoc}
*/
@Override
public void removePermissionAttributeFromSet(PermissionAttribute permAttribute, String attributeSetName) throws SecurityException {
VUtil.assertNotNull(permAttribute, GlobalErrIds.PERM_ATTRIBUTE_SET_NULL, CLS_NM + ".removePermissionAttributeFromSet");
VUtil.assertNotNull(attributeSetName, GlobalErrIds.PERM_ATTRIBUTE_SET_NM_NULL, CLS_NM + ".removePermissionAttributeFromSet");
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(permAttribute);
request.setValue(attributeSetName);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_DELETE_PERM_ATTRIBUTE_TO_SET);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrRestImpl method deleteDsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
public SDSet deleteDsdRoleMember(SDSet dsdSet, Role role) throws SecurityException {
VUtil.assertNotNull(dsdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".deleteDsdRoleMember");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".deleteSsdRoleMember");
SDSet retSet;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(dsdSet);
request.setValue(role.getName());
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_DEL_MEMBER);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
Aggregations