cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5311] Renaming Algorithms to Algorithm
Date Thu, 22 May 2014 15:46:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a8e21dff6 -> e9ac42b6d


[CXF-5311] Renaming Algorithms to Algorithm


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

Branch: refs/heads/master
Commit: e9ac42b6d4cfe14d40ddc9cc5232cfc89af153a0
Parents: a8e21df
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu May 22 16:46:08 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu May 22 16:46:08 2014 +0100

----------------------------------------------------------------------
 .../security/oauth2/jwe/JweCompactConsumer.java |   4 +-
 .../rs/security/oauth2/jwe/JweDecryptor.java    |   6 +-
 .../rs/security/oauth2/jwe/JweEncryptor.java    |   8 +-
 .../rs/security/oauth2/jwe/RSAJweEncryptor.java |   6 +-
 .../oauth2/jws/HmacJwsSignatureProvider.java    |   4 +-
 .../jws/PrivateKeyJwsSignatureProvider.java     |   4 +-
 .../jws/PublicKeyJwsSignatureVerifier.java      |   4 +-
 .../cxf/rs/security/oauth2/jwt/Algorithm.java   | 100 +++++++++++++++++++
 .../cxf/rs/security/oauth2/jwt/Algorithms.java  | 100 -------------------
 .../cxf/rs/security/oauth2/jwt/JwtHeaders.java  |   2 +-
 .../oauth2/jwe/JweCompactReaderWriterTest.java  |   6 +-
 .../oauth2/jws/JwsCompactReaderWriterTest.java  |  14 +--
 12 files changed, 129 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactConsumer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactConsumer.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactConsumer.java
index d59667b..9c11dcf 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactConsumer.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactConsumer.java
@@ -24,7 +24,7 @@ import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
 
 import org.apache.cxf.common.util.Base64Exception;
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtConstants;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
 import org.apache.cxf.rs.security.oauth2.utils.Base64UrlUtility;
