Search in sources :

Example 21 with Group

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

the class GroupAntTest method readGroups.

private void readGroups(String msg, List<Group> groups) {
    LogUtil.logIt(msg);
    try {
        GroupMgr groupMgr = GroupMgrFactory.createInstance();
        for (Group inGroup : groups) {
            Group outGroup = groupMgr.read(inGroup);
            assertNotNull(outGroup);
            assertEqual(inGroup, outGroup);
        }
    } catch (SecurityException ex) {
        LOG.error("readGroups caught SecurityException=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : GroupMgr(org.apache.directory.fortress.core.GroupMgr) Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 22 with Group

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

the class GroupAntTest method testFindGroups.

@Test
public void testFindGroups() {
    // gather role input data:
    List<Addgroup> addgroups = fortressAntTask.getAddgroups();
    for (Addgroup addgroup : addgroups) {
        List<Group> groups = addgroup.getGroups();
        findGroups("FIND-GRPS", groups);
    }
}
Also used : Group(org.apache.directory.fortress.core.model.Group) Addgroup(org.apache.directory.fortress.core.ant.Addgroup) Test(org.junit.Test)

Example 23 with Group

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

the class GroupMgrImplTest method deassignRoleMember.

private void deassignRoleMember(String message, Group group, String[][] roles) {
    LogUtil.logIt(message);
    try {
        groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
        for (String[] roleArray : roles) {
            Role role = RoleTestData.getRole(roleArray);
            groupMgr.deassign(group, role.getName());
        }
        LOG.debug("deassignRoleMember group [" + group.getName() + "] successful");
        int countOfOldRoles = group.getMembers().size();
        // read from LDAP and get count of members
        Group groupFromLdap = groupMgr.read(group);
        int actualAmountOfMembers = groupFromLdap.getMembers().size();
        assertEquals(CLS_NM + ".deassignRoleMember failed members size check", countOfOldRoles, actualAmountOfMembers);
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("deassignRoleMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 24 with Group

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

the class GroupMgrImplTest method deleteGroups.

private void deleteGroups(String message, Group group) {
    LogUtil.logIt(message);
    try {
        groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
        Group nameOnlyGroup = new Group(group.getName());
        groupMgr.delete(nameOnlyGroup);
        LOG.debug("addGroup group [" + group.getName() + "] successful");
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("addGroup: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 25 with Group

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

the class GroupMgrImplTest method assignRoleMember.

private void assignRoleMember(String message, Group group, String[][] roles) {
    LogUtil.logIt(message);
    try {
        groupMgr = GroupMgrFactory.createInstance(TestUtils.getContext());
        for (String[] roleArray : roles) {
            Role role = RoleTestData.getRole(roleArray);
            groupMgr.assign(group, role.getName());
        }
        LOG.debug("assignRoleMember group [" + group.getName() + "] successful");
        int countOfOldRoles = group.getMembers().size();
        int countOfNewRoles = roles.length;
        // read from LDAP and get count of members
        Group groupFromLdap = groupMgr.read(group);
        int actualAmountOfMembers = groupFromLdap.getMembers().size();
        assertEquals(CLS_NM + ".assignRoleMember failed members size check", countOfOldRoles + countOfNewRoles, actualAmountOfMembers);
    } catch (SecurityException ex) {
        ex.printStackTrace();
        LOG.error("assignRoleMember: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Role(org.apache.directory.fortress.core.model.Role) UserRole(org.apache.directory.fortress.core.model.UserRole) Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

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