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

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


                throw new FailedLoginException("Password for " + user + " does not match");
              }
            }

            principals = new HashSet<Principal>();
            principals.add(new UserPrincipal(user));
            for (int i = 1; i < infos.length; i++) {
                principals.add(new RolePrincipal(infos[i]));
            }

            return true;
View Full Code Here


            throw new FailedLoginException("Password for " + user + " does not match");
          }
        }

        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());
View Full Code Here

        module.initialize(subject, getCallbackHandler("abc", "xyz"), null, options);

        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

        assertTrue(engine.listUsers().isEmpty());

        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

        for (Object user : users.keySet()) {
            String userName = (String) user;
            if (userName.startsWith(GROUP_PREFIX))
                continue;

            UserPrincipal userPrincipal = new UserPrincipal(userName);
            result.add(userPrincipal);
        }
        return result;
    }
View Full Code Here

                    int end = responseTO.indexOf("</username>");
                    if (end == -1) {
                        index = -1;
                    }
                    String username = responseTO.substring(0, end);
                    users.add(new UserPrincipal(username));
                    responseTO = responseTO.substring(end + "</username>".length());
                    index = responseTO.indexOf("<username>");
                }
            }
        } catch (Exception e) {
View Full Code Here

                        throw new LoginException("login failed");
                    } else {
                        throw new LoginException("Password for " + user + " does not match");
                    }
                }
                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())));
View Full Code Here

        try {
            try (Connection connection = dataSource.getConnection()) {
                List<UserPrincipal> users = new ArrayList<>();
                for (String name : rawSelect(connection, selectUsersQuery)) {
                    if (!name.startsWith(GROUP_PREFIX)) {
                        users.add(new UserPrincipal(name));
                    }
                }
                return users;
            }
        } catch (SQLException e) {
View Full Code Here

                } catch (Exception e) {
                    // ignore
                }
            }
        }
        principals.add(new UserPrincipal(user));
        // step 3: retrieving user roles
        try {
            String[] roles = LDAPCache.getCache(env).getUserRoles(userDN, new Callable<String[]>() {
                @Override
                public String[] call() throws Exception {
View Full Code Here

TOP

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

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.