cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Updating JWT claims to use Long instead of Integer to represent date properties
Date Tue, 22 Jul 2014 09:29:42 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 2f4c97ffa -> 903b25083


Updating JWT claims to use Long instead of Integer to represent date properties


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/903b2508
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/903b2508
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/903b2508

Branch: refs/heads/master
Commit: 903b2508397daa08ccdc241330d3985b43ee585c
Parents: 2f4c97f
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Jul 22 12:29:21 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Jul 22 12:29:21 2014 +0300

----------------------------------------------------------------------
 .../rs/security/oauth2/jwt/AbstractJwtObject.java |  4 ++--
 .../cxf/rs/security/oauth2/jwt/JwtClaims.java     | 18 +++++++++---------
 .../security/oauth2/jwt/JwtTokenReaderWriter.java |  2 +-
 .../oauth2/jwt/grant/AbstractJwtHandler.java      |  6 +++---
 .../oauth2/jws/JwsCompactReaderWriterTest.java    | 10 +++++-----
 5 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/903b2508/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/AbstractJwtObject.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/AbstractJwtObject.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/AbstractJwtObject.java
index 85b1210..fcb8a07 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/AbstractJwtObject.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/AbstractJwtObject.java
@@ -45,9 +45,9 @@ public abstract class AbstractJwtObject {
         return new LinkedHashMap<String, Object>(values);
     }
     
-    protected Integer getIntDate(String name) {
+    protected Long getLongDate(String name) {
         Object object = getValue(name);
-        return object instanceof Integer ? (Integer)object : Integer.valueOf(object.toString());
+        return object instanceof Long ? (Long)object : Long.valueOf(object.toString());
     }
     
     public int hashCode() { 

http://git-wip-us.apache.org/repos/asf/cxf/blob/903b2508/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtClaims.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtClaims.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtClaims.java
index 5cef4fc..7260904 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtClaims.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtClaims.java
@@ -57,28 +57,28 @@ public class JwtClaims extends AbstractJwtObject {
         return (String)getClaim(JwtConstants.CLAIM_AUDIENCE);
     }
     
-    public void setExpiryTime(Integer expiresIn) {
+    public void setExpiryTime(Long expiresIn) {
         setClaim(JwtConstants.CLAIM_EXPIRY, expiresIn);
     }
     
-    public Integer getExpiryTime() {
-        return getIntDate(JwtConstants.CLAIM_EXPIRY);
+    public Long getExpiryTime() {
+        return getLongDate(JwtConstants.CLAIM_EXPIRY);
     }
     
-    public void setNotBefore(Integer notBefore) {
+    public void setNotBefore(Long notBefore) {
         setClaim(JwtConstants.CLAIM_NOT_BEFORE, notBefore);
     }
     
-    public Integer getNotBefore() {
-        return getIntDate(JwtConstants.CLAIM_NOT_BEFORE);
+    public Long getNotBefore() {
+        return getLongDate(JwtConstants.CLAIM_NOT_BEFORE);
     }
     
-    public void setIssuedAt(Integer issuedAt) {
+    public void setIssuedAt(Long issuedAt) {
         setClaim(JwtConstants.CLAIM_ISSUED_AT, issuedAt);
     }
     
-    public Integer getIssuedAt() {
-        return getIntDate(JwtConstants.CLAIM_ISSUED_AT);
+    public Long getIssuedAt() {
+        return getLongDate(JwtConstants.CLAIM_ISSUED_AT);
     }
     
     public void setTokenId(String id) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/903b2508/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtTokenReaderWriter.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtTokenReaderWriter.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtTokenReaderWriter.java
index d8d6dd4..2c20c11 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtTokenReaderWriter.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtTokenReaderWriter.java
@@ -183,7 +183,7 @@ public class JwtTokenReaderWriter implements JwtTokenReader, JwtTokenWriter
{
                 int commaIndex = getCommaIndex(json, sepIndex + j);
                 Object value = readPrimitiveValue(json, sepIndex + j, commaIndex);
                 if (DATE_PROPERTIES.contains(name)) {
-                    value = Integer.valueOf(value.toString());
+                    value = Long.valueOf(value.toString());
                 }
                 values.put(name, value);
                 i = commaIndex + 1;

http://git-wip-us.apache.org/repos/asf/cxf/blob/903b2508/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/AbstractJwtHandler.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/AbstractJwtHandler.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/AbstractJwtHandler.java
index 8dfdf60..f1bb9c9 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/AbstractJwtHandler.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/grant/AbstractJwtHandler.java
@@ -69,17 +69,17 @@ public abstract class AbstractJwtHandler extends AbstractGrantHandler
{
     protected void validateAudience(Client client, String audience) {
         //TODO
     }
-    protected void validateExpiryTime(Integer timestamp) {
+    protected void validateExpiryTime(Long timestamp) {
         if (timestamp != null) {
             //TODO
         }
     }
-    protected void validateNotBeforeTime(Integer timestamp) {
+    protected void validateNotBeforeTime(Long timestamp) {
         if (timestamp != null) {
             //TODO    
         }
     }
-    protected void validateIssuedAtTime(Integer timestamp) {
+    protected void validateIssuedAtTime(Long timestamp) {
         if (timestamp != null) {
             //TODO
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/903b2508/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
index 8378aab..83e3c86 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
@@ -100,8 +100,8 @@ public class JwsCompactReaderWriterTest extends Assert {
         claims.setIssuer("https://jwt-idp.example.com");
         claims.setSubject("mailto:mike@example.com");
         claims.setAudience("https://jwt-rp.example.net");
-        claims.setNotBefore(1300815780);
-        claims.setExpiryTime(1300819380);
+        claims.setNotBefore(1300815780L);
+        claims.setExpiryTime(1300819380L);
         claims.setClaim("http://claims.example.com/member", true);
         
         JwsCompactProducer writer = new JwsJwtCompactProducer(headers, claims);
@@ -150,7 +150,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("joe");
-        claims.setExpiryTime(1300819380);
+        claims.setExpiryTime(1300819380L);
         claims.setClaim("http://example.com/is_root", Boolean.TRUE);
         
         JwtToken token = new JwtToken(headers, claims);
@@ -181,7 +181,7 @@ public class JwsCompactReaderWriterTest extends Assert {
     
     private void validateSpecClaim(JwtClaims claims) {
         assertEquals("joe", claims.getIssuer());
-        assertEquals(Integer.valueOf(1300819380), claims.getExpiryTime());
+        assertEquals(Long.valueOf(1300819380), claims.getExpiryTime());
         assertEquals(Boolean.TRUE, claims.getClaim("http://example.com/is_root"));
     }
     
@@ -211,7 +211,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         
         JwtClaims claims = new JwtClaims();
         claims.setIssuer("joe");
-        claims.setExpiryTime(1300819380);
+        claims.setExpiryTime(1300819380L);
         claims.setClaim("http://example.com/is_root", Boolean.TRUE);
         
         JwtToken token = new JwtToken(headers, claims);


Mime
View raw message