Search in sources :

Example 16 with Group

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

the class GroupMgrConsole method assign.

void assign() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter userId");
        String userId = ReaderUtil.readLn();
        System.out.println("Enter group name");
        String name = ReaderUtil.readLn();
        groupMgr.assign(new Group(name), userId);
        System.out.println("Group assigned user");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("assign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 17 with Group

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

the class GroupMgrConsole method deleteProperty.

void deleteProperty() {
    try {
        Group group = new Group();
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        group.setName(ReaderUtil.readLn());
        System.out.println("Enter property key:");
        String key = ReaderUtil.readLn();
        System.out.println("Enter property value:");
        String value = ReaderUtil.readLn();
        groupMgr.delete(group, key, value);
        System.out.println("Delete property from Group successful");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("deleteProperty caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 18 with Group

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

the class PropertyMgrImplTest method testCrudProperties.

public void testCrudProperties() {
    Role role = RoleTestData.getRole(RoleTestData.ROLES_TR1[0]);
    AdminRole adminRole = AdminRoleTestData.getRole(AdminRoleTestData.AROLES_TR1[0]);
    PermObj permObj = PermTestData.getObj(PermTestData.OBJS_TOB1[0]);
    Permission permOp = PermTestData.getOp(permObj.getObjName(), PermTestData.OPS_TOP1[0]);
    Group group = GroupTestData.TEST_GROUP1;
    addProperties("ADD-PROP-RLE", role, PROPS);
    addProperties("ADD-PROP-ADMRLE", adminRole, PROPS);
    addProperties("ADD-PROP-POBJ", permObj, PROPS);
    addProperties("ADD-PROP-POP", permOp, PROPS);
    addProperties("ADD-PROP-GRP", group, PROPS);
    updateProperties("UPD-PROP-RLE", role, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", permOp, PROPS_UPDATED[0]);
    updateProperties("UPD-PROP-POP", group, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-RLE", role, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-ADMRLE", adminRole, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POBJ", permObj, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", permOp, PROPS_UPDATED[0]);
    deleteProperties("DEL-PROP-POP", group, PROPS_UPDATED[0]);
}
Also used : AdminRole(org.apache.directory.fortress.core.model.AdminRole) Role(org.apache.directory.fortress.core.model.Role) Group(org.apache.directory.fortress.core.model.Group) PermObj(org.apache.directory.fortress.core.model.PermObj) Permission(org.apache.directory.fortress.core.model.Permission) AdminRole(org.apache.directory.fortress.core.model.AdminRole)

Example 19 with Group

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

the class FortressAntTask method deleteGroupProperties.

/**
 * @throws BuildException An error occurred while building
 */
private void deleteGroupProperties() throws BuildException {
    if (delgroupproperties == null) {
        return;
    }
    // Loop through the entityclass elements
    for (Delgroupproperty delgroupproperty : delgroupproperties) {
        List<Group> groups = delgroupproperty.getGroups();
        for (Group group : groups) {
            if (PropUtil.isNotEmpty(group.getProperties())) {
                for (Enumeration<?> e = group.getProperties().propertyNames(); e.hasMoreElements(); ) {
                    // This LDAP attr is stored as a name-value pair separated by a ':'.
                    String key = (String) e.nextElement();
                    String val = group.getProperties().getProperty(key);
                    try {
                        groupMgr.delete(group, key, val);
                    } catch (SecurityException se) {
                        LOG.warn("deleteGroupProperties tenant={} name [{}], key [{}], value [{}] caught SecurityException={}", getTenant(), group.getName(), key, val, se);
                    }
                }
            } else {
                LOG.info("deleteGroupProperties tenant={} name={}, no properties found", getTenant(), group.getName());
            }
        }
    }
}
Also used : Group(org.apache.directory.fortress.core.model.Group) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 20 with Group

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

the class GroupAntTest method findGroups.

private void findGroups(String msg, List<Group> inGroups) {
    LogUtil.logIt(msg);
    try {
        GroupMgr groupMgr = GroupMgrFactory.createInstance();
        List<Group> outGroups = groupMgr.find(new Group("t"));
        assertNotNull(outGroups);
        assertTrue("findGroups result set wrong size", outGroups.size() == inGroups.size());
        for (Group inGroupAnt : inGroups) {
            Group inGroup = inGroupAnt;
            int index = outGroups.indexOf(inGroup);
            assertTrue("findGroups input data error ", index != -1);
            Group outGroup = outGroups.get(index);
            assertNotNull(outGroup);
            assertEqual(inGroup, outGroup);
        }
    } catch (SecurityException ex) {
        LOG.error("findGroups 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)

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