pk.edu.niit.clarens.client
Class ClarensClient

java.lang.Object
  extended byorg.apache.xmlrpc.XmlRpcClient
      extended bypk.edu.niit.clarens.client.ClarensClient
All Implemented Interfaces:
org.apache.xmlrpc.XmlRpcHandler

public class ClarensClient
extends org.apache.xmlrpc.XmlRpcClient

A xmlrpc client for use with clarens servers. The client handles the clarens xmlrpc authentication. The constructor merely sets up the remote connection. The connection is not actually established until the connect() method is called. The private key of the user must be unencrypted. Both PKCS#8 and traditional openssl private keys can be used.


Field Summary
 
Fields inherited from class org.apache.xmlrpc.XmlRpcClient
asyncWorkers, pool, url, workers
 
Constructor Summary
ClarensClient(java.lang.String url)
          Constructor.
ClarensClient(java.lang.String url, java.lang.String certFile, java.lang.String keyFile)
          Constructor.
 
Method Summary
 boolean connect()
          Connect to the remote server.
 java.lang.String getClientCertFile()
          Get the location of the client certificate.
 java.lang.String getClientPrivateKeyFile()
          Get the value of the clientPrivateKeyFile property
 boolean isConnected()
          Indicates if the client has made a successful authenticated connection to the server.
 void loadCertificate()
          Load the client certificate and private key.
 void setClientCertFile(java.lang.String clientCertFile)
          Set the location of the client certificate.
 void setClientPrivateKeyFile(java.lang.String clientPrivateKeyFile)
          Set the location of the client's private key file.
 
Methods inherited from class org.apache.xmlrpc.XmlRpcClient
execute, executeAsync, getURL, main, setBasicAuthentication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClarensClient

public ClarensClient(java.lang.String url,
                     java.lang.String certFile,
                     java.lang.String keyFile)
              throws java.lang.Exception
Constructor. The client certificates are loaded and prepared for remote connections.

Parameters:
url - The URL for the remote server.
certFile - The path to the file containing the client certificate.
keyFile - The path to the file containing the client's private key.

ClarensClient

public ClarensClient(java.lang.String url)
              throws java.lang.Exception
Constructor.

Parameters:
url - The URL for the remote server.
Method Detail

loadCertificate

public void loadCertificate()
                     throws java.lang.Exception
Load the client certificate and private key. The cert and key are stored for later use when connecting to the remote server.

Throws:
java.lang.Exception - A generic exception is thrown when an error occurs.

connect

public boolean connect()
Connect to the remote server. Calls the system.auth() method to authenticate and prepare for future methods.

Returns:
true if the connection (and authentication) was successful, false if not.

setClientCertFile

public void setClientCertFile(java.lang.String clientCertFile)
Set the location of the client certificate. The filename must be specified relative to the certificate base directory (as used with loadCertificate()

Parameters:
clientCertFile - The name of the file containing the client certificate.

getClientCertFile

public java.lang.String getClientCertFile()
Get the location of the client certificate.

Returns:
The name of the file containing the client certificate.

setClientPrivateKeyFile

public void setClientPrivateKeyFile(java.lang.String clientPrivateKeyFile)
Set the location of the client's private key file. The private key must be unencrypted. The filename must be specified relative to the certificate base directory (as used with loadCertificate()

Parameters:
clientPrivateKeyFile - The name of the file containing the client's private key.

getClientPrivateKeyFile

public java.lang.String getClientPrivateKeyFile()
Get the value of the clientPrivateKeyFile property

Returns:
The name of the file containing the client's private key.

isConnected

public boolean isConnected()
Indicates if the client has made a successful authenticated connection to the server.

Returns:
true if the client has connected to the server and made a successful "system.auth" call. false if the connection has not been made or if the "system.auth" call failed.