[Jboss-cvs] JBossAS SVN: r56898 - trunk/testsuite/src/main/org/jboss/test/security/service

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 15 15:26:57 EDT 2006


Author: anil.saldhana at jboss.com
Date: 2006-09-15 15:26:56 -0400 (Fri, 15 Sep 2006)
New Revision: 56898

Modified:
   trunk/testsuite/src/main/org/jboss/test/security/service/HttpsClient.java
Log:
remove sun protocol handler specifics

Modified: trunk/testsuite/src/main/org/jboss/test/security/service/HttpsClient.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/security/service/HttpsClient.java	2006-09-15 19:25:20 UTC (rev 56897)
+++ trunk/testsuite/src/main/org/jboss/test/security/service/HttpsClient.java	2006-09-15 19:26:56 UTC (rev 56898)
@@ -30,17 +30,17 @@
 import java.net.URL;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
+import java.security.Provider; 
 import java.security.Security;
 import java.util.StringTokenizer;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import javax.net.ssl.SSLSocketFactory;
 
-import com.sun.net.ssl.internal.ssl.Provider;
-
 import org.jboss.logging.Logger;
 import org.jboss.system.ServiceMBeanSupport;
 import org.jboss.invocation.http.interfaces.Util;
+import org.jboss.test.util.SecurityProviderUtil;
 
 /** A test mbean service that reads input from an https url passed in
  to its readURL method.
@@ -56,7 +56,7 @@
    // Attributes ----------------------------------------------------
    private boolean addedHttpsHandler;
    
-   private boolean addedSunJSSEProvider;
+   private boolean addedJSSEProvider;
 
    // Static --------------------------------------------------------
 
@@ -113,7 +113,7 @@
    // Public --------------------------------------------------------
    protected void startService() throws Exception
    {
-      addedSunJSSEProvider = false;
+      addedJSSEProvider = false;
       try
       {
          new URL("https://www.https.test");
@@ -121,19 +121,23 @@
       catch(MalformedURLException e)
       {
          // Install the default JSSE security provider
-         log.debug("Adding com.sun.net.ssl.internal.ssl.Provider");
-         addedSunJSSEProvider = Security.addProvider(new Provider()) != -1;
-         if (addedSunJSSEProvider)
+         Provider provider = SecurityProviderUtil.getJSSEProvider();
+         log.debug("Adding " + provider.getName());
+         
+         addedJSSEProvider = Security.addProvider(provider) != -1;
+         if (addedJSSEProvider)
          {
-            log.debug("Added com.sun.net.ssl.internal.ssl.Provider");
-         }
+            log.debug("Added " + provider.getName());
+         } 
          
          addedHttpsHandler = false;
          // Install the JSSE https handler if it has not already been added
+         String protocolHandler = SecurityProviderUtil.getProtocolHandlerName();
+
          String handlers = System.getProperty("java.protocol.handler.pkgs");
-         if( handlers == null || handlers.indexOf("com.sun.net.ssl.internal.www.protocol") < 0 )
+         if( handlers == null || handlers.indexOf(protocolHandler ) < 0 )
          {
-            handlers += "|com.sun.net.ssl.internal.www.protocol";
+            handlers += "|" + protocolHandler;
             log.debug("Adding https handler to java.protocol.handler.pkgs");
             System.setProperty("java.protocol.handler.pkgs", handlers);
             addedHttpsHandler = true;
@@ -167,22 +171,25 @@
    }
    protected void stopService() throws Exception
    {
-      if (addedSunJSSEProvider)
-      {
-         String name = (new Provider()).getName();
-         log.debug("Removing com.sun.net.ssl.internal.ssl.Provider");
+      if (addedJSSEProvider)
+      { 
+         Provider provider = SecurityProviderUtil.getJSSEProvider();
+         String name = provider.getName();
+         log.debug("Removing " + name);
          Security.removeProvider(name);
-      }
+       }
+
       if( addedHttpsHandler == true )
       {
          log.debug("Removing https handler from java.protocol.handler.pkgs");
+         String protocolHandler = SecurityProviderUtil.getProtocolHandlerName(); 
          String handlers = System.getProperty("java.protocol.handler.pkgs");
          StringTokenizer tokenizer = new StringTokenizer(handlers, "|");
          StringBuffer buffer = new StringBuffer();
          while( tokenizer.hasMoreTokens() )
          {
             String handler = tokenizer.nextToken();
-            if( handler.equals("com.sun.net.ssl.internal.www.protocol") == false )
+            if( handler.equals(protocolHandler) == false )
             {
                buffer.append('|');
                buffer.append(handler);




More information about the jboss-cvs-commits mailing list