com.distinct.rpc
Class AuthDes

java.lang.Object
  |
  +--com.distinct.rpc.Auth
        |
        +--com.distinct.rpc.AuthDes
All Implemented Interfaces:
java.io.Serializable, XDRType

public class AuthDes
extends Auth

Implements AUTH_DES authenticators. Used in Secure RPC.

See Also:
JRPC.Auth, JRPC.AuthUnix, JRPC.AuthShort, Serialized Form

Field Summary
static int kMAXNETNAME
           
 
Constructor Summary
AuthDes(java.lang.String clientnetname, java.math.BigInteger SK, java.math.BigInteger PK, int win)
          Creates an authenticator of flavor AUTH_DES.
AuthDes(java.lang.String clientnetname, java.lang.String passwd, java.lang.String servernetname, PublicKeyDB db, int win)
          Creates an authenticator of flavor AUTH_DES.
 
Method Summary
static java.lang.String generateKeyPair(java.lang.String passwd)
          Generates a new key pair (public key/private key)
 java.lang.String getClientNetname()
          Returns the full authenticated netname of the client.
 javax.crypto.SecretKey getSessionKey()
          Returns the DES secret key that is used in this session.
 Auth getVerifier()
          Returns the verifier that belongs to this authenticator.
 void setServerTime(int server_time)
          Sets the current system time of the server, measured in seconds, since midnight, January 1, 1970 UTC.
 void update()
          Updates the authenticator for a new call with the latest timestamp.
 void validate(Auth verf)
          Checks whether the other authenticator (the one returned from the server) fits to this one and updates the status of this instance if required.
 
Methods inherited from class com.distinct.rpc.Auth
getAuthOpaque, getFlavor, setAuthOpaque, setFlavor, xdr_decode, xdr_encode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kMAXNETNAME

public static final int kMAXNETNAME
See Also:
Constant Field Values
Constructor Detail

AuthDes

public AuthDes(java.lang.String clientnetname,
               java.lang.String passwd,
               java.lang.String servernetname,
               PublicKeyDB db,
               int win)
        throws RPCError
Creates an authenticator of flavor AUTH_DES.

Parameters:
clientnetname - The name of the client's authority.
passwd - The password that authenticates the client's authority.
servernetname - The name of the servers's authority.
db - The key store.
win - The time window size in seconds.
Throws:
RPCError - Thrown if creation fails.

AuthDes

public AuthDes(java.lang.String clientnetname,
               java.math.BigInteger SK,
               java.math.BigInteger PK,
               int win)
        throws RPCError
Creates an authenticator of flavor AUTH_DES.

Parameters:
clientnetname - The name of the client's authority.
SK - The secret private key of the client.
PK - The public key of the server.
win - The time window size in seconds.
Throws:
RPCError - Thrown if creation fails.
Method Detail

setServerTime

public void setServerTime(int server_time)
Sets the current system time of the server, measured in seconds, since midnight, January 1, 1970 UTC. Used for time synchronization between Secure RPC clients and servers. Typically only called by JRPC.ClientSecureRPC.

Parameters:
server_time - The current system time of the server.

getClientNetname

public java.lang.String getClientNetname()
Returns the full authenticated netname of the client.

Returns:
The netname of the client.

getSessionKey

public javax.crypto.SecretKey getSessionKey()
Returns the DES secret key that is used in this session. This is a secred shared only by the client and the server during this session. It can be used for encrypting additional parts of the RPC communication.

Returns:
The currently used DES secret key.

getVerifier

public Auth getVerifier()
Returns the verifier that belongs to this authenticator. This verifier is updated automatically each time the update() or AuthDesServerDB.checkAuth() method of is called on this object.

Returns:
The verifier that belongs to this authenticator.

validate

public void validate(Auth verf)
              throws RPCAuthError
Checks whether the other authenticator (the one returned from the server) fits to this one and updates the status of this instance if required. param auth The authenticator to be checked.

Throws:
RPCAuthError - Thrown if the check fails.

update

public void update()
            throws RPCError
Updates the authenticator for a new call with the latest timestamp. Usually only called by JRPC.ClientSecureRPC.

RPCError

generateKeyPair

public static java.lang.String generateKeyPair(java.lang.String passwd)
                                        throws RPCError
Generates a new key pair (public key/private key)

Parameters:
passwd - The password used to encrypt the secret key.
Returns:
A string that is ready for insertion into the "/etc/publickey" database (format "public_key:encrypted_private_key").
Throws:
RPCError - Thrown if something fails in the crypto stuff.