FileDocCategorySizeDatePackage
PublicKeyStore.javaAPI DocJ2ME MIDP 2.03751Thu Nov 07 12:02:26 GMT 2002com.sun.midp.publickeystore

PublicKeyStore

public class PublicKeyStore extends Object
A read-only public keystore for use with MIDP.

Fields Summary
private Vector
keyList
Holds the all the keys as {@link PublicKeyInfo} objects.
Constructors Summary
protected PublicKeyStore()
Constructor for subclasses.


            
      
    
public PublicKeyStore(InputStream in)
Constructs a read-only keystore from a serialized keystore created by {@link PublicKeyStoreBuilder}.

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

        initPublicKeyStore(in, new Vector());
    
Methods Summary
public synchronized java.util.VectorfindKeys(java.lang.String owner)
Finds a CAs Public keys based on the distinguished name.

param
owner distinguished name of keys' owner
return
public key information of the keys

        PublicKeyInfo keyInfo;
        Vector keys = null;
  
        for (int i = 0; i < keyList.size(); i++) {
            keyInfo = (PublicKeyInfo)keyList.elementAt(i);
	    if (keyInfo.getOwner().compareTo(owner) == 0) {
                if (keys == null) {
                    keys = new Vector();
                }

                keys.addElement(keyInfo);
            }
	}

        return keys;
    
public synchronized PublicKeyInfogetKey(int number)
Gets a by number from the keystore. 0 is the first key.

param
number number of key
return
public key information of the key
exception
ArrayIndexOutOfBoundsException if an invalid number was given.

        return (PublicKeyInfo)keyList.elementAt(number);
    
protected voidinitPublicKeyStore(java.util.Vector sharedKeyList)
Lets this class work with a writeable key list of a subclass. This is needed because we cannot make the key list in this class protected for security reasons. This method will only work if the PublicKeyStore has not been initialized.

param
sharedKeyList key list of a subclass

        if (keyList != null) {
            return;
        }

        keyList = sharedKeyList;
    
protected voidinitPublicKeyStore(java.io.InputStream in, java.util.Vector sharedKeyList)
Lets this class work with a writeable key list of a subclass and initialized that key list from a serialized key list. This is needed because we cannot make the key list in this class protected for security reasons. This method will only work if the PublicKeyStore has not been initialized.

param
sharedKeyList key list of a subclass
param
in stream to read the serialized keystore
exception
IOException if the key storage was corrupted

        InputStorage storage = new InputStorage(in);
        PublicKeyInfo keyInfo;

        if (keyList != null) {
            return;
        }

        keyList = sharedKeyList;
        for (;;) {
            keyInfo = PublicKeyInfo.getKeyFromStorage(storage);
            if (keyInfo == null)
                return;
            
            keyList.addElement(keyInfo);
        }
    
public synchronized intnumberOfKeys()
Gets the number of keys in the store.

return
number of keys in the keystore

        return keyList.size();