com.distinct.rpc
Class PublicKeyDB

java.lang.Object
  |
  +--com.distinct.rpc.PublicKeyDB
Direct Known Subclasses:
PublicKeyDBYP

public class PublicKeyDB
extends java.lang.Object

Key database for Secure RPC.


Constructor Summary
PublicKeyDB(java.io.File file)
          Creates a new secure RPC key database and initializes it from a local file.
PublicKeyDB(java.net.URL url)
          Creates a new secure RPC key database and initializes it from an URL.
 
Method Summary
 boolean doLogin(boolean free)
          Opens the default login dialog on the screen and waits for user's imput.
 boolean doLogin(java.lang.String title, int x, int y, boolean free)
          Opens a login dialog on the screen and waits for user's imput.
 java.lang.String getFirstName()
          Method for enumerating the stored name.
 java.lang.String getNetname()
          Returns the netname entered during the most recent invocation of doLogin().
 java.lang.String getNextName()
          Method for enumerating the stored name.
 java.lang.String getPassword()
          Returns the password entered during the most recent invocation of doLogin().
 java.lang.String getPublicKey(java.lang.String name)
          Returns the public key of an authority.
 java.lang.String getSecretKey(java.lang.String name)
          Returns the encrypted private key of an authority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PublicKeyDB

public PublicKeyDB(java.io.File file)
            throws java.io.IOException
Creates a new secure RPC key database and initializes it from a local file. The file must have the format of the UNIX "/etc/publickey" file (one entry per line, line format "usernetname:public_key:encrypted_private_key").

Parameters:
file - The file that is used fo initilization.
Throws:
java.io.IOException - Thrown if the file cannot be read.

PublicKeyDB

public PublicKeyDB(java.net.URL url)
            throws java.io.IOException
Creates a new secure RPC key database and initializes it from an URL. The content of the URL must have the format of the UNIX "publickey" file (one entry per line, line format "usernetname:public_key:encrypted_private_key").

Parameters:
url - The URL that is used fo initilization.
Throws:
java.io.IOException - Thrown if the URL is unreachable.
Method Detail

getPublicKey

public java.lang.String getPublicKey(java.lang.String name)
                              throws RPCError
Returns the public key of an authority.

Parameters:
name - The name of the authority.
Returns:
The stored public key of the requested authority in hex notation.
Throws:
RPCError - Thrown if the key is not found in the database.

getSecretKey

public java.lang.String getSecretKey(java.lang.String name)
                              throws RPCError
Returns the encrypted private key of an authority.

Parameters:
name - The name of the authority.
Returns:
The stored encrypted private key of the requested authority in hex notation.
Throws:
RPCError - Thrown if the key is not found in the database.

getFirstName

public java.lang.String getFirstName()
Method for enumerating the stored name. Returns the first stored name. Use getNextName to retrieve the subsequent entries.

Returns:
The first stored name. Null if no names are stored.

getNextName

public java.lang.String getNextName()
Method for enumerating the stored name. Returns the next stored name. Use getFirstName to initialize an enumeration.

Returns:
The next stored name. Null if no further names are stored.

doLogin

public boolean doLogin(boolean free)
Opens the default login dialog on the screen and waits for user's imput.

Parameters:
free - If true, the user has to enter the netname as free text, If false, the user may select the netname from a choice of all known names.
Returns:
True if the user closed the dialog with "OK" or the "Enter" Key, otherwise False.

doLogin

public boolean doLogin(java.lang.String title,
                       int x,
                       int y,
                       boolean free)
Opens a login dialog on the screen and waits for user's imput.

Parameters:
title - The title of the dialog.
x - The x coordinate of the dialog.
y - The y coordinate of the dialog.
free - If true, the user has to enter the netname as free text, If false, the user may select the netname from a choice of all known names.
Returns:
True if the user closed the dialog with "OK" or the "Enter" Key, otherwise False.

getNetname

public java.lang.String getNetname()
Returns the netname entered during the most recent invocation of doLogin().

Returns:
The netname.

getPassword

public java.lang.String getPassword()
Returns the password entered during the most recent invocation of doLogin().

Returns:
The password.