com.tucows.oxrs.epp0604.rtk

Class EPPClient

Implemented Interfaces:
epp_Session, epp_SessionOperations, org.omg.CORBA.portable.IDLEntity, org.omg.CORBA.Object

public class EPPClient
extends RTKBase
implements epp_Session

EPP Client -- encapsulates all the connection and communication with the EPP Server.
Version:
$Revision: 1.1 $ $Date: 2003/03/21 15:52:23 $
Author:
Daniel Manley
See Also:
DomainExample, ContactExample, HostExample

Field Summary

static String
DEFAULT_LANG
The default language/locale: "en".
static String
DEFAULT_TRANSPORT_CLASS
The default transport class if none is set in the rtk.properties file.
static String
DEFAULT_TRANSPORT_PACKAGE
The default transport package if none is set in the rtk.properties file.
static String
VERSION
The current EPP version.

Fields inherited from class com.tucows.oxrs.epp0604.rtk.RTKBase

CRLF, DATE_FMT, DEBUG_LEVEL_ONE, DEBUG_LEVEL_THREE, DEBUG_LEVEL_TWO, DEBUG_NONE, RTK_VERSION, UTC_FMT

Fields inherited from interface org.openrtk.idl.epp0604.epp_Session

EPP_AUTHENTICATION_FAILURE, EPP_AUTHORIZATION_FAILURE, EPP_BILLING_FAILURE, EPP_COMMAND_COMPLETED_SUCCESSFULLY, EPP_COMMAND_COMPLETED_SUCCESSFULLY_ENDING_SESSION, EPP_COMMAND_COMPLETED_SUCCESSFULLY_MESSAGE_PRESENT, EPP_COMMAND_COMPLETED_SUCCESSFULLY_NO_MESSAGES, EPP_COMMAND_FAILED, EPP_COMMAND_FAILED_SERVER_ENDING_SESSION, EPP_COMMAND_SYNTAX_ERROR, EPP_COMMAND_USE_ERROR, EPP_DATA_MANAGEMENT_POLICY_VIOLATION, EPP_INVALID_AUTHORIZATION_IDENTIFIER, EPP_OBJECT_ASSOCIATION_PROHIBITS_OPERATION, EPP_OBJECT_DOES_NOT_EXIST, EPP_OBJECT_EXISTS, EPP_OBJECT_IS_NOT_ELIGIBLE_FOR_RENEWAL, EPP_OBJECT_IS_NOT_ELIGIBLE_FOR_TRANSFER, EPP_OBJECT_NOT_PENDING_TRANSFER, EPP_OBJECT_PENDING_TRANSFER, EPP_OBJECT_STATUS_PROHIBITS_OPERATION, EPP_PARAMETER_VALUE_POLICY_ERROR, EPP_PARAMETER_VALUE_RANGE_ERROR, EPP_PARAMETER_VALUE_SYNTAX_ERROR, EPP_REQUIRED_PARAMETER_MISSING, EPP_SESSION_LIMIT_EXCEEDED_SERVER_CLOSING_CONNECTION, EPP_TIMEOUT_SERVER_ENDING_SESSION, EPP_UNIMPLEMENTED_COMMAND, EPP_UNIMPLEMENTED_EXTENSION, EPP_UNIMPLEMENTED_OBJECT_SERVICE, EPP_UNIMPLEMENTED_OPTION, EPP_UNIMPLEMENTED_PROTOCOL_VERSION, EPP_UNKNOWN_COMMAND, RTK_COMMUNICATIONS_FAILURE, RTK_UNEXPECTED_SERVER_DISCONNECT

Constructor Summary

EPPClient()
Default constructor -- uses default version, lang values.
EPPClient(String epp_client_id, String epp_password)
Construtor with client id and password
EPPClient(String epp_host_name, int epp_host_port, String epp_client_id, String epp_password)
Constructor with EPP Hostname, EPP Host port, client id and password, in that order.

Method Summary

