cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: More minor JOSE updates
Date Wed, 04 Mar 2015 16:24:47 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 94064c89f -> d609267b8


More minor JOSE updates


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

Branch: refs/heads/3.0.x-fixes
Commit: d609267b862c8a7643913665d71edb4c71664d29
Parents: 94064c8
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Mar 4 16:22:55 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Mar 4 16:24:13 2015 +0000

----------------------------------------------------------------------
 .../apache/cxf/rs/security/jose/jwk/JwkUtils.java    | 15 +++++++++++++++
 .../cxf/rs/security/jose/jws/JwsCompactConsumer.java |  4 ++++
 2 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d609267b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
index 201d418..70f534d 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
@@ -25,6 +25,7 @@ import java.net.URI;
 import java.security.cert.X509Certificate;
 import java.security.interfaces.ECPrivateKey;
 import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPrivateCrtKey;
 import java.security.interfaces.RSAPrivateKey;
 import java.security.interfaces.RSAPublicKey;
 import java.util.ArrayList;
@@ -381,6 +382,20 @@ public final class JwkUtils {
         JsonWebKey jwk = prepareRSAJwk(pk.getModulus(), algo);
         String encodedPrivateExponent = Base64UrlUtility.encode(pk.getPrivateExponent().toByteArray());
         jwk.setProperty(JsonWebKey.RSA_PRIVATE_EXP, encodedPrivateExponent);
+        if (pk instanceof RSAPrivateCrtKey) {
+            RSAPrivateCrtKey pkCrt = (RSAPrivateCrtKey)pk;
+            jwk.setProperty(JsonWebKey.RSA_FIRST_PRIME_FACTOR, 
+                            Base64UrlUtility.encode(pkCrt.getPrimeP().toByteArray()));
+            jwk.setProperty(JsonWebKey.RSA_SECOND_PRIME_FACTOR, 
+                            Base64UrlUtility.encode(pkCrt.getPrimeQ().toByteArray()));
+            jwk.setProperty(JsonWebKey.RSA_FIRST_PRIME_CRT, 
+                            Base64UrlUtility.encode(pkCrt.getPrimeExponentP().toByteArray()));
+            jwk.setProperty(JsonWebKey.RSA_SECOND_PRIME_CRT, 
+                            Base64UrlUtility.encode(pkCrt.getPrimeExponentQ().toByteArray()));
+            jwk.setProperty(JsonWebKey.RSA_FIRST_CRT_COEFFICIENT, 
+                            Base64UrlUtility.encode(pkCrt.getCrtCoefficient().toByteArray()));
+        }
+        // "oth" can be populated too if needed
         return jwk;
     }
     public static ECPublicKey toECPublicKey(JsonWebKey jwk) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/d609267b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
index 97f49c8..c6ee9cd 100644
--- a/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
+++ b/rt/rs/security/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactConsumer.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.rs.security.jose.jws;
 
+import java.security.cert.X509Certificate;
 import java.security.interfaces.RSAPublicKey;
 
 import org.apache.cxf.common.util.StringUtils;
@@ -107,6 +108,9 @@ public class JwsCompactConsumer {
     public boolean verifySignatureWith(JsonWebKey key, String algo) {
         return verifySignatureWith(JwsUtils.getSignatureVerifier(key, algo));
     }
+    public boolean verifySignatureWith(X509Certificate cert, String algo) {
+        return verifySignatureWith(JwsUtils.getRSAKeySignatureVerifier(cert, algo));
+    }
     public boolean verifySignatureWith(RSAPublicKey key, String algo) {
         return verifySignatureWith(JwsUtils.getRSAKeySignatureVerifier(key, algo));
     }


Mime
View raw message