org.opends.server.protocols.internal
Class InternalLDAPSocket

java.lang.Object
  extended by java.net.Socket
      extended by org.opends.server.protocols.internal.InternalLDAPSocket

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class InternalLDAPSocket
extends java.net.Socket

This class provides an implementation of a java.net.Socket object that can be used to facilitate internal communication with the Directory Server through third-party LDAP APIs that provide the ability to use a custom socket factory when creating connections. Whenever data is written over the socket, it is decoded as LDAP communication and converted to an appropriate internal operation, which the server then processes and converts the response back to an LDAP encoding.

Note that this implementation only supports those operations which can be performed in the Directory Server via internal operations. This includes add, compare, delete, modify, modify DN, and search operations, and some types of extended operations. Special support has been added for simple bind operations to function properly, but SASL binds are not supported. Abandon and unbind operations are not supported, nor are the cancel or StartTLS extended operations. Only clear-text LDAP communication may be used.


Constructor Summary
InternalLDAPSocket()
          Creates a new internal LDAP socket.
 
Method Summary
 void bind(java.net.SocketAddress bindpoint)
          Binds the socket to a local address.
 void close()
          Closes this socket.
 void connect(java.net.SocketAddress endpoint)
          Connects this socket to the specified remote endpoint.
 void connect(java.net.SocketAddress endpoint, int timeout)
          Connects this socket to the specified remote endpoint.
 java.nio.channels.SocketChannel getChannel()
          Retrieves the socket channel associated with this socket.
 java.net.InetAddress getInetAddress()
          Retrieves the address to which this socket is connected.
 InternalLDAPInputStream getInputStream()
          Retrieves the input stream for this socket.
 boolean getKeepAlive()
          Indicates whether SO_KEEPALIVE is enabled.
 java.net.InetAddress getLocalAddress()
          Retrieves the local address to which this socket is bound.
 int getLocalPort()
          Retrieves the local port to which this socket is bound.
 java.net.SocketAddress getLocalSocketAddress()
          Retrieves the local socket address to which this socket is bound.
 boolean getOOBInline()
          Indicates whether OOBINLINE is enabled.
 InternalLDAPOutputStream getOutputStream()
          Retrieves the output stream for this socket.
 int getPort()
          Retrieves the remote port to which this socket is connected.
 int getReceiveBufferSize()
          Retrieves the value of the SO_RCVBUF option for this socket.
 java.net.SocketAddress getRemoteSocketAddress()
          Retrieves the remote socket address to which this socket is connected.
 boolean getReuseAddress()
          Indicates whether SO_REUSEADDR is enabled.
 int getSendBufferSize()
          Retrieves the value of the SO_SNDBUF option for this socket.
 int getSoLinger()
          Retrieves the value of the SO_LINGER option for this socket.
 int getSoTimeout()
          Retrieves the value of the SO_TIMEOUT option for this socket.
 boolean getTcpNoDelay()
          Indicates whether TCP_NODELAY is enabled.
 int getTrafficClass()
          Retrieves the traffic class for this socket.
 boolean isBound()
          Indicates whether this socket is bound to a local address.
 boolean isClosed()
          Indicates whether this socket is closed.
 boolean isConnected()
          Indicates whether this socket is connected to both local and remote endpoints.
 boolean isInputShutdown()
          Indicates whether the input side of this socket has been closed.
 boolean isOutputShutdown()
          Indicates whether the output side of this socket has been closed.
 void sendUrgentData(int data)
          Sends a single byte of urgent data over this socket.
 void setKeepAlive(boolean on)
          Sets the value of SO_KEEPALIVE for this socket.
 void setOOBInline(boolean on)
          Sets the value of OOBINLINE for this socket.
 void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
          Sets the provided performance preferences for this socket.
 void setReceiveBufferSize(int size)
          Sets the value of SO_RCVBUF for this socket.
 void setReuseAddress(boolean on)
          Sets the value of SO_REUSEADDR for this socket.
 void setSendBufferSize(int size)
          Sets the value of SO_SNDBUF for this socket.
 void setSoLinger(boolean on, int linger)
          Sets the value of SO_LINGER for this socket.
 void setSoTimeout(int timeout)
          Sets the value of SO_TIMEOUT for this socket.
 void setTcpNoDelay(boolean on)
          Sets the value of TCP_NODELAY for this socket.
 void setTrafficClass(int tc)
          Sets the traffic class for this socket.
 void shutdownInput()
          Shuts down the input side of this socket.
 void shutdownOutput()
          Shuts down the output side of this socket.
 java.lang.String toString()
          Retrieves a string representation of this internal LDAP socket.
 
Methods inherited from class java.net.Socket
setSocketImplFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InternalLDAPSocket

public InternalLDAPSocket()
Creates a new internal LDAP socket.

Method Detail

bind

public void bind(java.net.SocketAddress bindpoint)
Binds the socket to a local address. This does nothing, since there is no actual network communication performed by this socket implementation.

