Search in sources :

Example 26 with FortResponse

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

the class DelReviewMgrRestImpl method assignedUsers.

/**
 * {@inheritDoc}
 */
@Override
public List<User> assignedUsers(AdminRole role) throws SecurityException {
    VUtil.assertNotNull(role, GlobalErrIds.ARLE_NULL, CLS_NM + ".assignedUsers");
    List<User> retUsers;
    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.USER_ASGNED_ADMIN);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        retUsers = response.getEntities();
        // do not return a null list to the caller:
        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 27 with FortResponse

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

the class GroupMgrRestImpl method read.

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

Example 28 with FortResponse

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

the class GroupMgrRestImpl method add.

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

Example 29 with FortResponse

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

the class GroupMgrRestImpl method roleGroups.

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

Example 30 with FortResponse

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

the class AdminMgrRestImpl method addInheritance.

/**
 * {@inheritDoc}
 */
@Override
public void addInheritance(Role parentRole, Role childRole) throws SecurityException {
    VUtil.assertNotNull(parentRole, GlobalErrIds.PARENT_ROLE_NULL, CLS_NM + ".addInheritance");
    VUtil.assertNotNull(childRole, GlobalErrIds.CHILD_ROLE_NULL, CLS_NM + ".addInheritance");
    FortRequest request = RestUtils.getRequest(this.contextId);
    RoleRelationship relationship = new RoleRelationship();
    relationship.setParent(parentRole);
    relationship.setChild(childRole);
    request.setEntity(relationship);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_ADDINHERIT);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() != 0) {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
}
Also used : RoleRelationship(org.apache.directory.fortress.core.model.RoleRelationship) 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