[jsslutils commit] r72 - Added log statements and split SSLImplementation.

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 26, 2009, 11:50:51 AM3/26/09
to jsslut...@googlegroups.com
Author: Bruno.H...@manchester.ac.uk
Date: Thu Mar 26 08:50:19 2009
New Revision: 72

Added:

trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsFactory.java
- copied, changed from r71,
/trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java
Modified:

trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java

trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsJSSESocketFactory.java

Log:
Added log statements and split SSLImplementation.

Copied:
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsFactory.java
(from r71,
/trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java)
==============================================================================
---
/trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java
(original)
+++
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsFactory.java
Thu Mar 26 08:50:19 2009
@@ -17,27 +17,17 @@
package org.jsslutils.extra.grizzly;

import com.sun.grizzly.util.net.ServerSocketFactory;
-import com.sun.grizzly.util.net.jsse.JSSEImplementation;
+import com.sun.grizzly.util.net.jsse.JSSE14Factory;

/**
- * This is an SSLImplementation extending the default JSSEImplementation
to use
- * <a href="http://www.jsslutils.org">jSSLutils</a>.
+ * This is an SSLImplementation extending the default JSSE14Factory to use
<a
+ * href="http://www.jsslutils.org">jSSLutils</a>.
*
* @author Bruno Harbulot
*/
-public class JSSLutilsImplementation extends JSSEImplementation {
+public class JSSLutilsFactory extends JSSE14Factory {
@Override
- public String getImplementationName() {
- return "jsslutils";
- }
-
- public JSSLutilsImplementation() throws ClassNotFoundException {
-
- }
-
- @Override
- public ServerSocketFactory getServerSocketFactory() {
+ public ServerSocketFactory getSocketFactory() {
return new JSSLutilsJSSESocketFactory();
}
-
}

Modified:
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java
==============================================================================
---
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java
(original)
+++
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsImplementation.java
Thu Mar 26 08:50:19 2009
@@ -16,8 +16,16 @@
*/
package org.jsslutils.extra.grizzly;

+import java.net.Socket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.net.ssl.SSLEngine;
+
+import com.sun.grizzly.util.LoggerUtils;
+import com.sun.grizzly.util.net.SSLImplementation;
+import com.sun.grizzly.util.net.SSLSupport;
import com.sun.grizzly.util.net.ServerSocketFactory;
-import com.sun.grizzly.util.net.jsse.JSSEImplementation;

/**
* This is an SSLImplementation extending the default JSSEImplementation
to use
@@ -25,19 +33,44 @@
*
* @author Bruno Harbulot
*/
-public class JSSLutilsImplementation extends JSSEImplementation {
+public class JSSLutilsImplementation extends SSLImplementation {
+ private final static Logger logger = LoggerUtils.getLogger();
+
+ private final JSSLutilsFactory factory;
+
+ public JSSLutilsImplementation() {
+ this.factory = new JSSLutilsFactory();
+ }
+
@Override
public String getImplementationName() {
return "jsslutils";
}

- public JSSLutilsImplementation() throws ClassNotFoundException {
-
+ @Override
+ public ServerSocketFactory getServerSocketFactory() {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsImplementation.class.getName()
+ + "#getServerSocketFactory()");
+ }
+ return factory.getSocketFactory();
}

@Override
- public ServerSocketFactory getServerSocketFactory() {
- return new JSSLutilsJSSESocketFactory();
+ public SSLSupport getSSLSupport(Socket s) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsImplementation.class.getName()
+ + "#getSSLSupport()");
+ }
+ return factory.getSSLSupport(s);
}

+ @Override
+ public SSLSupport getSSLSupport(SSLEngine sslEngine) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsImplementation.class.getName()
+ + "#getSSLSupport()");
+ }
+ return factory.getSSLSupport(sslEngine);
+ }
}

Modified:
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsJSSESocketFactory.java
==============================================================================
---
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsJSSESocketFactory.java
(original)
+++
trunk/extra/grizzly/src/main/java/org/jsslutils/extra/grizzly/JSSLutilsJSSESocketFactory.java
Thu Mar 26 08:50:19 2009
@@ -25,6 +25,8 @@
import java.security.KeyStore;
import java.util.StringTokenizer;
import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
@@ -37,6 +39,7 @@
import org.jsslutils.sslcontext.trustmanagers.GsiWrappingTrustManager;
import
org.jsslutils.sslcontext.trustmanagers.TrustAllClientsWrappingTrustManager;

