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
SessionConfigurationException
public void configure(SessionProperties properties) throws SessionConfigurationException
configure
in interface Session
properties
- Properties as defined in the SessionProperties
interface, which govern the behaviour of a Session.SessionConfigurationException
- Possible causes:
public boolean isInvalid()
Session
public boolean isOpen()
Session
public 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 Session
SessionOpenException
- 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
Session
changePassword
in interface Session
newPassword
- The new client password.SessionOpenException
public Greeting getGreeting()
Session
getGreeting
in interface Session
public void close()
Session
public java.lang.String read() throws java.io.IOException
public void read(Response response) throws java.io.IOException, ParsingException
Session
read
in interface Session
java.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
Session
readToDocument
in interface Session
java.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
Session
Command
instance. The XML representation
of the service element is obtained from the toXML method of the Command
instance.write
in interface Session
java.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)
StatsManager
StatsViewer.getCommandCount()
.incCommandCounter
in interface StatsManager
public void incResultCounter(int resultCode)
StatsManager
StatsViewer.getResultCodeCount(int)
.incResultCounter
in interface StatsManager
public void recordResponseTime(CommandType type, long responseTime)
StatsManager
recordResponseTime
in interface StatsManager
public long getAverageResponseTime()
StatsViewer
getAverageResponseTime
in interface StatsViewer
public long getAverageResponseTime(CommandType type)
StatsViewer
getAverageResponseTime
in interface StatsViewer
public long getCommandCount()
StatsViewer
getCommandCount
in interface StatsViewer
public long getCommandCount(CommandType type)
StatsViewer
getCommandCount
in interface StatsViewer
public int getRecentCommandCount()
StatsViewer
getRecentCommandCount
in interface StatsViewer
public int getRecentCommandCount(CommandType type)
StatsViewer
getRecentCommandCount
in interface StatsViewer
public long getResultCodeCount(int resultCode)
StatsViewer
getResultCodeCount
in interface StatsViewer
public long getMruInterval()
getMruInterval
in interface StatsViewer
public StatsManager getStatsManager()
Session
getStatsManager
in interface Session
public boolean isAvailable()
Session
acquire
would block.isAvailable
in interface Session
public void acquire() throws java.lang.InterruptedException, TimeoutException
Session
acquire
in interface Session
java.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()