use of org.apache.directory.fortress.core.model.PermGrant in project directory-fortress-core by apache.
the class AdminMgrRestImpl method revokePermission.
/**
* {@inheritDoc}
*/
@Override
public void revokePermission(Permission perm, User user) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".revokePermission");
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".revokePermission");
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.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_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
use of org.apache.directory.fortress.core.model.PermGrant in project directory-fortress-core by apache.
the class AdminMgrRestImpl method revokePermission.
/**
* {@inheritDoc}
*/
@Override
public void revokePermission(Permission perm, Role role) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".revokePermission");
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".revokePermission");
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_REVOKE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() != 0) {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
}
Aggregations