Package org.codehaus.plexus.redback.users

Examples of org.codehaus.plexus.redback.users.UserManager


    {
        createUser( USER_ALPACA, "Al 'Archiva' Paca" );

        assignRepositoryManagerRole( USER_ALPACA, "corporate" );

        UserManager userManager = securitySystem.getUserManager();
        User user = userManager.findUser( USER_ALPACA );

        AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null );

        SecuritySession session = new DefaultSecuritySession( result, user );
        boolean isAuthorized =
View Full Code Here


        assignRepositoryObserverRole( USER_ALPACA, "corporate" );

        httpServletRequestControl.expectAndReturn( request.getRemoteAddr(), "192.168.111.111" );

        UserManager userManager = securitySystem.getUserManager();
        User user = userManager.findUser( USER_ALPACA );

        AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null );

        SecuritySession session = new DefaultSecuritySession( result, user );
View Full Code Here

    {
        createUser( USER_ALPACA, "Al 'Archiva' Paca" );

        assignRepositoryObserverRole( USER_ALPACA, "corporate" );

        UserManager userManager = securitySystem.getUserManager();
        User user = userManager.findUser( USER_ALPACA );

        AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null );

        SecuritySession session = new DefaultSecuritySession( result, user );
        boolean isAuthorized =
View Full Code Here

    public void testIsAuthorizedUserHasNoReadAccess()
        throws Exception
    {
        createUser( USER_ALPACA, "Al 'Archiva' Paca" );

        UserManager userManager = securitySystem.getUserManager();
        User user = userManager.findUser( USER_ALPACA );

        AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null );

        SecuritySession session = new DefaultSecuritySession( result, user );
        try
View Full Code Here

        roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId, principal );
    }

    protected User createUser( String principal, String fullname )
    {
        UserManager userManager = securitySystem.getUserManager();

        User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" );
        securitySystem.getPolicy().setEnabled( false );
        userManager.addUser( user );
        securitySystem.getPolicy().setEnabled( true );

        return user;
    }
View Full Code Here

        return null;
    }

    public UserManager getUserManager()
    {
        return new UserManager()
        {
            public boolean isReadOnly()
            {
                return false//To change body of implemented methods use File | Settings | File Templates.
            }
View Full Code Here

    }

    private User createUser( String principal, String fullname, String password )
        throws UserNotFoundException
    {
        UserManager userManager = securitySystem.getUserManager();

        User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" );
        securitySystem.getPolicy().setEnabled( false );
        userManager.addUser( user );
        securitySystem.getPolicy().setEnabled( true );

        user.setPassword( password );
        userManager.updateUser( user );

        return user;
    }
View Full Code Here

    public void testIsAuthorizedUserExistsButNotAuthorized()
        throws Exception
    {
        createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD );

        UserManager userManager = securitySystem.getUserManager();
        try
        {
            User user = userManager.findUser( USER_ALPACA );
            assertEquals( USER_ALPACA, user.getPrincipal() );
        }
        catch ( UserNotFoundException e )
        {
            fail( "User should exist in the database." );
View Full Code Here

    public void testIsAuthorizedUserExistsAndAuthorized()
        throws Exception
    {
        createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD );

        UserManager userManager = securitySystem.getUserManager();
        try
        {
            User user = userManager.findUser( USER_ALPACA );
            assertEquals( USER_ALPACA, user.getPrincipal() );
        }
        catch ( UserNotFoundException e )
        {
            fail( "User should exist in the database." );
        }

        //TODO cannot assign global repo manager role - it says role does not exist :|

        //roleManager.assignRole( ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE, USER_ALPACA );

        xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(), config, 2 );

        configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA );

        configControl.expectAndReturn( config.getBasicPassword(), PASSWORD );

        xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getMethodName(),
                                              "AdministrationService.getAllManagedRepositories" );

        xmlRpcRequestControl.replay();
        configControl.replay();

        @SuppressWarnings( "unused" ) boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest );
        // TODO: broken or bad test?
        // assertTrue( isAuthorized );

        xmlRpcRequestControl.verify();
        configControl.verify();

        userManager.deleteUser( USER_ALPACA );
    }
View Full Code Here

    @Test
    public void testIsAuthorizedUserDoesNotExist()
        throws Exception
    {
        UserManager userManager = securitySystem.getUserManager();
        try
        {
            userManager.findUser( USER_ALPACA );
            fail( "User should not exist in the database." );
        }
        catch ( UserNotFoundException e )
        {
            assertEquals( "Unable to find user 'alpaca'", e.getMessage() );
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.redback.users.UserManager

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.