Search in sources :

Example 86 with FortRequest

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

the class ReviewMgrRestImpl method findAnyPermissions.

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

Example 87 with FortRequest

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

the class ReviewMgrRestImpl method dsdRoleSet.

/**
 * {@inheritDoc}
 */
@Override
public SDSet dsdRoleSet(SDSet set) throws SecurityException {
    VUtil.assertNotNull(set, GlobalErrIds.DSD_NULL, CLS_NM + ".dsdRoleSet");
    SDSet retSet;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(set);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_READ);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retSet = (SDSet) response.getEntity();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retSet;
}
Also used : SDSet(org.apache.directory.fortress.core.model.SDSet) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 88 with FortRequest

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

the class ReviewMgrRestImpl method authorizedPermissionRoles.

/**
 * {@inheritDoc}
 */
@Override
public Set<String> authorizedPermissionRoles(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".authorizedPermissionRoles");
    Set<String> retRoleNames = 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_ROLES_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.
        retRoleNames.addAll(tempNames);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoleNames;
}
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 89 with FortRequest

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

the class ReviewMgrRestImpl method permissionRoles.

/**
 * {@inheritDoc}
 */
@Override
public List<String> permissionRoles(Permission perm) throws SecurityException {
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OBJECT_NULL, CLS_NM + ".permissionRoles");
    List<String> retRoleNames;
    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_ROLES);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retRoleNames = response.getValues();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoleNames;
}
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 90 with FortRequest

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

the class ReviewMgrRestImpl method readRole.

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

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