Examples of UserData


Examples of org.apache.roller.pojos.UserData

     * Test lookup mechanisms.
     */
    public void testPermissionsLookups() throws Exception {
       
        // we need a second user for this test
        UserData user = TestUtils.setupUser("foofoo");
        TestUtils.endSession(true);
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perm = null;
        List perms = null;
       
        // get all permissions for a user
        perms = mgr.getAllPermissions(user);
        assertEquals(0, perms.size());
        perms = mgr.getAllPermissions(testUser);
        assertEquals(1, perms.size());
       
        // get all permissions for a weblog
        perms = mgr.getAllPermissions(testWeblog);
        assertEquals(1, perms.size());
       
        perm = new PermissionsData();
        perm.setUser(user);
        perm.setWebsite(testWeblog);
        perm.setPending(true);
        perm.setPermissionMask(PermissionsData.AUTHOR);
        mgr.savePermissions(perm);
       
        // get pending permissions for a user
        perms = mgr.getPendingPermissions(testUser);
        assertEquals(0, perms.size());
        perms = mgr.getPendingPermissions(user);
        assertEquals(1, perms.size());
       
        // get pending permissions for a weblog
        perms = mgr.getPendingPermissions(testWeblog);
        assertEquals(1, perms.size());
       
        // get permissions by id
        String id = perm.getId();
        perm = null;
        perm = mgr.getPermissions(id);
        assertNotNull(perm);
        assertEquals(id, perm.getId());
       
        // get permissions for a specific user/weblog
        perm = null;
        perm = mgr.getPermissions(testWeblog, testUser);
        assertNotNull(perm);
        assertEquals(PermissionsData.ADMIN, perm.getPermissionMask());
        perm = null;
        perm = mgr.getPermissions(testWeblog, user);
        assertNotNull(perm);
        assertEquals(PermissionsData.AUTHOR, perm.getPermissionMask());
        assertEquals(true, perm.isPending());
       
        // cleanup the extra test user
        TestUtils.teardownUser(user.getId());
        TestUtils.endSession(true);
    }
View Full Code Here

Examples of org.apache.roller.pojos.UserData

     * Tests weblog invitation process.
     */
    public void testInvitations() throws Exception {
       
        // we need a second user for this test
        UserData user = TestUtils.setupUser("foobee");
        TestUtils.endSession(true);
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        PermissionsData perm = null;
        List perms = null;
       
        // invite user to weblog
        perm = mgr.inviteUser(testWeblog, user, PermissionsData.LIMITED);
        String id = perm.getId();
        TestUtils.endSession(true);
       
        // accept invitation
        perm = mgr.getPermissions(testWeblog, user);
        perm.setPending(false);
        mgr.savePermissions(perm);
        TestUtils.endSession(true);
       
        // re-query now that we have changed things
        user = mgr.getUserByUsername(user.getUserName());
        testWeblog = mgr.getWebsiteByHandle(testWeblog.getHandle());
       
        // assert that invitation list is empty
        assertTrue(mgr.getPendingPermissions(user).isEmpty());
        assertTrue(mgr.getPendingPermissions(testWeblog).isEmpty());
       
        // assert that user is member of weblog
        assertFalse(mgr.getPermissions(testWeblog, user).isPending());
        List weblogs = mgr.getWebsites(user, null, null);
        assertEquals(1, weblogs.size());
        assertEquals(testWeblog.getId(), ((WebsiteData)weblogs.get(0)).getId());
       
        // assert that website has user
        List users = mgr.getUsers(testWeblog, null);
        assertEquals(2, users.size());
       
        // test user can be retired from website
        mgr.retireUser(testWeblog, user);
        TestUtils.endSession(true);
       
        user = mgr.getUser(user.getId());
        weblogs = mgr.getWebsites(user, null, null);
        assertEquals(0, weblogs.size());
       
        // cleanup the extra test user
        TestUtils.teardownUser(user.getId());
        TestUtils.endSession(true);
    }
View Full Code Here

