Search in sources :

Example 26 with Group

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

the class GroupTestData method createGroup.

private static Group createGroup(String name, Type type, String protocol, boolean memberDn, List<String> memberNames) {
    Group group = new Group();
    group.setName(name);
    group.setProtocol(protocol);
    group.setMemberDn(memberDn);
    group.setType(type);
    group.setMembers(memberNames);
    return group;
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 27 with Group

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

the class GroupMgrRestImpl method deassign.

/**
 * {@inheritDoc}
 */
@Override
public Group deassign(Group group, String member) throws SecurityException {
    VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".deassign");
    VUtil.assertNotNull(member, GlobalErrIds.GROUP_MEMBER_NULL, CLS_NM + ".deassign");
    Group retGroup;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(group);
    request.setValue(member);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_DEASGN);
    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 Group

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

the class GroupMgrRestImpl method delete.

/**
 * {@inheritDoc}
 */
@Override
public Group delete(Group group) throws SecurityException {
    VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".delete");
    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_DELETE);
    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 Group

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

the class GroupMgrRestImpl method assign.

/**
 * {@inheritDoc}
 */
@Override
public Group assign(Group group, String member) throws SecurityException {
    VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".assign");
    VUtil.assertNotNull(member, GlobalErrIds.GROUP_MEMBER_NULL, CLS_NM + ".assign");
    Group retGroup;
    FortRequest request = RestUtils.getRequest(this.contextId);
    request.setEntity(group);
    request.setValue(member);
    if (this.adminSess != null) {
        request.setSession(adminSess);
    }
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_ASGN);
    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 30 with Group

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

the class GroupMgrRestImpl method update.

/**
 * {@inheritDoc}
 */
@Override
public Group update(Group group) throws SecurityException {
    VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".update");
    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_UPDATE);
    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)

Aggregations

Group (org.apache.directory.fortress.core.model.Group)33 SecurityException (org.apache.directory.fortress.core.SecurityException)19 FortRequest (org.apache.directory.fortress.core.model.FortRequest)7 FortResponse (org.apache.directory.fortress.core.model.FortResponse)7 Role (org.apache.directory.fortress.core.model.Role)5 UserRole (org.apache.directory.fortress.core.model.UserRole)4 Enumeration (java.util.Enumeration)3 User (org.apache.directory.fortress.core.model.User)3 GroupMgr (org.apache.directory.fortress.core.GroupMgr)2 Addgroup (org.apache.directory.fortress.core.ant.Addgroup)2 AdminRole (org.apache.directory.fortress.core.model.AdminRole)2 Test (org.junit.Test)2 AdminPermissionOperation (org.apache.directory.fortress.annotation.AdminPermissionOperation)1 PermObj (org.apache.directory.fortress.core.model.PermObj)1 Permission (org.apache.directory.fortress.core.model.Permission)1 Relationship (org.apache.directory.fortress.core.model.Relationship)1 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)1