void
connect()
Connects to the EPP Server using previously set hostname and port.
void
connect(String epp_client_id, String epp_password)
Connects to the EPP Server using the given client id and password and using the previously set EPP hostname and port.
void
connect(String epp_host_name, int epp_host_port)
Connects to the EPP Server using the given hostname and port and using the previously set client id and password.
void
connect(String epp_host_name, int epp_host_port, String epp_client_id, String epp_password)
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_Greeting
connectAndGetGreeting()
Connects to the EPP Server and reads the greeting from it.
void
disconnect()
Closes the connection to the EPP Server.
String
getEPPClientID()
Accessor method for the client id.
String
getEPPHostName()
Accessor method for the EPP Hostname
int
getEPPHostPort()
Accessor method for the EPP Host port
String
getEPPPassword()
Accessor method for the password
String[]
getEPPServiceExtensions()
Accessor method for the epp service extensions.
String[]
getEPPServices()
Accessor method for the epp services.
int
getEPPTimeout()
Accessor method for the EPP server timeout, in milliseconds
epp_Greeting
getGreeting()
Retrieves the greeting from the EPP Server and returns it.
String
getLang()
Accessor method for the lang
long
getLastNetTransaction()
Accessor method for the time of the last successfull network transaction.
String
getVersion()
Accessor method for the version
epp_Greeting
hello()
Issues a hello request to the EPP Server.
boolean
isValid()
returns if the connections is valid.
boolean
isVersionSentOnLogin()
Returns whether RTK version number will be send on Login.
void
login(String client_tr_id)
Logs into the EPP Server using previously set client id and password.
void
login(String client_tr_id, String new_password)
Logs into the EPP Server using the previously set client id, and password.
void
login(String client_tr_id, String epp_client_id, String epp_password)
Logs into the EPP Server using the given client id, password.
void
login(String client_tr_id, String client_id, String password, String new_password)
Logs into the EPP Server using the given client id, password and new password.
void
logout(String client_trid)
Logs out of EPP Server
epp_PollRsp
poll(String client_tr_id)
Sends a poll request to the server.
epp_PollRsp
poll(String client_tr_id, String message_id)
Sends a poll request or acknowledge to the server.
epp_Action
processAction(epp_Action request)
Sends EPP request to the server and retrieves the response.
String
processXML(String request_xml)
Sends raw XML to the server and returns the XML response.
String
readFromServer()
Reads a complete XML message from the EPP Server.
void
setEPPClientID(String value)
Accessor method for the client id.
void
setEPPHostName(String value)
Accessor method for the EPP Hostname
void
setEPPHostPort(int value)
Accessor method for the EPP Host port
void
setEPPPassword(String value)
Accessor method for the password
void
setEPPServiceExtensions(String[] service_extensions)
Accessor method for the epp service extensions
void
setEPPServices(String[] services)
Accessor method for the epp services.
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.
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).
void
setSocketToEPPServer(Socket value)
Bypass to the EPPClient's connect() methods.
void
setTransport(EPPTransportBase value)
Bypass to the EPPClient's connect() methods.
void
setVersion(String value)
Accessor method for the EPP version The EPP version is sent to the server on login.
void
setVersionSentOnLogin(boolean send)
Set whether to send RTK version number on Login.
void
writeToServer(String outbound_xml)
Sends an XML string to the EPP Server.

Methods inherited from class com.tucows.oxrs.epp0604.rtk.RTKBase

_ids, debug, debug, getDebugLevel, getDebugPrintStream, getRTKProperties, setDebugLevel, setDebugLevel, setDebugPrintStream

Field Details

DEFAULT_LANG

public static final String DEFAULT_LANG
The default language/locale: "en". Sent to the EPP Server on login.

DEFAULT_TRANSPORT_CLASS

public static final String DEFAULT_TRANSPORT_CLASS
The default transport class if none is set in the rtk.properties file.

DEFAULT_TRANSPORT_PACKAGE

public static final String DEFAULT_TRANSPORT_PACKAGE
The default transport package if none is set in the rtk.properties file.

VERSION

public static final String VERSION
The current EPP version. Sent to the EPP Server on login.

Constructor Details

EPPClient

public EPPClient()
Default constructor -- uses default version, lang values.

EPPClient

public EPPClient(String epp_client_id,
                 String epp_password)
Construtor with client id and password
Parameters:
epp_client_id - The EPP client id
epp_password - The password associated with the client id

EPPClient

public EPPClient(String epp_host_name,
                 int epp_host_port,
                 String epp_client_id,
                 String epp_password)
Constructor with EPP Hostname, EPP Host port, client id and password, in that order.
Parameters:
epp_host_name - The EPP Hostname (eg. "host.domain.tld")
epp_host_port - The EPP port
epp_client_id - The EPP client id
epp_password - The password associated with the client id