Overrides:
bind in class java.net.Socket
Parameters:
bindpoint - The socket address to which to bind.

close

public void close()
Closes this socket. This will make it unavailable for use.

Overrides:
close in class java.net.Socket

connect

public void connect(java.net.SocketAddress endpoint)
Connects this socket to the specified remote endpoint. This will make the connection available again if it has been previously closed. The provided address is irrelevant, as it will always be an internal connection.

Overrides:
connect in class java.net.Socket
Parameters:
endpoint - The address of the remote endpoint.

connect

public void connect(java.net.SocketAddress endpoint,
                    int timeout)
Connects this socket to the specified remote endpoint. This does nothing, since there is no actual network communication performed by this socket implementation.

Overrides:
connect in class java.net.Socket
Parameters:
endpoint - The address of the remote endpoint.
timeout - The maximum length of time in milliseconds to wait for the connection to be established.

getChannel

public java.nio.channels.SocketChannel getChannel()
Retrieves the socket channel associated with this socket. This method always returns null since this implementation does not support use with NIO channels.

Overrides:
getChannel in class java.net.Socket
Returns:
null because this implementation does not support use with NIO channels.

getInetAddress

public java.net.InetAddress getInetAddress()
Retrieves the address to which this socket is connected. The address returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getInetAddress in class java.net.Socket
Returns:
The address to which this socket is connected.

getInputStream

public InternalLDAPInputStream getInputStream()
Retrieves the input stream for this socket.

Overrides:
getInputStream in class java.net.Socket
Returns:
The input stream for this socket.

getKeepAlive

public boolean getKeepAlive()
Indicates whether SO_KEEPALIVE is enabled. This implementation will return true by default, but if its value is changed using setKeepalive then that value will be returned. This setting has no effect in this socket implementation.

Overrides:
getKeepAlive in class java.net.Socket
Returns:
true if SO_KEEPALIVE is enabled, or false if not.

getLocalAddress

public java.net.InetAddress getLocalAddress()
Retrieves the local address to which this socket is bound. The address returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getLocalAddress in class java.net.Socket
Returns:
The local address to which this socket is bound.

getLocalPort

public int getLocalPort()
Retrieves the local port to which this socket is bound. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getLocalPort in class java.net.Socket
Returns:
The local port to which this socket is bound.

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
Retrieves the local socket address to which this socket is bound. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getLocalSocketAddress in class java.net.Socket
Returns:
The local socket address to which this socket is bound.

getOOBInline

public boolean getOOBInline()
Indicates whether OOBINLINE is enabled. This implementation will return true by default, but if its value is changed using setOOBInline then that value will be returned. This setting has no effect in this socket implementation.

Overrides:
getOOBInline in class java.net.Socket
Returns:
true if OOBINLINE is enabled, or false if it is not.

getOutputStream

public InternalLDAPOutputStream getOutputStream()
Retrieves the output stream for this socket.

Overrides:
getOutputStream in class java.net.Socket
Returns:
The output stream for this socket.

getPort

public int getPort()
Retrieves the remote port to which this socket is connected. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getPort in class java.net.Socket
Returns:
The remote port to which this socket is connected.

getReceiveBufferSize

public int getReceiveBufferSize()
Retrieves the value of the SO_RCVBUF option for this socket. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getReceiveBufferSize in class java.net.Socket
Returns:
The value of the SO_RCVBUF option for this socket.

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()
Retrieves the remote socket address to which this socket is connected. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getRemoteSocketAddress in class java.net.Socket
Returns:
The remote socket address to which this socket is connected.

getReuseAddress

public boolean getReuseAddress()
Indicates whether SO_REUSEADDR is enabled. This implementation will return true by default, but if its value is changed using setReuseAddress then that value will be returned. This setting has no effect in this socket implementation.

Overrides:
getReuseAddress in class java.net.Socket
Returns:
true if SO_REUSEADDR is enabled, or false if it is not.

getSendBufferSize

public int getSendBufferSize()
Retrieves the value of the SO_SNDBUF option for this socket. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getSendBufferSize in class java.net.Socket
Returns:
The value of the SO_SNDBUF option for this socket.

getSoLinger

public int getSoLinger()
Retrieves the value of the SO_LINGER option for this socket. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getSoLinger in class java.net.Socket
Returns:
The value of the SO_LINGER option for this socket.

getSoTimeout

public int getSoTimeout()
Retrieves the value of the SO_TIMEOUT option for this socket. The value returned is meaningless, since there is no actual network communication performed by this socket implementation.

Overrides:
getSoTimeout in class java.net.Socket
Returns:
The value of the SO_TIMEOUT option for this socket.

getTcpNoDelay

public boolean getTcpNoDelay()
Indicates whether TCP_NODELAY is enabled. This implementation will return true by default, but if its value is changed using setTcpNoDelay then that value will be returned. This setting has no effect in this socket implementation.

