Package org.apache.turbine.om.security

Examples of org.apache.turbine.om.security.User


    public void testAcl3()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        User user = ss.getUser("user");
        assertNotNull(user);

        AccessControlList acl = ss.getACL(user);
        assertNotNull(acl);
View Full Code Here


      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User u = um.retrieve("admin");
        assertNotNull("No Admin found!", u);
        assertEquals("Admin Id wrong!", u.getId(), 1);

        // Check Logged in
        assertFalse(u.hasLoggedIn());
        u.setHasLoggedIn(Boolean.TRUE);
        assertTrue(u.hasLoggedIn());
        u.setHasLoggedIn(Boolean.FALSE);
        assertFalse(u.hasLoggedIn());

        // Check perm and temp storage
        assertEquals(u.getPermStorage().getClass(), Hashtable.class);
        assertEquals(u.getTempStorage().getClass(), Hashtable.class);

        Hashtable permStorage = u.getPermStorage();

        int access = u.getAccessCounter();
        u.incrementAccessCounter();

        um.store(u);

        u = null;

        User u2 = um.retrieve("admin");


        // Hashtable has changed
        assertNotSame(permStorage, u2.getPermStorage());

        // But the Count should be the same
        assertEquals(access + 1 , u2.getAccessCounter());

        checkUserList();
    }
View Full Code Here

    public void testAddUser()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        User newbie = TurbineSecurity.getUserInstance();
        newbie.setName("newbie");

        newbie.setFirstName("John");
        newbie.setLastName("Doe");

        ss.addUser(newbie, "newbie");

        List users = ss.getUserList(new org.apache.torque.util.Criteria());
        assertEquals("User was not added", users.size(), 3);

        try
        {
            User admin = ss.getUser("admin");

            ss.addUser(admin, "admin");
            fail("Existing User could be added!");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), e.getClass(), EntityExistsException.class);
        }

        try
        {
            User empty = TurbineSecurity.getUserInstance();

            ss.addUser(empty, "empty");
            fail("User with empty Username could be added!");
        }
        catch (Exception e)
View Full Code Here

    public void testRemoveUser()
      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();

        User newbie = ss.getUser("newbie");
        assertNotNull(newbie);

        ss.removeUser(newbie);

        try
        {
            User foo = TurbineSecurity.getUserInstance();
            foo.setName("foo");

            ss.removeUser(foo);
            fail("Non Existing User could be deleted!");
        }
        catch (Exception e)
View Full Code Here

            throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User u = um.retrieve("admin");
        assertNotNull("No Admin found!", u);
        assertEquals("Admin Id wrong!", u.getId(), 1);

        User u2 = um.retrieveById(new Integer(1));
        assertNotNull("No Admin found!", u2);
        assertEquals("Admin Name wrong!", u.getName(), "admin");

        assertEquals("Two different User objects retrieved!", u, u2);
    }
View Full Code Here

        UserManager um = ss.getUserManager();

        assertTrue(um.accountExists("admin"));
        assertFalse(um.accountExists("does-not-exist"));

        User admin = um.retrieve("admin");
        assertTrue(um.accountExists(admin));

        User doesNotExist = TurbineSecurity.getUserInstance();
        assertFalse(um.accountExists(doesNotExist));

        checkUserList();
    }
View Full Code Here

      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User admin = um.retrieve("admin");

        try
        {
            User doesNotExist = um.retrieve("does-not-exist");
            fail("Non existing Account was retrieved");
        }
        catch (Exception e)
        {
            assertEquals("Wrong Exception thrown: " + e.getClass().getName(), e.getClass(), UnknownEntityException.class);
View Full Code Here

      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User admin = um.retrieve("admin", "admin");

        try
        {
            admin = um.retrieve("admin", "no such password");
            fail("User was authenticated with wrong password");
View Full Code Here

      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User admin = um.retrieve("admin");
        um.store(admin);

        try
        {
            User newbie = TurbineSecurity.getUserInstance();
            newbie.setName("newbie");

            um.store(newbie);
            fail("Non Existing User could be stored!");
        }
        catch (Exception e)
View Full Code Here

      throws Exception
    {
        SecurityService ss = TurbineSecurity.getService();
        UserManager um = ss.getUserManager();

        User admin = um.retrieve("admin");

        um.authenticate(admin, "admin");

        try
        {
            User newbie = TurbineSecurity.getUserInstance();
            newbie.setName("newbie");

            um.authenticate(newbie, "somePw");
            fail("User was authenticated with wrong password");
        }
        catch (Exception e)
View Full Code Here

TOP

Related Classes of org.apache.turbine.om.security.User

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.