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] Minor update
Date Wed, 23 Jul 2014 08:23:08 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 27987cc37 -> 9e663d12d


[CXF-5311] Minor update


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

Branch: refs/heads/master
Commit: 9e663d12d2b240c6d172a96e3043de65fd111404
Parents: 27987cc
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 23 11:22:46 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 23 11:22:46 2014 +0300

----------------------------------------------------------------------
 .../security/oauth2/utils/crypto/CryptoUtils.java  | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9e663d12/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
index 69edbfc..1e5a84f 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtils.java
@@ -301,10 +301,7 @@ public final class CryptoUtils {
     }
     public static ECPrivateKey getECPrivateKey(byte[] privateKey) {
         try {
-            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
-            ECGenParameterSpec kpgparams = new ECGenParameterSpec("secp256r1");
-            kpg.initialize(kpgparams);
-            ECParameterSpec params = ((ECPublicKey) kpg.generateKeyPair().getPublic()).getParams();
+            ECParameterSpec params = getECParameterSpec();
 
             ECPrivateKeySpec keySpec = new ECPrivateKeySpec(
                                            new BigInteger(1, privateKey), params);
@@ -315,6 +312,13 @@ public final class CryptoUtils {
             throw new SecurityException(ex);
         }    
     }
+    private static ECParameterSpec getECParameterSpec() throws Exception {
+        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
+        ECGenParameterSpec kpgparams = new ECGenParameterSpec("secp256r1");
+        kpg.initialize(kpgparams);
+        return ((ECPublicKey) kpg.generateKeyPair().getPublic()).getParams();
+    }
+    
     public static ECPublicKey getECPublicKey(String encodedXPoint, String encodedYPoint)
{
         try {
             return getECPublicKey(Base64UrlUtility.decode(encodedXPoint),
@@ -325,10 +329,7 @@ public final class CryptoUtils {
     }
     public static ECPublicKey getECPublicKey(byte[] xPoint, byte[] yPoint) {
         try {
-            KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
-            ECGenParameterSpec kpgparams = new ECGenParameterSpec("secp256r1");
-            kpg.initialize(kpgparams);
-            ECParameterSpec params = ((ECPublicKey) kpg.generateKeyPair().getPublic()).getParams();
+            ECParameterSpec params = getECParameterSpec();
 
             ECPoint ecPoint = new ECPoint(new BigInteger(1, xPoint),
                                           new BigInteger(1, yPoint));


Mime
View raw message