Package org.codehaus.plexus.redback.users

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


    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


        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

        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 boolean isAuthorized( String principal, String repoId, String permission )
        throws UnauthorizedException
    {
        try
        {
            User user = securitySystem.getUserManager().findUser( principal );
            if ( user == null )
            {
                throw new UnauthorizedException( "The security system had an internal error - please check your system logs" );
            }
            if ( user.isLocked() )
            {
                throw new UnauthorizedException( "User account is locked." );
            }

            AuthenticationResult authn = new AuthenticationResult( true, principal, null );
View Full Code Here

        if ( securitySession == null )
        {
            return UserManager.GUEST_USERNAME;
        }

        User user = securitySession.getUser();
        if ( user == null )
        {
            return UserManager.GUEST_USERNAME;
        }

        return (String) user.getPrincipal();
    }
View Full Code Here

    }

    private SecuritySession createSession( String principal )
        throws ArchivaSecurityException, AccessDeniedException
    {
        User user;
        try
        {
            user = securitySystem.getUserManager().findUser( principal );
            if ( user == null )
            {
                throw new ArchivaSecurityException(
                    "The security system had an internal error - please check your system logs" );
            }
        }
        catch ( UserNotFoundException e )
        {
            throw new PrincipalNotFoundException( "Unable to find principal " + principal + "" );
        }

        if ( user.isLocked() )
        {
            throw new AccessDeniedException( "User " + principal + "(" + user.getFullName() + ") is locked." );
        }

        AuthenticationResult authn = new AuthenticationResult( true, principal, null );
        return new DefaultSecuritySession( authn, user );
    }
View Full Code Here

    }

    protected User getUser( String principal )
        throws UserNotFoundException
    {
        User user = new JdoUser();
        user.setUsername( principal );

        return user;
    }
View Full Code Here

    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

        assertNotNull( roleManager );
        assertNotNull( userRepos );
        assertNotNull( archivaConfiguration );

        // Setup Admin User.
        User adminUser = createUser( USER_ADMIN, "Admin User" );
        roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() );

        // Setup Guest User.
        User guestUser = createUser( USER_GUEST, "Guest User" );
        roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() );
    }
View Full Code Here

        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 = servletAuth.isAuthorized( request, session, "corporate", true );
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.redback.users.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.