@@ -91,7 +91,7 @@ public class JweCompactConsumer {
     public byte[] getDecryptedContent(ContentEncryptionProvider provider) {
         byte[] cek = provider.getContentEncryptionKey(getJweHeaders(), getEncryptedContentEncryptionKey());
         KeyProperties keyProperties = new KeyProperties(
-            Algorithms.toJavaName(getJweHeaders().getContentEncryptionAlgorithm()));
+            Algorithm.toJavaName(getJweHeaders().getContentEncryptionAlgorithm()));
         keyProperties.setAdditionalData(getContentEncryptionCipherAAD());
         
         AlgorithmParameterSpec spec = provider.getContentEncryptionCipherSpec(getJweHeaders(),

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweDecryptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweDecryptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweDecryptor.java
index 9cf1f17..625f424 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweDecryptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweDecryptor.java
@@ -21,7 +21,7 @@ package org.apache.cxf.rs.security.oauth2.jwe;
 import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.KeyProperties;
 
@@ -74,10 +74,10 @@ public class JweDecryptor {
                                                    getContentEncryptionCipherInitVector());
     }
     protected String getKeyEncryptionAlgorithm() {
-        return Algorithms.toJavaName(getJweHeaders().getKeyEncryptionAlgorithm());
+        return Algorithm.toJavaName(getJweHeaders().getKeyEncryptionAlgorithm());
     }
     protected String getContentEncryptionAlgorithm() {
-        return Algorithms.toJavaName(getJweHeaders().getContentEncryptionAlgorithm());
+        return Algorithm.toJavaName(getJweHeaders().getContentEncryptionAlgorithm());
     }
     protected byte[] getEncryptedContentEncryptionKey() {
         return getJweConsumer().getEncryptedContentEncryptionKey();

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
index 2c2c32b..cb6aabb 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweEncryptor.java
@@ -22,7 +22,7 @@ import java.io.UnsupportedEncodingException;
 import java.security.Key;
 import java.security.spec.AlgorithmParameterSpec;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeadersWriter;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtTokenReaderWriter;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
@@ -85,10 +85,10 @@ public class JweEncryptor {
     }
     
     protected String getContentEncryptionKeyEncryptionAlgo() {
-        return Algorithms.toJavaName(headers.getKeyEncryptionAlgorithm());
+        return Algorithm.toJavaName(headers.getKeyEncryptionAlgorithm());
     }
     protected String getContentEncryptionAlgo() {
-        return Algorithms.toJavaName(headers.getContentEncryptionAlgorithm());
+        return Algorithm.toJavaName(headers.getContentEncryptionAlgorithm());
     }
     
     protected int getAuthTagLen() {
@@ -98,7 +98,7 @@ public class JweEncryptor {
     public String getJweContent(byte[] content) {
         byte[] jweContentEncryptionKey = getEncryptedContentEncryptionKey();
         
-        String contentEncryptionAlgoJavaName = Algorithms.toJavaName(headers.getContentEncryptionAlgorithm());
+        String contentEncryptionAlgoJavaName = Algorithm.toJavaName(headers.getContentEncryptionAlgorithm());
         KeyProperties keyProps = new KeyProperties(contentEncryptionAlgoJavaName);
         byte[] additionalEncryptionParam = headers.toCipherAdditionalAuthData(writer);
         keyProps.setAdditionalData(additionalEncryptionParam);

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/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 8727430..44557b8 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
@@ -22,7 +22,7 @@ import java.security.interfaces.RSAPrivateKey;
 
 import javax.crypto.SecretKey;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeadersWriter;
 
 public class RSAJweEncryptor extends JweEncryptor {
@@ -31,8 +31,8 @@ public class RSAJweEncryptor extends JweEncryptor {
     }
     public RSAJweEncryptor(RSAPrivateKey privateKey, SecretKey secretKey, byte[] iv) {
         this(privateKey, 
-             new JweHeaders(Algorithms.RSA_OAEP_ALGO.getJwtName(),
-                            Algorithms.toJwtName(secretKey.getAlgorithm())), 
+             new JweHeaders(Algorithm.RSA_OAEP_ALGO.getJwtName(),
+                            Algorithm.toJwtName(secretKey.getAlgorithm())), 
              secretKey.getEncoded(), iv, 128, true);
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/HmacJwsSignatureProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/HmacJwsSignatureProvider.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/HmacJwsSignatureProvider.java
index 3d50ff5..ced6c19 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/HmacJwsSignatureProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/HmacJwsSignatureProvider.java
@@ -21,7 +21,7 @@ package org.apache.cxf.rs.security.oauth2.jws;
 import java.util.Arrays;
 
 import org.apache.cxf.common.util.Base64Exception;
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
 import org.apache.cxf.rs.security.oauth2.utils.Base64UrlUtility;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.HmacUtils;
@@ -52,7 +52,7 @@ public class HmacJwsSignatureProvider implements JwsSignatureVerifier, JwsSignat
     
     private byte[] computeMac(JwtHeaders headers, String text) {
         return HmacUtils.computeHmac(key, 
-                                     Algorithms.toJavaName(headers.getAlgorithm()), 
+                                     Algorithm.toJavaName(headers.getAlgorithm()), 
                                      text);
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PrivateKeyJwsSignatureProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PrivateKeyJwsSignatureProvider.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PrivateKeyJwsSignatureProvider.java
index 3c6990e..5b1708c 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PrivateKeyJwsSignatureProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PrivateKeyJwsSignatureProvider.java
@@ -22,7 +22,7 @@ import java.security.PrivateKey;
 import java.security.SecureRandom;
 import java.security.spec.AlgorithmParameterSpec;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
 
@@ -49,7 +49,7 @@ public class PrivateKeyJwsSignatureProvider implements JwsSignatureVerifier
{
         try {
             return CryptoUtils.signData(unsignedText.getBytes("UTF-8"), 
                                         key, 
-                                        Algorithms.toJavaName(headers.getAlgorithm()),
+                                        Algorithm.toJavaName(headers.getAlgorithm()),
                                         random,
                                         signatureSpec);
         } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PublicKeyJwsSignatureVerifier.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PublicKeyJwsSignatureVerifier.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PublicKeyJwsSignatureVerifier.java
index 8e453e9..dede646 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PublicKeyJwsSignatureVerifier.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jws/PublicKeyJwsSignatureVerifier.java
@@ -21,7 +21,7 @@ package org.apache.cxf.rs.security.oauth2.jws;
 import java.security.PublicKey;
 import java.security.spec.AlgorithmParameterSpec;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
 
@@ -41,7 +41,7 @@ public class PublicKeyJwsSignatureVerifier implements JwsSignatureValidator
{
             return CryptoUtils.verifySignature(unsignedText.getBytes("UTF-8"), 
                                                signature, 
                                                key, 
-                                               Algorithms.toJavaName(headers.getAlgorithm()),
+                                               Algorithm.toJavaName(headers.getAlgorithm()),
                                                signatureSpec);
         } catch (Exception ex) {
             throw new SecurityException(ex);

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/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
new file mode 100644
index 0000000..3856eeb
--- /dev/null
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithm.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.rs.security.oauth2.jwt;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+
+public enum Algorithm {
+    // Signature
+    HmacSHA256(JwtConstants.HMAC_SHA_256_ALGO),
+    HmacSHA384(JwtConstants.HMAC_SHA_384_ALGO),
+    HmacSHA512(JwtConstants.HMAC_SHA_512_ALGO),
+    
+    SHA256withRSA(JwtConstants.RS_SHA_256_ALGO),
+    SHA384withRSA(JwtConstants.RS_SHA_384_ALGO),
+    SHA512withRSA(JwtConstants.RS_SHA_512_ALGO),
+    
+    // Key Encryption
+    RSA_OAEP_ALGO(JwtConstants.RSA_OAEP_ALGO, "RSA/ECB/OAEPWithSHA-1AndMGF1Padding"),
+    // Content Encryption
+    A256GCM_ALGO(JwtConstants.A256GCM_ALGO, "AES/GCM/NoPadding");
+    
+    public static final String HMAC_SHA_256_JAVA = "HmacSHA256";
+    public static final String HMAC_SHA_384_JAVA = "HmacSHA384";
+    public static final String HMAC_SHA_512_JAVA = "HmacSHA512";
+    public static final String RS_SHA_256_JAVA = "SHA256withRSA";
+    public static final String RS_SHA_384_JAVA = "SHA384withRSA";
+    public static final String RS_SHA_512_JAVA = "SHA512withRSA";
+    public static final String RSA_OAEP_ALGO_JAVA = "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
+    public static final String A256GCM_ALGO_JAVA = "AES/GCM/NoPadding";
+    
+    private static final Map<String, String> JAVA_TO_JWT_NAMES;
+    private static final Map<String, String> JWT_TO_JAVA_NAMES;
+    static {
+        JAVA_TO_JWT_NAMES = new HashMap<String, String>();
+        JAVA_TO_JWT_NAMES.put(HMAC_SHA_256_JAVA, JwtConstants.HMAC_SHA_256_ALGO);
+        JAVA_TO_JWT_NAMES.put(HMAC_SHA_384_JAVA, JwtConstants.HMAC_SHA_384_ALGO);
+        JAVA_TO_JWT_NAMES.put(HMAC_SHA_512_JAVA, JwtConstants.HMAC_SHA_512_ALGO);
+        JAVA_TO_JWT_NAMES.put(RS_SHA_256_JAVA, JwtConstants.RS_SHA_256_ALGO);
+        JAVA_TO_JWT_NAMES.put(RS_SHA_384_JAVA, JwtConstants.RS_SHA_384_ALGO);
+        JAVA_TO_JWT_NAMES.put(RS_SHA_512_JAVA, JwtConstants.RS_SHA_512_ALGO);
+        JAVA_TO_JWT_NAMES.put(RSA_OAEP_ALGO_JAVA, JwtConstants.RSA_OAEP_ALGO);
+        JAVA_TO_JWT_NAMES.put(A256GCM_ALGO_JAVA, JwtConstants.A256GCM_ALGO);
+        JWT_TO_JAVA_NAMES = new HashMap<String, String>();
+        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_256_ALGO, HMAC_SHA_256_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_384_ALGO, HMAC_SHA_384_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_512_ALGO, HMAC_SHA_512_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_256_ALGO, RS_SHA_256_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_384_ALGO, RS_SHA_384_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_512_ALGO, RS_SHA_512_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.RSA_OAEP_ALGO, RSA_OAEP_ALGO_JAVA);
+        JWT_TO_JAVA_NAMES.put(JwtConstants.A256GCM_ALGO, A256GCM_ALGO_JAVA);
+    }
+    private final String jwtName;
+    private final String javaName;
+
+    private Algorithm(String jwtName) {
+        this(jwtName, null);
+    }
+    private Algorithm(String jwtName, String javaName) {
+        this.jwtName = jwtName;
+        this.javaName = javaName;
+    }
+
+    public String getJwtName() {
+        return jwtName;
+    }
+
+    public String getJavaName() {
+        return javaName == null ? name() : javaName;
+    }
+
+    public static String toJwtName(String javaName) {    
+        return JAVA_TO_JWT_NAMES.get(javaName);
+    }
+    public static String toJavaName(String jwtName) {    
+        return JWT_TO_JAVA_NAMES.get(jwtName);
+    }
+    
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithms.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithms.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithms.java
deleted file mode 100644
index 6f20864..0000000
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/Algorithms.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.rs.security.oauth2.jwt;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-
-public enum Algorithms {
-    // Signature
-    HmacSHA256(JwtConstants.HMAC_SHA_256_ALGO),
-    HmacSHA384(JwtConstants.HMAC_SHA_384_ALGO),
-    HmacSHA512(JwtConstants.HMAC_SHA_512_ALGO),
-    
-    SHA256withRSA(JwtConstants.RS_SHA_256_ALGO),
-    SHA384withRSA(JwtConstants.RS_SHA_384_ALGO),
-    SHA512withRSA(JwtConstants.RS_SHA_512_ALGO),
-    
-    // Key Encryption
-    RSA_OAEP_ALGO(JwtConstants.RSA_OAEP_ALGO, "RSA/ECB/OAEPWithSHA-1AndMGF1Padding"),
-    // Content Encryption
-    A256GCM_ALGO(JwtConstants.A256GCM_ALGO, "AES/GCM/NoPadding");
-    
-    public static final String HMAC_SHA_256_JAVA = "HmacSHA256";
-    public static final String HMAC_SHA_384_JAVA = "HmacSHA384";
-    public static final String HMAC_SHA_512_JAVA = "HmacSHA512";
-    public static final String RS_SHA_256_JAVA = "SHA256withRSA";
-    public static final String RS_SHA_384_JAVA = "SHA384withRSA";
-    public static final String RS_SHA_512_JAVA = "SHA512withRSA";
-    public static final String RSA_OAEP_ALGO_JAVA = "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
-    public static final String A256GCM_ALGO_JAVA = "AES/GCM/NoPadding";
-    
-    private static final Map<String, String> JAVA_TO_JWT_NAMES;
-    private static final Map<String, String> JWT_TO_JAVA_NAMES;
-    static {
-        JAVA_TO_JWT_NAMES = new HashMap<String, String>();
-        JAVA_TO_JWT_NAMES.put(HMAC_SHA_256_JAVA, JwtConstants.HMAC_SHA_256_ALGO);
-        JAVA_TO_JWT_NAMES.put(HMAC_SHA_384_JAVA, JwtConstants.HMAC_SHA_384_ALGO);
-        JAVA_TO_JWT_NAMES.put(HMAC_SHA_512_JAVA, JwtConstants.HMAC_SHA_512_ALGO);
-        JAVA_TO_JWT_NAMES.put(RS_SHA_256_JAVA, JwtConstants.RS_SHA_256_ALGO);
-        JAVA_TO_JWT_NAMES.put(RS_SHA_384_JAVA, JwtConstants.RS_SHA_384_ALGO);
-        JAVA_TO_JWT_NAMES.put(RS_SHA_512_JAVA, JwtConstants.RS_SHA_512_ALGO);
-        JAVA_TO_JWT_NAMES.put(RSA_OAEP_ALGO_JAVA, JwtConstants.RSA_OAEP_ALGO);
-        JAVA_TO_JWT_NAMES.put(A256GCM_ALGO_JAVA, JwtConstants.A256GCM_ALGO);
-        JWT_TO_JAVA_NAMES = new HashMap<String, String>();
-        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_256_ALGO, HMAC_SHA_256_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_384_ALGO, HMAC_SHA_384_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.HMAC_SHA_512_ALGO, HMAC_SHA_512_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_256_ALGO, RS_SHA_256_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_384_ALGO, RS_SHA_384_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.RS_SHA_512_ALGO, RS_SHA_512_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.RSA_OAEP_ALGO, RSA_OAEP_ALGO_JAVA);
-        JWT_TO_JAVA_NAMES.put(JwtConstants.A256GCM_ALGO, A256GCM_ALGO_JAVA);
-    }
-    private final String jwtName;
-    private final String javaName;
-
-    private Algorithms(String jwtName) {
-        this(jwtName, null);
-    }
-    private Algorithms(String jwtName, String javaName) {
-        this.jwtName = jwtName;
-        this.javaName = javaName;
-    }
-
-    public String getJwtName() {
-        return jwtName;
-    }
-
-    public String getJavaName() {
-        return javaName == null ? name() : javaName;
-    }
-
-    public static String toJwtName(String javaName) {    
-        return JAVA_TO_JWT_NAMES.get(javaName);
-    }
-    public static String toJavaName(String jwtName) {    
-        return JWT_TO_JAVA_NAMES.get(jwtName);
-    }
-    
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
index 8470bbd..c6ffedd 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwt/JwtHeaders.java
@@ -34,7 +34,7 @@ public class JwtHeaders extends AbstractJwtObject {
         init(algorithm);
     }
     
-    public JwtHeaders(Algorithms algo) {
+    public JwtHeaders(Algorithm algo) {
         init(algo.getJwtName());
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactReaderWriterTest.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactReaderWriterTest.java
index 66ff518..f9673a2 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactReaderWriterTest.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jwe/JweCompactReaderWriterTest.java
@@ -26,7 +26,7 @@ import javax.crypto.Cipher;
 import javax.crypto.SecretKey;
 
 import org.apache.cxf.rs.security.oauth2.jws.JwsCompactReaderWriterTest;
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.utils.crypto.CryptoUtils;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 
@@ -68,7 +68,7 @@ public class JweCompactReaderWriterTest extends Assert {
         if (!IGNORE_TESTS) {    
             try {
                 // Java 8 apparently has it
-                Cipher.getInstance(Algorithms.A256GCM_ALGO_JAVA);
+                Cipher.getInstance(Algorithm.A256GCM_ALGO_JAVA);
             } catch (Throwable t) {
                 // Oracle Java 7
                 Security.addProvider(new BouncyCastleProvider());    
@@ -105,7 +105,7 @@ public class JweCompactReaderWriterTest extends Assert {
     
     private String encryptContent(String content) throws Exception {
         RSAPrivateKey privateKey = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
-        SecretKey key = CryptoUtils.createSecretKeySpec(CONTENT_ENCRYPTION_KEY, Algorithms.A256GCM_ALGO.getJavaName());
+        SecretKey key = CryptoUtils.createSecretKeySpec(CONTENT_ENCRYPTION_KEY, Algorithm.A256GCM_ALGO.getJavaName());
         RSAJweEncryptor encryptor = new RSAJweEncryptor(privateKey, key, INIT_VECTOR);
         return encryptor.getJweContent(content);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/e9ac42b6/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
index 1385d64..b356835 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
+++ b/rt/rs/security/oauth-parent/oauth2-jwt/src/test/java/org/apache/cxf/rs/security/oauth2/jws/JwsCompactReaderWriterTest.java
@@ -25,7 +25,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cxf.rs.security.oauth2.jwt.Algorithms;
+import org.apache.cxf.rs.security.oauth2.jwt.Algorithm;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtClaims;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtConstants;
 import org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders;
@@ -84,7 +84,7 @@ public class JwsCompactReaderWriterTest extends Assert {
      
     @Test
     public void testWriteJwsSignedByMacSpecExample() throws Exception {
-        JwtHeaders headers = new JwtHeaders(Algorithms.HmacSHA256.getJwtName());
+        JwtHeaders headers = new JwtHeaders(Algorithm.HmacSHA256.getJwtName());
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY));
         
@@ -121,7 +121,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         JwtToken token = jws.getJwtToken();
         JwtHeaders headers = token.getHeaders();
         assertEquals(JwtConstants.TYPE_JWT, headers.getType());
-        assertEquals(Algorithms.HmacSHA256.getJwtName(), headers.getAlgorithm());
+        assertEquals(Algorithm.HmacSHA256.getJwtName(), headers.getAlgorithm());
         validateSpecClaim(token.getClaims());
     }
     
@@ -144,7 +144,7 @@ public class JwsCompactReaderWriterTest extends Assert {
     }
     
     private void doTestWriteJwsWithJwkSignedByMac(Object jsonWebKey) throws Exception {
-        JwtHeaders headers = new JwtHeaders(Algorithms.HmacSHA256.getJwtName());
+        JwtHeaders headers = new JwtHeaders(Algorithm.HmacSHA256.getJwtName());
         
         headers.setHeader(JwtConstants.HEADER_JSON_WEB_KEY, jsonWebKey);
         
@@ -167,7 +167,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         JwtToken token = jws.getJwtToken();
         JwtHeaders headers = token.getHeaders();
         assertEquals(JwtConstants.TYPE_JWT, headers.getType());
-        assertEquals(Algorithms.HmacSHA256.getJwtName(), headers.getAlgorithm());
+        assertEquals(Algorithm.HmacSHA256.getJwtName(), headers.getAlgorithm());
         
         JsonWebKey key = headers.getJsonWebKey();
         assertEquals(JsonWebKey.KEY_TYPE_OCTET, key.getKeyType());
@@ -188,7 +188,7 @@ public class JwsCompactReaderWriterTest extends Assert {
     @Test
     public void testWriteReadJwsSignedByPrivateKey() throws Exception {
         JwtHeaders headers = new JwtHeaders();
-        headers.setAlgorithm(Algorithms.SHA256withRSA.getJwtName());
+        headers.setAlgorithm(Algorithm.SHA256withRSA.getJwtName());
         JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
         PrivateKey key = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
         jws.signWith(new PrivateKeyJwsSignatureProvider(key));
@@ -203,7 +203,7 @@ public class JwsCompactReaderWriterTest extends Assert {
         assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key)));
         JwtToken token = jws.getJwtToken();
         JwtHeaders headers = token.getHeaders();
-        assertEquals(Algorithms.SHA256withRSA.getJwtName(), headers.getAlgorithm());
+        assertEquals(Algorithm.SHA256withRSA.getJwtName(), headers.getAlgorithm());
         validateSpecClaim(token.getClaims());
     }
     


Mime
View raw message