[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/sslbisocket ...
Ron Sigal
ron_sigal at yahoo.com
Wed Dec 27 00:58:39 EST 2006
User: rsigal
Date: 06/12/27 00:58:39
Added: src/main/org/jboss/remoting/transport/sslbisocket
TransportServerFactory.java
SSLBisocketClientInvoker.java
SSLBisocketServerInvoker.java
TransportClientFactory.java
Log:
JBREM-650: Added sslbisocket transport.
Revision Changes Path
1.2 +24 -0 JBossRemoting/src/main/org/jboss/remoting/transport/sslbisocket/TransportServerFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransportServerFactory.java
===================================================================
RCS file: TransportServerFactory.java
diff -N TransportServerFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TransportServerFactory.java 27 Dec 2006 05:58:39 -0000 1.2
@@ -0,0 +1,24 @@
+package org.jboss.remoting.transport.sslbisocket;
+
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.transport.ServerFactory;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class TransportServerFactory implements ServerFactory
+{
+ public ServerInvoker createServerInvoker(InvokerLocator locator, Map config)
+ {
+ return new SSLBisocketServerInvoker(locator, config);
+ }
+
+ public boolean supportsSSL()
+ {
+ return true;
+ }
+}
1.2 +137 -0 JBossRemoting/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SSLBisocketClientInvoker.java
===================================================================
RCS file: SSLBisocketClientInvoker.java
diff -N SSLBisocketClientInvoker.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SSLBisocketClientInvoker.java 27 Dec 2006 05:58:39 -0000 1.2
@@ -0,0 +1,137 @@
+/*
+* 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.remoting.transport.sslbisocket;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.Map;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.SSLSocket;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
+import org.jboss.remoting.util.socket.HandshakeRepeater;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ * * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class SSLBisocketClientInvoker extends BisocketClientInvoker
+{
+ private static final Logger log = Logger.getLogger(SSLBisocketClientInvoker.class);
+
+ public SSLBisocketClientInvoker(InvokerLocator locator) throws IOException
+ {
+ super(locator);
+ try
+ {
+ setup();
+ }
+ catch (Exception ex)
+ {
+ log.error("Error setting up ssl bisocket client invoker.", ex);
+ throw new RuntimeException(ex.getMessage());
+ }
+ }
+
+ public SSLBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException
+ {
+ super(locator, configuration);
+ try
+ {
+ setup();
+ }
+ catch (Exception ex)
+ {
+ log.error("Error setting up ssl bisocket client invoker.", ex);
+ throw new RuntimeException(ex.getMessage());
+ }
+ }
+
+ protected SocketFactory createSocketFactory(Map configuration)
+ {
+ SocketFactory sf = super.createSocketFactory(configuration);
+
+ if (sf != null)
+ {
+ return sf;
+ }
+
+ try
+ {
+ SSLSocketBuilder server = new SSLSocketBuilder(configuration);
+ sf = server.createSSLSocketFactory();
+ }
+ catch (Exception e)
+ {
+ log.error("Error creating SSL Socket Factory for client invoker.", e);
+ }
+
+ return sf;
+ }
+
+
+
+ protected Socket createSocket(String address, int port) throws IOException
+ {
+ log.info("listenerId: " + listenerId);
+ if (listenerId != null)
+ return super.createSocket(address, port);
+
+ SocketFactory sf = getSocketFactory();
+
+ if (sf == null)
+ sf = createSocketFactory(configuration);
+
+ Socket s = sf.createSocket(address, port);
+log.info("socket factory: " + sf);
+log.info("socket: " + s);
+ if (s instanceof SSLSocket)
+ {
+ // need to check for handshake listener and add them if there is one
+ Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER);
+ if (obj != null && obj instanceof HandshakeCompletedListener)
+ {
+ SSLSocket sslSocket = (SSLSocket) s;
+ HandshakeCompletedListener listener = (HandshakeCompletedListener) obj;
+ establishHandshake(sslSocket, listener);
+ }
+ }
+
+ return s;
+ }
+
+ private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener)
+ throws IOException
+ {
+ HandshakeRepeater repeater = new HandshakeRepeater(listener);
+ sslSocket.addHandshakeCompletedListener(repeater);
+ sslSocket.getSession();
+ repeater.waitForHandshake();
+ }
+}
\ No newline at end of file
1.2 +107 -0 JBossRemoting/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SSLBisocketServerInvoker.java
===================================================================
RCS file: SSLBisocketServerInvoker.java
diff -N SSLBisocketServerInvoker.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SSLBisocketServerInvoker.java 27 Dec 2006 05:58:39 -0000 1.2
@@ -0,0 +1,107 @@
+/*
+* 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.remoting.transport.sslbisocket;
+
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvokerMBean;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLServerSocketFactory;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class SSLBisocketServerInvoker
+ extends BisocketServerInvoker
+ implements SSLSocketServerInvokerMBean
+{
+
+ public SSLBisocketServerInvoker(InvokerLocator locator)
+ {
+ super(locator);
+ }
+
+ public SSLBisocketServerInvoker(InvokerLocator locator, Map configuration)
+ {
+ super(locator, configuration);
+ }
+
+ protected ServerSocketFactory getDefaultServerSocketFactory()
+ {
+ return SSLServerSocketFactory.getDefault();
+ }
+
+ protected ServerSocketFactory createServerSocketFactory() throws IOException
+ {
+ if (isCallbackServer)
+ return null;
+
+ return super.createServerSocketFactory();
+ }
+
+ protected void setup() throws Exception
+ {
+ super.setup();
+ if (isCallbackServer)
+ {
+ socketFactory = createSocketFactory(configuration);
+ }
+ }
+
+ protected SocketFactory createSocketFactory(Map configuration)
+ {
+ SocketFactory sf = super.createSocketFactory(configuration);
+
+ if (sf != null)
+ {
+ return sf;
+ }
+
+ try
+ {
+ SSLSocketBuilder server = new SSLSocketBuilder(configuration);
+ sf = server.createSSLSocketFactory();
+ }
+ catch (Exception e)
+ {
+ log.error("Error creating SSL Socket Factory for client invoker.", e);
+ }
+
+ return sf;
+ }
+
+ protected ServerSocket createServerSocket(int serverBindPort, int backlog, InetAddress bindAddress) throws IOException
+ {
+ ServerSocket svrSocket = getServerSocketFactory().createServerSocket(serverBindPort, backlog, bindAddress);
+ return svrSocket;
+ }
+
+}
\ No newline at end of file
1.2 +46 -0 JBossRemoting/src/main/org/jboss/remoting/transport/sslbisocket/TransportClientFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransportClientFactory.java
===================================================================
RCS file: TransportClientFactory.java
diff -N TransportClientFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TransportClientFactory.java 27 Dec 2006 05:58:39 -0000 1.2
@@ -0,0 +1,46 @@
+/*
+* 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.remoting.transport.sslbisocket;
+
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.ClientFactory;
+import org.jboss.remoting.transport.ClientInvoker;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
+ * @author <a href="mailto:ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class TransportClientFactory implements ClientFactory
+{
+ public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException
+ {
+ return new SSLBisocketClientInvoker(locator, config);
+ }
+
+ public boolean supportsSSL()
+ {
+ return true;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list