Examples of UserPrincipal


Examples of org.apache.activemq.jaas.UserPrincipal

        assertEquals(p1.hashCode(), p1.hashCode());
        assertEquals(p1.hashCode(), p2.hashCode());
    }

    public void testEquals() {
        UserPrincipal p1 = new UserPrincipal("FOO");
        UserPrincipal p2 = new UserPrincipal("FOO");
        UserPrincipal p3 = new UserPrincipal("BAR");

        assertTrue(p1.equals(p1));
        assertTrue(p1.equals(p2));
        assertFalse(p1.equals(null));
        assertFalse(p1.equals("FOO"));
View Full Code Here

Examples of org.apache.felix.karaf.jaas.modules.UserPrincipal

            if (!new String(tmpPassword).equals(infos[0])) {
                throw new FailedLoginException("Password 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

Examples of org.apache.harmony.auth.UserPrincipal

        userPassword = jndiPasswordCallback.getPassword();
    }
   
    private void getPrinclpalsFromLdap() throws InvalidNameException{
        ldapPrincipal = new LdapPrincipal(ldapPrincipalEntryName);
        userPrincipal = new UserPrincipal(userID);
        if(authzIdentity != null){
            extraUserPrincipal = new UserPrincipal(authzIdentity);
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.security.UserPrincipal

        public Principal getPrincipal(String principalName) {
            if (principals.containsKey(principalName)) {
                return principals.get(principalName);
            } else {
                return new UserPrincipal(principalName);
            }
        }
View Full Code Here

Examples of org.apache.jetspeed.security.UserPrincipal

        // Check if user already exists.
        if (userExists(username)) {
            throw new SecurityException(SecurityException.USER_ALREADY_EXISTS.create(username));
        }

        UserPrincipal userPrincipal = new UserPrincipalImpl(username);
        String fullPath = userPrincipal.getFullPath();
        // Add the preferences.
        Preferences preferences = Preferences.userRoot().node(fullPath);
        if (log.isDebugEnabled())
        {
            log.debug("Added user preferences node: " + fullPath);
View Full Code Here

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

                throw new FailedLoginException("Public key 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]));
        }

        users.clear();
View Full Code Here

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

            Properties p = new Properties(f);

            PropertiesBackingEngine engine = new PropertiesBackingEngine(p);
            engine.addUser("a", "aa");
            assertEquals(1, engine.listUsers().size());
            UserPrincipal upa = engine.listUsers().iterator().next();
            assertEquals("a", upa.getName());
            engine.addUser("b", "bb");

            engine.addRole("a", "role1");
            engine.addRole("a", "role2");
            assertEquals(2, engine.listRoles(upa).size());

            boolean foundR1 = false;
            boolean foundR2 = false;
            for (RolePrincipal rp : engine.listRoles(upa)) {
                if ("role1".equals(rp.getName())) {
                    foundR1 = true;
                } else if ("role2".equals(rp.getName())) {
                    foundR2 = true;
                }
            }
            assertTrue(foundR1);
            assertTrue(foundR2);

            engine.addGroup("a", "g");
            engine.addGroupRole("g", "role2");
            engine.addGroupRole("g", "role3");
            engine.addGroup("b", "g");
            engine.addGroup("b", "g2");
            engine.addGroupRole("g2", "role4");

            assertEquals(2, engine.listUsers().size());
            UserPrincipal upa_1 = null;
            UserPrincipal upb_1 = null;
            for (UserPrincipal u : engine.listUsers()) {
                if ("a".equals(u.getName())) {
                    upa_1 = u;
                } else if ("b".equals(u.getName())) {
                    upb_1 = u;
                }
            }
            assertNotNull(upa_1);
            assertNotNull(upb_1);

            assertEquals(3, engine.listRoles(upa).size());
            boolean foundR1_2 = false;
            boolean foundR2_2 = false;
            boolean foundR3_2 = false;
            for (RolePrincipal rp : engine.listRoles(upa)) {
                if ("role1".equals(rp.getName())) {
                    foundR1_2 = true;
                } else if ("role2".equals(rp.getName())) {
                    foundR2_2 = true;
                } else if ("role3".equals(rp.getName())) {
                    foundR3_2 = true;
                }
            }
            assertTrue(foundR1_2);
            assertTrue(foundR2_2);
            assertTrue(foundR3_2);

            // check that the loading works
            PropertiesBackingEngine engine2 = new PropertiesBackingEngine(new Properties(f));
            assertEquals(2, engine2.listUsers().size());
            UserPrincipal upa_2 = null;
            UserPrincipal upb_2 = null;
            for (UserPrincipal u : engine2.listUsers()) {
                if ("a".equals(u.getName())) {
                    upa_2 = u;
                } else if ("b".equals(u.getName())) {
                    upb_2 = u;
                }
            }
            assertNotNull(upa_2);
            assertNotNull(upb_2);

            assertEquals(3, engine2.listRoles(upa_2).size());
            boolean foundR1_3 = false;
            boolean foundR2_3 = false;
            boolean foundR3_3 = false;
            for (RolePrincipal rp : engine2.listRoles(upa_2)) {
                if ("role1".equals(rp.getName())) {
                    foundR1_3 = true;
                } else if ("role2".equals(rp.getName())) {
                    foundR2_3 = true;
                } else if ("role3".equals(rp.getName())) {
                    foundR3_3 = true;
                }
            }
            assertTrue(foundR1_3);
            assertTrue(foundR2_3);
            assertTrue(foundR3_3);

            assertEquals(3, engine2.listRoles(upb_2).size());
            boolean foundR2_4 = false;
            boolean foundR3_4 = false;
            boolean foundR4_4 = false;
            for (RolePrincipal rp : engine2.listRoles(upb_2)) {
                if ("role2".equals(rp.getName())) {
                    foundR2_4 = true;
                } else if ("role3".equals(rp.getName())) {
                    foundR3_4 = true;
                } else if ("role4".equals(rp.getName())) {
                    foundR4_4 = true;
                }
            }
            assertTrue(foundR2_4);
            assertTrue(foundR3_4);
            assertTrue(foundR4_4);

            // removing some stuff
            UserPrincipal upb = null;
            for (UserPrincipal up : engine.listUsers()) {
                if ("b".equals(up.getName())) {
                    upb = up;
                }
            }
View Full Code Here

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

                    throw new LoginException("login failed");
                  } else {
                    throw new LoginException("Password for " + user + " does not match");
                  }
                }
                principals.add(new UserPrincipal(user));
            }

            //Retrieve user roles from database
            roleStatement = connection.prepareStatement(roleQuery);
            roleStatement.setString(1, user);
View Full Code Here

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++) {
            if (infos[i].startsWith(PropertiesBackingEngine.GROUP_PREFIX)) {
                // it's a group reference
                principals.add(new GroupPrincipal(infos[i].substring(PropertiesBackingEngine.GROUP_PREFIX.length())));
                String groupInfo = (String) users.get(infos[i]);
View Full Code Here

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

        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
TOP
Copyright © 2018 www.massapi.com. 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.