oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1480567 - /oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java
Date Thu, 09 May 2013 08:44:27 GMT
Author: simonetripodi
Date: Thu May  9 08:44:27 2013
New Revision: 1480567

URL: http://svn.apache.org/r1480567
Log:
extracted constants

Modified:
    oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java

Modified: oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java?rev=1480567&r1=1480566&r2=1480567&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java (original)
+++ oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTUtil.java Thu May
 9 08:44:27 2013
@@ -27,6 +27,16 @@ import org.apache.commons.codec.binary.B
 public class JWTUtil {
 
     /**
+     * The {@code UTF-8} charset reference.
+     */
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    /**
+     * The Base64 JSON string default separator.
+     */
+    private static final String DEFAULT_SEPARATOR = "\\.";
+
+    /**
      * Hidden constructor, this class must not be instantiated.
      */
     private JWTUtil() {
@@ -41,7 +51,7 @@ public class JWTUtil {
      * @return the decoded JWT header
      */
     public static String getHeader(String base64jsonString){
-        return decodeJSON(base64jsonString.split("\\.")[0]);
+        return decodeJSON(base64jsonString.split(DEFAULT_SEPARATOR)[0]);
     }
 
     /**
@@ -52,10 +62,10 @@ public class JWTUtil {
      * @return the decoded JWT claim set
      */
     public static String getClaimsSet(String base64jsonString){
-        return decodeJSON(base64jsonString.split("\\.")[1]);
+        return decodeJSON(base64jsonString.split(DEFAULT_SEPARATOR)[1]);
     }
 
     private static String decodeJSON(String base64jsonString){
-        return new String(new Base64(true).decode(base64jsonString),Charset.forName("UTF-8"));
+        return new String(new Base64(true).decode(base64jsonString), UTF_8);
     }
 }



Mime
View raw message