use of org.apache.directory.fortress.core.model.RolePerm in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method canGrant.
/**
* {@inheritDoc}
*/
@Override
public boolean canGrant(Session session, Role role, Permission perm) throws SecurityException {
String methodName = CLS_NM + "canGrant";
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_GRANT);
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.RolePerm 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;
}
Aggregations