chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1574130 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/ chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/o...
Date Tue, 04 Mar 2014 16:40:50 GMT
Author: fmui
Date: Tue Mar  4 16:40:50 2014
New Revision: 1574130

URL: http://svn.apache.org/r1574130
Log:
Standard authentication provider: added parameter to define the charset for username and password

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java?rev=1574130&r1=1574129&r2=1574130&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
Tue Mar  4 16:40:50 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.chemistry.opencmis.client.bindings.spi;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -230,7 +231,21 @@ public class StandardAuthenticationProvi
             password = "";
         }
 
-        return Collections.singletonList("Basic " + Base64.encodeBytes(IOUtils.toUTF8Bytes(username
+ ":" + password)));
+        Object charset = getSession().get(SessionParameter.AUTH_HTTP_BASIC_CHARSET);
+        if (charset instanceof String) {
+            charset = ((String) charset).trim();
+        } else {
+            charset = IOUtils.UTF8;
+        }
+
+        byte[] usernamePassword;
+        try {
+            usernamePassword = (username + ":" + password).getBytes((String) charset);
+        } catch (UnsupportedEncodingException e) {
+            throw new CmisRuntimeException("Unsupported encoding '" + charset + "'!", e);
+        }
+
+        return Collections.singletonList("Basic " + Base64.encodeBytes(usernamePassword));
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1574130&r1=1574129&r2=1574130&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
Tue Mar  4 16:40:50 2014
@@ -122,6 +122,14 @@ package org.apache.chemistry.opencmis.co
  * <td>depends on {@link #BINDING_TYPE}</td>
  * </tr>
  * <tr>
+ * <td>{@link #AUTH_HTTP_BASIC_CHARSET}</td>
+ * <td>Charset to encode HTTP basic authentication username and password</td>
+ * <td>AtomPub, Web Services, Browser</td>
+ * <td>character set name</td>
+ * <td>no</td>
+ * <td>UTF-8</td>
+ * </tr>
+ * <tr>
  * <td>{@link #AUTH_SOAP_USERNAMETOKEN}</td>
  * <td>Switch to turn UsernameTokens on or off</td>
  * <td>Web Services</td>
@@ -571,6 +579,7 @@ public final class SessionParameter {
      * authentication provider.
      */
     public static final String AUTH_HTTP_BASIC = "org.apache.chemistry.opencmis.binding.auth.http.basic";
+    public static final String AUTH_HTTP_BASIC_CHARSET = "org.apache.chemistry.opencmis.binding.auth.http.basic.charset";
 
     /**
      * Toggle for OAuth Bearer token authentication. Evaluated by the standard



Mime
View raw message