[jbossws-commits] JBossWS SVN: r4918 - in stack/native/branches/asoldano/trunk/src: test/java/org/jboss/test/ws/interop/nov2007/wsse and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Oct 29 10:15:56 EDT 2007


Author: alessio.soldano at jboss.com
Date: 2007-10-29 10:15:56 -0400 (Mon, 29 Oct 2007)
New Revision: 4918

Modified:
   stack/native/branches/asoldano/trunk/src/main/java/org/jboss/ws/extensions/security/EncryptionOperation.java
   stack/native/branches/asoldano/trunk/src/test/java/org/jboss/test/ws/interop/nov2007/wsse/EncryptTestCase.java
Log:
Unlimited Strength Cryptography Extension check


Modified: stack/native/branches/asoldano/trunk/src/main/java/org/jboss/ws/extensions/security/EncryptionOperation.java
===================================================================
--- stack/native/branches/asoldano/trunk/src/main/java/org/jboss/ws/extensions/security/EncryptionOperation.java	2007-10-29 14:13:24 UTC (rev 4917)
+++ stack/native/branches/asoldano/trunk/src/main/java/org/jboss/ws/extensions/security/EncryptionOperation.java	2007-10-29 14:15:56 UTC (rev 4918)
@@ -21,11 +21,13 @@
 */
 package org.jboss.ws.extensions.security;
 
+import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.security.cert.X509Certificate;
 import java.util.HashMap;
 import java.util.List;
 
+import javax.crypto.Cipher;
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
 import javax.xml.namespace.QName;
@@ -170,4 +172,34 @@
       EncryptedKey eKey = new EncryptedKey(message, secretKey, token, list);
       header.addSecurityProcess(eKey);
    }
+   
+   
+   public static boolean probeUnlimitedCrypto() throws WSSecurityException
+   {
+      try
+      {
+         //Check AES-256
+         KeyGenerator kgen = KeyGenerator.getInstance("AES");
+         kgen.init(256);
+         SecretKey key = kgen.generateKey();
+         Cipher c = Cipher.getInstance("AES");
+         c.init(Cipher.ENCRYPT_MODE, key);
+         
+         //Check Blowfish
+         kgen = KeyGenerator.getInstance("Blowfish");
+         key = kgen.generateKey();
+         c = Cipher.getInstance("Blowfish");
+         c.init(Cipher.ENCRYPT_MODE, key);
+         
+         return true;
+      }
+      catch (InvalidKeyException e)
+      {
+         return false;
+      }
+      catch (Exception e)
+      {
+         throw new WSSecurityException("Error probing cryptographic permissions", e);
+      }
+   }
 }

Modified: stack/native/branches/asoldano/trunk/src/test/java/org/jboss/test/ws/interop/nov2007/wsse/EncryptTestCase.java
===================================================================
--- stack/native/branches/asoldano/trunk/src/test/java/org/jboss/test/ws/interop/nov2007/wsse/EncryptTestCase.java	2007-10-29 14:13:24 UTC (rev 4917)
+++ stack/native/branches/asoldano/trunk/src/test/java/org/jboss/test/ws/interop/nov2007/wsse/EncryptTestCase.java	2007-10-29 14:15:56 UTC (rev 4918)
@@ -26,6 +26,7 @@
 import junit.framework.Test;
 
 import org.jboss.ws.core.StubExt;
+import org.jboss.ws.extensions.security.EncryptionOperation;
 import org.jboss.wsf.test.JBossWSTestSetup;
 
 /**
@@ -69,6 +70,12 @@
 
    public void testScenario() throws Exception
    {
+      if (!EncryptionOperation.probeUnlimitedCrypto())
+      {
+         System.out.println("Please install the Unlimited Strength Java(TM) Cryptography Extension to run this test; " +
+         		"please note that your country might have limits on allowed crypto strength.\n Test skipped.");
+         return;
+      }
       String text = "Hello!";
       String result = port.ping(text);
       assertNotNull(result);




More information about the jbossws-commits mailing list