[jboss-cvs] JBoss Messaging SVN: r3814 - in trunk: src/main/org/jboss/messaging/core/remoting/impl/ssl and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 27 08:21:59 EST 2008


Author: jmesnil
Date: 2008-02-27 08:21:59 -0500 (Wed, 27 Feb 2008)
New Revision: 3814

Removed:
   trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSL.java
   trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSLTest.java
Modified:
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/ssl/SSLSupport.java
   trunk/tests/src/org/jboss/test/messaging/jms/SerializedClientSupport.java
Log:
* rewrote SSL tests using JBM 2 core API (instead of JMS)

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -145,6 +145,13 @@
          return false;
       }
 
+      CloseFuture closeFuture = session.close().awaitUninterruptibly();
+      boolean closed = closeFuture.isClosed();
+      
+      blockingScheduler.shutdown();
+      connector.removeListener(ioListener);
+      connector.dispose();
+
       SslFilter sslFilter = (SslFilter) session.getFilterChain().get("ssl");
       // FIXME without this hack, exceptions are thrown:
       // "Unexpected exception from SSLEngine.closeInbound()." -> because the ssl session is not stopped
@@ -160,13 +167,7 @@
             // ignore
          }
       }
-      CloseFuture closeFuture = session.close().awaitUninterruptibly();
-      boolean closed = closeFuture.isClosed();
       