Examples of org.apache.roller.pojos.UserData

        mockRequest.setUserPrincipal(new MockPrincipal(username));
        mockRequest.setUserInRole(role, true);
       
        HttpSession session = mockRequest.getSession(true);       
        UserManager umgr = getRoller().getUserManager();
        UserData user = umgr.getUserByUsername(username);

        RollerSession rollerSession = new RollerSession();
        rollerSession.setAuthenticatedUser(user);
        session.setAttribute(RollerSession.ROLLER_SESSION, rollerSession);
    }
View Full Code Here

Examples of org.apache.roller.pojos.UserData

        ctx.setServletContextName("/roller");       
        MockHttpServletRequest request = getMockFactory().getMockRequest();
        request.setContextPath("/roller");

        UserManager umgr = null;
        UserData user = null;
        try
        {
            umgr = getRoller().getUserManager();
            user = (UserData)umgr.getUsers(mWebsite, null).get(0);      
            doFilters();
            authenticateUser(user.getUserName(), "editor");
        }
        catch (RollerException e)
        {
            e.printStackTrace();
            fail();
View Full Code Here

Examples of org.apache.roller.pojos.UserData

     * This method should be called by extensions of this class within their
     * implementation of authenticate().
     */
    protected void verifyUser() throws HandlerException {
        try {
            UserData user = getRoller().getUserManager().getUserByUsername(getUserName());
            if (user != null && user.hasRole("admin") && user.getEnabled().booleanValue()) {
                // success! no exception
            } else {
                throw new UnauthorizedException("ERROR: User must have the admin role to use the AAPP endpoint: " + getUserName());
            }
        } catch (RollerException re) {
View Full Code Here

Examples of org.apache.roller.pojos.UserData

            if (rollerSession.getAuthenticatedUser() == null && principal != null)
            {
                try
                {
                    UserManager umgr = RollerFactory.getRoller().getUserManager();
                    UserData user = umgr.getUserByUsername(principal.getName());
                    // only set authenticated user if user is enabled
                    if (user.getEnabled().booleanValue())
                    {
                        rollerSession.setAuthenticatedUser(user)
                    }                   
                }
                catch (RollerException e)
View Full Code Here

Examples of org.apache.roller.pojos.UserData

    /**
     * Does our authenticated user have the global admin role?
     */
    public boolean isGlobalAdminUser() throws RollerException
    {
        UserData user = getAuthenticatedUser();
        if (user != null && user.hasRole("admin")
            && user.getEnabled().booleanValue()) return true;
        return false;
    }
View Full Code Here

Examples of org.apache.roller.pojos.UserData

    /**
     * Convenience method that creates a user and stores it.
     */
    public static UserData setupUser(String username) throws Exception {
       
        UserData testUser = new UserData();
        testUser.setUserName(username);
        testUser.setPassword("password");
        testUser.setFullName("Test User");
        testUser.setEmailAddress("TestUser@dev.null");
        testUser.setLocale("en_US");
        testUser.setTimeZone("America/Los_Angeles");
        testUser.setDateCreated(new java.util.Date());
        testUser.setEnabled(Boolean.TRUE);
       
        // store the user
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        mgr.addUser(testUser);
       
        // query for the user to make sure we return the persisted object
        UserData user = mgr.getUserByUsername(username);
       
        if(user == null)
            throw new RollerException("error inserting new user");
       
        return user;
View Full Code Here

Examples of org.apache.roller.pojos.UserData

     */
    public static void teardownUser(String id) throws Exception {
       
        // lookup the user
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        UserData user = mgr.getUser(id);
       
        // remove the user
        mgr.removeUser(user);
    }
View Full Code Here

Examples of org.apache.roller.pojos.UserData

            String email) throws RollerException {
        UserManager umgr = getRoller().getUserManager();
        WeblogManager wmgr = getRoller().getWeblogManager();
       
        // Create and add new new user
        UserData ud = new UserData(null,
                username,      // userName
                password,      // password
                fullName,      // fullName
                email,         // emailAddress
                "en_US_WIN",
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.