Search in sources :

Example 21 with FortResponse

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

Example 22 with FortResponse

use of org.apache.directory.fortress.core.model.FortResponse 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());
    }
}
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)

Example 23 with FortResponse

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

Example 24 with FortResponse

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

Example 25 with FortResponse

use of org.apache.directory.fortress.core.model.FortResponse in project directory-fortress-core by apache.

the class DelReviewMgrRestImpl method assignedRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<UserAdminRole> assignedRoles(User user) throws SecurityException {
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".assignedRoles");
    List<UserAdminRole> retUserRoles;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(user);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ARLE_ASGNED);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUserRoles = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUserRoles;
}
Also used : UserAdminRole(org.apache.directory.fortress.core.model.UserAdminRole) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Aggregations

FortResponse (org.apache.directory.fortress.core.model.FortResponse)153 SecurityException (org.apache.directory.fortress.core.SecurityException)152 FortRequest (org.apache.directory.fortress.core.model.FortRequest)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