cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5944] Making it simpler to deal with integer amd long headers
Date Tue, 16 Sep 2014 15:39:43 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c9331dfde -> 5a407ef98


[CXF-5944] Making it simpler to deal with integer amd long headers


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

Branch: refs/heads/master
Commit: 5a407ef98d9ddccc588f2686da2dc7cb9eddc8a7
Parents: c9331df
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Sep 16 16:39:00 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Sep 16 16:39:00 2014 +0100

----------------------------------------------------------------------
 .../PbesHmacAesWrapKeyDecryptionAlgorithm.java  |  2 +-
 .../PbesHmacAesWrapKeyEncryptionAlgorithm.java  |  2 +-
 .../cxf/rs/security/oauth2/jwt/JwtHeaders.java  | 27 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5a407ef9/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyDecryptionAlgorithm.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyDecryptionAlgorithm.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyDecryptionAlgorithm.java
index 192b3f0..22eba6d 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyDecryptionAlgorithm.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyDecryptionAlgorithm.java
@@ -34,7 +34,7 @@ public class PbesHmacAesWrapKeyDecryptionAlgorithm implements KeyDecryptionAlgor
     @Override
     public byte[] getDecryptedContentEncryptionKey(JweCompactConsumer consumer) {
         byte[] saltInput = getDecodedBytes(consumer, "p2s");
-        int pbesCount = Integer.parseInt((String)consumer.getJweHeaders().getHeader("p2c"));
+        int pbesCount = consumer.getJweHeaders().getIntegerHeader("p2c");
         String keyAlgoJwt = consumer.getJweHeaders().getAlgorithm();
         int keySize = PbesHmacAesWrapKeyEncryptionAlgorithm.getKeySize(keyAlgoJwt);
         byte[] derivedKey = PbesHmacAesWrapKeyEncryptionAlgorithm

http://git-wip-us.apache.org/repos/asf/cxf/blob/5a407ef9/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java
index 9015760..1cba7b6 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/PbesHmacAesWrapKeyEncryptionAlgorithm.java
@@ -95,7 +95,7 @@ public class PbesHmacAesWrapKeyEncryptionAlgorithm implements KeyEncryptionAlgor
         byte[] derivedKey = createDerivedKey(keyAlgoJwt, keySize, password, saltInput, pbesCount);
         
         headers.setHeader("p2s", Base64UrlUtility.encode(saltInput));
-        headers.setHeader("p2c", Integer.valueOf(pbesCount));
+        headers.setIntegerHeader("p2c", pbesCount);
         
         final String aesAlgoJwt = PBES_AES_MAP.get(keyAlgoJwt);
         KeyEncryptionAlgorithm aesWrap = new AesWrapKeyEncryptionAlgorithm(derivedKey, aesAlgoJwt)
{

http://git-wip-us.apache.org/repos/asf/cxf/blob/5a407ef9/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
index 240c084..f83ee6b 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
@@ -141,4 +141,31 @@ public class JwtHeaders extends AbstractJwtObject {
     public Object getHeader(String name) {
         return getValue(name);
     }
+    
+    public JwtHeaders setIntegerHeader(String name, Integer value) {
+        setValue(name, value);
+        return this;
+    }
+    
+    public Integer getIntegerHeader(String name) {
+        Object value = getValue(name);
+        if (value != null) {
+            return value instanceof Integer ? (Integer)value : Integer.parseInt(value.toString());
+        } else {
+            return null;
+        }
+    }
+    public JwtHeaders setLongHeader(String name, Long value) {
+        setValue(name, value);
+        return this;
+    }
+    
+    public Long getLongHeader(String name) {
+        Object value = getValue(name);
+        if (value != null) {
+            return value instanceof Long ? (Long)value : Long.parseLong(value.toString());
+        } else {
+            return null;
+        }
+    }
 }


Mime
View raw message