Package org.apache.jetspeed.om.security

Examples of org.apache.jetspeed.om.security.UserNamePrincipal


     * @see UserManagement#getUser
     */
    public static JetspeedUser getUser(String username)
        throws JetspeedSecurityException
    {
        return JetspeedUserManagement.getUser(new UserNamePrincipal(username));
    }
View Full Code Here


     * @see UserManagement#removeUser
     */
    public static void removeUser(String username)
        throws JetspeedSecurityException
    {
        JetspeedUserManagement.removeUser(new UserNamePrincipal(username));
    }
View Full Code Here

        UserManagement service = getService();
        JetspeedUser user = null;
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
        }
        catch (Exception e)
        {
            fail(StringUtils.stackTrace(e));
        }
        assertNotNull(user);
        assertTrue(user.getUserId().equals("2"));
        assertTrue(user.getUserName().equals("turbine"));
        assertTrue(user.getFirstName().equals("Tommy"));
        assertTrue(user.getLastName().equals("Turbine"));
        assertTrue(user.getEmail().equals("tommy@jakarta-jetspeed.com"));
        assertTrue(user.getConfirmed().equals("CONFIRMED"));
        assertTrue(user.getDisabled() == false);
        subtestTemp(user);

        try
        {
            JetspeedUserManagement.getUser(new UserNamePrincipal("nobody"));
        }
        catch (Exception e)
        {
            System.out.println("CAUGHT GETUSER EXCEPTION: " + e.toString());
            assertTrue(e instanceof UnknownUserException);
View Full Code Here

        JetspeedUser user = null;

        try
        {
            // test updating and retrieving some fields
            user = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
            String lastName = user.getLastName();
            user.setLastName(TEMP_LAST_NAME);
            user.setDisabled(true);

            JetspeedUserManagement.saveUser(user);
            JetspeedUser user2 = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
            assertTrue(user2.getLastName().equals(TEMP_LAST_NAME));
            assertTrue(user2.getDisabled() == true);

            user2.setLastName(lastName);
            user2.setDisabled(false);
            JetspeedUserManagement.saveUser(user2);
            JetspeedUser user3 = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
            assertTrue(user3.getLastName().equals(lastName));
            assertTrue(user3.getDisabled() == false);

            // test set/get Perm
            user3.setPerm("unittest", "test");
            JetspeedUserManagement.saveUser(user3);
            JetspeedUser user4 = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
            String unitTestValue = (String)user4.getPerm("unittest");
            assertTrue(unitTestValue.equals("test"));
            user4.setPerm("unittest", null);
            JetspeedUserManagement.saveUser(user4);           

            // try saving to an non-existing user
            try
            {
                JetspeedUser user5 = JetspeedUserFactory.getInstance();
                user5.setLastName("junk");
                JetspeedUserManagement.saveUser(user5);      
            }
            catch (Exception e)
            {
                assertTrue(e instanceof UnknownUserException);
            }
   
            // test dup on unique username key
            JetspeedUser user6 = JetspeedUserManagement.getUser(new UserNamePrincipal("turbine"));
            user6.setUserName("admin");
            try
            {
                JetspeedUserManagement.saveUser(user6);
            }
View Full Code Here

            user.setDisabled(false);
            user.setConfirmed("NO");
            user.setPerm("dogfood", "alpo");
            JetspeedUserManagement.addUser(user);

            JetspeedUser user2 = JetspeedUserManagement.getUser(new UserNamePrincipal("busby"));
            assertTrue(user2.getUserName().equals("busby"));
            assertTrue(user2.getLastName().equals("Taylor"));
            assertTrue(user2.getFirstName().equals("Busby"));
            assertTrue(user2.getEmail().equals("busby@jakarta-jetspeed.com"));
            assertTrue(user2.getConfirmed().equals("NO"));
View Full Code Here

        UserManagement service = getService();

        try
        {
            // depending on testAddUser running first!
            JetspeedUserManagement.removeUser(new UserNamePrincipal("busby"));

            try
            {
                JetspeedUserManagement.removeUser(new UserNamePrincipal("nobody"));
            }
            catch (Exception e)
            {
                System.out.println("CAUGHT REMOVE EXCEPTION: " + e.toString());
                assertTrue(e instanceof UnknownUserException);
            }

            try
            {
                JetspeedUserManagement.getUser(new UserNamePrincipal("busby"));
            }
            catch (Exception e)
            {
                System.out.println("CAUGHT REMOVE EXCEPTION: " + e.toString());
                assertTrue(e instanceof UnknownUserException);
View Full Code Here

        username = JetspeedSecurity.convertUserName(username);
        password = JetspeedSecurity.convertPassword(password);
      
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(username));
            password = JetspeedSecurity.encryptPassword(password);
        }                           
        catch (UnknownUserException e)
        {
            logger.warn("Unknown user attempted access: " + username, e);
View Full Code Here

        throws LoginException
    {
        JetspeedUser user = null;
        try
        {
            user = JetspeedUserManagement.getUser(new UserNamePrincipal(anonymousUser));
            user.setHasLoggedIn(new Boolean(false));
            putUserIntoContext(user);
            if (cachingEnable)
            {
                JetspeedSecurityCache.load(user.getUserName());
View Full Code Here

            }
        }
        catch (Exception e)
        {
            logger.error( "Failed to create profile for new user ", e );
            removeUser(new UserNamePrincipal(user.getUserName()));
            throw new UserException("Failed to create profile for new user ", e);
        }
    }
View Full Code Here

                if (null != result)
                {
                    return result;
                }
            }
            user = (LDAPUser)JetspeedSecurity.getUser(new UserNamePrincipal(username));
        }
        catch(JetspeedSecurityException e)
        {
            throw new RoleException("Failed to Retrieve User: ", e);
        }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.security.UserNamePrincipal

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.