oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1524724 - in /oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt: ClaimsSet.java Header.java JWTEntity.java
Date Thu, 19 Sep 2013 13:03:16 GMT
Author: simonetripodi
Date: Thu Sep 19 13:03:16 2013
New Revision: 1524724

URL: http://svn.apache.org/r1524724
Log:
trivial: improved toString() representation

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

Modified: oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/ClaimsSet.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/ClaimsSet.java?rev=1524724&r1=1524723&r2=1524724&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/ClaimsSet.java (original)
+++ oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/ClaimsSet.java Thu Sep
19 13:03:16 2013
@@ -161,7 +161,7 @@ public final class ClaimsSet extends JWT
 
     @Override
     public String toString() {
-        return format("{\"iss\": \"%s\", \"sub\": \"%s\", \"aud\": \"%s\", \"exp\": %s, \"nbf\":
\"%s\", \"iat\": %s, \"jti\": \"%s\", \"typ\": \"%s\", %s }",
+        return format("{\"iss\": \"%s\", \"sub\": \"%s\", \"aud\": \"%s\", \"exp\": %s, \"nbf\":
\"%s\", \"iat\": %s, \"jti\": \"%s\", \"typ\": \"%s\" }",
                       issuer, subject, audience, expirationTime, notBefore, issuedAt, jwdId,
type, super.toString());
     }
 

Modified: oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/Header.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/Header.java?rev=1524724&r1=1524723&r2=1524724&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/Header.java (original)
+++ oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/Header.java Thu Sep
19 13:03:16 2013
@@ -81,7 +81,7 @@ public final class Header extends JWTEnt
 
     @Override
     public String toString() {
-        return format("{\"typ\": \"%s\", \"alg\": \"%s\", \"cty\": \"%s\", %s}", type, algorithm,
contentType, super.toString());
+        return format("{\"typ\": \"%s\", \"alg\": \"%s\", \"cty\": \"%s\" %s}", type, algorithm,
contentType, super.toString());
     }
 
 }

Modified: oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java?rev=1524724&r1=1524723&r2=1524724&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java (original)
+++ oltu/trunk/oauth-2.0/jwt/src/main/java/org/apache/oltu/oauth2/jwt/JWTEntity.java Thu Sep
19 13:03:16 2013
@@ -71,20 +71,32 @@ public abstract class JWTEntity {
 
     @Override
     public String toString() {
+        if (customFields.isEmpty()) {
+            return "";
+        }
+
         Formatter formatter = new Formatter();
 
+        formatter.format( ", " );
+
         int counter = 0;
         for (Entry<String, Object> customField : customFields.entrySet()) {
             if (counter++ > 0) {
                 formatter.format(", ");
             }
 
-            formatter.format("\"%s\": \"%s\"", customField.getKey(), customField.getValue());
+            if (customField.getValue() instanceof Number) {
+                formatter.format("\"%s\": %s", customField.getKey(), customField.getValue());
+            } else {
+                formatter.format("\"%s\": \"%s\"", customField.getKey(), customField.getValue());
+            }
         }
 
-        formatter.close();
-
-        return formatter.toString();
+        try {
+            return formatter.toString();
+        } finally {
+            formatter.close();
+        }
     }
 
 }



Mime
View raw message