use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method grantPermission.
/**
* {@inheritDoc}
*/
@Override
public void grantPermission(Permission perm, User user) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".grantPermissionUser");
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".grantPermissionUser");
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
PermGrant permGrant = new PermGrant();
permGrant.setAdmin(true);
permGrant.setObjName(perm.getObjName());
permGrant.setObjId(perm.getObjId());
permGrant.setOpName(perm.getOpName());
permGrant.setUserId(user.getUserId());
request.setEntity(permGrant);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_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 DelAdminMgrRestImpl method add.
/**
* {@inheritDoc}
*/
@Override
public OrgUnit add(OrgUnit entity) throws SecurityException {
VUtil.assertNotNull(entity, GlobalErrIds.ORG_NULL, CLS_NM + ".addOU");
OrgUnit retOrg;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(entity);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ORG_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retOrg = (OrgUnit) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retOrg;
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method deletePermObj.
/**
* {@inheritDoc}
*/
@Override
public void deletePermObj(PermObj pObj) throws SecurityException {
VUtil.assertNotNull(pObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".deletePermObj");
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
pObj.setAdmin(true);
request.setEntity(pObj);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_DELETE);
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 DelReviewMgrRestImpl method readRole.
/**
* {@inheritDoc}
*/
@Override
public AdminRole readRole(AdminRole role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".readRole");
AdminRole retRole;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRole = (AdminRole) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRole;
}
use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.
the class DelReviewMgrRestImpl method findRoles.
/**
* {@inheritDoc}
*/
@Override
public List<AdminRole> findRoles(String searchVal) throws SecurityException {
VUtil.assertNotNull(searchVal, GlobalErrIds.ARLE_NM_NULL, CLS_NM + ".findRoles");
List<AdminRole> retRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setValue(searchVal);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRoles = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoles;
}
Aggregations