continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r769074 - /continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Date Mon, 27 Apr 2009 18:01:42 GMT
Author: jzurbano
Date: Mon Apr 27 18:01:41 2009
New Revision: 769074

URL: http://svn.apache.org/viewvc?rev=769074&view=rev
Log:
merge r 769070:769071

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?rev=769074&r1=769073&r2=769074&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Mon Apr 27 18:01:41 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;
+    }
 }



Mime
View raw message