FileDocCategorySizeDatePackage
PublicKeyStoreBuilderBase.javaAPI DocphoneME MR2 API (J2ME)4875Wed May 02 18:00:26 BST 2007com.sun.midp.publickeystore

PublicKeyStoreBuilderBase

public class PublicKeyStoreBuilderBase extends PublicKeyStore
A read-write serializable {@link PublicKeyStore}. This class is the base for {@link PublicKeyStoreBuilder}, and does not have any methods that depend on any Microediton specific classes so it can be used alone in a tool written with Standard Edition Java.

Fields Summary
private Vector
keyList
Vecor of keys maintained as a list.
Constructors Summary
public PublicKeyStoreBuilderBase()
Constructs an empty read-write keystore.


              
      
        initPublicKeyStore(keyList);
    
public PublicKeyStoreBuilderBase(InputStream in)
Constructs a read-write keystore from a serialized keystore created by this class.

param
in stream to read a keystore serialized by {@link #serialize(OutputStream)} from
exception
IOException if the key storage was corrupted

        initPublicKeyStore(in, keyList);
    
public PublicKeyStoreBuilderBase(Vector sharedKeyList)
Constructs an read-write keystore.

param
sharedKeyList shared key list

        keyList = sharedKeyList;
        initPublicKeyStore(keyList);
    
Methods Summary
public synchronized voidaddKey(PublicKeyInfo keyInfo)
Adds a public key.

param
keyInfo the key to add

        keyList.addElement(keyInfo);
    
public voiddeleteKey(int number)
Deletes a public key from this keystore by number.

param
number number of the key with 0 being the first.
exception
ArrayIndexOutOfBoundsException if an invalid number was given.

        keyList.removeElementAt(number);
    
private voidputKeyInStorage(OutputStorage storage, PublicKeyInfo key)
Serializes every field with a tag.

param
storage what to put the key in
param
key key information object

        storage.writeValue(PublicKeyInfo.OWNER_TAG, key.getOwner());
        storage.writeValue(PublicKeyInfo.NOT_BEFORE_TAG, key.getNotBefore());
        storage.writeValue(PublicKeyInfo.NOT_AFTER_TAG, key.getNotAfter());
        storage.writeValue(PublicKeyInfo.MODULUS_TAG, key.getModulus());
        storage.writeValue(PublicKeyInfo.EXPONENT_TAG, key.getExponent());
        storage.writeValue(PublicKeyInfo.DOMAIN_TAG, key.getDomain());
        storage.writeValue(PublicKeyInfo.ENABLED_TAG, key.isEnabled());
    
public voidserialize(java.io.OutputStream out)
Serializes the keystore to the given stream.

param
out stream to serialize the keystore to
exception
IOException is thrown, if an I/O error occurs

        OutputStorage storage = new OutputStorage(out);
        Enumeration e;
        PublicKeyInfo keyInfo;
  
        e = keyList.elements();
        while (e.hasMoreElements()) {
            keyInfo = (PublicKeyInfo)e.nextElement();
            putKeyInStorage(storage, keyInfo);
        }
    
public synchronized voidupdateKey(int number, PublicKeyInfo newKeyInfo)
Updates all of an key's information except for the security domain. information in the store.

param
number key number of key 0 being the first
param
newKeyInfo new key information
exception
ArrayIndexOutOfBoundsException if an invalid number was given.

        PublicKeyInfo oldKeyInfo;

        oldKeyInfo = getKey(number);

        newKeyInfo.setDomain(oldKeyInfo.getDomain());

        keyList.setElementAt(newKeyInfo, number);