commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r452588 - in /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs: ./ impl/ provider/ provider/local/ provider/smb/ provider/url/
Date Tue, 03 Oct 2006 18:13:37 GMT
Author: imario
Date: Tue Oct  3 11:13:36 2006
New Revision: 452588

URL: http://svn.apache.org/viewvc?view=rev&rev=452588
Log:
VFS-42: allow to create a "friendly uri" which is one without the password. Instead the system
will render "*****" if the original filename contained a password.

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java Tue Oct
 3 11:13:36 2006
@@ -183,4 +183,10 @@
      * @return {@link FileType#FOLDER} or {@link FileType#FILE}
      */
     public FileType getType();
+
+    /**
+     * returns a "friendly path", this is a path without a password.<br />
+     * This path can not be used to resolve the path again
+     */
+    public String getFriendlyURI();
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
Tue Oct  3 11:13:36 2006
@@ -37,7 +37,7 @@
         return new VirtualFileName(getScheme(), absPath, type);
     }
 
-    protected void appendRootUri(StringBuffer buffer)
+    protected void appendRootUri(StringBuffer buffer, boolean addPassword)
     {
         buffer.append(getScheme());
     }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
Tue Oct  3 11:13:36 2006
@@ -124,7 +124,7 @@
      * Builds the root URI for this file name.  Note that the root URI must not
      * end with a separator character.
      */
-    protected abstract void appendRootUri(StringBuffer buffer);
+    protected abstract void appendRootUri(StringBuffer buffer, boolean addPassword);
 
     /**
      * Returns the base name of the file.
@@ -236,7 +236,7 @@
     protected String createURI()
     {
         final StringBuffer buffer = new StringBuffer();
-        appendRootUri(buffer);
+        appendRootUri(buffer, true);
         buffer.append(getPath());
         return buffer.toString();
     }
@@ -309,7 +309,7 @@
         if (rootUri == null)
         {
             final StringBuffer buffer = new StringBuffer();
-            appendRootUri(buffer);
+            appendRootUri(buffer, true);
             buffer.append(SEPARATOR_CHAR);
             rootUri = buffer.toString().intern();
         }
@@ -487,5 +487,16 @@
         }
 
         return true;
+    }
+
+    /**
+     * returns a "friendly path", this is a path without a password.
+     */
+    public String getFriendlyURI()
+    {
+        final StringBuffer buffer = new StringBuffer();
+        appendRootUri(buffer, false);
+        buffer.append(getPath());
+        return buffer.toString();
     }
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
Tue Oct  3 11:13:36 2006
@@ -117,11 +117,11 @@
     /**
      * Builds the root URI for this file name.
      */
-    protected void appendRootUri(final StringBuffer buffer)
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
     {
         buffer.append(getScheme());
         buffer.append("://");
-        appendCredentials(buffer);
+        appendCredentials(buffer, addPassword);
         buffer.append(hostName);
         if (port != getDefaultPort())
         {
@@ -133,7 +133,7 @@
     /**
      * append the user credentials
      */
-    protected void appendCredentials(StringBuffer buffer)
+    protected void appendCredentials(StringBuffer buffer, boolean addPassword)
     {
         if (userName != null && userName.length() != 0)
         {
@@ -141,7 +141,14 @@
             if (password != null && password.length() != 0)
             {
                 buffer.append(':');
-                UriParser.appendEncoded(buffer, password, PASSWORD_RESERVED);
+                if (addPassword)
+                {
+                    UriParser.appendEncoded(buffer, password, PASSWORD_RESERVED);
+                }
+                else
+                {
+                    buffer.append("*****");
+                }
             }
             buffer.append('@');
         }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
Tue Oct  3 11:13:36 2006
@@ -50,7 +50,7 @@
         return new LayeredFileName(getScheme(), getOuterName(), path, type);
     }
 
-    protected void appendRootUri(StringBuffer buffer)
+    protected void appendRootUri(StringBuffer buffer, boolean addPassword)
     {
         buffer.append(getScheme());
         buffer.append(":");

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
Tue Oct  3 11:13:36 2006
@@ -118,7 +118,7 @@
     public String getURIEncoded(String charset) throws FileSystemException, URIException
     {
         StringBuffer sb = new StringBuffer(80);
-        appendRootUri(sb);
+        appendRootUri(sb, true);
         sb.append(getPathQueryEncoded(charset));
         return sb.toString();
     }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
Tue Oct  3 11:13:36 2006
@@ -57,7 +57,7 @@
     /**
      * Builds the root URI for this file name.
      */
-    protected void appendRootUri(final StringBuffer buffer)
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
     {
         buffer.append(getScheme());
         buffer.append("://");

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
Tue Oct  3 11:13:36 2006
@@ -45,7 +45,7 @@
     /**
      * Builds the root URI for this file name.
      */
-    protected void appendRootUri(final StringBuffer buffer)
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
     {
         buffer.append(getScheme());
         buffer.append("://");

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
Tue Oct  3 11:13:36 2006
@@ -62,9 +62,9 @@
     /**
      * Builds the root URI for this file name.
      */
-    protected void appendRootUri(final StringBuffer buffer)
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
     {
-        super.appendRootUri(buffer);
+        super.appendRootUri(buffer, addPassword);
         buffer.append('/');
         buffer.append(share);
     }
@@ -72,7 +72,7 @@
     /**
      * put domain before username if both are set
      */
-    protected void appendCredentials(StringBuffer buffer)
+    protected void appendCredentials(StringBuffer buffer, boolean addPassword)
     {
         if (getDomain() != null && getDomain().length() != 0 &&
             getUserName() != null && getUserName().length() != 0)
@@ -80,7 +80,7 @@
             buffer.append(getDomain());
             buffer.append("\\");
         }
-        super.appendCredentials(buffer);
+        super.appendCredentials(buffer, addPassword);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java?view=diff&rev=452588&r1=452587&r2=452588
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
(original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
Tue Oct  3 11:13:36 2006
@@ -17,11 +17,11 @@
         super(scheme, hostName, port, defaultPort, userName, password, path, type, queryString);
     }
 
-    protected void appendRootUri(final StringBuffer buffer)
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
     {
         if (getHostName() != null && !"".equals(getHostName()))
         {
-            super.appendRootUri(buffer);
+            super.appendRootUri(buffer, addPassword);
             return;
         }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message