You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2017/01/19 08:01:50 UTC

[04/16] cxf git commit: [CXF-7050]the default blocksize should be 256 when use the private key under java9

[CXF-7050]the default blocksize should be 256 when use the private key under java9


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

Branch: refs/heads/master
Commit: c3a1392d1656c41a9bbdb24698eb27fbc757628b
Parents: c2daeb5
Author: Freeman Fang <fr...@gmail.com>
Authored: Mon Sep 12 16:17:14 2016 +0800
Committer: Freeman Fang <fr...@gmail.com>
Committed: Mon Sep 12 16:17:14 2016 +0800

----------------------------------------------------------------------
 .../cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java  | 6 +++---
 .../java/org/apache/cxf/rt/security/crypto/CryptoUtils.java   | 7 ++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/c3a1392d/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java
index 907d446..8730d91 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/utils/crypto/CryptoUtilsTest.java
@@ -48,7 +48,6 @@ import org.apache.cxf.rt.security.crypto.KeyProperties;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class CryptoUtilsTest extends Assert {
@@ -131,8 +130,8 @@ public class CryptoUtilsTest extends Assert {
         // compare tokens
         compareAccessTokens(token, token2);
     }
-    
-    @Ignore
+   
+    @Test
     public void testBearerTokenJSONCertificate() throws Exception {
         if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
             return;
@@ -189,6 +188,7 @@ public class CryptoUtilsTest extends Assert {
         assertEquals("id", c2.getSubject().getId());
     }
     
+        
     @Test
     public void testCodeGrantJSON() throws Exception {
         Client c = new Client("client", "secret", true);

http://git-wip-us.apache.org/repos/asf/cxf/blob/c3a1392d/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
index df3b19c..664b140 100644
--- a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
+++ b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
@@ -520,7 +520,12 @@ public final class CryptoUtils {
                 result = c.doFinal(bytes);
             } else {
                 if (blockSize == -1) {
-                    blockSize = secretKey instanceof PublicKey ? 117 : 128;
+                    if (System.getProperty("java.version").startsWith("9")) {
+                        //the default block size is 256 when use private key under java9
+                        blockSize = secretKey instanceof PublicKey ? 117 : 256;
+                    } else {
+                        blockSize = secretKey instanceof PublicKey ? 117 : 128;
+                    }
                 }
                 boolean updateRequired = keyProps != null && keyProps.getAdditionalData() != null;
                 int offset = 0;