com.distinct.rpc
Class ClientSecureRPC

java.lang.Object
  |
  +--com.distinct.rpc.ClientGeneric
        |
        +--com.distinct.rpc.ClientSecureRPC
All Implemented Interfaces:
java.io.Serializable

public final class ClientSecureRPC
extends ClientGeneric

Java implementation of Secure RPC protocol with AuthDes.

See Also:
ClientGeneric, AuthDes, Serialized Form

Constructor Summary
ClientSecureRPC(ClientGeneric protocolp, AuthDes auth)
          Creates a Secure RPC protocol client and initializes it with a protocol client object.
ClientSecureRPC(java.net.InetAddress host, int prog, int vers, boolean stream, AuthDes auth)
          Creates a Secure RPC protocol client.
 
Method Summary
 void Call(int prog, int vers, int proc, XDRType in, XDRType out)
          Calls the server.
 void close()
          Closes the connection and frees the socket resource.
 int getServerTime()
          Returns the current system time of the server.
 void setCredential(Auth credp)
          Sets a new authenticator and (if it is of type AuthDes) updates also the corresponding verifier.
 void setResend(int milliseconds)
          Changes the timeout value for retransmission of the request (UDP only, default is 5s).
 void setTimeout(int timeout)
          Changes the timeout value for waiting on server replies (default is 25s).
 
Methods inherited from class com.distinct.rpc.ClientGeneric
Call, getReturnedVerifier, setVerifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientSecureRPC

public ClientSecureRPC(java.net.InetAddress host,
                       int prog,
                       int vers,
                       boolean stream,
                       AuthDes auth)
                throws RPCError,
                       java.io.IOException
Creates a Secure RPC protocol client.

Parameters:
host - The host on which the server lives.
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
stream - true for a TCP connection, false for UDP.
auth - The AUTH_DES credential.
Throws:
JRPC.RPCError - When the port can not be found in the portmapper (perhaps there is even no portmapper running).
java.io.IOException - When the socket could not be opened.
RPCError

ClientSecureRPC

public ClientSecureRPC(ClientGeneric protocolp,
                       AuthDes auth)
Creates a Secure RPC protocol client and initializes it with a protocol client object.

Parameters:
protocolp - The protocol object that implements the client connection (of class ClientTCP or ClientUDP).
auth - The AUTH_DES credential.
Method Detail

Call

public void Call(int prog,
                 int vers,
                 int proc,
                 XDRType in,
                 XDRType out)
          throws RPCError,
                 java.io.IOException
Calls the server.

Specified by:
Call in class ClientGeneric
Parameters:
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
proc - The ID of the request function as defined in the .x IDL file.
in - The input parameter (as it has to be marshalled it must be derived from XDRType).
out - The output parameter (as it has to be marshalled it must be derived from XDRType).
Throws:
java.io.IOException - When the call fails because the socket connetion fails.
JRPC.RPCError - When the calls fails for any other reason.
RPCError - When the calls fails for any other reason.

close

public void close()
Closes the connection and frees the socket resource.

Specified by:
close in class ClientGeneric

setTimeout

public void setTimeout(int timeout)
Changes the timeout value for waiting on server replies (default is 25s).

Specified by:
setTimeout in class ClientGeneric
Parameters:
timeout - The new timeout value in ms (0 means no timeout at all, -1 means immediate return).

setResend

public void setResend(int milliseconds)
Changes the timeout value for retransmission of the request (UDP only, default is 5s).

Specified by:
setResend in class ClientGeneric
Parameters:
milliseconds - The new timeout value in ms.

setCredential

public void setCredential(Auth credp)
Sets a new authenticator and (if it is of type AuthDes) updates also the corresponding verifier.

Overrides:
setCredential in class ClientGeneric
Parameters:
credp - The new AUTH_DES authenticator.

getServerTime

public int getServerTime()
Returns the current system time of the server. Helpful (but not mandatory) for time synchronization between Secure RPC clients and servers. getServerTime() only works if the server run at least a portmapper (rpcbind) server version 3.

Returns:
the time, measured in seconds, since midnight, January 1, 1970 UTC. O if an error occurs.