Package org.apache.karaf.jaas.boot.principal

Examples of org.apache.karaf.jaas.boot.principal.GroupPrincipal


        principals = new HashSet<Principal>();
        principals.add(new UserPrincipal(user));
        for (int i = 1; i < infos.length; i++) {
            if (infos[i].trim().startsWith(PropertiesBackingEngine.GROUP_PREFIX)) {
                // it's a group reference
                principals.add(new GroupPrincipal(infos[i].trim().substring(PropertiesBackingEngine.GROUP_PREFIX.length())));
                String groupInfo = (String) users.get(infos[i].trim());
                if (groupInfo != null) {
                    String[] roles = groupInfo.split(",");
                    for (int j = 1; j < roles.length; j++) {
                        principals.add(new RolePrincipal(roles[j].trim()));
View Full Code Here


        module.login();
        module.commit();

        assertTrue(subject.getPrincipals().contains(new UserPrincipal("abc")));
        assertTrue(subject.getPrincipals().contains(new GroupPrincipal("group1")));
        assertTrue(subject.getPrincipals().contains(new RolePrincipal("role1")));
        assertTrue(subject.getPrincipals().contains(new RolePrincipal("role2")));
    }
View Full Code Here

        engine.addUser("abc", "xyz");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).isEmpty());
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).isEmpty());
        assertTrue(engine.listGroups(new UserPrincipal("abc")).isEmpty());

        engine.addRole("abc", "role1");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role1")));
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).isEmpty());
        assertTrue(engine.listGroups(new UserPrincipal("abc")).isEmpty());

        engine.addGroupRole("group1", "role2");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role1")));
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).contains(new RolePrincipal("role2")));
        assertTrue(engine.listGroups(new UserPrincipal("abc")).isEmpty());

        engine.addGroup("abc", "group1");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role1")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role2")));
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).contains(new RolePrincipal("role2")));
        assertTrue(engine.listGroups(new UserPrincipal("abc")).contains(new GroupPrincipal("group1")));

        engine.deleteRole("abc", "role1");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role2")));
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).contains(new RolePrincipal("role2")));
        assertTrue(engine.listGroups(new UserPrincipal("abc")).contains(new GroupPrincipal("group1")));

        engine.deleteGroupRole("group1", "role2");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).isEmpty());
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).isEmpty());
        assertTrue(engine.listGroups(new UserPrincipal("abc")).contains(new GroupPrincipal("group1")));

        engine.addGroupRole("group1", "role3");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).contains(new RolePrincipal("role3")));
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).contains(new RolePrincipal("role3")));
        assertTrue(engine.listGroups(new UserPrincipal("abc")).contains(new GroupPrincipal("group1")));

        engine.deleteGroup("abc", "group1");

        assertTrue(engine.listUsers().contains(new UserPrincipal("abc")));
        assertTrue(engine.listRoles(new UserPrincipal("abc")).isEmpty());
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).isEmpty());
        assertTrue(engine.listGroups(new UserPrincipal("abc")).isEmpty());

        engine.deleteUser("abc");

        assertTrue(engine.listUsers().isEmpty());
        assertTrue(engine.listRoles(new UserPrincipal("abc")).isEmpty());
        assertTrue(engine.listRoles(new GroupPrincipal("group1")).isEmpty());
        assertTrue(engine.listGroups(new UserPrincipal("abc")).isEmpty());
    }
View Full Code Here

        principals = new HashSet<Principal>();
        principals.add(new UserPrincipal(user));
        for (int i = 1; i < infos.length; i++) {
            if (infos[i].trim().startsWith(PropertiesBackingEngine.GROUP_PREFIX)) {
                // it's a group reference
                principals.add(new GroupPrincipal(infos[i].trim().substring(PropertiesBackingEngine.GROUP_PREFIX.length())));
                String groupInfo = (String) users.get(infos[i].trim());
                if (groupInfo != null) {
                    String[] roles = groupInfo.split(",");
                    for (int j = 1; j < roles.length; j++) {
                        principals.add(new RolePrincipal(roles[j].trim()));
View Full Code Here

        if (userInfo != null) {
            String[] infos = userInfo.split(",");
            for (int i = 1; i < infos.length; i++) {
                String name = infos[i];
                if (name.startsWith(GROUP_PREFIX)) {
                    result.add(new GroupPrincipal(name.substring(GROUP_PREFIX.length())));
                }
            }
        }
        return result;
    }
View Full Code Here

                principals.add(new UserPrincipal(user));

                List<String> roles = JDBCUtils.rawSelect(connection, roleQuery, user);
                for (String role : roles) {
                    if (role.startsWith(BackingEngine.GROUP_PREFIX)) {
                        principals.add(new GroupPrincipal(role.substring(BackingEngine.GROUP_PREFIX.length())));
                        for (String r : JDBCUtils.rawSelect(connection, roleQuery, role)) {
                            principals.add(new RolePrincipal(r));
                        }
                    } else {
                        principals.add(new RolePrincipal(role));
View Full Code Here

        try {
            try (Connection connection = dataSource.getConnection()) {
            List<GroupPrincipal> roles = new ArrayList<>();
            for (String role : rawSelect(connection, selectRolesQuery, principal.getName())) {
                if (role.startsWith(GROUP_PREFIX)) {
                    roles.add(new GroupPrincipal(role.substring(GROUP_PREFIX.length())));
                }
            }
            return roles;
            }
        } catch (SQLException e) {
View Full Code Here

TOP

Related Classes of org.apache.karaf.jaas.boot.principal.GroupPrincipal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.