use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrRestImpl method grantPermission.
/**
* {@inheritDoc}
*/
@Override
public void grantPermission(Permission perm, Role role) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".grantPermission");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".grantPermission");
FortRequest request = RestUtils.getRequest(this.contextId);
PermGrant permGrant = new PermGrant();
permGrant.setAdmin(perm.isAdmin());
permGrant.setObjName(perm.getObjName());
permGrant.setObjId(perm.getObjId());
permGrant.setOpName(perm.getOpName());
permGrant.setRoleNm(role.getName());
request.setEntity(permGrant);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_GRANT);
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 deassignUser.
/**
* {@inheritDoc}
*/
@Override
public void deassignUser(UserRole uRole) throws SecurityException {
VUtil.assertNotNull(uRole, GlobalErrIds.URLE_NULL, CLS_NM + ".deassignUser");
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(uRole);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_DEASGN);
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 addDescendant.
/**
* {@inheritDoc}
*/
@Override
public void addDescendant(Role parentRole, Role childRole) throws SecurityException {
VUtil.assertNotNull(parentRole, GlobalErrIds.PARENT_ROLE_NULL, CLS_NM + ".addDescendant");
VUtil.assertNotNull(childRole, GlobalErrIds.CHILD_ROLE_NULL, CLS_NM + ".addDescendant");
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_DESC);
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 addDsdRoleMember.
/**
* {@inheritDoc}
*/
@Override
public SDSet addDsdRoleMember(SDSet dsdSet, Role role) throws SecurityException {
VUtil.assertNotNull(dsdSet, GlobalErrIds.SSD_NULL, CLS_NM + ".addDsdRoleMember");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".addDsdRoleMember");
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_ADD_MEMBER);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retSet = (SDSet) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retSet;
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class AdminMgrRestImpl method removeRoleConstraint.
/**
* {@inheritDoc}
*/
@Override
public void removeRoleConstraint(UserRole uRole, RoleConstraint roleConstraint) throws SecurityException {
VUtil.assertNotNull(uRole, GlobalErrIds.URLE_NULL, CLS_NM + ".removeRoleConstraint");
VUtil.assertNotNull(roleConstraint, GlobalErrIds.RCON_NULL, CLS_NM + ".removeRoleConstraint");
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(uRole);
request.setEntity2(roleConstraint);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_DELETE_CONSTRAINT);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
Aggregations