use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method canRevoke.
/**
* {@inheritDoc}
*/
@Override
public boolean canRevoke(Session session, Role role, Permission perm) throws SecurityException {
String methodName = CLS_NM + "canRevoke";
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OBJECT_NULL, methodName);
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, methodName);
boolean result;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
RolePerm context = new RolePerm();
context.setPerm(perm);
context.setRole(role);
request.setSession(session);
request.setEntity(context);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
result = response.getAuthorized();
Session outSession = response.getSession();
session.copy(outSession);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return result;
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method dropActiveRole.
/**
* {@inheritDoc}
*/
@Override
public void dropActiveRole(Session session, UserAdminRole role) throws SecurityException {
String methodName = CLS_NM + ".dropActiveRole";
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, methodName);
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setSession(session);
request.setEntity(role);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_DROP);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
Session outSession = response.getSession();
session.copy(outSession);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method canDeassign.
/**
* {@inheritDoc}
*/
@Override
public boolean canDeassign(Session session, User user, Role role) throws SecurityException {
String methodName = CLS_NM + ".canDeassign";
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, methodName);
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, methodName);
boolean result;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
UserRole uRole = new UserRole(user.getUserId(), role.getName());
request.setSession(session);
request.setEntity(uRole);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_DEASSIGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
result = response.getAuthorized();
Session outSession = response.getSession();
session.copy(outSession);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return result;
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method addDescendant.
/**
* {@inheritDoc}
*/
@Override
public void addDescendant(AdminRole parentRole, AdminRole childRole) throws SecurityException {
String methodName = "addDescendantRole";
VUtil.assertNotNull(parentRole, GlobalErrIds.ARLE_PARENT_NULL, CLS_NM + "." + methodName);
VUtil.assertNotNull(childRole, GlobalErrIds.ARLE_CHILD_NULL, CLS_NM + "." + methodName);
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
AdminRoleRelationship relationship = new AdminRoleRelationship();
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.ARLE_DESC);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method updatePermObj.
/**
* {@inheritDoc}
*/
@Override
public PermObj updatePermObj(PermObj pObj) throws SecurityException {
VUtil.assertNotNull(pObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".updatePermObj");
PermObj retObj;
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_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retObj = (PermObj) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retObj;
}
Aggregations