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:00:28 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 9fe4c04a1 -> 669bd557f


[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/669bd557
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/669bd557
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/669bd557

Branch: refs/heads/master
Commit: 669bd557f38288fac54204478d8dc31cf82e8e94
Parents: 9fe4c04
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:00:12 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/669bd557/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