-      connector.removeListener(ioListener);
-      connector.dispose();
-      blockingScheduler.shutdown();
-
       connector = null;
       blockingScheduler = null;
       session = null;

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -57,7 +57,7 @@
    public void exceptionCaught(IoSession session, Throwable cause)
          throws Exception
    {
-      log.error("caught exception " + cause + " for session " + session);
+      log.error("caught exception " + cause + " for session " + session, cause);
       
       if (failureNotifier != null)
       {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/ssl/SSLSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/ssl/SSLSupport.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/ssl/SSLSupport.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -56,11 +56,13 @@
       return sslContext;
    }
 
-   public static SSLContext createClientContext() throws Exception
+   public static SSLContext createClientContext(String keystorePath,
+         String keystorePassword) throws Exception
    {
       SSLContext context = SSLContext.getInstance("TLS");
-      TrustManager[] trustManagers = loadTrustManager(true, null, null);
-      context.init(null, trustManagers, new SecureRandom());
+      KeyManager[] keyManagers = loadKeyManagers(keystorePath, keystorePassword);
+      TrustManager[] trustManagers = loadTrustManager(true,  null, null);
+      context.init(keyManagers, trustManagers, new SecureRandom());
       return context;
    }
 
@@ -70,7 +72,7 @@
    {
       if (client)
       {
-         return createClientContext();
+         return createClientContext(keystorePath, keystorePassword);
       } else
       {
          return createServerContext(keystorePath, keystorePassword,

Modified: trunk/tests/src/org/jboss/test/messaging/jms/SerializedClientSupport.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SerializedClientSupport.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SerializedClientSupport.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -6,8 +6,12 @@
  */
 package org.jboss.test.messaging.jms;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.ObjectOutputStream;
 
 import javax.jms.ConnectionFactory;
@@ -18,9 +22,9 @@
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
+ * 
  * @version <tt>$Revision$</tt>
- *
+ * 
  */
 public class SerializedClientSupport
 {
@@ -32,7 +36,8 @@
 
    // Static --------------------------------------------------------
 
-   public static Process spawnVM(String className, String[] args) throws Exception
+   public static Process spawnVM(String className, String... args)
+         throws Exception
    {
       StringBuffer sb = new StringBuffer();
 
@@ -43,15 +48,13 @@
       if (System.getProperty("os.name").equals("Linux"))
       {
          sb.append("-cp").append(" ").append(classPath).append(" ");
-      }
-      else
+      } else
       {
          sb.append("-cp").append(" \"").append(classPath).append("\" ");
       }
 
       sb.append(className).append(' ');
 
-      // the first argument
       for (int i = 0; i < args.length; i++)
       {
          sb.append(args[i]).append(' ');
@@ -65,10 +68,15 @@
 
       log.trace("process: " + process);
 
+      ProcessLogger outputLogger = new ProcessLogger(process.getInputStream(),
+            className);
+      outputLogger.start();
+
       return process;
    }
 
-   public static File writeToFile(String fileName, ConnectionFactory cf, Queue queue) throws Exception
+   public static File writeToFile(String fileName, ConnectionFactory cf,
+         Queue queue) throws Exception
    {
       String moduleOutput = System.getProperty("java.io.tmpdir");
       if (moduleOutput == null)
@@ -84,7 +92,8 @@
 
       File file = new File(dir, fileName);
 
-      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
+      ObjectOutputStream oos = new ObjectOutputStream(
+            new FileOutputStream(file));
       oos.writeObject(cf);
       oos.writeObject(queue);
       oos.flush();
@@ -92,7 +101,7 @@
 
       return file;
    }
-   
+
    // Constructors --------------------------------------------------
 
    // Public --------------------------------------------------------
@@ -104,4 +113,36 @@
    // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------
+
+   /**
+    * Redirect the input stream to a logger (as debug logs)
+    */
+   static class ProcessLogger extends Thread
+   {
+      InputStream is;
+      Logger processLogger;
+
+      ProcessLogger(InputStream is, String className)
+            throws ClassNotFoundException
+      {
+         this.is = is;
+         this.processLogger = Logger.getLogger(Class.forName(className));
+         setDaemon(true);
+      }
+
+      public void run()
+      {
+         try
+         {
+            InputStreamReader isr = new InputStreamReader(is);
+            BufferedReader br = new BufferedReader(isr);
+            String line = null;
+            while ((line = br.readLine()) != null)
+               processLogger.debug(line);
+         } catch (IOException ioe)
+         {
+            ioe.printStackTrace();
+         }
+      }
+   }
 }

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSL.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSL.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSL.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -1,88 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.messaging.jms.ssl;
-
-import java.io.FileInputStream;
-import java.io.ObjectInputStream;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-
-/**
- * This client will open a connection, receive a message and crash.
- * 
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class ClientOverSSL
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   // Static ---------------------------------------------------------------------------------------
-
-   public static void main(String[] args) throws Exception
-   {
-      String serializedFileName = args[0];
-
-      // we don't want to mess with JNDI, read the connection factory and the queue from their
-      // serialized format, from disk
-      ObjectInputStream ois =
-         new ObjectInputStream(new FileInputStream(serializedFileName));
-      ConnectionFactory cf =(ConnectionFactory)ois.readObject();
-      Queue queue = (Queue)ois.readObject();
-
-      ois.close();
-      
-      // create one connection which is used
-      Connection conn = cf.createConnection();
-      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-      MessageProducer prod = sess.createProducer(queue);
-      
-      prod.send(sess.createTextMessage(ClientOverSSLTest.MESSAGE_TEXT_FROM_CLIENT));
-      
-      conn.close();
-      
-      System.exit(0);
-   }
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   // Command implementation -----------------------------------------------------------------------
-
-   // Public ---------------------------------------------------------------------------------------
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSLTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSLTest.java	2008-02-27 12:48:22 UTC (rev 3813)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ssl/ClientOverSSLTest.java	2008-02-27 13:21:59 UTC (rev 3814)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.jms.ssl;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.RemotingService;
-import org.jboss.messaging.core.server.Configuration;
-import org.jboss.test.messaging.JBMServerTestCase;
-import org.jboss.test.messaging.jms.SerializedClientSupport;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision: 3716 $</tt>
- * 
- */
-public class ClientOverSSLTest extends JBMServerTestCase
-{
-   // Constants -----------------------------------------------------
-
-   public static final String SERIALIZED_CF_FILE_NAME = "ClientOverSSLTest_CFandQueue.ser";
-   public static final String MESSAGE_TEXT_FROM_SERVER = "ClientOverSSLTest from server";
-   public static final String MESSAGE_TEXT_FROM_CLIENT = "ClientOverSSLTest from client";
-
-   // Static --------------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(ClientOverSSLTest.class);
-
-   // Attributes ----------------------------------------------------
-
-   private File serialized;
-   private ConnectionFactory cf;
-   private Queue queue;
-
-   // Constructors --------------------------------------------------
-
-   public ClientOverSSLTest(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void testSSL() throws Exception
-   {
-      Connection conn = null;
-
-      try
-      {
-         // spawn a JVM that creates a JMS client, which waits to receive a test
-         // message
-         Process p = SerializedClientSupport.spawnVM(ClientOverSSL.class
-               .getName(), new String[] { serialized.getAbsolutePath() });
-
-         // send the message to the queue
-         conn = cf.createConnection();
-         conn.start();
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = sess.createProducer(queue);
-         MessageConsumer consumer = sess.createConsumer(queue);
-
-         TextMessage messageFromClient = (TextMessage) consumer.receive(5000);
-         assertEquals(MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getText());
-
-         log.info("waiting for the client VM to exit ...");
-         p.waitFor();
-
-         assertEquals(0, p.exitValue());
-
-      } finally
-      {
-         try
-         {
-            if (conn != null)
-               conn.close();
-         } catch (Throwable ignored)
-         {
-            log.warn("Exception ignored:" + ignored.toString(), ignored);
-         }
-      }
-   }
-
-   // Package protected ---------------------------------------------
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      System.setProperty(Configuration.REMOTING_ENABLE_SSL_SYSPROP_KEY, "true");
-
-      RemotingService remotingService = servers.get(0).getMessagingServer().getRemotingService();
-      remotingService.getRemotingConfiguration().setSSLEnabled(true);
-      remotingService.stop();
-      remotingService.start();
-      
-      ArrayList<String> bindings = new ArrayList<String>();
-      bindings.add("ConnectionFactoryOverSSL");
-      servers.get(0).deployConnectionFactory("ConnectionFactoryOverSSL", bindings);
-      createQueue("QueueOverSSL");
-
-      InitialContext ic = getInitialContext();
-      cf = (ConnectionFactory) ic.lookup("/ConnectionFactoryOverSSL");
-      queue = (Queue) ic.lookup("/queue/QueueOverSSL");
-
-      serialized = SerializedClientSupport.writeToFile(SERIALIZED_CF_FILE_NAME,
-            cf, queue);
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      removeAllMessages("QueueOverSSL", true);
-      servers.get(0).destroyQueue("QueueOverSSL", "/queue/QueueOverSSL");
-      servers.get(0).undeployConnectionFactory("ConnectionFactoryOverSSL");
-      
- 
-      if (serialized != null)
-      {
-         serialized.delete();
-      }
-
-      System.setProperty(Configuration.REMOTING_ENABLE_SSL_SYSPROP_KEY, "false");
-      RemotingService remotingService = servers.get(0).getMessagingServer().getRemotingService();
-      remotingService.getRemotingConfiguration().setSSLEnabled(false);
-      remotingService.stop();
-      remotingService.start();
-        
-      super.tearDown();
-   }
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}




More information about the jboss-cvs-commits mailing list