public class EPPSession
extends java.lang.Object
EPPSession
manages a session with an EPP Server. An initialized
instance of EPPSession
is required for using any of the EPP
interface classes (i.e. EPPDomain
). EPPSession
can
invoke the following EPP operations:EPPGreeting
,
EPPResponse
Modifier and Type | Field and Description |
---|---|
static int |
MODE_ASYNC
Asynchronous mode contant in processing commands/responses, where for the
processDocument(EPPCommand) will send the command and will not
wait for the response. |
static int |
MODE_SYNC
Synchronous mode constant in processing commands/responses, where for each
command sent the
EPPSession will immediately read for the
response. |
protected java.lang.String |
msgID
Message identifier associated with a
EPPPollCmd.OP_ACK poll
command. |
protected java.lang.String |
myClientID
Client identifier to use in login.
|
protected EPPCodec |
myCodec
EPP Codec used to encode and decode EPP messages
|
protected EPPClientCon |
myConnection
Session connection
|
protected java.util.Vector |
myExtensionServices
EPP extension services
|
protected java.io.InputStream |
myInputStream
Session input stream
|
protected java.lang.String |
myLanguage
Override EPP language
|
protected EPPMessage |
myMessage
Message being sent
|
protected java.lang.String |
myNewPassword
New password to use
|
protected java.io.OutputStream |
myOutputStream
Session output stream
|
protected java.lang.String |
myPassword
Client password
|
protected java.lang.String |
myPollOp
Poll Operation Command
|
protected EPPResponse |
myResponse
EPP response associated with last EPP command
|
protected java.util.Vector |
myServices
EPP services
|
protected java.lang.String |
myTransId
Client transaction identifier
|
protected java.lang.String |
myVersion
Override EPP version
|
protected EPPXMLStream |
myXMLStream
Used to read and write XML packets from/to streams.
|
static java.lang.String |
OP_ACK
Poll operation type indicating that the client has received a message and
that the server can remove the message.
|
static java.lang.String |
OP_REQ
Poll operation type indicating that the client is requesting information
from the server.
|
Constructor and Description |
---|
EPPSession()
Construct and initialize a new instance of EPPSession using the host name
and port number defined in
EPPEnv . |
EPPSession(java.lang.String aHostName,
int aPortNumber)
Construct and initialize a new instance of EPPSession with a specific host
and port.
|
EPPSession(java.lang.String aHostName,
int aPortNumber,
EPPSSLContext aSSLContext)
Construct and initialize a new instance of EPPSession with a specific host
and port.
|
EPPSession(java.lang.String aHostName,
int aPortNumber,
java.lang.String aClientHostName)
Construct and initialize a new instance of EPPSession with a specific
server host, server port, client host name, and client port.
|
EPPSession(java.lang.String aHostName,
int aPortNumber,
java.lang.String aClientHostName,
EPPSSLContext aSSLContext)
Construct and initialize a new instance of EPPSession with a specific
server host, server port, client host name, and client port.
|
Modifier and Type | Method and Description |
---|---|
void |
endConnection()
Closes the connection with the server.
|
void |
endSession()
Ends a session by logging out from the server and closing the connection
with the server.
|
EPPClientCon |
getClientCon()
Gets the client connection used for the
EPPSession . |
java.lang.String |
getClientID()
Gets the client identifier/name used in
initSession . |
protected EPPClientCon |
getConnection()
Gets the client connection.
|
java.io.InputStream |
getInputStream()
Gets the session input stream.
|
int |
getMode()
Gets the command/response processing mode, which should be either
MODE_SYNC or MODE_ASYNC . |
java.lang.String |
getMsgID()
Gets the poll Message Id.
|
java.lang.String |
getnewPassword()
Gets the new client password used in
initSession . |
java.io.OutputStream |
getOutputStream()
Gets the session output stream.
|
java.lang.String |
getPassword()
Gets the client password used in
initSession . |
java.lang.String |
getPollOp()
Gets the poll operation, which should be either
OP_REQ or
OP_ACK |
EPPResponse |
getResponse()
Gets response associated with the last command.
|
java.lang.String |
getStatusCommandType()
Gets the status command type.
|
java.lang.String |
getStatusTransId()
Gets the status client transaction identifier.
|
java.lang.String |
getTransId()
Gets an optional client transaction identifier used when sending an EPP
command (i.e.
|
java.lang.String |
getVersion()
Gets the EPP version used in
initSession . |
EPPGreeting |
hello()
Sends a Hello Command to the EPP Server.
|
protected void |
init()
Initializes an
EPPSession using the default
EPPEnv properties, which will do the following:Gets concrete connection factory Makes connection to EPP Server Initialize the streams for XML processing EPPSession.initSession needs to be called to fully initialize
a session with the EPP Server. |
protected void |
init(java.lang.String aHostName,
int aPortNumber,
EPPSSLContext aSSLContext)
Initializes an
EPPSession to connect to a specific host and
port, which will do the following:Gets concrete connection factory Makes connection to EPP Server Initialize the streams for XML processing EPPSession.initSession needs to be called to fully initialize
a session with the EPP Server. |
protected void |
init(java.lang.String aHostName,
int aPortNumber,
java.lang.String aClientHostName,
EPPSSLContext aSSLContext)
Initializes an
EPPSession to connect to a specific server
host, server port from a specific client host name/IP address. which will
do the following:Gets concrete connection factory Makes connection to EPP Server Initialize the streams for XML processing EPPSession.initSession needs to be called to fully initialize
a session with the EPP Server. |
void |
initSession()
Initialize an authenticated session with the EPP Server.
|
protected void |
initStreams()
Initializes the input stream, output stream, and XML stream from the
previously initialized client connection (
myConnection ). |
boolean |
isModeSupported(int aMode)
Does the session support the specified mode
MODE_SYNC or
MODE_ASYNC ? |
protected void |
login()
This methods does a session login.
|
protected void |
logout()
logout from the session.
|
EPPResponse |
processDocument(EPPCommand aCommand)
Process an
EPPCommand instance by writing the command to the
session output stream and reading an EPPResponse instance
from the sessin input stream. |
EPPResponse |
processDocument(EPPCommand aCommand,
java.lang.Class aExpectedResponse)
Process an
EPPCommand instance by writing the command to the
session output stream and reading an EPPResponse instance
from the sessin input stream and validate that the
EPPResponse is of the specified type. |
EPPResponse |
readResponse()
Reads a response from the server.
|
org.w3c.dom.Document |
recDocument()
Gets an validated EPP DOM Document from the session input stream.
|
void |
sendDocument(org.w3c.dom.Document newDoc,
EPPMessage aMessage)
Sends an EPP DOM Document to the session output stream.
|
void |
sendMessage(EPPMessage aMessage)
Sends an EPP Message (command, hello, etc.) to the session output stream.
|
void |
sendPacket(byte[] aPacket)
Sends a pre-formatted packet to the
EPPSession output stream
as an EPP packet with the 4 byte header. |
EPPResponse |
sendPoll()
This method creates an instance of EPPPollCmd and sets the given
attributes and invokes the send method associated with the command.
|
void |
setClientID(java.lang.String newClientID)
Sets the client identifier/name used in
initSession . |
void |
setExtensions(java.util.Vector ProtocolExtensions,
java.util.Vector CommandResponseExtensions)
Set the Extension Services to use with this session by EPP XML namespace
URIs.
|
void |
setInputStream(java.io.InputStream newInput)
Sets the input stream for the session.
|
java.lang.String |
setLang()
Gets the language of "us" used by
initSession . |
void |
setLang(java.lang.String newLanguage)
Overrides the default language of "us" used by
initSession . |
int |
setMode(int aMode)
Sets the command/response processing mode to either
MODE_SYNC or
MODE_ASYNC . |
void |
setMsgID(java.lang.String aMsgID)
Sets the poll Message Id.
|
void |
setNewPassword(java.lang.String newPassword)
Sets the new client password used in
initSession . |
void |
setOutputStream(java.io.OutputStream newOutput)
Sets the output stream for the session.
|
void |
setPassword(java.lang.String newPassword)
Sets the client password used in
initSession . |
void |
setPollOp(java.lang.String aOp)
Sets the poll operation to either
OP_REQ or
OP_ACK |
void |
setServices(java.lang.String[] newServiceNS)
Set the services to use with this session by EPP XML namespace URIs.
|
void |
setStatusCommandType(java.lang.String aStatusCommandType)
Sets the status command type.
|
void |
setStatusTransId(java.lang.String aStatusTrans)
Sets the status client transaction identifier.
|
void |
setTransId(java.lang.String newTransId)
Sets an optional client transaction identifier used when sending an EPP
command (i.e.
|
void |
setVersion(java.lang.String newVersion)
Overrides the default EPP version used in
initSession . |
void |
validateClientTransId(EPPCommand myCommand,
EPPResponse myResponse)
Validates that the response client transaction identifier matches the
command's client transaction identifier.
|
public static final java.lang.String OP_REQ
public static final java.lang.String OP_ACK
public static final int MODE_SYNC
EPPSession
will immediately read for the
response. This is the default mode, but can be overridden with the
setMode(int)
method.public static final int MODE_ASYNC
processDocument(EPPCommand)
will send the command and will not
wait for the response. The client must call readResponse()
to
read the response. The mode can be set with the setMode(int)
method.protected EPPCodec myCodec
protected java.lang.String myTransId
protected java.lang.String myVersion
protected java.lang.String myLanguage
protected java.lang.String myClientID
protected java.lang.String myPassword
protected java.lang.String myNewPassword
protected EPPResponse myResponse
protected java.util.Vector myServices
protected java.util.Vector myExtensionServices
protected EPPClientCon myConnection
protected java.io.InputStream myInputStream
protected java.io.OutputStream myOutputStream
protected EPPXMLStream myXMLStream
protected java.lang.String myPollOp
protected EPPMessage myMessage
protected java.lang.String msgID
EPPPollCmd.OP_ACK
poll
command.public EPPSession() throws EPPCommandException
EPPEnv
.EPPCommandException
- Thrown if there's an error initializing the
EPPSession
public EPPSession(java.lang.String aHostName, int aPortNumber) throws EPPCommandException
aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toEPPCommandException
- Thrown if there's an error initializing the
EPPSession
public EPPSession(java.lang.String aHostName, int aPortNumber, java.lang.String aClientHostName) throws EPPCommandException
aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toaClientHostName
- Host name or IP address to connect fromEPPCommandException
- Thrown if there's an error initializing the
EPPSession
public EPPSession(java.lang.String aHostName, int aPortNumber, EPPSSLContext aSSLContext) throws EPPCommandException
aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toaSSLContext
- Optional specific SSL context to useEPPCommandException
- Thrown if there's an error initializing the
EPPSession
public EPPSession(java.lang.String aHostName, int aPortNumber, java.lang.String aClientHostName, EPPSSLContext aSSLContext) throws EPPCommandException
aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toaClientHostName
- Host name or IP address to connect fromaSSLContext
- Optional specific SSL context to useEPPCommandException
- Thrown if there's an error initializing the
EPPSession
protected void init() throws EPPCommandException
EPPSession
using the default
EPPEnv
properties, which will do the following:EPPSession.initSession
needs to be called to fully initialize
a session with the EPP Server.EPPCommandException
- Thrown if there's an error initializing the
EPPSession
protected void init(java.lang.String aHostName, int aPortNumber, EPPSSLContext aSSLContext) throws EPPCommandException
EPPSession
to connect to a specific host and
port, which will do the following:EPPSession.initSession
needs to be called to fully initialize
a session with the EPP Server.aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toaSSLContext
- Optional specific SSL context to useEPPCommandException
- Thrown if there's an error initializing the
EPPSession
protected void init(java.lang.String aHostName, int aPortNumber, java.lang.String aClientHostName, EPPSSLContext aSSLContext) throws EPPCommandException
EPPSession
to connect to a specific server
host, server port from a specific client host name/IP address. which will
do the following:EPPSession.initSession
needs to be called to fully initialize
a session with the EPP Server.aHostName
- Host name or IP address of host to connect toaPortNumber
- Port number to connect toaClientHostName
- Host name or IP address to connect fromaSSLContext
- Optional specific SSL context to useEPPCommandException
- Thrown if there's an error initializing the
EPPSession
protected EPPClientCon getConnection() throws EPPCommandException
initialize
methods of the returned connection.EPPCommandException
- Error creating the connectionprotected void initStreams() throws EPPCommandException
myConnection
).EPPCommandException
- Error initializing streamsprotected void login() throws EPPCommandException
EPPCommandException
- Error with loginpublic EPPGreeting hello() throws EPPCommandException
EPPCommandException
- Unexpected error informationpublic EPPResponse sendPoll() throws EPPCommandException
EPPCommandException
protected void logout() throws EPPCommandException
EPPCommandException
public void validateClientTransId(EPPCommand myCommand, EPPResponse myResponse) throws EPPCommandException
myCommand
- Command sentmyResponse
- Response receivedEPPCommandException
- transaction ids don't matchpublic org.w3c.dom.Document recDocument() throws EPPCommandException
Document
instance read from streamEPPCommandException
- Error reading document from streampublic void sendMessage(EPPMessage aMessage) throws EPPCommandException
readResponse()
or recDocument()
to read the response
if any from the session.aMessage
- EPP Message to send to the session output streamEPPCommandException
- Error encoding or sending EPP message to the session output
streampublic void sendDocument(org.w3c.dom.Document newDoc, EPPMessage aMessage) throws EPPCommandException
newDoc
- DOM Document
instance to write to streamaMessage
- Message associated with newDoc
that is used for
packet logging logic. Set to null
if unavailable.EPPCommandException
- Error writing document to streampublic void sendPacket(byte[] aPacket) throws EPPCommandException
EPPSession
output stream
as an EPP packet with the 4 byte header.aPacket
- Packet to send to the EPPSession
output streamEPPCommandException
- Error writing packet to the streampublic EPPResponse processDocument(EPPCommand aCommand) throws EPPCommandException
EPPCommand
instance by writing the command to the
session output stream and reading an EPPResponse
instance
from the sessin input stream.aCommand
- Command to write to output streamEPPCommandException
- error processing the command. This can include an error
specified from the server or encountered while attempting to
process the command. If the exception contains an
EPPResponse
than it was a server specified
error.public EPPResponse readResponse() throws EPPCommandException
EPPResponse
. The
myResponse
attribute is set as a side-effect of calling
readResponse
so that getResponse()
can be called
later.EPPCommandException
- Error reading or decoding the server responsepublic EPPResponse processDocument(EPPCommand aCommand, java.lang.Class aExpectedResponse) throws EPPCommandException
EPPCommand
instance by writing the command to the
session output stream and reading an EPPResponse
instance
from the sessin input stream and validate that the
EPPResponse
is of the specified type.aCommand
- Command to write to output streamaExpectedResponse
- Expected type of EPPResponse
. If
aExpectedResponse
is non-null
and the
response is not of the specified type, than an
EPPCommandException
will be thrown.MODE_SYNC
; null
otherwise.EPPCommandException
- error processing the command. This can include an error
specified from the server or encountered while attempting to
process the command. If the exception contains an
EPPResponse
than it was a server specified
error.public void endSession() throws EPPCommandException
EPPCommandException
- Error ending sessionpublic void endConnection() throws EPPCommandException
EPPCommandException
- Error closing connection.public void initSession() throws EPPCommandException
setClientID
- Sets the client idenfifier/user namesetPassword
- Sets the passwordsetNewPassword
- Changes the passwordsetVersion
- Override the default EPP version. A default
setting is provided (i.e. 1.0).setLang
- Override the default language of "us".setServices
- Sets desired set of client EPP services by
EPP XML Namespace. A default setting is automatically provided based on
the EPP.MapFactories
configuration settingsetExtensions
- Sets desired set of client EPP services.
This can be a subset of the EPP services loaded in the client. A default
setting is automatically provided based on the
EPP.ProtocolExtension
and the
EPP.CmdRspExtensions
configuration settings.EPPCommandException
- Error initializing the session.public java.lang.String getVersion()
initSession
.public void setVersion(java.lang.String newVersion)
initSession
.newVersion
- EPP version to usepublic java.lang.String setLang()
initSession
.public void setLang(java.lang.String newLanguage)
initSession
.newLanguage
- Language following RFC3066 formatpublic java.lang.String getTransId()
null
otherwise.public void setTransId(java.lang.String newTransId)
newTransId
- Client transaction identiferpublic EPPResponse getResponse()
initSession
.null
otherwise.public java.io.InputStream getInputStream()
null
otherwise.public void setInputStream(java.io.InputStream newInput)
EPPSession
constructor. It is recommended to use the
default input stream.newInput
- Input stream to use in session.public java.io.OutputStream getOutputStream()
public EPPClientCon getClientCon()
EPPSession
.null
otherwisepublic void setOutputStream(java.io.OutputStream newOutput)
EPPSession
constructor. It is recommended to use the
default output stream.newOutput
- Output stream to use in session.public java.lang.String getClientID()
initSession
.public void setClientID(java.lang.String newClientID)
initSession
.newClientID
- Client identifierpublic java.lang.String getPassword()
initSession
.public void setPassword(java.lang.String newPassword)
initSession
.newPassword
- Client passwordpublic java.lang.String getnewPassword()
initSession
.public void setNewPassword(java.lang.String newPassword)
initSession
.newPassword
- New client passwordpublic void setServices(java.lang.String[] newServiceNS) throws EPPCommandException
initSession
or
login
. The default setting is to use all of the services
loaded in EPPFactory
. This method allows a client to specify
a subset of the services loaded in the EPPFactory
, which is
useful for synchronizing with the services supported by a specific server.
For example, to initialize a session that will manage domains,
newServicesNS
would be set to new
String[]{"urn:iana:xml:ns:domain-1.0"}
. Only a subset of the
services loaded in the EPPFactory
can be specified.newServiceNS
- An array of EPP XML namespace URIs to use in sesssionEPPCommandException
- Invalid namespace specified.public void setExtensions(java.util.Vector ProtocolExtensions, java.util.Vector CommandResponseExtensions) throws EPPCommandException
initSession
or
login
. The default setting is to use all of the services
loaded in EPPFactory
. This method allows a client to specify
a subset of the extensionservices loaded in the EPPFactory
,
which is useful for synchronizing with the extensionservices supported by
a specific server. Either of the Paramerter ProtocolExtenions or the
CommandResponseExtenisons can be null or both the parameteres can be null
in which case there are no extenisons to be set.ProtocolExtensions
- ProtocolExtensions An vector EPPPortocolExtension XML namespace
URIs to use in sesssionCommandResponseExtensions
- CommandResponseExtensions An vector of CommandResponseExtension
XML namespace URIs to use in sessionEPPCommandException
- Invalid namespace specified.public void setPollOp(java.lang.String aOp)
OP_REQ
or
OP_ACK
aOp
- OP_REQ
or OP_ACK
.public java.lang.String getPollOp()
OP_REQ
or
OP_ACK
OP_REQ
or OP_ACK
public java.lang.String getStatusTransId()
null
otherwise.public void setStatusTransId(java.lang.String aStatusTrans)
aStatusTrans
- Status client transaction identifier.public java.lang.String getStatusCommandType()
EPPCommand.TYPE_
constants.null
otherwise.public void setStatusCommandType(java.lang.String aStatusCommandType)
aStatusCommandType
- Status command type, which should be one of the following:EPPCommand.TYPE_CREATE
EPPCommand.TYPE_DELETE
EPPCommand.TYPE_RENEW
EPPCommand.TYPE_TRANSFER
EPPCommand.TYPE_UPDATE
public java.lang.String getMsgID()
public void setMsgID(java.lang.String aMsgID)
aMsgID
- Message Idpublic int getMode()
MODE_SYNC
or MODE_ASYNC
.MODE_SYNC
or MODE_ASYNC
public int setMode(int aMode)
MODE_SYNC
or
MODE_ASYNC
.aMode
- MODE_SYNC
or MODE_ASYNC
public boolean isModeSupported(int aMode)
MODE_SYNC
or
MODE_ASYNC
? A derived class of EPPSession
could
support a subset of the modes, so this method is provide to provide the
client with the ability to check whether a mode is supported.aMode
- MODE_SYNC
or MODE_ASYNC
true
if supported; false
otherwise.Copyright © VeriSign Inc. All Rights Reserved.