public class TLSSession extends java.lang.Object implements Session, StatsManager
RFC5734 specifies a transport mapping for EPP over TCP; this class implements that mapping. That specification requires that the session is layered over TLS (Transport Layer Security). This class complies with RFC5734 in implementing the Session interface. It also implements its own StatsManager since it is tightly coupled with the Session implementation.
Uses the debug, support and user level loggers.
| Modifier | Constructor and Description |
|---|---|
protected |
TLSSession() |
protected |
TLSSession(SessionProperties props) |
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Acquire the session for exclusive use.
|
void |
changePassword(java.lang.String newPassword)
Change the client password to the given value.
|
void |
close()
EPP sessions are closed cleanly by sending an EPP logout command,
awaiting a response from the server, then acknowledging the close
of the underlying transport mechanism initiated by the server upon
completion of sending the logout response.
|
void |
configure(SessionProperties properties)
Configure the session as described in the Session interface.
|
long |
getAverageResponseTime()
Get the average response time (in milliseconds) of all transactions.
|
long |
getAverageResponseTime(CommandType type)
Get the average response time (in milliseconds) of transactions of the
given command type.
|
long |
getCommandCount()
Get the number of commands of the given type that the Session(s)
associated with this viewer has/have processed since creation.
|
long |
getCommandCount(CommandType type)
Get the total number of commands processed by Sessions associated with
this StatsViewer.
|
Greeting |
getGreeting()
EPP service discovery is implemented by the greeting service element.
|
long |
getMruInterval()
Get the length of time (in milliseconds) since the most recent use (mru) of the session.
|
int |
getRecentCommandCount()
Get the number of commands of the given type that the Session(s)
associated with this viewer has/have processed recently (default: 1
second).
|
int |
getRecentCommandCount(CommandType type)
Get the total number of commands recently processed by Sessions
associated with this StatsViewer.
|
long |
getResultCodeCount(int resultCode)
Get the number of responses received having the given result code.
|
StatsManager |
getStatsManager()
Get the StatsManager as described in the class documentation.
|
void |
incCommandCounter(CommandType type)
Increment the command count for the given command type.
|
void |
incResultCounter(int resultCode)
Increment the result count for the given code.
|
boolean |
isAvailable()
Determine whether a call to
acquire would block. |
boolean |
isInvalid()
Determine whether a call to read or write would result in an
IOException.
|
boolean |
isOpen()
Determine whether a call to open has previously succeeded.
|
void |
keepAlive()
Send a poll command to the EPP server in order to prevent the session timing out.
|
void |
open()
* An EPP session is opened by first establishing a connection using the server location information and
authentication sources provided in
configure, then issuing a login command with further
authentication data and options provided in configure. |
java.lang.String |
read()
Receive data from the peer.
|
void |
read(Response response)
Read a single EPP service element from the transport layer and assign
values to the attributes of the given Response instance appropriately,
according to the received XML document content.
|
XMLDocument |
readToDocument()
Read a single EPP service element from the transport layer, then
construct an XMLDocument instance from the element read.
|
void |
recordResponseTime(CommandType type,
long responseTime)
Record the time interval (in milliseconds) which elapsed between sending a command and receiving a response to
that command - that is, the response time of a transaction.
|
void |
release()
Release the Session for use by another user.
|
void |
write(Command command)
Write an EPP service element to the transport layer service, with the
intention of sending the command to the connected EPP server.
|
void |
write(java.lang.String xml)
Send data to peer.
|
protected TLSSession()
protected TLSSession(SessionProperties props) throws SessionConfigurationException
SessionConfigurationExceptionpublic void configure(SessionProperties properties) throws SessionConfigurationException
configure in interface Sessionproperties - Properties as defined in the SessionProperties
interface, which govern the behaviour of a Session.SessionConfigurationException - Possible causes:
public boolean isInvalid()
Sessionpublic boolean isOpen()
Sessionpublic void open()
throws SessionOpenException
configure, then issuing a login command with further
authentication data and options provided in configure. Service information provided immediately upon
connection establishment may affect options provided in the login command.open in interface SessionSessionOpenException - The getCause() method should be invoked on the exception thrown. The cause may be one of:
public void changePassword(java.lang.String newPassword)
throws SessionOpenException
SessionchangePassword in interface SessionnewPassword - The new client password.SessionOpenExceptionpublic Greeting getGreeting()
SessiongetGreeting in interface Sessionpublic void close()
Sessionpublic java.lang.String read()
throws java.io.IOException
public void read(Response response) throws java.io.IOException, ParsingException
Sessionread in interface Sessionjava.io.IOException - There was a failure in the transport layer in
attempting to receive data from the server. The cause of the exception
should be described in the exception message.ParsingException - The XML parser reported an error while trying
to construct an XMLDocument instance from the data received from the
server.public XMLDocument readToDocument() throws java.io.IOException, ParsingException
SessionreadToDocument in interface Sessionjava.io.IOException - There was a failure in the transport layer in
attempting to receive data from the server. The cause of the exception
should be described in the exception message.ParsingException - The XML parser reported an error while trying
to construct an XMLDocument instance from the data received from the
server.public void write(java.lang.String xml)
throws java.io.IOException
write(String).public void write(Command command) throws java.io.IOException, ParsingException
SessionCommand instance. The XML representation
of the service element is obtained from the toXML method of the Command
instance.write in interface Sessionjava.io.IOException - The transport layer was unable to send the data to
the server. This condition is considered permanent and causes the
session state to become invalid, as indicated by isInvalid.ParsingException - See the description of Command.toXML().public void keepAlive()
throws java.io.IOException
public void incCommandCounter(CommandType type)
StatsManagerStatsViewer.getCommandCount().incCommandCounter in interface StatsManagerpublic void incResultCounter(int resultCode)
StatsManagerStatsViewer.getResultCodeCount(int).incResultCounter in interface StatsManagerpublic void recordResponseTime(CommandType type, long responseTime)
StatsManagerrecordResponseTime in interface StatsManagerpublic long getAverageResponseTime()
StatsViewergetAverageResponseTime in interface StatsViewerpublic long getAverageResponseTime(CommandType type)
StatsViewergetAverageResponseTime in interface StatsViewerpublic long getCommandCount()
StatsViewergetCommandCount in interface StatsViewerpublic long getCommandCount(CommandType type)
StatsViewergetCommandCount in interface StatsViewerpublic int getRecentCommandCount()
StatsViewergetRecentCommandCount in interface StatsViewerpublic int getRecentCommandCount(CommandType type)
StatsViewergetRecentCommandCount in interface StatsViewerpublic long getResultCodeCount(int resultCode)
StatsViewergetResultCodeCount in interface StatsViewerpublic long getMruInterval()
getMruInterval in interface StatsViewerpublic StatsManager getStatsManager()
SessiongetStatsManager in interface Sessionpublic boolean isAvailable()
Sessionacquire would block.isAvailable in interface Sessionpublic void acquire()
throws java.lang.InterruptedException,
TimeoutException
Sessionacquire in interface Sessionjava.lang.InterruptedException - The thread was interrupted while waiting to
acquire the lock on the session.TimeoutException - The acquire timeout period elapsed while
waiting to acquire exclusive use of the session.SessionProperties.getAcquireTimeout()