Index: modules/rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties =================================================================== --- modules/rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties (revision 470740) +++ modules/rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties (working copy) @@ -166,6 +166,7 @@ rmi.93=Object was not registered or already deactivated. rmi.94=Could not load class {0}(access to loader for codebase "{1}" denied). rmi.95=Connection to [{0}:{1}] timed out +rmi.96=Error in socket creation # log messages rmi.log.00=ActivationID.activate: activator = {0} Index: modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java =================================================================== --- modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java (revision 470740) +++ modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java (working copy) @@ -68,7 +68,8 @@ } finally { try { soc.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } } @@ -88,7 +89,7 @@ public ServerSocket createServerSocket(int port) throws IOException { SSLServerSocket soc; - soc = (SSLServerSocket) factory.createServerSocket(); + soc = (SSLServerSocket) factory.createServerSocket(port); if (enabledProtocols != null) { soc.setEnabledProtocols(enabledProtocols); } @@ -102,13 +103,14 @@ public boolean equals(Object obj) { if (obj instanceof SslRMIServerSocketFactory - || Arrays.equals(enabledCipherSuites, + && Arrays.equals(enabledCipherSuites, ((SslRMIServerSocketFactory) obj) - .getEnabledCipherSuites()) - || Arrays - .equals(enabledProtocols, - ((SslRMIServerSocketFactory) obj) - .getEnabledProtocols())) { + .getEnabledCipherSuites()) + && Arrays.equals(enabledProtocols, + ((SslRMIServerSocketFactory) obj) + .getEnabledProtocols()) + && (this.needClientAuth == ((SslRMIServerSocketFactory) obj) + .getNeedClientAuth())) { return true; } return false; @@ -116,7 +118,7 @@ public int hashCode() { - String hashSting = "javax.rmi.ssl.SslRMIServerSocketFactory"; + String hashSting = "javax.rmi.ssl.SslRMIServerSocketFactory"; //$NON-NLS-1$ if (enabledCipherSuites != null) { for (int i = 0; i < enabledCipherSuites.length; i++) { hashSting = hashSting + enabledCipherSuites[i]; Index: modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java =================================================================== --- modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java (revision 470740) +++ modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java (working copy) @@ -27,6 +27,8 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; +import org.apache.harmony.rmi.internal.nls.Messages; + public class SslRMIClientSocketFactory implements RMIClientSocketFactory, Serializable { @@ -34,12 +36,6 @@ private static SSLSocketFactory factory; - private static String enabledCipherSuites; - - private static String enabledProtocols; - - private static boolean isEnabledInitialized; - public SslRMIClientSocketFactory() { if (factory == null) { factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); @@ -49,25 +45,28 @@ public Socket createSocket(String host, int port) throws IOException { SSLSocket soc = (SSLSocket) factory.createSocket(host, port); - if (!isEnabledInitialized) { - isEnabledInitialized = true; - AccessController.doPrivileged(new java.security.PrivilegedAction() { - - public Object run() { - enabledCipherSuites = System - .getProperty("javax.rmi.ssl.client.enabledCipherSuites"); - enabledProtocols = System - .getProperty("javax.rmi.ssl.client.enabledProtocols"); - return null; + String[] enabled = + AccessController.doPrivileged(new java.security.PrivilegedAction() { + public String[] run() { + return new String[] { + System.getProperty("javax.rmi.ssl.client.enabledCipherSuites"), //$NON-NLS-1$ + System.getProperty("javax.rmi.ssl.client.enabledProtocols")}; //$NON-NLS-1$ } }); - } - if (enabledCipherSuites != null) { - soc.setEnabledCipherSuites(enabledCipherSuites.split(",")); - } + try { + if (enabled[0] != null) { //enabledCipherSuites + soc.setEnabledCipherSuites(enabled[0].split(",")); //$NON-NLS-1$ + } - if (enabledProtocols != null) { - soc.setEnabledProtocols(enabledProtocols.split(",")); + if (enabled[1]!= null) { //enabledProtocols + soc.setEnabledProtocols(enabled[1].split(",")); //$NON-NLS-1$ + } + } catch (IllegalArgumentException e) { + // rmi.96=Error in socket creation + IOException ioe = new IOException(Messages.getString("rmi.96")); //$NON-NLS-1$ + ioe.initCause(e); + soc.close(); + throw ioe; } return soc; @@ -78,7 +77,7 @@ } public int hashCode() { - return "javax.rmi.ssl.SslRMIClientSocketFactory".hashCode(); + return "javax.rmi.ssl.SslRMIClientSocketFactory".hashCode(); //$NON-NLS-1$ } }