Search in sources :

Example 16 with User

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

Example 17 with User

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

the class ReviewMgrRestImpl method findUsers.

/**
 * {@inheritDoc}
 */
@Override
public final List<User> findUsers(User user) throws SecurityException {
    VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".findUsers");
    List<User> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(user);
    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 18 with User

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

the class ReviewMgrRestImpl method authorizedUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<User> authorizedUsers(Role role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".authorizedUsers");
    List<User> retUsers;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(role);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_AUTHZED);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUsers = response.getEntities();
        if (retUsers == null) {
            retUsers = new ArrayList<>();
        }
    } 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 19 with User

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

the class ReviewMgrRestImpl method assignedUsers.

@Override
public List<User> assignedUsers(Role role, RoleConstraint roleConstraint) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".assignedUsers");
    VUtil.assertNotNull(roleConstraint, GlobalErrIds.ROLE_CONSTRAINT_NULL, CLS_NM + ".assignedUsers");
    List<User> users;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setEntity(role);
    request.setEntity2(roleConstraint);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED_CONSTRAINTS);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        users = response.getEntities();
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return users;
}
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 20 with User

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

the class ReviewMgrRestImpl method assignedUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<User> assignedUsers(Role role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".assignedUsers");
    List<User> retUsers;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(role);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_ASGNED);
    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)

Aggregations

User (org.apache.directory.fortress.core.model.User)217 SecurityException (org.apache.directory.fortress.core.SecurityException)148 UserRole (org.apache.directory.fortress.core.model.UserRole)78 Session (org.apache.directory.fortress.core.model.Session)57 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)46 AdminMgr (org.apache.directory.fortress.core.AdminMgr)41 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)41 Role (org.apache.directory.fortress.core.model.Role)38 AccessMgr (org.apache.directory.fortress.core.AccessMgr)34 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)31 Permission (org.apache.directory.fortress.core.model.Permission)29 FortResponse (org.apache.directory.fortress.core.model.FortResponse)22 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)18 AdminRole (org.apache.directory.fortress.core.model.AdminRole)18 ArrayList (java.util.ArrayList)13 AccelMgr (org.apache.directory.fortress.core.AccelMgr)12 PwPolicyMgr (org.apache.directory.fortress.core.PwPolicyMgr)10 Constraint (org.apache.directory.fortress.core.model.Constraint)9 FortRequest (org.apache.directory.fortress.core.model.FortRequest)9 Test (org.junit.Test)7