Package org.apache.turbine.om.security

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


    public static User row2Object(Record row, int offset, Class cls)
        throws TorqueException
    {
        try
        {
            User obj = TurbineSecurity.getUserInstance();
            populateObject(row, offset, obj);
            ((Persistent) obj).setNew(false);
            ((Persistent) obj).setModified(false);
            return obj;
        }
View Full Code Here


        //
        // Session Tool start right at the session once the user has been set
        // while persistent and authorized Tools are started when the user has
        // logged in
        //
        User user = data.getUser();

        // Note: Session tools are currently lost after the login action
        // because the anonymous user is replaced the the real user object.
        // We should either store the session pull tools in the session or
        // make Turbine.loginAction() copy the session pull tools into the
        // new user object.
        populateWithSessionTools(sessionTools, context, data, user);

        if (!TurbineSecurity.isAnonymousUser(user))
        {
            if (user.hasLoggedIn())
            {
                populateWithSessionTools(authorizedTools, context, data, user);
                populateWithPermTools(persistentTools, context, data, user);
            }
        }
View Full Code Here

        }

        try
        {
            // Authenticate the user and get the object.
            User user = TurbineSecurity.getAuthenticatedUser(
                    username, password);

            // Store the user object.
            data.setUser(user);

            // Mark the user as being logged in.
            user.setHasLoggedIn(Boolean.TRUE);

            // Set the last_login date in the database.
            user.updateLastLogin();

            // This only happens if the user is valid; otherwise, we
            // will get a valueBound in the User object when we don't
            // want to because the username is not set yet.  Save the
            // User object into the session.
View Full Code Here

     *            service.
     */
    public void doPerform(RunData data)
            throws TurbineSecurityException
    {
        User user = data.getUser();

        if (!TurbineSecurity.isAnonymousUser(user))
        {
            // Make sure that the user has really logged in...
            if (!user.hasLoggedIn())
            {
                return;
            }

            user.setHasLoggedIn(Boolean.FALSE);
            TurbineSecurity.saveUser(user);
        }

        Configuration conf = Turbine.getConfiguration();

View Full Code Here

     * @exception TurbineSecurityException problem with the security service.
     */
    public void doPerform(RunData data)
            throws TurbineSecurityException
    {
        User user = data.getUser();

        if (!TurbineSecurity.isAnonymousUser(user)
            && user.hasLoggedIn())
        {
            log.debug("Fetching ACL for " + user.getName());
            AccessControlList acl = (AccessControlList)
                    data.getSession().getAttribute(
                            AccessControlList.SESSION_KEY);
            if (acl == null)
            {
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

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.