+import com.sun.grizzly.util.LoggerUtils;
import com.sun.grizzly.util.net.ServerSocketFactory;

/**
@@ -61,26 +64,32 @@
* @author Bruno Harbulot -- jSSLutils
*/
public class JSSLutilsJSSESocketFactory extends ServerSocketFactory {
+ private final static Logger logger = LoggerUtils.getLogger();
+
public final static String SYSTEM_PROPERTIES_PREFIX
= "org.jsslutils.extra.grizzly";

static String defaultProtocol = "TLS";

- protected boolean initialized;
- protected String clientAuth = "false";
+ protected volatile boolean initialized;
+ protected final String defaultClientAuth = "false";
protected SSLServerSocketFactory sslProxy = null;
protected String[] enabledCiphers;

/**
* Flag to state that we require client authentication.
*/
- protected boolean requireClientAuth = false;
+ protected volatile boolean requireClientAuth = false;

/**
* Flag to state that we would like client authentication.
*/
- protected boolean wantClientAuth = false;
+ protected volatile boolean wantClientAuth = false;

public JSSLutilsJSSESocketFactory() {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsJSSESocketFactory.class.getName()
+ + " instantiated.");
+ }
}

@Override
@@ -118,6 +127,11 @@
try {
asock = (SSLSocket) socket.accept();
configureClientAuth(asock);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsJSSESocketFactory.class.getName()
+ + "#acceptSocket(): " + asock.getWantClientAuth() + "/"
+ + asock.getNeedClientAuth());
+ }
} catch (SSLException e) {
throw new SocketException("SSL handshake error" + e.toString());
}
@@ -139,7 +153,7 @@
* @return Array of SSL cipher suites to be enabled, or null if none of
the
* requested ciphers are supported
*/
- protected String[] getEnabledCiphers(String requestedCiphers,
+ protected synchronized String[] getEnabledCiphers(String requestedCiphers,
String[] supportedCiphers) {

String[] enabledCiphers = null;
@@ -335,9 +349,11 @@
String requestedCiphers = System.getProperty(
SYSTEM_PROPERTIES_PREFIX + ".ciphers", (String) attributes
.get("ciphers"));
- enabledCiphers = getEnabledCiphers(requestedCiphers, sslProxy
- .getSupportedCipherSuites());

+ synchronized (this) {
+ enabledCiphers = getEnabledCiphers(requestedCiphers, sslProxy
+ .getSupportedCipherSuites());
+ }
} catch (Exception e) {
if (e instanceof IOException)
throw (IOException) e;
@@ -446,11 +462,17 @@
* the SSLServerSocket
*/
protected void configureClientAuth(SSLServerSocket socket) {
+
if (wantClientAuth) {
socket.setWantClientAuth(wantClientAuth);
} else {
socket.setNeedClientAuth(requireClientAuth);
}
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsJSSESocketFactory.class.getName()
+ + "#configureClientAuth(): " + socket.getWantClientAuth()
+ + "/" + socket.getNeedClientAuth());
+ }
}

/**
@@ -462,11 +484,17 @@
* the SSLSocket
*/
protected void configureClientAuth(SSLSocket socket) {
+
if (wantClientAuth) {
socket.setWantClientAuth(wantClientAuth);
} else {
socket.setNeedClientAuth(requireClientAuth);
}
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsJSSESocketFactory.class.getName()
+ + "#configureClientAuth(): " + socket.getWantClientAuth()
+ + "/" + socket.getNeedClientAuth());
+ }
}

/**
@@ -474,11 +502,16 @@
* protocol versions, and need for client authentication
*/
private void initServerSocket(ServerSocket ssocket) {
-
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(JSSLutilsJSSESocketFactory.class.getName()
+ + "#initServerSocket(): ");
+ }
SSLServerSocket socket = (SSLServerSocket) ssocket;

- if (enabledCiphers != null) {
- socket.setEnabledCipherSuites(enabledCiphers);
+ synchronized (this) {
+ if (enabledCiphers != null) {
+ socket.setEnabledCipherSuites(enabledCiphers);
+ }
}

String requestedProtocols = (String) attributes.get("protocols");

Reply all
Reply to author
Forward
0 new messages