summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
commitc56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch)
tree5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a /java/src
parentFix Windows php build to restore nuget packages (diff)
downloadice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.bz2
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.xz
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.zip
Refactored SSL and iAP transports, support for running SSL on top
of TCP/iAP/Bluetooth.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/src/main/java/Ice/ConnectionI.java9
-rw-r--r--java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java171
-rw-r--r--java/src/Ice/src/main/java/IceInternal/EndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/EndpointI.java9
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IPEndpointI.java21
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IncomingBase.java11
-rw-r--r--java/src/Ice/src/main/java/IceInternal/Instance.java4
-rw-r--r--java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java38
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java41
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java48
-rw-r--r--java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java33
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSConnector.java6
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSEndpoint.java48
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java19
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java15
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSTransceiver.java14
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java19
-rw-r--r--java/src/Ice/src/main/java/IceMX/MetricsHelper.java43
-rw-r--r--java/src/Ice/src/main/java/IceSSL/AcceptorI.java112
-rw-r--r--java/src/Ice/src/main/java/IceSSL/ConnectorI.java61
-rw-r--r--java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java16
-rw-r--r--java/src/Ice/src/main/java/IceSSL/EndpointI.java326
-rw-r--r--java/src/Ice/src/main/java/IceSSL/Instance.java12
-rw-r--r--java/src/Ice/src/main/java/IceSSL/PluginI.java18
-rw-r--r--java/src/Ice/src/main/java/IceSSL/SSLEngine.java23
-rw-r--r--java/src/Ice/src/main/java/IceSSL/TransceiverI.java272
-rw-r--r--java/src/Ice/src/main/java/IceSSL/TrustManager.java9
-rw-r--r--java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java27
-rw-r--r--java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java4
-rw-r--r--java/src/IceBT/src/main/java/IceBT/EndpointI.java4
-rw-r--r--java/src/IceBT/src/main/java/IceBT/PluginI.java2
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java45
34 files changed, 601 insertions, 885 deletions
diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java
index 31efd7b40f1..76e42a41b99 100644
--- a/java/src/Ice/src/main/java/Ice/ConnectionI.java
+++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java
@@ -2709,9 +2709,12 @@ public final class ConnectionI extends IceInternal.EventHandler
{
_info = new ConnectionInfo();
}
- _info.connectionId = _endpoint.connectionId();
- _info.adapterName = _adapter != null ? _adapter.getName() : "";
- _info.incoming = _connector == null;
+ for(ConnectionInfo info = _info; info != null; info = info.underlying)
+ {
+ info.connectionId = _endpoint.connectionId();
+ info.adapterName = _adapter != null ? _adapter.getName() : "";
+ info.incoming = _connector == null;
+ }
return _info;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java b/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
index 14dd81f0d38..5b9f377d807 100644
--- a/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
+++ b/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
@@ -56,22 +56,22 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public class ConnectionHelper extends MetricsHelper<ConnectionMetrics>
{
static private AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", ConnectionHelper.class.getDeclaredMethod("getParent"));
- add("id", ConnectionHelper.class.getDeclaredMethod("getId"));
- add("state", ConnectionHelper.class.getDeclaredMethod("getState"));
- addConnectionAttributes(this, ConnectionHelper.class);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ add("parent", ConnectionHelper.class.getDeclaredMethod("getParent"));
+ add("id", ConnectionHelper.class.getDeclaredMethod("getId"));
+ add("state", ConnectionHelper.class.getDeclaredMethod("getState"));
+ addConnectionAttributes(this, ConnectionHelper.class);
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
{
@@ -87,9 +87,9 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
if(_id == null)
{
StringBuilder os = new StringBuilder();
- if(_connectionInfo instanceof Ice.IPConnectionInfo)
+ Ice.IPConnectionInfo info = getIPConnectionInfo();
+ if(info != null)
{
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)_connectionInfo;
os.append(info.localAddress).append(':').append(info.localPort);
os.append(" -> ");
os.append(info.remoteAddress).append(':').append(info.remotePort);
@@ -163,6 +163,19 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
return _endpointInfo;
}
+ private Ice.IPConnectionInfo
+ getIPConnectionInfo()
+ {
+ for(Ice.ConnectionInfo p = _connectionInfo; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ return (Ice.IPConnectionInfo)p;
+ }
+ }
+ return null;
+ }
+
private final Ice.ConnectionInfo _connectionInfo;
private final Ice.Endpoint _endpoint;
private final Ice.Instrumentation.ConnectionState _state;
@@ -173,30 +186,30 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class DispatchHelper extends MetricsHelper<DispatchMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- Class<?> cl = DispatchHelper.class;
- add("parent", cl.getDeclaredMethod("getParent"));
- add("id", cl.getDeclaredMethod("getId"));
-
- addConnectionAttributes(this, cl);
-
- Class<?> clc = Ice.Current.class;
- add("operation", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("operation"));
- add("identity", cl.getDeclaredMethod("getIdentity"));
- add("facet", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("facet"));
- add("requestId", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("requestId"));
- add("mode", cl.getDeclaredMethod("getMode"));
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ Class<?> cl = DispatchHelper.class;
+ add("parent", cl.getDeclaredMethod("getParent"));
+ add("id", cl.getDeclaredMethod("getId"));
+
+ addConnectionAttributes(this, cl);
+
+ Class<?> clc = Ice.Current.class;
+ add("operation", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("operation"));
+ add("identity", cl.getDeclaredMethod("getIdentity"));
+ add("facet", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("facet"));
+ add("requestId", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("requestId"));
+ add("mode", cl.getDeclaredMethod("getMode"));
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
DispatchHelper(Ice.Current current, int size)
{
@@ -318,30 +331,30 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class InvocationHelper extends MetricsHelper<InvocationMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- Class<?> cl = InvocationHelper.class;
- add("parent", cl.getDeclaredMethod("getParent"));
- add("id", cl.getDeclaredMethod("getId"));
-
- add("operation", cl.getDeclaredMethod("getOperation"));
- add("identity", cl.getDeclaredMethod("getIdentity"));
-
- Class<?> cli = Ice.ObjectPrx.class;
- add("facet", cl.getDeclaredMethod("getProxy"), cli.getDeclaredMethod("ice_getFacet"));
- add("encoding", cl.getDeclaredMethod("getEncodingVersion"));
- add("mode", cl.getDeclaredMethod("getMode"));
- add("proxy", cl.getDeclaredMethod("getProxy"));
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ Class<?> cl = InvocationHelper.class;
+ add("parent", cl.getDeclaredMethod("getParent"));
+ add("id", cl.getDeclaredMethod("getId"));
+
+ add("operation", cl.getDeclaredMethod("getOperation"));
+ add("identity", cl.getDeclaredMethod("getIdentity"));
+
+ Class<?> cli = Ice.ObjectPrx.class;
+ add("facet", cl.getDeclaredMethod("getProxy"), cli.getDeclaredMethod("ice_getFacet"));
+ add("encoding", cl.getDeclaredMethod("getEncodingVersion"));
+ add("mode", cl.getDeclaredMethod("getMode"));
+ add("proxy", cl.getDeclaredMethod("getProxy"));
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
}
- };
+ }
+ };
InvocationHelper(Ice.ObjectPrx proxy, String op, java.util.Map<String, String> ctx)
{
@@ -476,19 +489,19 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class ThreadHelper extends MetricsHelper<ThreadMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", ThreadHelper.class.getDeclaredField("_parent"));
- add("id", ThreadHelper.class.getDeclaredField("_id"));
- }
- catch(Exception ex)
- {
- assert(false);
- }
+ add("parent", ThreadHelper.class.getDeclaredField("_parent"));
+ add("id", ThreadHelper.class.getDeclaredField("_id"));
+ }
+ catch(Exception ex)
+ {
+ assert(false);
}
- };
+ }
+ };
ThreadHelper(String parent, String id, Ice.Instrumentation.ThreadState state)
{
@@ -526,21 +539,21 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class EndpointHelper extends MetricsHelper<Metrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", EndpointHelper.class.getDeclaredMethod("getParent"));
- add("id", EndpointHelper.class.getDeclaredMethod("getId"));
- addEndpointAttributes(this, EndpointHelper.class);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ add("parent", EndpointHelper.class.getDeclaredMethod("getParent"));
+ add("id", EndpointHelper.class.getDeclaredMethod("getId"));
+ addEndpointAttributes(this, EndpointHelper.class);
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
EndpointHelper(Ice.Endpoint endpt, String id)
{
diff --git a/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
index 9bf0f80cc66..350a9aa7e15 100644
--- a/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
@@ -17,5 +17,5 @@ public interface EndpointFactory
EndpointI read(Ice.InputStream s);
void destroy();
- EndpointFactory clone(ProtocolInstance instance);
+ EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/EndpointI.java b/java/src/Ice/src/main/java/IceInternal/EndpointI.java
index 9b4b06036b4..d393916472d 100644
--- a/java/src/Ice/src/main/java/IceInternal/EndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/EndpointI.java
@@ -11,6 +11,13 @@ package IceInternal;
abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<EndpointI>
{
+ public void streamWrite(Ice.OutputStream s)
+ {
+ s.startEncapsulation();
+ streamWriteImpl(s);
+ s.endEncapsulation();
+ }
+
@Override
public String toString()
{
@@ -33,7 +40,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En
//
// Marshal the endpoint.
//
- public abstract void streamWrite(Ice.OutputStream s);
+ public abstract void streamWriteImpl(Ice.OutputStream s);
//
// Return the endpoint type.
diff --git a/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java b/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
index c44434a204c..7a6057800c6 100644
--- a/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
@@ -43,14 +43,6 @@ public abstract class IPEndpointI extends EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
- {
- s.startEncapsulation();
- streamWriteImpl(s);
- s.endEncapsulation();
- }
-
- @Override
public Ice.EndpointInfo getInfo()
{
Ice.IPEndpointInfo info = new Ice.IPEndpointInfo()
@@ -250,16 +242,7 @@ public abstract class IPEndpointI extends EndpointI
return _connectionId.compareTo(p._connectionId);
}
- public String host()
- {
- return _host;
- }
-
- public int port()
- {
- return _port;
- }
-
+ @Override
public void streamWriteImpl(Ice.OutputStream s)
{
s.writeString(_host);
@@ -280,6 +263,8 @@ public abstract class IPEndpointI extends EndpointI
public void fillEndpointInfo(Ice.IPEndpointInfo info)
{
+ info.timeout = timeout();
+ info.compress = compress();
info.host = _host;
info.port = _port;
info.sourceAddress = _sourceAddr == null ? "" : _sourceAddr.getAddress().getHostAddress();
diff --git a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
index dfd2fb354b7..151343941af 100644
--- a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
+++ b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
@@ -240,12 +240,13 @@ class IncomingBase
out.print("\noperation: " + _current.operation);
if(_current.con != null)
{
- Ice.ConnectionInfo connInfo = _current.con.getInfo();
- if(connInfo instanceof Ice.IPConnectionInfo)
+ for(Ice.ConnectionInfo connInfo = _current.con.getInfo(); connInfo != null; connInfo = connInfo.underlying)
{
- Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
- out.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " +
- Integer.toString(ipConnInfo.remotePort));
+ if(connInfo instanceof Ice.IPConnectionInfo)
+ {
+ Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
+ out.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " + ipConnInfo.remotePort);
+ }
}
}
out.print("\n");
diff --git a/java/src/Ice/src/main/java/IceInternal/Instance.java b/java/src/Ice/src/main/java/IceInternal/Instance.java
index 1eeb4a3727f..1f019001136 100644
--- a/java/src/Ice/src/main/java/IceInternal/Instance.java
+++ b/java/src/Ice/src/main/java/IceInternal/Instance.java
@@ -1162,13 +1162,13 @@ public final class Instance implements Ice.ClassResolver
if(tcpFactory != null)
{
final ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null)));
}
final EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
if(sslFactory != null)
{
final ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null)));
}
//
diff --git a/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java b/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
index 3c825f02cea..c6c6b849ba5 100644
--- a/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
@@ -52,31 +52,37 @@ final class OpaqueEndpointI extends EndpointI
s.endEncapsulation();
}
+ @Override
+ public void streamWriteImpl(Ice.OutputStream s)
+ {
+ assert(false);
+ }
+
//
// Return the endpoint information.
//
@Override
public Ice.EndpointInfo getInfo()
{
- return new Ice.OpaqueEndpointInfo(-1, false, _rawEncoding, _rawBytes)
+ return new Ice.OpaqueEndpointInfo(null, -1, false, _rawEncoding, _rawBytes)
+ {
+ @Override
+ public short type()
{
- @Override
- public short type()
- {
- return _type;
- }
+ return _type;
+ }
- @Override
- public boolean datagram()
- {
- return false;
- }
+ @Override
+ public boolean datagram()
+ {
+ return false;
+ }
- @Override
- public boolean secure()
- {
- return false;
- }
+ @Override
+ public boolean secure()
+ {
+ return false;
+ }
};
}
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
index fb4e922b089..9211951ca59 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
@@ -49,7 +49,7 @@ final class TcpEndpointFactory implements EndpointFactory
}
@Override
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
return new TcpEndpointFactory(instance);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java b/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
index 687bed96f99..f038da63a2d 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
@@ -9,7 +9,7 @@
package IceInternal;
-final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
+final class TcpEndpointI extends IPEndpointI
{
public TcpEndpointI(ProtocolInstance instance, String ho, int po, java.net.InetSocketAddress sourceAddr, int ti,
String conId, boolean co)
@@ -64,37 +64,6 @@ final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
}
//
- // Return the WebSocket endpoint information.
- //
- @Override
- public Ice.EndpointInfo getWSInfo(String resource)
- {
- Ice.WSEndpointInfo info = new Ice.WSEndpointInfo()
- {
- @Override
- public short type()
- {
- return TcpEndpointI.this.type();
- }
-
- @Override
- public boolean datagram()
- {
- return TcpEndpointI.this.datagram();
- }
-
- @Override
- public boolean secure()
- {
- return TcpEndpointI.this.secure();
- }
- };
- fillEndpointInfo(info);
- info.resource = resource;
- return info;
- }
-
- //
// Return the timeout for the endpoint in milliseconds. 0 means
// non-blocking, -1 means no timeout.
//
@@ -270,14 +239,6 @@ final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
}
@Override
- public void fillEndpointInfo(Ice.IPEndpointInfo info)
- {
- super.fillEndpointInfo(info);
- info.timeout = _timeout;
- info.compress = _compress;
- }
-
- @Override
protected boolean checkOption(String option, String argument, String endpoint)
{
if(super.checkOption(option, argument, endpoint))
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
index ce84da8b2b6..069e79a3408 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
@@ -9,7 +9,7 @@
package IceInternal;
-final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
+final class TcpTransceiver implements Transceiver
{
@Override
public java.nio.channels.SelectableChannel fd()
@@ -85,16 +85,22 @@ final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
public Ice.ConnectionInfo getInfo()
{
Ice.TCPConnectionInfo info = new Ice.TCPConnectionInfo();
- fillConnectionInfo(info);
- return info;
- }
-
- @Override
- public Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers)
- {
- Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
- fillConnectionInfo(info);
- info.headers = headers; // Provided header is a copy so no need to clone here.
+ if(_stream.fd() != null)
+ {
+ java.net.Socket socket = _stream.fd().socket();
+ info.localAddress = socket.getLocalAddress().getHostAddress();
+ info.localPort = socket.getLocalPort();
+ if(socket.getInetAddress() != null)
+ {
+ info.remoteAddress = socket.getInetAddress().getHostAddress();
+ info.remotePort = socket.getPort();
+ }
+ if(!socket.isClosed())
+ {
+ info.rcvSize = Network.getRecvBufferSize(_stream.fd());
+ info.sndSize = Network.getSendBufferSize(_stream.fd());
+ }
+ }
return info;
}
@@ -115,26 +121,6 @@ final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
_stream = stream;
}
- private void fillConnectionInfo(Ice.IPConnectionInfo info)
- {
- if(_stream.fd() != null)
- {
- java.net.Socket socket = _stream.fd().socket();
- info.localAddress = socket.getLocalAddress().getHostAddress();
- info.localPort = socket.getLocalPort();
- if(socket.getInetAddress() != null)
- {
- info.remoteAddress = socket.getInetAddress().getHostAddress();
- info.remotePort = socket.getPort();
- }
- if(!socket.isClosed())
- {
- info.rcvSize = Network.getRecvBufferSize(_stream.fd());
- info.sndSize = Network.getSendBufferSize(_stream.fd());
- }
- }
- }
-
final private ProtocolInstance _instance;
final private StreamSocket _stream;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
index 07f9ad35410..6683b57dcb9 100644
--- a/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
@@ -49,7 +49,7 @@ final class UdpEndpointFactory implements EndpointFactory
}
@Override
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
return new UdpEndpointFactory(instance);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java b/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
index 8de493bb467..8c1d0bc837d 100644
--- a/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
@@ -51,26 +51,25 @@ final class UdpEndpointI extends IPEndpointI
public Ice.EndpointInfo getInfo()
{
Ice.UDPEndpointInfo info = new Ice.UDPEndpointInfo()
+ {
+ @Override
+ public short type()
{
- @Override
- public short type()
- {
- return UdpEndpointI.this.type();
- }
+ return UdpEndpointI.this.type();
+ }
- @Override
- public boolean datagram()
- {
- return UdpEndpointI.this.datagram();
- }
+ @Override
+ public boolean datagram()
+ {
+ return UdpEndpointI.this.datagram();
+ }
- @Override
- public boolean secure()
- {
- return UdpEndpointI.this.secure();
- }
+ @Override
+ public boolean secure()
+ {
+ return UdpEndpointI.this.secure();
+ }
};
-
fillEndpointInfo(info);
return info;
}
@@ -283,8 +282,6 @@ final class UdpEndpointI extends IPEndpointI
if(info instanceof Ice.UDPEndpointInfo)
{
Ice.UDPEndpointInfo udpInfo = (Ice.UDPEndpointInfo)info;
- udpInfo.timeout = -1;
- udpInfo.compress = _compress;
udpInfo.mcastInterface = _mcastInterface;
udpInfo.mcastTtl = _mcastTtl;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSConnector.java b/java/src/Ice/src/main/java/IceInternal/WSConnector.java
index 3e2978e03ee..3c9ecc7e06b 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSConnector.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSConnector.java
@@ -14,7 +14,7 @@ final class WSConnector implements Connector
@Override
public Transceiver connect()
{
- return new WSTransceiver(_instance, _delegate.connect(), _host, _port, _resource);
+ return new WSTransceiver(_instance, _delegate.connect(), _host, _resource);
}
@Override
@@ -35,12 +35,11 @@ final class WSConnector implements Connector
return _delegate.hashCode();
}
- WSConnector(ProtocolInstance instance, Connector del, String host, int port, String resource)
+ WSConnector(ProtocolInstance instance, Connector del, String host, String resource)
{
_instance = instance;
_delegate = del;
_host = host;
- _port = port;
_resource = resource;
}
@@ -74,6 +73,5 @@ final class WSConnector implements Connector
private ProtocolInstance _instance;
private Connector _delegate;
private String _host;
- private int _port;
private String _resource;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java b/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
index 8b34032ec5f..91ea36d1a62 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
@@ -14,14 +14,14 @@ final class WSEndpoint extends IceInternal.EndpointI
public WSEndpoint(ProtocolInstance instance, EndpointI del, String res)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = res;
}
public WSEndpoint(ProtocolInstance instance, EndpointI del, java.util.ArrayList<String> args)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
initWithOptions(args);
@@ -34,15 +34,36 @@ final class WSEndpoint extends IceInternal.EndpointI
public WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = s.readString();
}
@Override
public Ice.EndpointInfo getInfo()
{
- assert(_delegate instanceof WSEndpointDelegate);
- return ((WSEndpointDelegate)_delegate).getWSInfo(_resource);
+ Ice.WSEndpointInfo info = new Ice.WSEndpointInfo(_delegate.getInfo(), timeout(), compress(), _resource)
+ {
+ @Override
+ public short type()
+ {
+ return WSEndpoint.this.type();
+ }
+
+ @Override
+ public boolean datagram()
+ {
+ return WSEndpoint.this.datagram();
+ }
+
+ @Override
+ public boolean secure()
+ {
+ return WSEndpoint.this.secure();
+ }
+ };
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
+ return info;
}
@Override
@@ -58,12 +79,10 @@ final class WSEndpoint extends IceInternal.EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
+ public void streamWriteImpl(Ice.OutputStream s)
{
- s.startEncapsulation();
_delegate.streamWriteImpl(s);
s.writeString(_resource);
- s.endEncapsulation();
}
@Override
@@ -144,6 +163,15 @@ final class WSEndpoint extends IceInternal.EndpointI
@Override
public void connectors_async(Ice.EndpointSelectionType selType, final EndpointI_connectors callback)
{
+ Ice.IPEndpointInfo ipInfo = null;
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPEndpointInfo)
+ {
+ ipInfo = (Ice.IPEndpointInfo)p;
+ }
+ }
+ final String host = ipInfo != null ? (ipInfo.host + ":" + ipInfo.port) : "";
EndpointI_connectors cb = new EndpointI_connectors()
{
@Override
@@ -152,7 +180,7 @@ final class WSEndpoint extends IceInternal.EndpointI
java.util.List<Connector> l = new java.util.ArrayList<Connector>();
for(Connector c : connectors)
{
- l.add(new WSConnector(_instance, c, _delegate.host(), _delegate.port(), _resource));
+ l.add(new WSConnector(_instance, c, host, _resource));
}
callback.connectors(l);
}
@@ -291,6 +319,6 @@ final class WSEndpoint extends IceInternal.EndpointI
}
private ProtocolInstance _instance;
- private IPEndpointI _delegate;
+ private EndpointI _delegate;
private String _resource;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java b/java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java
deleted file mode 100644
index 158fd811c43..00000000000
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java
+++ /dev/null
@@ -1,19 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package IceInternal;
-
-//
-// Delegate interface implemented by TcpEndpoint or IceSSL.EndpointI or any endpoint that WS can
-// delegate to.
-//
-public interface WSEndpointDelegate
-{
- Ice.EndpointInfo getWSInfo(String resource);
-};
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
index dc2ad44e561..493cddfd5eb 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
@@ -9,9 +9,9 @@
package IceInternal;
-final public class WSEndpointFactory implements IceInternal.EndpointFactory
+final public class WSEndpointFactory implements EndpointFactory
{
- public WSEndpointFactory(ProtocolInstance instance, IceInternal.EndpointFactory delegate)
+ public WSEndpointFactory(ProtocolInstance instance, EndpointFactory delegate)
{
_instance = instance;
_delegate = delegate;
@@ -30,13 +30,13 @@ final public class WSEndpointFactory implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
+ public EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
{
return new WSEndpoint(_instance, _delegate.create(args, oaEndpoint), args);
}
@Override
- public IceInternal.EndpointI read(Ice.InputStream s)
+ public EndpointI read(Ice.InputStream s)
{
return new WSEndpoint(_instance, _delegate.read(s), s);
}
@@ -49,12 +49,11 @@ final public class WSEndpointFactory implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
- assert(false); // We don't support cloning this transport.
- return null;
+ return new WSEndpointFactory(instance, delegate);
}
private ProtocolInstance _instance;
- private IceInternal.EndpointFactory _delegate;
+ private EndpointFactory _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
index 217e866d1d6..8188ab322c8 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
@@ -65,8 +65,7 @@ final class WSTransceiver implements Transceiver
//
StringBuffer out = new StringBuffer();
out.append("GET " + _resource + " HTTP/1.1\r\n");
- out.append("Host: " + _host + ":");
- out.append(_port);
+ out.append("Host: " + _host);
out.append("\r\n");
out.append("Upgrade: websocket\r\n");
out.append("Connection: Upgrade\r\n");
@@ -498,8 +497,10 @@ final class WSTransceiver implements Transceiver
@Override
public Ice.ConnectionInfo getInfo()
{
- assert(_delegate instanceof WSTransceiverDelegate);
- return ((WSTransceiverDelegate)_delegate).getWSInfo(_parser.getHeaders());
+ Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
+ info.underlying = _delegate.getInfo();
+ info.headers = _parser.getHeaders();
+ return info;
}
@Override
@@ -514,11 +515,10 @@ final class WSTransceiver implements Transceiver
_delegate.setBufferSize(rcvSize, sndSize);
}
- WSTransceiver(ProtocolInstance instance, Transceiver del, String host, int port, String resource)
+ WSTransceiver(ProtocolInstance instance, Transceiver del, String host, String resource)
{
init(instance, del);
_host = host;
- _port = port;
_resource = resource;
_incoming = false;
@@ -542,7 +542,6 @@ final class WSTransceiver implements Transceiver
{
init(instance, del);
_host = "";
- _port = -1;
_resource = "";
_incoming = true;
@@ -1516,7 +1515,6 @@ final class WSTransceiver implements Transceiver
private ProtocolInstance _instance;
private Transceiver _delegate;
private String _host;
- private int _port;
private String _resource;
private boolean _incoming;
private ReadyCallback _readyCallback;
diff --git a/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java
deleted file mode 100644
index 2cce1ae1d99..00000000000
--- a/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java
+++ /dev/null
@@ -1,19 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package IceInternal;
-
-//
-// Delegate interface implemented by TcpTransceiver or IceSSL.TransceiverI or any endpoint that WS can
-// delegate to.
-//
-public interface WSTransceiverDelegate
-{
- Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers);
-};
diff --git a/java/src/Ice/src/main/java/IceMX/MetricsHelper.java b/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
index d2befeef9cb..8d5aac39062 100644
--- a/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
+++ b/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
@@ -67,7 +67,7 @@ public class MetricsHelper<T>
}
public void
- add(String name, final java.lang.reflect.Method method)
+ add(final String name, final java.lang.reflect.Method method)
{
_attributes.put(name, new Resolver()
{
@@ -81,7 +81,7 @@ public class MetricsHelper<T>
}
public void
- add(String name, final java.lang.reflect.Field field)
+ add(final String name, final java.lang.reflect.Field field)
{
_attributes.put(name, new Resolver()
{
@@ -89,7 +89,7 @@ public class MetricsHelper<T>
public Object
resolve(Object obj) throws Exception
{
- return field.get(obj);
+ return getField(name, field, obj);
}
});
}
@@ -103,12 +103,7 @@ public class MetricsHelper<T>
public Object
resolve(Object obj) throws Exception
{
- Object o = method.invoke(obj);
- if(o != null)
- {
- return field.get(o);
- }
- throw new IllegalArgumentException(name);
+ return getField(name, field, method.invoke(obj));
}
});
}
@@ -132,6 +127,36 @@ public class MetricsHelper<T>
});
}
+ private Object getField(String name, java.lang.reflect.Field field, Object o)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ while(o != null)
+ {
+ try
+ {
+ return field.get(o);
+ }
+ catch(IllegalArgumentException ex)
+ {
+ // If we're dealing with an endpoint/connection information class,
+ // check if the field is from the underlying info objects.
+ if(o instanceof Ice.EndpointInfo)
+ {
+ o = ((Ice.EndpointInfo)o).underlying;
+ }
+ else if(o instanceof Ice.ConnectionInfo)
+ {
+ o = ((Ice.ConnectionInfo)o).underlying;
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ }
+ throw new IllegalArgumentException(name);
+ }
+
private java.util.Map<String, Resolver> _attributes = new java.util.HashMap<String, Resolver>();
}
diff --git a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
index 639b8072f1b..bf21888839e 100644
--- a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
+++ b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
@@ -14,38 +14,25 @@ final class AcceptorI implements IceInternal.Acceptor
@Override
public java.nio.channels.ServerSocketChannel fd()
{
- return _fd;
+ return _delegate.fd();
}
@Override
public void setReadyCallback(IceInternal.ReadyCallback callback)
{
- // No need to for the ready callback.
+ _delegate.setReadyCallback(callback);
}
@Override
public void close()
{
- if(_fd != null)
- {
- IceInternal.Network.closeSocketNoThrow(_fd);
- _fd = null;
- }
+ _delegate.close();
}
@Override
public IceInternal.EndpointI listen()
{
- try
- {
- _addr = IceInternal.Network.doBind(_fd, _addr, _backlog);
- }
- catch(Ice.Exception ex)
- {
- _fd = null;
- throw ex;
- }
- _endpoint = _endpoint.endpoint(this);
+ _endpoint = _endpoint.endpoint(_delegate.listen());
return _endpoint;
}
@@ -62,114 +49,37 @@ final class AcceptorI implements IceInternal.Acceptor
throw ex;
}
- IceInternal.StreamSocket stream = new IceInternal.StreamSocket(_instance, IceInternal.Network.doAccept(_fd));
- try
- {
- java.net.InetSocketAddress peerAddr =
- (java.net.InetSocketAddress)stream.fd().socket().getRemoteSocketAddress();
- return new TransceiverI(_instance, _instance.createSSLEngine(true, peerAddr), stream, _adapterName, true);
- }
- catch(RuntimeException ex)
- {
- stream.close();
- throw ex;
- }
+ return new TransceiverI(_instance, _delegate.accept(), _adapterName, true);
}
@Override
public String protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
@Override
public String toString()
{
- return IceInternal.Network.addrToString(_addr);
+ return _delegate.toString();
}
@Override
public String toDetailedString()
{
- StringBuffer s = new StringBuffer("local address = ");
- s.append(toString());
-
- java.util.List<String> intfs =
- IceInternal.Network.getHostsForEndpointExpand(_addr.getAddress().getHostAddress(),
- _instance.protocolSupport(), true);
- if(!intfs.isEmpty())
- {
- s.append("\nlocal interfaces = ");
- s.append(IceUtilInternal.StringUtil.joinString(intfs, ", "));
- }
- return s.toString();
- }
-
- int effectivePort()
- {
- return _addr.getPort();
+ return _delegate.toDetailedString();
}
- AcceptorI(EndpointI endpoint, Instance instance, String adapterName, String host, int port)
+ AcceptorI(EndpointI endpoint, Instance instance, IceInternal.Acceptor delegate, String adapterName)
{
_endpoint = endpoint;
_instance = instance;
+ _delegate = delegate;
_adapterName = adapterName;
- _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);
-
- try
- {
- _fd = IceInternal.Network.createTcpServerSocket();
- IceInternal.Network.setBlock(_fd, false);
- IceInternal.Network.setTcpBufSize(_fd, _instance);
- if(!System.getProperty("os.name").startsWith("Windows"))
- {
- //
- // Enable SO_REUSEADDR on Unix platforms to allow
- // re-using the socket even if it's in the TIME_WAIT
- // state. On Windows, this doesn't appear to be
- // necessary and enabling SO_REUSEADDR would actually
- // not be a good thing since it allows a second
- // process to bind to an address even it's already
- // bound by another process.
- //
- // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
- // probably be better but it's only supported by recent
- // Windows versions (XP SP2, Windows Server 2003).
- //
- IceInternal.Network.setReuseAddress(_fd, true);
- }
- _addr = IceInternal.Network.getAddressForServer(host, port, _instance.protocolSupport(),
- _instance.preferIPv6());
- }
- catch(RuntimeException ex)
- {
- _fd = null;
- throw ex;
- }
- }
-
- @Override
- protected synchronized void finalize()
- throws Throwable
- {
- try
- {
- IceUtilInternal.Assert.FinalizerAssert(_fd == null);
- }
- catch(java.lang.Exception ex)
- {
- }
- finally
- {
- super.finalize();
- }
}
private EndpointI _endpoint;
private Instance _instance;
+ private IceInternal.Acceptor _delegate;
private String _adapterName;
- private java.nio.channels.ServerSocketChannel _fd;
- private int _backlog;
- private java.net.InetSocketAddress _addr;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/ConnectorI.java b/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
index 4a47254e006..d463a89bf3d 100644
--- a/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
+++ b/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
@@ -24,60 +24,35 @@ final class ConnectorI implements IceInternal.Connector
throw ex;
}
- IceInternal.StreamSocket stream = new IceInternal.StreamSocket(_instance, _proxy, _addr, _sourceAddr);
- try
- {
- javax.net.ssl.SSLEngine engine = _instance.createSSLEngine(false, _addr);
- return new TransceiverI(_instance, engine, stream, _host, false);
- }
- catch(RuntimeException ex)
- {
- stream.close();
- throw ex;
- }
+ return new TransceiverI(_instance, _delegate.connect(), _host, false);
}
@Override
public short type()
{
- return _instance.type();
+ return _delegate.type();
}
@Override
public String toString()
{
- return IceInternal.Network.addrToString(_proxy == null ? _addr : _proxy.getAddress());
+ return _delegate.toString();
}
@Override
public int hashCode()
{
- return _hashCode;
+ return _delegate.hashCode();
}
//
// Only for use by EndpointI.
//
- ConnectorI(Instance instance, String host, java.net.InetSocketAddress addr, IceInternal.NetworkProxy proxy,
- java.net.InetSocketAddress sourceAddr, int timeout, String connectionId)
+ ConnectorI(Instance instance, IceInternal.Connector delegate, String host)
{
_instance = instance;
+ _delegate = delegate;
_host = host;
- _addr = addr;
- _sourceAddr = sourceAddr;
- _proxy = proxy;
- _timeout = timeout;
- _connectionId = connectionId;
-
- _hashCode = 5381;
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getAddress().getHostAddress());
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getPort());
- if(_sourceAddr != null)
- {
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _sourceAddr.getAddress().getHostAddress());
- }
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _timeout);
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _connectionId);
}
@Override
@@ -94,30 +69,10 @@ final class ConnectorI implements IceInternal.Connector
}
ConnectorI p = (ConnectorI)obj;
- if(_timeout != p._timeout)
- {
- return false;
- }
-
- if(!_connectionId.equals(p._connectionId))
- {
- return false;
- }
-
- if(IceInternal.Network.compareAddress(_sourceAddr, p._sourceAddr) != 0)
- {
- return false;
- }
-
- return IceInternal.Network.compareAddress(_addr, p._addr) == 0;
+ return p._delegate.equals(_delegate);
}
private Instance _instance;
+ private IceInternal.Connector _delegate;
private String _host;
- private java.net.InetSocketAddress _addr;
- private IceInternal.NetworkProxy _proxy;
- private java.net.InetSocketAddress _sourceAddr;
- private int _timeout;
- private String _connectionId;
- private int _hashCode;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java b/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
index f13758a2522..ffe402c6193 100644
--- a/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
+++ b/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
@@ -11,9 +11,10 @@ package IceSSL;
final class EndpointFactoryI implements IceInternal.EndpointFactory
{
- EndpointFactoryI(Instance instance)
+ EndpointFactoryI(Instance instance, IceInternal.EndpointFactory delegate)
{
_instance = instance;
+ _delegate = delegate;
}
@Override
@@ -31,28 +32,29 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory
@Override
public IceInternal.EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
{
- IceInternal.IPEndpointI endpt = new EndpointI(_instance);
- endpt.initWithOptions(args, oaEndpoint);
- return endpt;
+ return new EndpointI(_instance, _delegate.create(args, oaEndpoint));
}
@Override
public IceInternal.EndpointI read(Ice.InputStream s)
{
- return new EndpointI(_instance, s);
+ return new EndpointI(_instance, _delegate.read(s));
}
@Override
public void destroy()
{
+ _delegate.destroy();
_instance = null;
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, IceInternal.EndpointFactory delegate)
{
- return new EndpointFactoryI(new Instance(_instance.engine(), instance.type(), instance.protocol()));
+ Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol());
+ return new EndpointFactoryI(instance, delegate != null ? delegate : _delegate.clone(instance, null));
}
private Instance _instance;
+ private IceInternal.EndpointFactory _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/EndpointI.java b/java/src/Ice/src/main/java/IceSSL/EndpointI.java
index 105530660d1..08de48c2f11 100644
--- a/java/src/Ice/src/main/java/IceSSL/EndpointI.java
+++ b/java/src/Ice/src/main/java/IceSSL/EndpointI.java
@@ -9,31 +9,18 @@
package IceSSL;
-final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSEndpointDelegate
+final class EndpointI extends IceInternal.EndpointI
{
- public EndpointI(Instance instance, String ho, int po, java.net.InetSocketAddress sourceAddr, int ti, String conId,
- boolean co)
+ public EndpointI(Instance instance, IceInternal.EndpointI delegate)
{
- super(instance, ho, po, sourceAddr, conId);
_instance = instance;
- _timeout = ti;
- _compress = co;
+ _delegate = delegate;
}
- public EndpointI(Instance instance)
- {
- super(instance);
- _instance = instance;
- _timeout = instance.defaultTimeout();
- _compress = false;
- }
-
- public EndpointI(Instance instance, Ice.InputStream s)
+ @Override
+ public void streamWriteImpl(Ice.OutputStream s)
{
- super(instance, s);
- _instance = instance;
- _timeout = s.readInt();
- _compress = s.readBool();
+ _delegate.streamWriteImpl(s);
}
//
@@ -42,7 +29,7 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
@Override
public Ice.EndpointInfo getInfo()
{
- Ice.IPEndpointInfo info = new IceSSL.EndpointInfo()
+ IceSSL.EndpointInfo info = new IceSSL.EndpointInfo(_delegate.getInfo(), timeout(), compress())
{
@Override
public short type()
@@ -62,104 +49,90 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
return EndpointI.this.secure();
}
};
- fillEndpointInfo(info);
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
return info;
}
- //
- // Return the secure WebSocket endpoint information.
- //
@Override
- public Ice.EndpointInfo getWSInfo(String resource)
+ public short type()
{
- IceSSL.WSSEndpointInfo info = new IceSSL.WSSEndpointInfo()
- {
- @Override
- public short type()
- {
- return EndpointI.this.type();
- }
-
- @Override
- public boolean datagram()
- {
- return EndpointI.this.datagram();
- }
+ return _delegate.type();
+ }
- @Override
- public boolean secure()
- {
- return EndpointI.this.secure();
- }
- };
- fillEndpointInfo(info);
- info.resource = resource;
- return info;
+ @Override
+ public String protocol()
+ {
+ return _delegate.protocol();
}
- //
- // Return the timeout for the endpoint in milliseconds. 0 means
- // non-blocking, -1 means no timeout.
- //
@Override
public int timeout()
{
- return _timeout;
+ return _delegate.timeout();
}
- //
- // Return a new endpoint with a different timeout value, provided
- // that timeouts are supported by the endpoint. Otherwise the same
- // endpoint is returned.
- //
@Override
public IceInternal.EndpointI timeout(int timeout)
{
- if(timeout == _timeout)
+ if(timeout == _delegate.timeout())
{
return this;
}
else
{
- return new EndpointI(_instance, _host, _port, _sourceAddr, timeout, _connectionId, _compress);
+ return new EndpointI(_instance, _delegate.timeout(timeout));
+ }
+ }
+
+ @Override
+ public String connectionId()
+ {
+ return _delegate.connectionId();
+ }
+
+ @Override
+ public IceInternal.EndpointI connectionId(String connectionId)
+ {
+ if(connectionId == _delegate.connectionId())
+ {
+ return this;
+ }
+ else
+ {
+ return new EndpointI(_instance, _delegate.connectionId(connectionId));
}
}
- //
- // Return true if the endpoints support bzip2 compress, or false
- // otherwise.
- //
@Override
public boolean compress()
{
- return _compress;
+ return _delegate.compress();
}
- //
- // Return a new endpoint with a different compression value,
- // provided that compression is supported by the
- // endpoint. Otherwise the same endpoint is returned.
- //
@Override
public IceInternal.EndpointI compress(boolean compress)
{
- if(compress == _compress)
+ if(compress == _delegate.compress())
{
return this;
}
else
{
- return new EndpointI(_instance, _host, _port, _sourceAddr, _timeout, _connectionId, compress);
+ return new EndpointI(_instance, _delegate.compress(compress));
}
}
- //
- // Return true if the endpoint is datagram-based.
- //
@Override
public boolean datagram()
{
- return false;
+ return _delegate.datagram();
+ }
+
+ @Override
+ public boolean secure()
+ {
+ return _delegate.secure();
}
//
@@ -172,6 +145,40 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
return null;
}
+ @Override
+ public void connectors_async(Ice.EndpointSelectionType selType, final IceInternal.EndpointI_connectors callback)
+ {
+ Ice.IPEndpointInfo ipInfo = null;
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPEndpointInfo)
+ {
+ ipInfo = (Ice.IPEndpointInfo)p;
+ }
+ }
+ final String host = ipInfo != null ? ipInfo.host : "";
+ IceInternal.EndpointI_connectors cb = new IceInternal.EndpointI_connectors()
+ {
+ @Override
+ public void connectors(java.util.List<IceInternal.Connector> connectors)
+ {
+ java.util.List<IceInternal.Connector> l = new java.util.ArrayList<IceInternal.Connector>();
+ for(IceInternal.Connector c : connectors)
+ {
+ l.add(new ConnectorI(_instance, c, host));
+ }
+ callback.connectors(l);
+ }
+
+ @Override
+ public void exception(Ice.LocalException ex)
+ {
+ callback.exception(ex);
+ }
+ };
+ _delegate.connectors_async(selType, cb);
+ }
+
//
// Return an acceptor for this endpoint, or null if no acceptors
// is available.
@@ -179,182 +186,75 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
@Override
public IceInternal.Acceptor acceptor(String adapterName)
{
- return new AcceptorI(this, _instance, adapterName, _host, _port);
+ return new AcceptorI(this, _instance, _delegate.acceptor(adapterName), adapterName);
}
- public EndpointI endpoint(AcceptorI acceptor)
+ public EndpointI endpoint(IceInternal.EndpointI delEndpt)
{
- return new EndpointI(_instance, _host, acceptor.effectivePort(), _sourceAddr, _timeout, _connectionId,
- _compress);
+ return new EndpointI(_instance, delEndpt);
}
-
@Override
- public String options()
+ public java.util.List<IceInternal.EndpointI> expand()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- String s = super.options();
-
- if(_timeout == -1)
- {
- s += " -t infinite";
- }
- else
+ java.util.List<IceInternal.EndpointI> endps = _delegate.expand();
+ java.util.List<IceInternal.EndpointI> l = new java.util.ArrayList<IceInternal.EndpointI>();
+ for(IceInternal.EndpointI e : endps)
{
- s += " -t " + _timeout;
+ l.add(e == _delegate ? this : new EndpointI(_instance, e));
}
-
- if(_compress)
- {
- s += " -z";
- }
-
- return s;
+ return l;
}
- //
- // Compare endpoints for sorting purposes
- //
@Override
- public int compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable
+ public boolean equivalent(IceInternal.EndpointI endpoint)
{
- if(!(obj instanceof EndpointI))
- {
- return type() < obj.type() ? -1 : 1;
- }
-
- EndpointI p = (EndpointI)obj;
- if(this == p)
- {
- return 0;
- }
-
- if(_timeout < p._timeout)
- {
- return -1;
- }
- else if(p._timeout < _timeout)
- {
- return 1;
- }
-
- if(!_compress && p._compress)
+ if(!(endpoint instanceof EndpointI))
{
- return -1;
- }
- else if(!p._compress && _compress)
- {
- return 1;
+ return false;
}
-
- return super.compareTo(obj);
- }
-
- @Override
- public void streamWriteImpl(Ice.OutputStream s)
- {
- super.streamWriteImpl(s);
- s.writeInt(_timeout);
- s.writeBool(_compress);
+ EndpointI endpointI = (EndpointI)endpoint;
+ return _delegate.equivalent(endpointI._delegate);
}
@Override
- public int hashInit(int h)
+ synchronized public int hashCode()
{
- h = super.hashInit(h);
- h = IceInternal.HashUtil.hashAdd(h, _timeout);
- h = IceInternal.HashUtil.hashAdd(h, _compress);
- return h;
+ return _delegate.hashCode();
}
@Override
- public void fillEndpointInfo(Ice.IPEndpointInfo info)
+ public String options()
{
- super.fillEndpointInfo(info);
- info.timeout = _timeout;
- info.compress = _compress;
+ return _delegate.options();
}
+ //
+ // Compare endpoints for sorting purposes
+ //
@Override
- protected boolean checkOption(String option, String argument, String endpoint)
+ public int compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable
{
- if(super.checkOption(option, argument, endpoint))
- {
- return true;
- }
-
- switch(option.charAt(1))
- {
- case 't':
- {
- if(argument == null)
- {
- throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint);
- }
-
- if(argument.equals("infinite"))
- {
- _timeout = -1;
- }
- else
- {
- try
- {
- _timeout = Integer.parseInt(argument);
- if(_timeout < 1)
- {
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
- "' in endpoint " + endpoint);
- }
- }
- catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
- "' in endpoint " + endpoint);
- }
- }
-
- return true;
- }
-
- case 'z':
+ if(!(obj instanceof EndpointI))
{
- if(argument != null)
- {
- throw new Ice.EndpointParseException("unexpected argument `" + argument +
- "' provided for -z option in " + endpoint);
- }
-
- _compress = true;
- return true;
+ return type() < obj.type() ? -1 : 1;
}
- default:
+ EndpointI p = (EndpointI)obj;
+ if(this == p)
{
- return false;
- }
+ return 0;
}
- }
- @Override
- protected IceInternal.Connector createConnector(java.net.InetSocketAddress addr, IceInternal.NetworkProxy proxy)
- {
- return new ConnectorI(_instance, _host, addr, proxy, _sourceAddr, _timeout, _connectionId);
+ return _delegate.compareTo(p._delegate);
}
@Override
- protected IceInternal.IPEndpointI createEndpoint(String host, int port, String connectionId)
+ protected boolean checkOption(String option, String argument, String endpoint)
{
- return new EndpointI(_instance, host, port, _sourceAddr, _timeout, connectionId, _compress);
+ return false;
}
private Instance _instance;
- private int _timeout;
- private boolean _compress;
+ private IceInternal.EndpointI _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/Instance.java b/java/src/Ice/src/main/java/IceSSL/Instance.java
index 8c18c961933..53ffac5c29f 100644
--- a/java/src/Ice/src/main/java/IceSSL/Instance.java
+++ b/java/src/Ice/src/main/java/IceSSL/Instance.java
@@ -37,19 +37,19 @@ class Instance extends IceInternal.ProtocolInstance
return _engine.initialized();
}
- javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, java.net.InetSocketAddress peerAddr)
+ javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, String host, int port)
{
- return _engine.createSSLEngine(incoming, peerAddr);
+ return _engine.createSSLEngine(incoming, host, port);
}
- void traceConnection(java.nio.channels.SocketChannel fd, javax.net.ssl.SSLEngine engine, boolean incoming)
+ void traceConnection(String desc, javax.net.ssl.SSLEngine engine, boolean incoming)
{
- _engine.traceConnection(fd, engine, incoming);
+ _engine.traceConnection(desc, engine, incoming);
}
- void verifyPeer(NativeConnectionInfo info, java.nio.channels.SelectableChannel fd, String address)
+ void verifyPeer(String address, NativeConnectionInfo info, String desc)
{
- _engine.verifyPeer(info, fd, address);
+ _engine.verifyPeer(address, info, desc);
}
void trustManagerFailure(boolean incoming, java.security.cert.CertificateException ex)
diff --git a/java/src/Ice/src/main/java/IceSSL/PluginI.java b/java/src/Ice/src/main/java/IceSSL/PluginI.java
index 6db69f7c264..a57d6e31245 100644
--- a/java/src/Ice/src/main/java/IceSSL/PluginI.java
+++ b/java/src/Ice/src/main/java/IceSSL/PluginI.java
@@ -21,8 +21,22 @@ class PluginI implements Plugin
// in initialize, because the communicator may need to interpret
// proxies before the plug-in is fully initialized.
//
- EndpointFactoryI factory = new EndpointFactoryI(new Instance(_engine, IceSSL.EndpointType.value, "ssl"));
- facade.addEndpointFactory(factory);
+
+ // SSL based on TCP
+ IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value);
+ if(tcp != null)
+ {
+ Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null)));
+ }
+
+ // SSL based on Bluetooth
+ IceInternal.EndpointFactory bluetooth = facade.getEndpointFactory(Ice.BTEndpointType.value);
+ if(bluetooth != null)
+ {
+ Instance instance = new Instance(_engine, Ice.BTSEndpointType.value, "bts");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, bluetooth.clone(instance, null)));
+ }
}
@Override
diff --git a/java/src/Ice/src/main/java/IceSSL/SSLEngine.java b/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
index 72810753755..e8da76b6b26 100644
--- a/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
+++ b/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
@@ -777,12 +777,12 @@ class SSLEngine
return _initialized;
}
- javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, java.net.InetSocketAddress peerAddr)
+ javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, String host, int port)
{
javax.net.ssl.SSLEngine engine;
- if(peerAddr != null)
+ if(host != null)
{
- engine = _context.createSSLEngine(peerAddr.getAddress().getHostAddress(), peerAddr.getPort());
+ engine = _context.createSSLEngine(host, port);
}
else
{
@@ -941,13 +941,12 @@ class SSLEngine
return _protocols;
}
- void traceConnection(java.nio.channels.SocketChannel fd, javax.net.ssl.SSLEngine engine, boolean incoming)
+ void traceConnection(String desc, javax.net.ssl.SSLEngine engine, boolean incoming)
{
javax.net.ssl.SSLSession session = engine.getSession();
String msg = "SSL summary for " + (incoming ? "incoming" : "outgoing") + " connection\n" +
"cipher = " + session.getCipherSuite() + "\n" +
- "protocol = " + session.getProtocol() + "\n" +
- IceInternal.Network.fdToString(fd);
+ "protocol = " + session.getProtocol() + "\n" + desc;
_logger.trace(_securityTraceCategory, msg);
}
@@ -956,7 +955,7 @@ class SSLEngine
return _communicator;
}
- void verifyPeer(NativeConnectionInfo info, java.nio.channels.SelectableChannel fd, String address)
+ void verifyPeer(String address, NativeConnectionInfo info, String desc)
{
//
// IceSSL.VerifyPeer is translated into the proper SSLEngine configuration
@@ -1108,8 +1107,7 @@ class SSLEngine
{
String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected:\n" +
"length of peer's certificate chain (" + info.nativeCerts.length + ") exceeds maximum of " +
- _verifyDepthMax + "\n" +
- IceInternal.Network.fdToString(fd);
+ _verifyDepthMax + "\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -1119,10 +1117,9 @@ class SSLEngine
throw ex;
}
- if(!_trustManager.verify(info))
+ if(!_trustManager.verify(info, desc))
{
- String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" +
- IceInternal.Network.fdToString(fd);
+ String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -1135,7 +1132,7 @@ class SSLEngine
if(_verifier != null && !_verifier.verify(info))
{
String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier\n" +
- IceInternal.Network.fdToString(fd);
+ desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
diff --git a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
index c1a3277a511..20caf5de188 100644
--- a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
+++ b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
@@ -13,30 +13,51 @@ import java.nio.*;
import javax.net.ssl.*;
import javax.net.ssl.SSLEngineResult.*;
-final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTransceiverDelegate
+final class TransceiverI implements IceInternal.Transceiver
{
@Override
public java.nio.channels.SelectableChannel fd()
{
- return _stream.fd();
+ return _delegate.fd();
}
@Override
public void setReadyCallback(IceInternal.ReadyCallback callback)
{
_readyCallback = callback;
+ _delegate.setReadyCallback(callback);
}
@Override
public int initialize(IceInternal.Buffer readBuffer, IceInternal.Buffer writeBuffer)
{
- int status = _stream.connect(readBuffer, writeBuffer);
- if(status != IceInternal.SocketOperation.None)
+ if(!_isConnected)
{
- return status;
+ int status = _delegate.initialize(readBuffer, writeBuffer);
+ if(status != IceInternal.SocketOperation.None)
+ {
+ return status;
+ }
+ _isConnected = true;
+
+ Ice.IPConnectionInfo ipInfo = null;
+ for(Ice.ConnectionInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ ipInfo = (Ice.IPConnectionInfo)p;
+ }
+ }
+ final String host = _incoming ? (ipInfo != null ? ipInfo.remoteAddress : "") : _host;
+ final int port = ipInfo != null ? ipInfo.remotePort : -1;
+ _engine = _instance.createSSLEngine(_incoming, host, port);
+ _appInput = ByteBuffer.allocateDirect(_engine.getSession().getApplicationBufferSize() * 2);
+ int bufSize = _engine.getSession().getPacketBufferSize() * 2;
+ _netInput = new IceInternal.Buffer(ByteBuffer.allocateDirect(bufSize * 2));
+ _netOutput = new IceInternal.Buffer(ByteBuffer.allocateDirect(bufSize * 2));
}
- status = handshakeNonBlocking();
+ int status = handshakeNonBlocking();
if(status != IceInternal.SocketOperation.None)
{
return status;
@@ -45,11 +66,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// Additional verification.
//
- _instance.verifyPeer((NativeConnectionInfo)getInfo(), _stream.fd(), _host);
+ _instance.verifyPeer(_host, (NativeConnectionInfo)getInfo(), _delegate.toString());
if(_instance.securityTraceLevel() >= 1)
{
- _instance.traceConnection(_stream.fd(), _engine, _incoming);
+ _instance.traceConnection(_delegate.toString(), _engine, _incoming);
}
return IceInternal.SocketOperation.None;
}
@@ -65,7 +86,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public void close()
{
- if(_stream.isConnected())
+ if(_isConnected)
{
try
{
@@ -73,10 +94,10 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// Send the close_notify message.
//
_engine.closeOutbound();
- _netOutput.clear();
+ _netOutput.b.clear();
while(!_engine.isOutboundDone())
{
- _engine.wrap(_emptyBuffer, _netOutput);
+ _engine.wrap(_emptyBuffer, _netOutput.b);
try
{
//
@@ -120,7 +141,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
}
- _stream.close();
+ _delegate.close();
}
@Override
@@ -133,9 +154,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public int write(IceInternal.Buffer buf)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.write(buf);
+ return _delegate.write(buf);
}
int status = writeNonBlocking(buf.b);
@@ -146,13 +167,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public int read(IceInternal.Buffer buf)
{
- _readyCallback.ready(IceInternal.SocketOperation.Read, false);
-
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.read(buf);
+ return _delegate.read(buf);
}
+ _readyCallback.ready(IceInternal.SocketOperation.Read, false);
+
//
// Try to satisfy the request from data we've already decrypted.
//
@@ -167,9 +188,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
{
while(buf.b.hasRemaining())
{
- _netInput.flip();
- SSLEngineResult result = _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ SSLEngineResult result = _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
Status status = result.getStatus();
assert status != Status.BUFFER_OVERFLOW;
@@ -180,11 +201,12 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
// Android API 21 SSLEngine doesn't report underflow, so look at the absence of
// network data and application data to signal a network read.
- else if(status == Status.BUFFER_UNDERFLOW || (_appInput.position() == 0 && _netInput.position() == 0))
+ else if(status == Status.BUFFER_UNDERFLOW || (_appInput.position() == 0 && _netInput.b.position() == 0))
{
- if(_stream.read(_netInput) == 0)
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == 0)
{
- return IceInternal.SocketOperation.Read;
+ return s;
}
continue;
}
@@ -196,9 +218,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// that the SSLEngine has no buffered data (Android R21 and greater only).
if(_appInput.position() == 0)
{
- _netInput.flip();
- _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
// Don't check the status here since we may have already filled
// the buffer with a complete request which must be processed.
@@ -212,7 +234,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// Indicate whether more data is available.
//
- if(_netInput.position() > 0 || _appInput.position() > 0)
+ if(_netInput.b.position() > 0 || _appInput.position() > 0)
{
_readyCallback.ready(IceInternal.SocketOperation.Read, true);
}
@@ -223,13 +245,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public String protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
@Override
public String toString()
{
- return _stream.toString();
+ return _delegate.toString();
}
@Override
@@ -242,81 +264,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
public Ice.ConnectionInfo getInfo()
{
NativeConnectionInfo info = new NativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- return info;
- }
-
- @Override
- public Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers)
- {
- WSSNativeConnectionInfo info = new WSSNativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- info.headers = headers; // Provided header is a copy so no need to clone here.
- return info;
- }
-
- @Override
- public void setBufferSize(int rcvSize, int sndSize)
- {
- _stream.setBufferSize(rcvSize, sndSize);
- }
-
- @Override
- public void checkSendSize(IceInternal.Buffer buf)
- {
- }
-
- TransceiverI(Instance instance, javax.net.ssl.SSLEngine engine, IceInternal.StreamSocket stream, String hostOrAdapterName,
- boolean incoming)
- {
- _instance = instance;
- _engine = engine;
- _appInput = ByteBuffer.allocateDirect(engine.getSession().getApplicationBufferSize() * 2);
- _netInput = ByteBuffer.allocateDirect(engine.getSession().getPacketBufferSize() * 2);
- _netOutput = ByteBuffer.allocateDirect(engine.getSession().getPacketBufferSize() * 2);
- _stream = stream;
- _incoming = incoming;
- if(_incoming)
- {
- _adapterName = hostOrAdapterName;
- }
- else
- {
- _host = hostOrAdapterName;
- }
- }
-
- private java.security.cert.Certificate[] fillConnectionInfo(ConnectionInfo info)
- {
- //
- // This can only be called on an open transceiver.
- //
- java.security.cert.Certificate[] nativeCerts = null;
- if(_stream.fd() != null)
+ info.underlying = _delegate.getInfo();
+ info.incoming = _incoming;
+ info.adapterName = _adapterName;
+ if(_engine != null)
{
- java.net.Socket socket = _stream.fd().socket();
- //
- // On some platforms (e.g., early Android releases), sockets don't
- // correctly return address information.
- //
- if(socket.getLocalAddress() != null)
- {
- info.localAddress = socket.getLocalAddress().getHostAddress();
- info.localPort = socket.getLocalPort();
- }
-
- if(socket.getInetAddress() != null)
- {
- info.remoteAddress = socket.getInetAddress().getHostAddress();
- info.remotePort = socket.getPort();
- }
-
- if(!socket.isClosed())
- {
- info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd());
- info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd());
- }
-
SSLSession session = _engine.getSession();
info.cipher = session.getCipherSuite();
try
@@ -324,9 +276,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
java.security.cert.Certificate[] pcerts = session.getPeerCertificates();
java.security.cert.Certificate[] vcerts = _instance.engine().getVerifiedCertificateChain(pcerts);
info.verified = vcerts != null;
- nativeCerts = vcerts != null ? vcerts : pcerts;
+ info.nativeCerts = vcerts != null ? vcerts : pcerts;
java.util.ArrayList<String> certs = new java.util.ArrayList<String>();
- for(java.security.cert.Certificate c : nativeCerts)
+ for(java.security.cert.Certificate c : info.nativeCerts)
{
StringBuilder s = new StringBuilder("-----BEGIN CERTIFICATE-----\n");
s.append(IceUtilInternal.Base64.encode(c.getEncoded()));
@@ -343,9 +295,34 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
{
}
}
- info.adapterName = _adapterName;
- info.incoming = _incoming;
- return nativeCerts;
+ return info;
+ }
+
+ @Override
+ public void setBufferSize(int rcvSize, int sndSize)
+ {
+ _delegate.setBufferSize(rcvSize, sndSize);
+ }
+
+ @Override
+ public void checkSendSize(IceInternal.Buffer buf)
+ {
+ _delegate.checkSendSize(buf);
+ }
+
+ TransceiverI(Instance instance, IceInternal.Transceiver delegate, String hostOrAdapterName, boolean incoming)
+ {
+ _instance = instance;
+ _delegate = delegate;
+ _incoming = incoming;
+ if(_incoming)
+ {
+ _adapterName = hostOrAdapterName;
+ }
+ else
+ {
+ _host = hostOrAdapterName;
+ }
}
private int handshakeNonBlocking()
@@ -375,9 +352,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
case NEED_UNWRAP:
{
- if(_netInput.position() == 0 && _stream.read(_netInput) == 0)
+ if(_netInput.b.position() == 0)
{
- return IceInternal.SocketOperation.Read;
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == 0)
+ {
+ return s;
+ }
}
//
@@ -385,9 +366,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// the _netInput buffer to satisfy the engine. If not, the engine
// responds with BUFFER_UNDERFLOW and we'll read from the socket.
//
- _netInput.flip();
- result = _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ result = _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
//
// FINISHED is only returned from wrap or unwrap, not from engine.getHandshakeResult().
//
@@ -402,9 +383,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
case BUFFER_UNDERFLOW:
{
assert(status == javax.net.ssl.SSLEngineResult.HandshakeStatus.NEED_UNWRAP);
- if(_stream.read(_netInput) == 0)
+ int position = _netInput.b.position();
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == position)
{
- return IceInternal.SocketOperation.Read;
+ return s;
}
break;
}
@@ -424,10 +407,14 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// The engine needs to send a message.
//
- result = _engine.wrap(_emptyBuffer, _netOutput);
- if(result.bytesProduced() > 0 && !flushNonBlocking())
+ result = _engine.wrap(_emptyBuffer, _netOutput.b);
+ if(result.bytesProduced() > 0)
{
- return IceInternal.SocketOperation.Write;
+ int s = flushNonBlocking();
+ if(s != IceInternal.SocketOperation.None)
+ {
+ return s;
+ }
}
//
@@ -473,19 +460,19 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
try
{
- while(buf.hasRemaining() || _netOutput.position() > 0)
+ while(buf.hasRemaining() || _netOutput.b.position() > 0)
{
if(buf.hasRemaining())
{
//
// Encrypt the buffer.
//
- SSLEngineResult result = _engine.wrap(buf, _netOutput);
+ SSLEngineResult result = _engine.wrap(buf, _netOutput.b);
switch(result.getStatus())
{
case BUFFER_OVERFLOW:
//
- // Need to make room in _netOutput.
+ // Need to make room in _netOutput.b.
//
break;
case BUFFER_UNDERFLOW:
@@ -503,9 +490,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// all of _netOutput, or until flushNonBlocking indicates that it cannot write
// (i.e., by returning SocketOperation.Write).
//
- if(_netOutput.position() > 0 && !flushNonBlocking())
+ if(_netOutput.b.position() > 0)
{
- return IceInternal.SocketOperation.Write;
+ int s = flushNonBlocking();
+ if(s != IceInternal.SocketOperation.None)
+ {
+ return s;
+ }
}
}
}
@@ -514,33 +505,29 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
throw new Ice.SecurityException("IceSSL: error while encoding message", ex);
}
- assert(_netOutput.position() == 0);
+ assert(_netOutput.b.position() == 0);
return IceInternal.SocketOperation.None;
}
- private boolean flushNonBlocking()
+ private int flushNonBlocking()
{
- _netOutput.flip();
+ _netOutput.b.flip();
try
{
- _stream.write(_netOutput);
+ int s = _delegate.write(_netOutput);
+ if(s != IceInternal.SocketOperation.None)
+ {
+ _netOutput.b.compact();
+ return s;
+ }
}
catch(Ice.SocketException ex)
{
throw new Ice.ConnectionLostException(ex);
}
-
- if(_netOutput.hasRemaining())
- {
- _netOutput.compact();
- return false;
- }
- else
- {
- _netOutput.clear();
- return true;
- }
+ _netOutput.b.clear();
+ return IceInternal.SocketOperation.None;
}
private void fill(ByteBuffer buf)
@@ -586,15 +573,16 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
private Instance _instance;
- private IceInternal.StreamSocket _stream;
+ private IceInternal.Transceiver _delegate;
private javax.net.ssl.SSLEngine _engine;
private String _host = "";
private String _adapterName = "";
private boolean _incoming;
private IceInternal.ReadyCallback _readyCallback;
+ private boolean _isConnected = false;
private ByteBuffer _appInput; // Holds clear-text data to be read by the application.
- private ByteBuffer _netInput; // Holds encrypted data read from the socket.
- private ByteBuffer _netOutput; // Holds encrypted data to be written to the socket.
+ private IceInternal.Buffer _netInput; // Holds encrypted data read from the socket.
+ private IceInternal.Buffer _netOutput; // Holds encrypted data to be written to the socket.
private static ByteBuffer _emptyBuffer = ByteBuffer.allocate(0); // Used during handshaking.
}
diff --git a/java/src/Ice/src/main/java/IceSSL/TrustManager.java b/java/src/Ice/src/main/java/IceSSL/TrustManager.java
index 4dde5cb6fce..ba17851dee8 100644
--- a/java/src/Ice/src/main/java/IceSSL/TrustManager.java
+++ b/java/src/Ice/src/main/java/IceSSL/TrustManager.java
@@ -55,7 +55,7 @@ class TrustManager
}
boolean
- verify(NativeConnectionInfo info)
+ verify(NativeConnectionInfo info, String desc)
{
java.util.List<java.util.List<java.util.List<RFC2253.RDNPair> > >
reject = new java.util.LinkedList<java.util.List<java.util.List<RFC2253.RDNPair> > >(),
@@ -143,15 +143,12 @@ class TrustManager
_communicator.getLogger().trace("Security", "trust manager evaluating client:\n" +
"subject = " + subjectName + "\n" +
"adapter = " + info.adapterName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ desc);
}
else
{
_communicator.getLogger().trace("Security", "trust manager evaluating server:\n" +
- "subject = " + subjectName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ "subject = " + subjectName + "\n" + desc);
}
}
java.util.List<RFC2253.RDNPair> dn = RFC2253.parseStrict(subjectName);
diff --git a/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java b/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java
deleted file mode 100644
index 6c165f7f0f0..00000000000
--- a/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package IceSSL;
-
-/**
- *
- * This class is a native extension of the Slice local class
- * IceSSL::WSSConnectionInfo. It provides access to the native
- * Java certificates.
- *
- **/
-public class WSSNativeConnectionInfo extends WSSConnectionInfo
-{
- /**
- * The certificate chain. This may be null if the peer did not
- * supply a certificate. The peer's certificate (if any) is the
- * first one in the chain.
- **/
- public java.security.cert.Certificate[] nativeCerts;
-}
diff --git a/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java b/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
index 4f9fce5ec3a..5ffc5141907 100644
--- a/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
+++ b/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
@@ -50,9 +50,9 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, IceInternal.EndpointFactory del)
{
- return new EndpointFactoryI(new Instance(_instance.communicator(), instance.type(), instance.protocol()));
+ return new EndpointFactoryI(new Instance(_instance.communicator(), inst.type(), inst.protocol()));
}
private Instance _instance;
diff --git a/java/src/IceBT/src/main/java/IceBT/EndpointI.java b/java/src/IceBT/src/main/java/IceBT/EndpointI.java
index e9db453200f..7576f458fae 100644
--- a/java/src/IceBT/src/main/java/IceBT/EndpointI.java
+++ b/java/src/IceBT/src/main/java/IceBT/EndpointI.java
@@ -71,17 +71,15 @@ final class EndpointI extends IceInternal.EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
+ public void streamWriteImpl(Ice.OutputStream s)
{
//
// _name and _channel are not marshaled.
//
- s.startEncapsulation();
s.writeString(_addr);
s.writeString(_uuid.toString());
s.writeInt(_timeout);
s.writeBool(_compress);
- s.endEncapsulation();
}
@Override
diff --git a/java/src/IceBT/src/main/java/IceBT/PluginI.java b/java/src/IceBT/src/main/java/IceBT/PluginI.java
index 635071c17e4..b2d0f8b17cf 100644
--- a/java/src/IceBT/src/main/java/IceBT/PluginI.java
+++ b/java/src/IceBT/src/main/java/IceBT/PluginI.java
@@ -20,7 +20,7 @@ class PluginI implements Ice.Plugin
// in initialize, because the communicator may need to interpret
// proxies before the plug-in is fully initialized.
//
- EndpointFactoryI factory = new EndpointFactoryI(new Instance(communicator, EndpointType.value, "bt"));
+ EndpointFactoryI factory = new EndpointFactoryI(new Instance(communicator, Ice.BTEndpointType.value, "bt"));
facade.addEndpointFactory(factory);
}
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
index 5c0e854c4e9..30d5e204a2d 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
@@ -1498,32 +1498,45 @@ public class Coordinator
validDate = false;
}
+ String remoteAddress = null;
+ for(Ice.ConnectionInfo p = info.underlying; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ remoteAddress = ((Ice.IPConnectionInfo)p).remoteAddress;
+ break;
+ }
+ }
+
//
// Check server alternate names match the connection remote address
//
- try
+ if(remoteAddress != null)
{
- Collection<java.util.List<?>> altNames = cert.getSubjectAlternativeNames();
- if(altNames != null)
+ try
{
- for(java.util.List<?> l : altNames)
+ Collection<java.util.List<?>> altNames = cert.getSubjectAlternativeNames();
+ if(altNames != null)
{
- Integer kind = (Integer)l.get(0);
- if(kind != 2 && kind != 7)
- {
- continue;
- }
- if(info.remoteAddress.equalsIgnoreCase(l.get(1).toString()))
+ for(java.util.List<?> l : altNames)
{
- validAlternateName = true;
- break;
+ Integer kind = (Integer)l.get(0);
+ if(kind != 2 && kind != 7)
+ {
+ continue;
+ }
+ if(remoteAddress.equalsIgnoreCase(l.get(1).toString()))
+ {
+ validAlternateName = true;
+ break;
+ }
}
}
}
- }
- catch(java.security.cert.CertificateParsingException ex)
- {
- validAlternateName = false;
+ catch(java.security.cert.CertificateParsingException ex)
+ {
+ validAlternateName = false;
+ }
}
//