summaryrefslogtreecommitdiff
path: root/java/ssl/jdk1.5/IceSSL/AcceptorI.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/ssl/jdk1.5/IceSSL/AcceptorI.java')
-rw-r--r--java/ssl/jdk1.5/IceSSL/AcceptorI.java432
1 files changed, 216 insertions, 216 deletions
diff --git a/java/ssl/jdk1.5/IceSSL/AcceptorI.java b/java/ssl/jdk1.5/IceSSL/AcceptorI.java
index ce4a1c804b7..80c95477a36 100644
--- a/java/ssl/jdk1.5/IceSSL/AcceptorI.java
+++ b/java/ssl/jdk1.5/IceSSL/AcceptorI.java
@@ -14,200 +14,200 @@ final class AcceptorI implements IceInternal.Acceptor
public java.nio.channels.ServerSocketChannel
fd()
{
- return _fd;
+ return _fd;
}
public void
close()
{
- if(_instance.networkTraceLevel() >= 1)
- {
- String s = "stopping to accept ssl connections at " + toString();
- _logger.trace(_instance.networkTraceCategory(), s);
- }
+ if(_instance.networkTraceLevel() >= 1)
+ {
+ String s = "stopping to accept ssl connections at " + toString();
+ _logger.trace(_instance.networkTraceCategory(), s);
+ }
- java.nio.channels.ServerSocketChannel fd;
- java.nio.channels.Selector selector;
- synchronized(this)
- {
- fd = _fd;
- selector = _selector;
- _fd = null;
- _selector = null;
- }
- if(fd != null)
- {
- try
- {
- fd.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- }
- if(selector != null)
- {
- try
- {
- selector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- }
+ java.nio.channels.ServerSocketChannel fd;
+ java.nio.channels.Selector selector;
+ synchronized(this)
+ {
+ fd = _fd;
+ selector = _selector;
+ _fd = null;
+ _selector = null;
+ }
+ if(fd != null)
+ {
+ try
+ {
+ fd.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ }
+ if(selector != null)
+ {
+ try
+ {
+ selector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ }
}
public void
listen()
{
- // Nothing to do.
+ // Nothing to do.
- if(_instance.networkTraceLevel() >= 1)
- {
- String s = "accepting ssl connections at " + toString();
- _logger.trace(_instance.networkTraceCategory(), s);
- }
+ if(_instance.networkTraceLevel() >= 1)
+ {
+ String s = "accepting ssl connections at " + toString();
+ _logger.trace(_instance.networkTraceCategory(), s);
+ }
}
public IceInternal.Transceiver
accept(int timeout)
{
- //
- // The plugin may not be fully initialized.
- //
- if(!_instance.initialized())
- {
- Ice.PluginInitializationException ex = new Ice.PluginInitializationException();
- ex.reason = "IceSSL: plugin is not initialized";
- throw ex;
- }
+ //
+ // The plugin may not be fully initialized.
+ //
+ if(!_instance.initialized())
+ {
+ Ice.PluginInitializationException ex = new Ice.PluginInitializationException();
+ ex.reason = "IceSSL: plugin is not initialized";
+ throw ex;
+ }
- java.nio.channels.SocketChannel fd = null;
- while(fd == null)
- {
- try
- {
- fd = _fd.accept();
- if(fd == null)
- {
- if(_selector == null)
- {
- _selector = java.nio.channels.Selector.open();
- }
+ java.nio.channels.SocketChannel fd = null;
+ while(fd == null)
+ {
+ try
+ {
+ fd = _fd.accept();
+ if(fd == null)
+ {
+ if(_selector == null)
+ {
+ _selector = java.nio.channels.Selector.open();
+ }
- while(true)
- {
- try
- {
- java.nio.channels.SelectionKey key =
- _fd.register(_selector, java.nio.channels.SelectionKey.OP_ACCEPT);
- if(timeout > 0)
- {
- if(_selector.select(timeout) == 0)
- {
- throw new Ice.TimeoutException();
- }
- }
- else if(timeout == 0)
- {
- if(_selector.selectNow() == 0)
- {
- throw new Ice.TimeoutException();
- }
- }
- else
- {
- _selector.select();
- }
+ while(true)
+ {
+ try
+ {
+ java.nio.channels.SelectionKey key =
+ _fd.register(_selector, java.nio.channels.SelectionKey.OP_ACCEPT);
+ if(timeout > 0)
+ {
+ if(_selector.select(timeout) == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else if(timeout == 0)
+ {
+ if(_selector.selectNow() == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else
+ {
+ _selector.select();
+ }
- break;
- }
- catch(java.io.IOException ex)
- {
- if(IceInternal.Network.interrupted(ex))
- {
- continue;
- }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
- }
- }
- catch(java.io.IOException ex)
- {
- if(IceInternal.Network.interrupted(ex))
- {
- continue;
- }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
+ break;
+ }
+ catch(java.io.IOException ex)
+ {
+ if(IceInternal.Network.interrupted(ex))
+ {
+ continue;
+ }
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ if(IceInternal.Network.interrupted(ex))
+ {
+ continue;
+ }
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
- //
- // Check whether this socket is the result of a call to connectToSelf.
- // Despite the fact that connectToSelf immediately closes the socket,
- // the server-side handshake process does not raise an exception.
- // Furthermore, we can't simply proceed with the regular handshake
- // process because we don't want to pass such a socket to the
- // certificate verifier (if any).
- //
- // In order to detect a call to connectToSelf, we compare the remote
- // address of the newly-accepted socket to that in _connectToSelfAddr.
- //
- java.net.SocketAddress remoteAddr = fd.socket().getRemoteSocketAddress();
- synchronized(this)
- {
- if(remoteAddr.equals(_connectToSelfAddr))
- {
- try
- {
- fd.close();
- }
- catch(java.io.IOException e)
- {
- }
- return null;
- }
- }
+ //
+ // Check whether this socket is the result of a call to connectToSelf.
+ // Despite the fact that connectToSelf immediately closes the socket,
+ // the server-side handshake process does not raise an exception.
+ // Furthermore, we can't simply proceed with the regular handshake
+ // process because we don't want to pass such a socket to the
+ // certificate verifier (if any).
+ //
+ // In order to detect a call to connectToSelf, we compare the remote
+ // address of the newly-accepted socket to that in _connectToSelfAddr.
+ //
+ java.net.SocketAddress remoteAddr = fd.socket().getRemoteSocketAddress();
+ synchronized(this)
+ {
+ if(remoteAddr.equals(_connectToSelfAddr))
+ {
+ try
+ {
+ fd.close();
+ }
+ catch(java.io.IOException e)
+ {
+ }
+ return null;
+ }
+ }
- javax.net.ssl.SSLEngine engine = null;
- try
- {
- try
- {
- java.net.Socket socket = fd.socket();
- socket.setTcpNoDelay(true);
- socket.setKeepAlive(true);
- }
- catch(java.io.IOException ex)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
+ javax.net.ssl.SSLEngine engine = null;
+ try
+ {
+ try
+ {
+ java.net.Socket socket = fd.socket();
+ socket.setTcpNoDelay(true);
+ socket.setKeepAlive(true);
+ }
+ catch(java.io.IOException ex)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
- IceInternal.Network.setBlock(fd, false);
+ IceInternal.Network.setBlock(fd, false);
- engine = _instance.createSSLEngine(true);
- }
- catch(RuntimeException ex)
- {
- try
- {
- fd.close();
- }
- catch(java.io.IOException e)
- {
- // Ignore.
- }
- throw ex;
- }
+ engine = _instance.createSSLEngine(true);
+ }
+ catch(RuntimeException ex)
+ {
+ try
+ {
+ fd.close();
+ }
+ catch(java.io.IOException e)
+ {
+ // Ignore.
+ }
+ throw ex;
+ }
if(_instance.networkTraceLevel() >= 1)
{
@@ -215,84 +215,84 @@ final class AcceptorI implements IceInternal.Acceptor
IceInternal.Network.fdToString(fd));
}
- return new TransceiverI(_instance, engine, fd, "", true, _adapterName);
+ return new TransceiverI(_instance, engine, fd, "", true, _adapterName);
}
public void
connectToSelf()
{
- java.nio.channels.SocketChannel fd = IceInternal.Network.createTcpSocket();
- IceInternal.Network.setBlock(fd, false);
- synchronized(this)
- {
- //
- // connectToSelf is called to wake up the thread blocked in
- // accept. We remember the originating address for use in
- // accept. See accept for details.
- //
- IceInternal.Network.doConnect(fd, _addr, -1);
- _connectToSelfAddr = (java.net.InetSocketAddress)fd.socket().getLocalSocketAddress();
- }
- IceInternal.Network.closeSocket(fd);
+ java.nio.channels.SocketChannel fd = IceInternal.Network.createTcpSocket();
+ IceInternal.Network.setBlock(fd, false);
+ synchronized(this)
+ {
+ //
+ // connectToSelf is called to wake up the thread blocked in
+ // accept. We remember the originating address for use in
+ // accept. See accept for details.
+ //
+ IceInternal.Network.doConnect(fd, _addr, -1);
+ _connectToSelfAddr = (java.net.InetSocketAddress)fd.socket().getLocalSocketAddress();
+ }
+ IceInternal.Network.closeSocket(fd);
}
public String
toString()
{
- return IceInternal.Network.addrToString(_addr);
+ return IceInternal.Network.addrToString(_addr);
}
final boolean
equivalent(String host, int port)
{
- java.net.InetSocketAddress addr = IceInternal.Network.getAddress(host, port);
- return addr.equals(_addr);
+ java.net.InetSocketAddress addr = IceInternal.Network.getAddress(host, port);
+ return addr.equals(_addr);
}
int
effectivePort()
{
- return _addr.getPort();
+ return _addr.getPort();
}
AcceptorI(Instance instance, String adapterName, String host, int port)
{
- _instance = instance;
- _adapterName = adapterName;
- _logger = instance.communicator().getLogger();
- _backlog = 0;
+ _instance = instance;
+ _adapterName = adapterName;
+ _logger = instance.communicator().getLogger();
+ _backlog = 0;
- if(_backlog <= 0)
- {
- _backlog = 5;
- }
+ if(_backlog <= 0)
+ {
+ _backlog = 5;
+ }
- try
- {
- _fd = IceInternal.Network.createTcpServerSocket();
- IceInternal.Network.setBlock(_fd, false);
- _addr = new java.net.InetSocketAddress(host, port);
- if(_instance.networkTraceLevel() >= 2)
- {
- String s = "attempting to bind to ssl socket " + toString();
- _logger.trace(_instance.networkTraceCategory(), s);
- }
- _addr = IceInternal.Network.doBind(_fd, _addr);
- }
- catch(RuntimeException ex)
- {
- _fd = null;
- throw ex;
- }
+ try
+ {
+ _fd = IceInternal.Network.createTcpServerSocket();
+ IceInternal.Network.setBlock(_fd, false);
+ _addr = new java.net.InetSocketAddress(host, port);
+ if(_instance.networkTraceLevel() >= 2)
+ {
+ String s = "attempting to bind to ssl socket " + toString();
+ _logger.trace(_instance.networkTraceCategory(), s);
+ }
+ _addr = IceInternal.Network.doBind(_fd, _addr);
+ }
+ catch(RuntimeException ex)
+ {
+ _fd = null;
+ throw ex;
+ }
}
protected synchronized void
finalize()
- throws Throwable
+ throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_fd == null);
+ IceUtil.Assert.FinalizerAssert(_fd == null);
- super.finalize();
+ super.finalize();
}
private Instance _instance;