You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@continuum.apache.org by Brett Porter <br...@apache.org> on 2009/03/13 01:14:59 UTC

Re: svn commit: r752953 - in /continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/ continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/ continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/cont

He's using a newer redback snapshot - but I haven't deployed them yet  
because there's still some bugs.

It might work better if you change both that and  
AccountLockedException to PolicyViolationException since the handling  
is the same and it's a common base class.

- Brett

On 13/03/2009, at 11:11 AM, Marica Tan wrote:

> On Fri, Mar 13, 2009 at 1:57 AM, <ev...@apache.org> wrote:
>
>> Author: evenisse
>> Date: Thu Mar 12 17:57:35 2009
>> New Revision: 752953
>>
>> URL: http://svn.apache.org/viewvc?rev=752953&view=rev
>> Log:
>> Fix compilation error due to latest changes in redback
>>
>> Modified:
>>
>> continuum/trunk/continuum-core/src/main/java/org/apache/maven/ 
>> continuum/DefaultContinuum.java
>>
>> continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/ 
>> web/action/admin/BuildAgentAction.java
>>
>> continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/ 
>> java/org/apache/maven/continuum/xmlrpc/server/ 
>> ContinuumXmlRpcServlet.java
>>
>> Modified:
>> continuum/trunk/continuum-core/src/main/java/org/apache/maven/ 
>> continuum/DefaultContinuum.java
>> URL:
>> http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=752953&r1=752952&r2=752953&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> ---
>> continuum/trunk/continuum-core/src/main/java/org/apache/maven/ 
>> continuum/DefaultContinuum.java
>> (original)
>> +++
>> continuum/trunk/continuum-core/src/main/java/org/apache/maven/ 
>> continuum/DefaultContinuum.java
>> Thu Mar 12 17:57:35 2009
>> @@ -417,9 +417,9 @@
>>                throw new ContinuumException( "Unable to delete  
>> group.", e
>> );
>>            }
>>
>> -            for ( int i = 0; i < projectIds.length; i++ )
>> +            for ( int projectId : projectIds )
>>            {
>> -                removeProject( projectIds[i] );
>> +                removeProject( projectId );
>>            }
>>
>>            log.info( "Remove project group " +  
>> projectGroup.getName() +
>> "(" + projectGroup.getId() + ")" );
>> @@ -603,14 +603,7 @@
>>    {
>>        List<BuildResult> builds =
>> buildResultDao.getBuildResultByBuildNumber( projectId, buildNumber );
>>
>> -        if ( builds.isEmpty() )
>> -        {
>> -            return null;
>> -        }
>> -        else
>> -        {
>> -            return builds.get( 0 );
>> -        }
>> +        return ( builds.isEmpty() ? null : builds.get( 0 ) );
>>    }
>>
>>    //
>> ----------------------------------------------------------------------
>>
>> Modified:
>> continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/ 
>> web/action/admin/BuildAgentAction.java
>> URL:
>> http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java?rev=752953&r1=752952&r2=752953&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> ---
>> continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/ 
>> web/action/admin/BuildAgentAction.java
>> (original)
>> +++
>> continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/ 
>> web/action/admin/BuildAgentAction.java
>> Thu Mar 12 17:57:35 2009
>> @@ -351,10 +351,9 @@
>>                    this.selectedBuildAgentIds = new  
>> ArrayList<String>();
>>                    if ( this.buildAgentGroup.getBuildAgents() !=  
>> null )
>>                    {
>> -                        for ( Iterator<BuildAgentConfiguration>  
>> iterator =
>> buildAgentGroup.getBuildAgents().iterator();
>> -                              iterator.hasNext(); )
>> +                        for ( BuildAgentConfiguration
>> buildAgentConfiguration : buildAgentGroup.getBuildAgents() )
>>                        {
>> -                            this.selectedBuildAgentIds.add(
>> iterator.next().getUrl() );
>> +                            this.selectedBuildAgentIds.add(
>> buildAgentConfiguration.getUrl() );
>>                        }
>>
>>                    }
>>
>> Modified:
>> continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/ 
>> java/org/apache/maven/continuum/xmlrpc/server/ 
>> ContinuumXmlRpcServlet.java
>> URL:
>> http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumXmlRpcServlet.java?rev=752953&r1=752952&r2=752953&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> ---
>> continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/ 
>> java/org/apache/maven/continuum/xmlrpc/server/ 
>> ContinuumXmlRpcServlet.java
>> (original)
>> +++
>> continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/ 
>> java/org/apache/maven/continuum/xmlrpc/server/ 
>> ContinuumXmlRpcServlet.java
>> Thu Mar 12 17:57:35 2009
>> @@ -35,6 +35,7 @@
>> import  
>> org.codehaus.plexus.redback.authentication.AuthenticationException;
>> import
>> org 
>> .codehaus 
>> .plexus.redback.authentication.PasswordBasedAuthenticationDataSource;
>> import org.codehaus.plexus.redback.policy.AccountLockedException;
>> +import  
>> org.codehaus.plexus.redback.policy.MustChangePasswordException;
>> import org.codehaus.plexus.redback.system.DefaultSecuritySession;
>> import org.codehaus.plexus.redback.system.SecuritySystem;
>> import org.codehaus.plexus.redback.users.UserNotFoundException;
>> @@ -128,62 +129,65 @@
>>
>>    private AbstractReflectiveHandlerMapping.AuthenticationHandler
>> getAuthenticationHandler()
>>    {
>> -        AbstractReflectiveHandlerMapping.AuthenticationHandler  
>> handler =
>> -            new  
>> AbstractReflectiveHandlerMapping.AuthenticationHandler()
>> +        return new
>> AbstractReflectiveHandlerMapping.AuthenticationHandler()
>> +        {
>> +            public boolean isAuthorized( XmlRpcRequest pRequest )
>>            {
>> -                public boolean isAuthorized( XmlRpcRequest  
>> pRequest )
>> +                if ( pRequest.getConfig() instanceof  
>> ContinuumXmlRpcConfig
>> )
>>                {
>> -                    if ( pRequest.getConfig() instanceof
>> ContinuumXmlRpcConfig )
>> -                    {
>> -                        ContinuumXmlRpcConfig config =
>> (ContinuumXmlRpcConfig) pRequest.getConfig();
>> +                    ContinuumXmlRpcConfig config =  
>> (ContinuumXmlRpcConfig)
>> pRequest.getConfig();
>>
>> -                        try
>> +                    try
>> +                    {
>> +                        // if username is null, then treat this as  
>> a guest
>> user with an empty security session
>> +                        if ( config.getBasicUserName() == null )
>>                        {
>> -                            // if username is null, then treat  
>> this as a
>> guest user with an empty security session
>> -                            if ( config.getBasicUserName() == null )
>> -                            {
>> -                                config.setSecuritySession( new
>> DefaultSecuritySession() );
>> -
>> -                                return true;
>> -                            }
>> -                            else
>> -                            {
>> -                                // otherwise treat this as an authn
>> required session, and if the credentials are invalid
>> -                                // do not default to guest  
>> privileges
>> -                                 
>> PasswordBasedAuthenticationDataSource
>> authdatasource =
>> -                                    new
>> PasswordBasedAuthenticationDataSource();
>> -                                authdatasource.setPrincipal(
>> config.getBasicUserName() );
>> -                                authdatasource.setPassword(
>> config.getBasicPassword() );
>> +                            config.setSecuritySession( new
>> DefaultSecuritySession() );
>>
>> -                                config.setSecuritySession(
>> securitySystem.authenticate( authdatasource ) );
>> -
>> -                                return
>> config.getSecuritySession().isAuthenticated();
>> -                            }
>> -                        }
>> -                        catch ( AuthenticationException e )
>> -                        {
>> -                            e.printStackTrace();
>> -                            return false;
>> +                            return true;
>>                        }
>> -                        catch ( AccountLockedException e )
>> +                        else
>>                        {
>> -                            e.printStackTrace();
>> -                            return false;
>> -                        }
>> -                        catch ( UserNotFoundException e )
>> -                        {
>> -                            e.printStackTrace();
>> -                            return false;
>> +                            // otherwise treat this as an authn  
>> required
>> session, and if the credentials are invalid
>> +                            // do not default to guest privileges
>> +                            PasswordBasedAuthenticationDataSource
>> authdatasource =
>> +                                new
>> PasswordBasedAuthenticationDataSource();
>> +                            authdatasource.setPrincipal(
>> config.getBasicUserName() );
>> +                            authdatasource.setPassword(
>> config.getBasicPassword() );
>> +
>> +                            config.setSecuritySession(
>> securitySystem.authenticate( authdatasource ) );
>> +
>> +                            return
>> config.getSecuritySession().isAuthenticated();
>>                        }
>>                    }
>> -                    else
>> +                    catch ( AuthenticationException e )
>> +                    {
>> +                        e.printStackTrace();
>> +                        return false;
>> +                    }
>> +                    catch ( AccountLockedException e )
>> +                    {
>> +                        e.printStackTrace();
>> +                        return false;
>> +                    }
>> +                    catch ( UserNotFoundException e )
>>                    {
>> -                        System.out.println( "unknown xml rpc  
>> configiration
>> object found..." );
>> +                        e.printStackTrace();
>> +                        return false;
>> +                    }
>> +                    catch ( MustChangePasswordException e )
>> +                    {
>> +                        e.printStackTrace();
>>                        return false;
>>                    }
>
>
> I'm having a compilation error because "MustChangePasswordException"  
> was
> never thrown. Are you also getting that error?
>
>>
>>                }
>> -            };
>> -        return handler;
>> +                else
>> +                {
>> +                    System.out.println( "unknown xml rpc  
>> configiration
>> object found..." );
>> +                    return false;
>> +                }
>> +            }
>> +        };
>>    }
>>
>>    public void doPost( HttpServletRequest pRequest,  
>> HttpServletResponse
>> pResponse )
>>
>>
>>
>
> Thanks,
> --
> Marica

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/