You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@continuum.apache.org by Wendy Smoak <ws...@gmail.com> on 2009/04/27 20:12:22 UTC

Re: svn commit: r769071 - /continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java

Can you please edit the comment to include the JIRA ticket this
belongs to?  (The comment on the merge also needs more info --
basically repeat the original comment, plus the 'merged r... from ___'
bit.)  We probably need to write this down somewhere. :) Thanks!
-Wendy

On Mon, Apr 27, 2009 at 10:59 AM,  <jz...@apache.org> wrote:
> Author: jzurbano
> Date: Mon Apr 27 17:59:02 2009
> New Revision: 769071
>
> URL: http://svn.apache.org/viewvc?rev=769071&view=rev
> Log:
> modified commit in r767816 to show scm credentials used
>
> Modified:
>    continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
>
> Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
> URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?rev=769071&r1=769070&r2=769071&view=diff
> ==============================================================================
> --- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java (original)
> +++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java Mon Apr 27 17:59:02 2009
> @@ -112,16 +112,7 @@
>                                                         this.getBuildDefinitionTemplateId() );
>         }
>
> -        String projectUrl = pomUrl;
> -
> -        if ( projectUrl.indexOf( "@" ) > 0 )
> -        {
> -            // remove scm credentials from the url
> -            StringBuilder urlBuilder = new StringBuilder();
> -            urlBuilder.append( projectUrl.substring( 0, projectUrl.indexOf( "://" ) + 3 ) );
> -            urlBuilder.append( projectUrl.substring( projectUrl.indexOf( "@" ) + 1 ) );
> -            projectUrl = urlBuilder.toString();
> -        }
> +        String projectUrl = hidePasswordInUrl( pomUrl );
>
>         AuditLog event = new AuditLog( projectUrl, AuditLogConstants.ADD_M2_PROJECT );
>         event.setCategory( AuditLogConstants.PROJECT );
> @@ -172,4 +163,32 @@
>     {
>         this.nonRecursiveProject = nonRecursiveProject;
>     }
> +
> +    private String hidePasswordInUrl( String pomUrl )
> +    {
> +        String projectUrl = pomUrl;
> +
> +        int idx = projectUrl.indexOf( "@" );
> +
> +        if ( idx > 0 )
> +        {
> +            int pwdIndex = projectUrl.lastIndexOf( ":" );
> +
> +            if ( ( pwdIndex > 0 ) && ( pwdIndex > projectUrl.indexOf( "://" ) ) )
> +            {
> +                String password = projectUrl.substring( pwdIndex, idx + 1 );
> +
> +                String newPwd = "@";
> +
> +                if ( ( password.length() ) > 2 )
> +                {
> +                    newPwd = ":*****@";
> +                }
> +
> +                projectUrl = projectUrl.replace( password, newPwd );
> +            }
> +        }
> +
> +        return projectUrl;
> +    }
>  }
>
>
>