Overrides:
getTcpNoDelay in class java.net.Socket
Returns:
true if TCP_NODELAY is enabled, or false if it is not.

getTrafficClass

public int getTrafficClass()
Retrieves the traffic class for this socket. The value returned will be meaningless, since there is no actual network communication performed by this socket.

Overrides:
getTrafficClass in class java.net.Socket
Returns:
The traffic class for this socket.

isBound

public boolean isBound()
Indicates whether this socket is bound to a local address. This method will always return true to indicate that it is bound.

Overrides:
isBound in class java.net.Socket
Returns:
true to indicate that the socket is bound to a local address.

isClosed

public boolean isClosed()
Indicates whether this socket is closed. This method will always return false to indicate that it is not closed.

Overrides:
isClosed in class java.net.Socket
Returns:
false to indicate that the socket is not closed.

isConnected

public boolean isConnected()
Indicates whether this socket is connected to both local and remote endpoints. This method will always return true to indicate that it is connected.

Overrides:
isConnected in class java.net.Socket
Returns:
true to indicate that the socket is connected.

isInputShutdown

public boolean isInputShutdown()
Indicates whether the input side of this socket has been closed. This method will always return false to indicate that it is not closed.

Overrides:
isInputShutdown in class java.net.Socket
Returns:
false to indicate that the input side of this socket is not closed.

isOutputShutdown

public boolean isOutputShutdown()
Indicates whether the output side of this socket has been closed. This method will always return false to indicate that it is not closed.

Overrides:
isOutputShutdown in class java.net.Socket
Returns:
false to indicate that the output side of this socket is not closed.

sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
Sends a single byte of urgent data over this socket.

Overrides:
sendUrgentData in class java.net.Socket
Parameters:
data - The data to be sent.
Throws:
java.io.IOException - If a problem occurs while trying to write the provided data over this socket.

setKeepAlive

public void setKeepAlive(boolean on)
Sets the value of SO_KEEPALIVE for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setKeepAlive in class java.net.Socket
Parameters:
on - The value to use for the SO_KEEPALIVE option.

setOOBInline

public void setOOBInline(boolean on)
Sets the value of OOBINLINE for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setOOBInline in class java.net.Socket
Parameters:
on - The value to use for the OOBINLINE option.

setPerformancePreferences

public void setPerformancePreferences(int connectionTime,
                                      int latency,
                                      int bandwidth)
Sets the provided performance preferences for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setPerformancePreferences in class java.net.Socket
Parameters:
connectionTime - An int expressing the relative importance of a short connection time.
latency - An int expressing the relative importance of low latency.
bandwidth - An int expressing the relative importance of high bandwidth.

setReceiveBufferSize

public void setReceiveBufferSize(int size)
Sets the value of SO_RCVBUF for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setReceiveBufferSize in class java.net.Socket
Parameters:
size - The value to use for the SO_RCVBUF option.

setReuseAddress

public void setReuseAddress(boolean on)
Sets the value of SO_REUSEADDR for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setReuseAddress in class java.net.Socket
Parameters:
on - The value to use for the SO_REUSEADDR option.

setSendBufferSize

public void setSendBufferSize(int size)
Sets the value of SO_SNDBUF for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setSendBufferSize in class java.net.Socket
Parameters:
size - The value to use for the SO_SNDBUF option.

setSoLinger

public void setSoLinger(boolean on,
                        int linger)
Sets the value of SO_LINGER for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setSoLinger in class java.net.Socket
Parameters:
on - Indicates whether to enable the linger option.
linger - The length of time in milliseconds to allow the connection to linger.

setSoTimeout

public void setSoTimeout(int timeout)
Sets the value of SO_TIMEOUT for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setSoTimeout in class java.net.Socket
Parameters:
timeout - The value to use for the SO_TIMEOUT option.

setTcpNoDelay

public void setTcpNoDelay(boolean on)
Sets the value of TCP_NODELAY for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setTcpNoDelay in class java.net.Socket
Parameters:
on - The value to use for the TCP_NODELAY option.

setTrafficClass

public void setTrafficClass(int tc)
Sets the traffic class for this socket. This will not affect anything, since there is no actual network communication performed by this socket.

Overrides:
setTrafficClass in class java.net.Socket
Parameters:
tc - The value to use for the traffic class.

shutdownInput

public void shutdownInput()
Shuts down the input side of this socket. This will have the effect of closing the entire socket.

Overrides:
shutdownInput in class java.net.Socket

shutdownOutput

public void shutdownOutput()
Shuts down the output side of this socket. This will have the effect of closing the entire socket.

Overrides:
shutdownOutput in class java.net.Socket

toString

public java.lang.String toString()
Retrieves a string representation of this internal LDAP socket.

Overrides:
toString in class java.net.Socket
Returns:
A string representation of this internal LDAP socket.