cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Adding the utility code for stripping the algo properties in some cases, thanks to Colm
Date Thu, 05 Jun 2014 13:31:51 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 90404af4e -> e44fba741


Adding the utility code for stripping the algo properties in some cases, thanks to Colm


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

Branch: refs/heads/master
Commit: e44fba741bfab2febada4bc506e7a193c29207ff
Parents: 90404af
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Jun 5 14:31:36 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Jun 5 14:31:36 2014 +0100

----------------------------------------------------------------------
 .../cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java |  3 +++
 .../cxf/rs/security/oauth2/jwt/Algorithm.java       | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e44fba74/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java
index 6ae43b6..9be12a1 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/RSAJweEncryptor.java
@@ -39,6 +39,9 @@ public class RSAJweEncryptor extends JweEncryptor {
              new JweHeaders(Algorithm.RSA_OAEP_ALGO.getJwtName(), secretKeyJwtAlgorithm),
              secretKey.getEncoded(), iv, DEFAULT_AUTH_TAG_LENGTH, true);
     }
+    public RSAJweEncryptor(RSAPublicKey publicKey, SecretKey secretKey, byte[] iv) {
+        this(publicKey, secretKey, Algorithm.stripAlgoProperties(secretKey.getAlgorithm()),
iv);
+    }
     
     public RSAJweEncryptor(RSAPublicKey publicKey, JweHeaders headers, byte[] cek, byte[]
iv, 
                            int authTagLen, boolean wrap) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/e44fba74/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
index ea2cacb..c675016 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
@@ -97,6 +97,10 @@ public enum Algorithm {
     public String getJavaName() {
         return javaName == null ? name() : javaName;
     }
+    
+    public String getJavaAlgoName() {
+        return stripAlgoProperties(getJavaName());
+    }
 
     public int getKeySizeBits() {
         return keySizeBits;
@@ -108,5 +112,17 @@ public enum Algorithm {
     public static String toJavaName(String jwtName) {    
         return JWT_TO_JAVA_NAMES.get(jwtName);
     }
+    public static String toJavaAlgoNameOnly(String jwtName) {    
+        return stripAlgoProperties(toJavaName(jwtName));
+    }
+    public static String stripAlgoProperties(String javaName) {    
+        if (javaName != null) {
+            int index = javaName.indexOf('/');
+            if (index != -1) {
+                javaName = javaName.substring(0, index);
+            }
+        }
+        return javaName;
+    }
     
 }
\ No newline at end of file


Mime
View raw message