Search in sources :

Example 61 with FortRequest

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

the class ReviewMgrRestImpl method findUsers.

/**
 * {@inheritDoc}
 */
@Override
public final List<String> findUsers(User user, int limit) throws SecurityException {
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".findUsers");
    List<String> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setLimit(limit);
    request.setEntity(user);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_SEARCH);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUsers = response.getValues();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUsers;
}
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 62 with FortRequest

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

the class ReviewMgrRestImpl method permissionUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<String> permissionUsers(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".permissionUsers");
    List<String> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_USERS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUsers = response.getValues();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUsers;
}
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 63 with FortRequest

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

the class ReviewMgrRestImpl method findPermObjs.

/**
 * {@inheritDoc}
 */
@Override
public List<PermObj> findPermObjs(PermObj permObj) throws SecurityException {
    VUtil.assertNotNull(permObj, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".findPermObjs");
    List<PermObj> retObjs;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(permObj);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.OBJ_SEARCH);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retObjs = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retObjs;
}
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)

Example 64 with FortRequest

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

the class ReviewMgrRestImpl method authorizedPermissionUsers.

/**
 * {@inheritDoc}
 */
@Override
public Set<String> authorizedPermissionUsers(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".authorizedPermissionUsers");
    Set<String> retUserIds = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(perm);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_USERS_AUTHZED);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        Set<String> tempNames = response.getValueSet();
        // This is done to use a case insensitive TreeSet for returned names.
        retUserIds.addAll(tempNames);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUserIds;
}
Also used : TreeSet(java.util.TreeSet) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 65 with FortRequest

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

the class ReviewMgrRestImpl method readUser.

/**
 * {@inheritDoc}
 */
@Override
public final User readUser(User user) throws SecurityException {
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".readUser");
    User retUser;
    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.USER_READ);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUser = (User) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUser;
}
Also used : User(org.apache.directory.fortress.core.model.User) 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