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] Adding few more JWK utility methods
Date Mon, 22 Sep 2014 09:01:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 8326aef6d -> feb97e5b1


[CXF-5944] Adding few more JWK utility methods


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

Branch: refs/heads/3.0.x-fixes
Commit: feb97e5b1bd0959a50022ccd29a620031a8f8761
Parents: 8326aef
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Sep 22 10:00:12 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Sep 22 10:01:08 2014 +0100

----------------------------------------------------------------------
 .../cxf/rs/security/jose/jwk/JwkUtils.java      | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/feb97e5b/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
b/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
index 3e61fd4..bf255b9 100644
--- a/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwk/JwkUtils.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.rs.security.jose.jwk;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.security.interfaces.ECPrivateKey;
@@ -53,6 +54,12 @@ public final class JwkUtils {
     private JwkUtils() {
         
     }
+    public static JsonWebKey readJwkKey(InputStream is) throws IOException {
+        return new DefaultJwkReaderWriter().jsonToJwk(IOUtils.readStringFromStream(is));
+    }
+    public static JsonWebKeys readJwkSet(InputStream is) throws IOException {
+        return new DefaultJwkReaderWriter().jsonToJwkSet(IOUtils.readStringFromStream(is));
+    }
     public static JsonWebKey readJwkKey(String jwkJson) {
         return new DefaultJwkReaderWriter().jsonToJwk(jwkJson);
     }
@@ -83,6 +90,17 @@ public final class JwkUtils {
     public static JsonWebKeys decryptJwkSet(String jsonJwkSet, JweDecryptionProvider jwe,
JwkReaderWriter reader) {
         return reader.jsonToJwkSet(jwe.decrypt(jsonJwkSet).getContentText());
     }
+    public static JsonWebKeys decryptJwkSet(InputStream is, char[] password) throws IOException
{
+        return decryptJwkSet(is, password, new DefaultJwkReaderWriter());
+    }
+    public static JsonWebKeys decryptJwkSet(InputStream is, char[] password, JwkReaderWriter
reader) 
+        throws IOException {
+        return decryptJwkSet(is, createDefaultDecryption(password), reader);
+    }
+    public static JsonWebKeys decryptJwkSet(InputStream is, JweDecryptionProvider jwe, JwkReaderWriter
reader)
+        throws IOException {
+        return reader.jsonToJwkSet(jwe.decrypt(IOUtils.readStringFromStream(is)).getContentText());
+    }
     public static String encryptJwkKey(JsonWebKey jwk, char[] password) {
         return encryptJwkKey(jwk, password, new DefaultJwkReaderWriter());
     }
@@ -101,6 +119,17 @@ public final class JwkUtils {
     public static JsonWebKey decryptJwkKey(String jsonJwkKey, JweDecryptionProvider jwe,
JwkReaderWriter reader) {
         return reader.jsonToJwk(jwe.decrypt(jsonJwkKey).getContentText());
     }
+    public static JsonWebKey decryptJwkKey(InputStream is, char[] password) throws IOException
{
+        return decryptJwkKey(is, password, new DefaultJwkReaderWriter());
+    }
+    public static JsonWebKey decryptJwkKey(InputStream is, char[] password, JwkReaderWriter
reader) 
+        throws IOException {
+        return decryptJwkKey(is, createDefaultDecryption(password), reader);
+    }
+    public static JsonWebKey decryptJwkKey(InputStream is, JweDecryptionProvider jwe, JwkReaderWriter
reader) 
+        throws IOException {
+        return reader.jsonToJwk(jwe.decrypt(IOUtils.readStringFromStream(is)).getContentText());
+    }
     private static JweEncryptionProvider createDefaultEncryption(char[] password) {
         KeyEncryptionAlgorithm keyEncryption = 
             new PbesHmacAesWrapKeyEncryptionAlgorithm(password, Algorithm.PBES2_HS256_A128KW.getJwtName());


Mime
View raw message