Search in sources :

Example 96 with FortResponse

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

the class ReviewMgrRestImpl method findUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<User> findUsers(OrgUnit ou) throws SecurityException {
    VUtil.assertNotNull(ou, GlobalErrIds.ORG_NULL_USER, CLS_NM + ".findUsers");
    List<User> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    User inUser = new User();
    inUser.setOu(ou.getName());
    request.setEntity(inUser);
    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.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retUsers;
}
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)

Example 97 with FortResponse

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

the class ReviewMgrRestImpl method dsdRoleSetRoles.

/**
 * {@inheritDoc}
 */
@Override
public Set<String> dsdRoleSetRoles(SDSet dsd) throws SecurityException {
    VUtil.assertNotNull(dsd, GlobalErrIds.SSD_NULL, CLS_NM + ".dsdRoleSetRoles");
    Set<String> retRoleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(dsd);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_ROLES);
    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 98 with FortResponse

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

the class ReviewMgrRestImpl method dsdSets.

/**
 * {@inheritDoc}
 */
public List<SDSet> dsdSets(SDSet dsd) throws SecurityException {
    VUtil.assertNotNull(dsd, GlobalErrIds.ROLE_NULL, CLS_NM + ".dsdSets");
    List<SDSet> retDsdSets;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(dsd);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.DSD_SETS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retDsdSets = response.getEntities();
        if (retDsdSets == null) {
            retDsdSets = new ArrayList<>();
        }
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retDsdSets;
}
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 99 with FortResponse

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

the class AuditMgrRestImpl method searchInvalidUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<AuthZ> searchInvalidUsers(UserAudit uAudit) throws SecurityException {
    VUtil.assertNotNull(uAudit, GlobalErrIds.AUDT_INPUT_NULL, CLS_NM + ".searchInvalidUsers");
    List<AuthZ> outRecords;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(uAudit);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_INVLD);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        outRecords = response.getEntities();
        // do not return a null list to the caller:
        if (outRecords == null) {
            outRecords = new ArrayList<>();
        }
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return outRecords;
}
Also used : AuthZ(org.apache.directory.fortress.core.model.AuthZ) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 100 with FortResponse

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

the class AuditMgrRestImpl method searchUserSessions.

/**
 * {@inheritDoc}
 */
@Override
public List<Mod> searchUserSessions(UserAudit uAudit) throws SecurityException {
    VUtil.assertNotNull(uAudit, GlobalErrIds.AUDT_INPUT_NULL, CLS_NM + ".searchUserSessions");
    List<Mod> outRecords;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(uAudit);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_SESSIONS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        outRecords = response.getEntities();
        // do not return a null list to the caller:
        if (outRecords == null) {
            outRecords = new ArrayList<>();
        }
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return outRecords;
}
Also used : Mod(org.apache.directory.fortress.core.model.Mod) 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