oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1552690 - /oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java
Date Fri, 20 Dec 2013 14:52:58 GMT
Author: asanso
Date: Fri Dec 20 14:52:58 2013
New Revision: 1552690

URL: http://svn.apache.org/r1552690
Log:
OLTU-131 - Signature parsing from access token is broken for character encodings that are
not single-byte

* partially apply patch from Andrei Dulvac (thanks !!)

Modified:
    oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java

Modified: oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java
URL: http://svn.apache.org/viewvc/oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java?rev=1552690&r1=1552689&r2=1552690&view=diff
==============================================================================
--- oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java
(original)
+++ oltu/trunk/commons/encodedtoken/src/main/java/org/apache/oltu/commons/encodedtoken/TokenDecoder.java
Fri Dec 20 14:52:58 2013
@@ -20,7 +20,7 @@ import java.nio.charset.Charset;
 
 import org.apache.commons.codec.binary.Base64;
 
-abstract class TokenDecoder {
+public abstract class TokenDecoder {
 
     /**
      * The {@code UTF-8} charset reference.
@@ -28,16 +28,26 @@ abstract class TokenDecoder {
     private static final Charset UTF_8 = Charset.forName("UTF-8");
 
     /**
+     * Empty Line separator for rfc 2045 section 6.8
+     * {@see org.apache.commons.codec.binary.Base64}
+     */
+    private static final byte[] LINE_SEPARATOR = {};
+
+    /**
      * The BASE64 encoder/decoder.
+     * Encode base64url rfc4648
      */
-    private final Base64 base64 = new Base64(true);
+    private static final Base64 base64 = new Base64(-1, LINE_SEPARATOR, true);
 
-    protected final String base64Decode(String base64encoded) {
+    public static final String base64Decode(String base64encoded) {
         return new String(base64.decode(base64encoded), UTF_8);
     }
 
-    protected final String base64Encode(String input) {
+    public static final String base64Encode(String input) {
         return new String(base64.encode(input.getBytes(UTF_8)), UTF_8);
     }
-
+    
+    public static final String base64Encode(byte [] input) {
+        return new String(base64.encode(input));
+    }
 }



Mime
View raw message