Search in sources :

Example 11 with FortRequest

use of org.apache.directory.fortress.core.model.FortRequest 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;
}
Also used : RolePerm(org.apache.directory.fortress.core.model.RolePerm) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Example 12 with FortRequest

use of org.apache.directory.fortress.core.model.FortRequest 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());
    }
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Example 13 with FortRequest

use of org.apache.directory.fortress.core.model.FortRequest 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;
}
Also used : UserRole(org.apache.directory.fortress.core.model.UserRole) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Example 14 with FortRequest

use of org.apache.directory.fortress.core.model.FortRequest 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());
    }
}
Also used : AdminRoleRelationship(org.apache.directory.fortress.core.model.AdminRoleRelationship) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 15 with FortRequest

use of org.apache.directory.fortress.core.model.FortRequest 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;
}
Also used : PermObj(org.apache.directory.fortress.core.model.PermObj) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Aggregations

FortRequest (org.apache.directory.fortress.core.model.FortRequest)153 SecurityException (org.apache.directory.fortress.core.SecurityException)152 FortResponse (org.apache.directory.fortress.core.model.FortResponse)152 SDSet (org.apache.directory.fortress.core.model.SDSet)20 Permission (org.apache.directory.fortress.core.model.Permission)11 Session (org.apache.directory.fortress.core.model.Session)10 PermGrant (org.apache.directory.fortress.core.model.PermGrant)8 User (org.apache.directory.fortress.core.model.User)8 UserRole (org.apache.directory.fortress.core.model.UserRole)8 Group (org.apache.directory.fortress.core.model.Group)7 PermObj (org.apache.directory.fortress.core.model.PermObj)7 TreeSet (java.util.TreeSet)6 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)6 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)5 AdminRole (org.apache.directory.fortress.core.model.AdminRole)4 AdminRoleRelationship (org.apache.directory.fortress.core.model.AdminRoleRelationship)4 OrgUnitRelationship (org.apache.directory.fortress.core.model.OrgUnitRelationship)4 Props (org.apache.directory.fortress.core.model.Props)4 Role (org.apache.directory.fortress.core.model.Role)4 RoleRelationship (org.apache.directory.fortress.core.model.RoleRelationship)4