cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Minor update to the utility converting JwtToken to ServerAccessToken
Date Tue, 07 Oct 2014 16:53:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 08fbe43f2 -> 6ea206160


Minor update to the utility converting JwtToken to ServerAccessToken


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

Branch: refs/heads/3.0.x-fixes
Commit: 6ea2061602527aa5a3a15e022aa6efbe0aee5996
Parents: 08fbe43
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Oct 7 17:51:17 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Oct 7 17:53:25 2014 +0100

----------------------------------------------------------------------
 .../security/jose/jwt/token/JwtAccessTokenUtils.java | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6ea20616/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/token/JwtAccessTokenUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/token/JwtAccessTokenUtils.java
b/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/token/JwtAccessTokenUtils.java
index 1474675..1372adf 100644
--- a/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/token/JwtAccessTokenUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2-jose/src/main/java/org/apache/cxf/rs/security/jose/jwt/token/JwtAccessTokenUtils.java
@@ -26,6 +26,7 @@ import org.apache.cxf.rs.security.jose.jwe.AesGcmContentEncryptionAlgorithm;
 import org.apache.cxf.rs.security.jose.jwe.ContentEncryptionAlgorithm;
 import org.apache.cxf.rs.security.jose.jwe.DirectKeyJweDecryption;
 import org.apache.cxf.rs.security.jose.jwe.DirectKeyJweEncryption;
+import org.apache.cxf.rs.security.jose.jwe.JweDecryptionProvider;
 import org.apache.cxf.rs.security.jose.jwe.JweEncryptionProvider;
 import org.apache.cxf.rs.security.jose.jws.JwsHeaders;
 import org.apache.cxf.rs.security.jose.jws.JwsJwtCompactConsumer;
@@ -45,11 +46,18 @@ public final class JwtAccessTokenUtils {
     public static ServerAccessToken toAccessToken(JwtToken jwt, 
                                                   Client client,
                                                   SecretKey key) {
-        String jwtString = new JwsJwtCompactProducer(jwt)
-                               .signWith(new NoneSignatureProvider());
         ContentEncryptionAlgorithm contentEncryption = 
             new AesGcmContentEncryptionAlgorithm(key, null, Algorithm.A128GCM.getJwtName());
         JweEncryptionProvider jweEncryption = new DirectKeyJweEncryption(contentEncryption);
+        return toAccessToken(jwt, client, jweEncryption);
+        
+    }
+    
+    public static ServerAccessToken toAccessToken(JwtToken jwt, 
+                                                  Client client,
+                                                  JweEncryptionProvider jweEncryption) {
+        String jwtString = new JwsJwtCompactProducer(jwt)
+                               .signWith(new NoneSignatureProvider());
         String tokenId = jweEncryption.encrypt(getBytes(jwtString), null);
         Long issuedAt = jwt.getClaims().getIssuedAt();
         Long notBefore = jwt.getClaims().getNotBefore();
@@ -71,6 +79,9 @@ public final class JwtAccessTokenUtils {
         DirectKeyJweDecryption jweDecryption = 
             new DirectKeyJweDecryption(key, 
                 new AesGcmContentDecryptionAlgorithm(Algorithm.A128GCM.getJwtName()));
+        return fromAccessTokenId(tokenId, jweDecryption);
+    }
+    public static JwtToken fromAccessTokenId(String tokenId, JweDecryptionProvider jweDecryption)
{
         String decrypted = jweDecryption.decrypt(tokenId).getContentText();
         JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(decrypted);
         return consumer.getJwtToken();


Mime
View raw message