EPP Client -- encapsulates all the connection and communication with the
EPP Server.
connect
public void connect()
throws epp_Exception,
UnknownHostException,
SocketException,
IOException,
EPPTransportException
Connects to the EPP Server using previously set hostname and port.
It is recommended to use connectAndGetGreeting() to connect and
retrieve the EPPGreeting in one single call.
connect
public void connect(String epp_client_id,
String epp_password)
throws epp_Exception,
UnknownHostException,
SocketException,
IOException,
EPPTransportException
Connects to the EPP Server using the given client id and password and
using the previously set EPP hostname and port.
It is recommended to use connectAndGetGreeting() to connect and
retrieve the EPPGreeting in one single call.
epp_client_id
- The EPP client idepp_password
- The password associated with the client id
connect
public void connect(String epp_host_name,
int epp_host_port)
throws epp_Exception,
UnknownHostException,
SocketException,
IOException,
EPPTransportException
Connects to the EPP Server using the given hostname and port and
using the previously set client id and password.
It is recommended to use connectAndGetGreeting() to connect and
retrieve the EPPGreeting in one single call.
epp_host_name
- The EPP Hostname (eg. "host.domain.tld")epp_host_port
- The EPP port
connect
public void connect(String epp_host_name,
int epp_host_port,
String epp_client_id,
String epp_password)
throws epp_Exception,
UnknownHostException,
SocketException,
IOException,
EPPTransportException
Connects to and logs into the EPP Server using the given hostname,
port, client id and password
It is recommended to use connectAndGetGreeting() to connect and
retrieve the EPPGreeting in one single call.
epp_host_name
- The EPP Hostname (eg. "host.domain.tld")epp_host_port
- The EPP portepp_client_id
- The EPP client idepp_password
- The password associated with the client id
connectAndGetGreeting
public epp_Greeting connectAndGetGreeting()
throws epp_Exception,
IOException,
epp_XMLException,
EPPTransportException
Connects to the EPP Server and reads the greeting from it.
Calls the connect() method to establish a connection to the
EPP server. And calls getGreeting() to read the greeting from
the server.
If an exception occurs, it is internall caught here, the isValid
value is set to false and the exception is rethrown.
- The greeting from the EPP Server.
disconnect
public void disconnect()
throws IOException
Closes the connection to the EPP Server.
Nulls the transport so it must be recreated for subsequent
connections with the same instance of EPPClient. If
setTransport() or setSocketToEPPServer() were called to
create the transport, then they must be called again.
getEPPClientID
public String getEPPClientID()
Accessor method for the client id.
getEPPHostName
public String getEPPHostName()
Accessor method for the EPP Hostname
getEPPHostPort
public int getEPPHostPort()
Accessor method for the EPP Host port
getEPPPassword
public String getEPPPassword()
Accessor method for the password
getEPPServiceExtensions
public String[] getEPPServiceExtensions()
Accessor method for the epp service extensions.
- The current service extensions in an array.
getEPPServices
public String[] getEPPServices()
Accessor method for the epp services.
- The current services in an array.
getEPPTimeout
public int getEPPTimeout()
Accessor method for the EPP server timeout, in milliseconds
- The current timeout setting. in milliseconds
getGreeting
public epp_Greeting getGreeting()
throws epp_Exception,
epp_XMLException
Retrieves the greeting from the EPP Server and returns it.
This method is useful if a new connection is provided to the
EPPClient (eg. in the case of an SSL connection not using the
JSSE standard) and the greeting must be read separately.
If an exception occurs, it is internall caught here, the isValid
value is set to false and the exception is rethrown.
- The greeting from the EPP Server
getLang
public String getLang()
Accessor method for the lang
getLastNetTransaction
public long getLastNetTransaction()
Accessor method for the time of the last successfull
network transaction.
Useful for tracking when a keepAlive (poll) transaction
needs to be sent.
- Last transation time in seconds.
getVersion
public String getVersion()
Accessor method for the version
hello
public epp_Greeting hello()
throws epp_Exception,
epp_XMLException
Issues a hello request to the EPP Server.
This forces the server to respond with an epp_Greeting, which
is otherwise only sent on initial connections to the EPP Server.
- The greeting from the EPP Server
isValid
public boolean isValid()
returns if the connections is valid.
A connection is valid if the following are true
- a coonection has been established to the server
- an I/O Error has not been thrown
- a login has been successfully completed
- The flag indicating the state of the connection to the server
isVersionSentOnLogin
public boolean isVersionSentOnLogin()
Returns whether RTK version number will be send on Login.
- true in case RTK version number will be send on Login, else false
login
public void login(String client_tr_id)
throws epp_XMLException,
epp_Exception
Logs into the EPP Server using previously set client id and password.
Call setEPPServices() or setEPPServiceExtensions() before this method if you want to add epp services
or epp service extensions.
client_tr_id
- The client TRID String
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
login
public void login(String client_tr_id,
String new_password)
throws epp_XMLException,
epp_Exception
Logs into the EPP Server using the previously set client id, and password.
If the new password is not null, it is also passed to the server to
change your EPP client password.
This method also includes default domain, host and contact object/XML information
in the services section. If you wish to set your own services and service extensions,
call setEPPServices() and setEPPServiceExtensions() before this method,
or you'll have to populate the EPPLogin command manually and call
processAction() yourself.
If an exception occurs, it is internall caught here, the isValid
value is set to false and the exception is rethrown.
new_password
- The password associated with the client id. Use null if you do not want to change the password
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
login
public void login(String client_tr_id,
String epp_client_id,
String epp_password)
throws epp_XMLException,
epp_Exception
Logs into the EPP Server using the given client id, password.
Call setEPPServices() or setEPPServiceExtensions() before this method if you want to add epp services
or epp service extensions.
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
login
public void login(String client_tr_id,
String client_id,
String password,
String new_password)
throws epp_XMLException,
epp_Exception
Logs into the EPP Server using the given client id, password and new password.
Use this method if you want to change your EPP client password in the server.
Call setEPPServices() or setEPPServiceExtensions() before this method if you want to add epp services
or epp service extensions.
client_tr_id
- The client TRID Stringclient_id
- The EPP client idpassword
- The password associated with the client idnew_password
- The password associated with the client id, use null if you do not want to change the password
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
logout
public void logout(String client_trid)
throws epp_XMLException,
epp_Exception
Logs out of EPP Server
client_trid
- the client TRID, can be null
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
poll
public epp_PollRsp poll(String client_tr_id)
throws epp_XMLException,
epp_Exception
Sends a poll request to the server.
If there is a message in the response, the user should subsequently
call poll(String, String), providing the message's id to acknowledge
receipt of the message from the server.
client_tr_id
- The client TRID for the EPP request
- The poll response as epp_PollRsp
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
poll
public epp_PollRsp poll(String client_tr_id,
String message_id)
throws epp_XMLException,
epp_Exception
Sends a poll request or acknowledge to the server.
client_tr_id
- The client TRID for the EPP requestmessage_id
- The id of the message to ACK. If null, the Poll op will be REQ.
- The poll response as epp_PollRsp
epp_XMLException
- if the request XML could not be built or if the response XML could not be parsed.epp_Exception
- if the EPP Server responded with an error code
processXML
public String processXML(String request_xml)
throws epp_Exception
Sends raw XML to the server and returns the XML response.
Method required by the epp_Action interface.
- processXML in interface epp_SessionOperations
request_xml
- The XML request String to send to the server.
- The raw XML String response from the server.
readFromServer
public String readFromServer()
throws epp_Exception
Reads a complete XML message from the EPP Server.
Uses the instance transport to read from the server.
You would normally pass the returned XML response to
a fromXML() in the class that created the request in the first place.
eg. EPPDomainCreate
If an exception occurs, it is internall caught here, the isValid
value is set to false and the exception is rethrown.
epp_Exception
- if there was a socket error in reading from the EPP Server
setEPPClientID
public void setEPPClientID(String value)
Accessor method for the client id.
This value is also used in the creation of the default EPPTransID.
Changing this value after a session has been logged in will
have no effect.
value
- The client id String
setEPPHostName
public void setEPPHostName(String value)
Accessor method for the EPP Hostname
value
- The hostname string (eg. "host.domain.tld" or "100.101.200.201")
setEPPHostPort
public void setEPPHostPort(int value)
Accessor method for the EPP Host port
value
- The int port value
setEPPPassword
public void setEPPPassword(String value)
Accessor method for the password
value
- The password String
setEPPServiceExtensions
public void setEPPServiceExtensions(String[] service_extensions)
Accessor method for the epp service extensions
service_extensions
- The service extension array
setEPPServices
public void setEPPServices(String[] services)
Accessor method for the epp services.
This value is used in the EPP Login command.
services
- The service URI array
setEPPTimeout
public void setEPPTimeout(int value)
Accessor method for the EPP server timeout, in milliseconds
Setting this value after a connection has been established
has no effect.
value
- The int timeout value, in milliseconds
setLang
public void setLang(String value)
Accessor method for the lang
The lang setting is used in the creds portion of
EPP commands (such as the login).
value
- The lang/locale String (eg. "fr_CA")
setSocketToEPPServer
public void setSocketToEPPServer(Socket value)
throws epp_Exception,
UnknownHostException,
SocketException,
IOException
Bypass to the EPPClient's connect() methods. Allows a connection
to be established externally.
Mostly useful if opting to not use JSSE
in favour of another SSL package. This method also sets the SO Timeout
to the value from getEPPTimeout(). Creates a new instance of
EPPTransportTCP using the given socket.
value
- The Socket to the EPP Server
setTransport
public void setTransport(EPPTransportBase value)
Bypass to the EPPClient's connect() methods. Allows a connection
and transport to be established externally.
Mostly useful if opting to not use JSSE
in favour of another SSL package.
value
- The Transport to the EPP Server
setVersion
public void setVersion(String value)
Accessor method for the EPP version
The EPP version is sent to the server on login.
value
- The version string
setVersionSentOnLogin
public void setVersionSentOnLogin(boolean send)
Set whether to send RTK version number on Login.
send
- If true, RTK version number will be send in svcExtension section on
Login
writeToServer
public void writeToServer(String outbound_xml)
throws epp_Exception
Sends an XML string to the EPP Server.
Uses the instance transport to send the message to the server.
readFromServer() should be called to read the response.
If an exception occurs, it is internall caught here, the isValid
value is set to false and the exception is rethrown.
outbound_xml
- String The EPP XML String to send to the server.
epp_Exception
- if there was a socket error in writing to the EPP Server.
The epp_Exception will contain a result with the cope epp_Session.RTK_COMMUNICATIONS_FAILURE