Search in sources :

Example 11 with Group

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

the class GroupMgrConsole method add.

/**
 * Description of the Method
 */
void add() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        String name = ReaderUtil.readLn();
        System.out.println("Enter description:");
        String desc = ReaderUtil.readLn();
        Group group = new Group(name, desc);
        System.out.println("Is this a group of Users - Y or N");
        String choice = ReaderUtil.readLn();
        if (choice == null || choice.equalsIgnoreCase("Y")) {
            group.setType(Group.Type.USER);
        } else {
            group.setType(Group.Type.ROLE);
        }
        System.out.println("Enter protocol:");
        String protocol = ReaderUtil.readLn();
        group.setProtocol(protocol);
        System.out.println("Enter member name:");
        String mname = ReaderUtil.readLn();
        group.setMember(mname);
        groupMgr.add(group);
        System.out.println("Group successfully added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("add caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 12 with Group

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

the class GroupMgrConsole method readGroup.

void readGroup() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        Group inGroup = new Group(ReaderUtil.readLn());
        Group outGroup = groupMgr.read(inGroup);
        System.out.println("GROUP");
        System.out.println("    name        [" + outGroup.getName() + "]");
        System.out.println("    desc        [" + outGroup.getDescription() + "]");
        System.out.println("    protocol    [" + outGroup.getProtocol() + "]");
        if (CollectionUtils.isNotEmpty(outGroup.getMembers())) {
            int ctr = 0;
            for (String member : outGroup.getMembers()) {
                System.out.println("    member[" + ctr++ + "]=" + member);
            }
        }
        if (PropUtil.isNotEmpty(outGroup.getProperties())) {
            int ctr = 0;
            for (Enumeration e = outGroup.getProperties().propertyNames(); e.hasMoreElements(); ) {
                String key = (String) e.nextElement();
                String val = outGroup.getProperty(key);
                System.out.println("    prop key[" + ctr + "]=" + key);
                System.out.println("    prop val[" + ctr++ + "]=" + val);
            }
        }
        System.out.println("Group node successfully read");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("readGroup caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group) Enumeration(java.util.Enumeration)

Example 13 with Group

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

the class GroupMgrConsole method update.

/**
 * Description of the Method
 */
void update() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        String name = ReaderUtil.readLn();
        Group group = new Group(name);
        System.out.println("Enter description:");
        group.setDescription(ReaderUtil.readLn());
        System.out.println("Enter protocol:");
        String protocol = ReaderUtil.readLn();
        group.setProtocol(protocol);
        System.out.println("Enter member userId or NULL to skip");
        String userId = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(userId))
            group.setMember(userId);
        System.out.println("Enter property key or NULL to skip");
        String key = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(key)) {
            System.out.println("Enter property value");
            String value = ReaderUtil.readLn();
            group.addProperty(key, value);
        }
        groupMgr.update(group);
        System.out.println("Group successfully updated");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("update caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 14 with Group

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

the class GroupMgrConsole method deassign.

void deassign() {
    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 deassigned user");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("deassign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group)

Example 15 with Group

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

the class GroupMgrConsole method findGroups.

void findGroups() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group search name:");
        Group inGroup = new Group(ReaderUtil.readLn());
        List<Group> outGroups = groupMgr.find(inGroup);
        if (CollectionUtils.isNotEmpty(outGroups)) {
            int grpctr = 0;
            for (Group outGroup : outGroups) {
                System.out.println("GROUP[" + grpctr++ + "]");
                System.out.println("    name        [" + outGroup.getName() + "]");
                System.out.println("    desc        [" + outGroup.getDescription() + "]");
                System.out.println("    protocol    [" + outGroup.getProtocol() + "]");
                if (CollectionUtils.isNotEmpty(outGroup.getMembers())) {
                    int memberctr = 0;
                    for (String member : outGroup.getMembers()) {
                        System.out.println("    member[" + memberctr++ + "]=" + member);
                    }
                }
                if (PropUtil.isNotEmpty(outGroup.getProperties())) {
                    int propctr = 0;
                    for (Enumeration e = outGroup.getProperties().propertyNames(); e.hasMoreElements(); ) {
                        String key = (String) e.nextElement();
                        String val = outGroup.getProperty(key);
                        System.out.println("    prop key[" + propctr + "]=" + key);
                        System.out.println("    prop val[" + propctr++ + "]=" + val);
                    }
                }
            }
            System.out.println("Group nodes successfully searched");
        } else {
            System.out.println("No Group nodes found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("readGroup caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : Group(org.apache.directory.fortress.core.model.Group) Enumeration(java.util.Enumeration)

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