Method Details

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.
Throws:
EPPTransportException - if there are problem initializing the transport class

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.
Parameters:
epp_client_id - The EPP client id
epp_password - The password associated with the client id
Throws:
EPPTransportException - if there are problem initializing the transport class

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.
Parameters:
epp_host_name - The EPP Hostname (eg. "host.domain.tld")
epp_host_port - The EPP port
Throws:
EPPTransportException - if there are problem initializing the transport class

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.
Parameters:
epp_host_name - The EPP Hostname (eg. "host.domain.tld")
epp_host_port - The EPP port
epp_client_id - The EPP client id
epp_password - The password associated with the client id
Throws:
EPPTransportException - if there are problem initializing the transport class

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.
Returns:
The greeting from the EPP Server.
Throws:
epp_XMLException - if the server's greeting is not parsable
EPPTransportException - if there are problems initializing the transport

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.
Returns:
The current client id.

getEPPHostName

public String getEPPHostName()
Accessor method for the EPP Hostname
Returns:
The EPP host name String

getEPPHostPort

public int getEPPHostPort()
Accessor method for the EPP Host port

getEPPPassword

public String getEPPPassword()
Accessor method for the password
Returns:
The current EPP Password

getEPPServiceExtensions

public String[] getEPPServiceExtensions()
Accessor method for the epp service extensions.
Returns:
The current service extensions in an array.

getEPPServices

public String[] getEPPServices()
Accessor method for the epp services.
Returns:
The current services in an array.

getEPPTimeout

public int getEPPTimeout()
Accessor method for the EPP server timeout, in milliseconds
Returns:
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.
Returns:
The greeting from the EPP Server
Throws:
epp_Exception - if the server greeting is not present
epp_XMLException - if the server's greeting is not parsable

getLang

public String getLang()
Accessor method for the lang
Returns:
The langue

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.
Returns:
Last transation time in seconds.

getVersion

public String getVersion()
Accessor method for the version
Returns:
String 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.
Returns:
The greeting from the EPP Server
Throws:
epp_Exception - if the server greeting is not present
epp_XMLException - if the server's greeting is not parsable

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
Returns:
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.
Returns:
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.
Parameters:
client_tr_id - The client TRID String
Throws:
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.
Parameters:
new_password - The password associated with the client id. Use null if you do not want to change the password
Throws:
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.
Parameters:
Throws:
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.
Parameters:
client_tr_id - The client TRID String
client_id - The EPP client id
password - The password associated with the client id
new_password - The password associated with the client id, use null if you do not want to change the password
Throws:
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
Parameters:
client_trid - the client TRID, can be null
Throws:
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.
Parameters:
client_tr_id - The client TRID for the EPP request
Returns:
The poll response as epp_PollRsp
Throws:
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.
Parameters:
client_tr_id - The client TRID for the EPP request
message_id - The id of the message to ACK. If null, the Poll op will be REQ.
Returns:
The poll response as epp_PollRsp
Throws:
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

processAction

public epp_Action processAction(epp_Action request)
            throws epp_XMLException,
                   epp_Exception
Sends EPP request to the server and retrieves the response. Method required by the epp_Action interface.
Calls processXML().
Specified by:
processAction in interface epp_SessionOperations
Parameters:
request - epp_Action The action to send to the registry
Throws:
epp_XMLException - if any request data or response data is missing
epp_Exception - if a communication error occurs or if the server returns 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.
Specified by:
processXML in interface epp_SessionOperations
Parameters:
request_xml - The XML request String to send to the server.
Returns:
The raw XML String response from the server.
Throws:
epp_Exception - if a communication error occurs

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.
Returns:
Full XML String
Throws:
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.
Parameters:
value - The client id String

setEPPHostName

public void setEPPHostName(String value)
Accessor method for the EPP Hostname
Parameters:
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
Parameters:
value - The int port value

setEPPPassword

public void setEPPPassword(String value)
Accessor method for the password
Parameters:
value - The password String

setEPPServiceExtensions

public void setEPPServiceExtensions(String[] service_extensions)
Accessor method for the epp service extensions
Parameters:
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.
Parameters:
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.
Parameters:
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).
Parameters:
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.
Parameters:
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.
Parameters:
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.
Parameters:
value - The version string

setVersionSentOnLogin

public void setVersionSentOnLogin(boolean send)
Set whether to send RTK version number on Login.
Parameters:
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.
Parameters:
outbound_xml - String The EPP XML String to send to the server.
Throws:
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

Copyright © 2001-2002 - Tucows, Inc., 2003 - LibertyRMS