edu.nyu.cs.pdsg.util
Class HRShadowKeyDirectory

java.lang.Object
  extended byedu.nyu.cs.pdsg.util.HRShadowKeyDirectory
All Implemented Interfaces:
KeyDirectoryInterface

public class HRShadowKeyDirectory
extends java.lang.Object
implements KeyDirectoryInterface

KeyDirectory is a temporary hack which will allow us to provide public and private keys.

You must call KeyDirectory.init() before using any of it's functions


Field Summary
protected static java.util.HashMap codecs
           
private static java.util.HashMap keyList
           
private static Reservoir keyReserv
           
private static java.lang.String saveFile
           
 
Constructor Summary
HRShadowKeyDirectory(java.lang.String file)
          Initialize KeyDirectory with a given set of key/name associations
HRShadowKeyDirectory(java.lang.String file, boolean genKeys)
           
 
Method Summary
static void addCodec(KeyReaderWriter codec)
          Add a key codec
 java.security.KeyPair addKeyPair(java.lang.String keyName)
           
 void addKeyPair(java.lang.String keyName, java.security.KeyPair pair)
           
(package private)  java.security.KeyPair decodeBCKeyPair(java.util.StringTokenizer data)
           
(package private)  java.lang.String encodeBCKeyPair(java.security.KeyPair pair)
           
protected  java.security.KeyPair genKeyPair(java.lang.String name)
          Returns a newly generated KeyPair and associates it with the given name
protected  java.security.KeyPair getKeyPair(java.lang.String keyName)
          Returns the public and private keys associated with a given name
 java.util.Iterator getNamesIterator()
           
 java.security.PrivateKey getPrivateKey(java.lang.String keyName)
          Returns the private key associated with a given name
 java.security.PublicKey getPublicKey(java.lang.String keyName)
          Returns the public key associated with a given name
 boolean providesPrivate()
           
 boolean providesPublic()
           
 void removeKeyPair(java.lang.String keyName)
           
protected  void save()
          Save the key/name associations to the file KeyDirectory was initialized with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codecs

protected static java.util.HashMap codecs

keyList

private static java.util.HashMap keyList

keyReserv

private static Reservoir keyReserv

saveFile

private static java.lang.String saveFile
Constructor Detail

HRShadowKeyDirectory

public HRShadowKeyDirectory(java.lang.String file)
Initialize KeyDirectory with a given set of key/name associations

Parameters:
file - the key/name association file

HRShadowKeyDirectory

public HRShadowKeyDirectory(java.lang.String file,
                            boolean genKeys)
Method Detail

providesPublic

public boolean providesPublic()
Specified by:
providesPublic in interface KeyDirectoryInterface
Returns:
true if this implementation can provide public keys

providesPrivate

public boolean providesPrivate()
Specified by:
providesPrivate in interface KeyDirectoryInterface
Returns:
true if this implementation can provide privatekeys

addCodec

public static void addCodec(KeyReaderWriter codec)
Add a key codec

Parameters:
codec - the codec to add

getNamesIterator

public java.util.Iterator getNamesIterator()
Returns:
a list of the names that have been loaded from the shadow file

getPublicKey

public java.security.PublicKey getPublicKey(java.lang.String keyName)
Returns the public key associated with a given name

Specified by:
getPublicKey in interface KeyDirectoryInterface
Parameters:
keyName - the name of the key
Returns:
the PublicKey associated with the name

getPrivateKey

public java.security.PrivateKey getPrivateKey(java.lang.String keyName)
Returns the private key associated with a given name

Specified by:
getPrivateKey in interface KeyDirectoryInterface
Parameters:
keyName - the name of the key
Returns:
the PrivateKey associated with the name

getKeyPair

protected java.security.KeyPair getKeyPair(java.lang.String keyName)
Returns the public and private keys associated with a given name

Parameters:
keyName - the name of the key
Returns:
the KeyPair associated with the name

addKeyPair

public java.security.KeyPair addKeyPair(java.lang.String keyName)
                                 throws java.security.InvalidKeyException,
                                        java.security.NoSuchAlgorithmException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException

addKeyPair

public void addKeyPair(java.lang.String keyName,
                       java.security.KeyPair pair)
                throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

removeKeyPair

public void removeKeyPair(java.lang.String keyName)
                   throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

genKeyPair

protected java.security.KeyPair genKeyPair(java.lang.String name)
Returns a newly generated KeyPair and associates it with the given name

Returns:
the generated KeyPair

save

protected void save()
             throws java.io.IOException
Save the key/name associations to the file KeyDirectory was initialized with

Throws:
java.io.IOException

encodeBCKeyPair

java.lang.String encodeBCKeyPair(java.security.KeyPair pair)
                           throws java.security.NoSuchAlgorithmException,
                                  java.security.spec.InvalidKeySpecException
Throws:
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException

decodeBCKeyPair

java.security.KeyPair decodeBCKeyPair(java.util.StringTokenizer data)
                                throws java.security.spec.InvalidKeySpecException,
                                       java.security.NoSuchAlgorithmException
Throws:
java.security.spec.InvalidKeySpecException
java.security.NoSuchAlgorithmException


Copyright (c) 2002-2003 New York University RLAB