org.apache.geronimo.security.keystore
Class FileKeystoreInstance

java.lang.Object
  extended by org.apache.geronimo.security.keystore.FileKeystoreInstance
All Implemented Interfaces:
org.apache.geronimo.gbean.GBeanLifecycle, org.apache.geronimo.management.geronimo.KeystoreInstance

public class FileKeystoreInstance
extends Object
implements org.apache.geronimo.management.geronimo.KeystoreInstance, org.apache.geronimo.gbean.GBeanLifecycle

Implementation of KeystoreInstance that accesses a keystore file on the local filesystem, identified by the file's name (the last component of the name only, not the full path).


Field Summary
static org.apache.geronimo.gbean.GBeanInfo GBEAN_INFO
           
 
Constructor Summary
FileKeystoreInstance(org.apache.geronimo.system.serverinfo.ServerInfo serverInfo, URI keystorePath, String keystoreName, String keystorePassword, String keyPasswords, org.apache.geronimo.kernel.Kernel kernel, org.apache.geronimo.gbean.AbstractName abstractName)
           
 
Method Summary
 void deleteEntry(String alias, char[] storePassword)
           
 void doFail()
           
 void doStart()
           
 void doStop()
           
 String generateCSR(String alias, char[] storePassword)
           
 void generateKeyPair(String alias, char[] storePassword, char[] keyPassword, String keyAlgorithm, int keySize, String signatureAlgorithm, int validity, String commonName, String orgUnit, String organization, String locality, String state, String country)
           
 Certificate getCertificate(String alias, char[] storePassword)
          Gets a particular certificate from the keystore.
 String getCertificateAlias(Certificate cert, char[] storePassword)
           
 Certificate[] getCertificateChain(String alias, char[] storePassword)
           
static org.apache.geronimo.gbean.GBeanInfo getGBeanInfo()
           
 KeyManager[] getKeyManager(String algorithm, String alias, char[] storePassword)
           
 String getKeystoreName()
           
 PrivateKey getPrivateKey(String alias, char[] storePassword, char[] keyPassword)
          Gets the private key with the specified alias.
 TrustManager[] getTrustManager(String algorithm, char[] storePassword)
           
 String[] getUnlockedKeys(char[] storePassword)
           
 void importPKCS7Certificate(String alias, String certbuf, char[] storePassword)
           
 void importTrustCertificate(Certificate cert, String alias, char[] storePassword)
           
 boolean isKeyLocked(String alias)
          Checks whether the specified private key is locked, which is to say, available for other components to use to generate socket factories.
 boolean isKeystoreLocked()
           
 boolean isTrustStore(char[] storePassword)
           
 String[] listPrivateKeys(char[] storePassword)
           
 String[] listTrustCertificates(char[] storePassword)
           
 void lockKeystore(char[] password)
           
 void lockPrivateKey(String alias, char[] storePassword)
           
 void setKeyPasswords(String passwords)
           
 void setKeystorePassword(String password)
           
 void unlockKeystore(char[] password)
           
 void unlockPrivateKey(String alias, char[] storePassword, char[] password)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GBEAN_INFO

public static final org.apache.geronimo.gbean.GBeanInfo GBEAN_INFO
Constructor Detail

FileKeystoreInstance

public FileKeystoreInstance(org.apache.geronimo.system.serverinfo.ServerInfo serverInfo,
                            URI keystorePath,
                            String keystoreName,
                            String keystorePassword,
                            String keyPasswords,
                            org.apache.geronimo.kernel.Kernel kernel,
                            org.apache.geronimo.gbean.AbstractName abstractName)
Method Detail

doStart

public void doStart()
             throws Exception
Specified by:
doStart in interface org.apache.geronimo.gbean.GBeanLifecycle
Throws:
Exception

doStop

public void doStop()
            throws Exception
Specified by:
doStop in interface org.apache.geronimo.gbean.GBeanLifecycle
Throws:
Exception

doFail

public void doFail()
Specified by:
doFail in interface org.apache.geronimo.gbean.GBeanLifecycle

getGBeanInfo

public static org.apache.geronimo.gbean.GBeanInfo getGBeanInfo()

getKeystoreName

public String getKeystoreName()
Specified by:
getKeystoreName in interface org.apache.geronimo.management.geronimo.KeystoreInstance

unlockKeystore

public void unlockKeystore(char[] password)
                    throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
unlockKeystore in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

setKeystorePassword

public void setKeystorePassword(String password)

lockKeystore

public void lockKeystore(char[] password)
                  throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
lockKeystore in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

isKeystoreLocked

public boolean isKeystoreLocked()
Specified by:
isKeystoreLocked in interface org.apache.geronimo.management.geronimo.KeystoreInstance

listPrivateKeys

public String[] listPrivateKeys(char[] storePassword)
                         throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
listPrivateKeys in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

unlockPrivateKey

public void unlockPrivateKey(String alias,
                             char[] storePassword,
                             char[] password)
                      throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
unlockPrivateKey in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

getUnlockedKeys

public String[] getUnlockedKeys(char[] storePassword)
                         throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
getUnlockedKeys in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

isTrustStore

public boolean isTrustStore(char[] storePassword)
                     throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
isTrustStore in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

lockPrivateKey

public void lockPrivateKey(String alias,
                           char[] storePassword)
                    throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
lockPrivateKey in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

setKeyPasswords

public void setKeyPasswords(String passwords)

isKeyLocked

public boolean isKeyLocked(String alias)
Checks whether the specified private key is locked, which is to say, available for other components to use to generate socket factories. Does not check whether the unlock password is actually correct.

Specified by:
isKeyLocked in interface org.apache.geronimo.management.geronimo.KeystoreInstance

listTrustCertificates

public String[] listTrustCertificates(char[] storePassword)
                               throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
listTrustCertificates in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

importTrustCertificate

public void importTrustCertificate(Certificate cert,
                                   String alias,
                                   char[] storePassword)
                            throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
importTrustCertificate in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

generateKeyPair

public void generateKeyPair(String alias,
                            char[] storePassword,
                            char[] keyPassword,
                            String keyAlgorithm,
                            int keySize,
                            String signatureAlgorithm,
                            int validity,
                            String commonName,
                            String orgUnit,
                            String organization,
                            String locality,
                            String state,
                            String country)
                     throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
generateKeyPair in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

generateCSR

public String generateCSR(String alias,
                          char[] storePassword)
                   throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
generateCSR in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

importPKCS7Certificate

public void importPKCS7Certificate(String alias,
                                   String certbuf,
                                   char[] storePassword)
                            throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
importPKCS7Certificate in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

deleteEntry

public void deleteEntry(String alias,
                        char[] storePassword)
                 throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
deleteEntry in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

getKeyManager

public KeyManager[] getKeyManager(String algorithm,
                                  String alias,
                                  char[] storePassword)
                           throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
getKeyManager in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

getTrustManager

public TrustManager[] getTrustManager(String algorithm,
                                      char[] storePassword)
                               throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
getTrustManager in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

getPrivateKey

public PrivateKey getPrivateKey(String alias,
                                char[] storePassword,
                                char[] keyPassword)
                         throws org.apache.geronimo.management.geronimo.KeyNotFoundException,
                                org.apache.geronimo.management.geronimo.KeystoreException,
                                org.apache.geronimo.management.geronimo.KeystoreIsLocked
Gets the private key with the specified alias.

Specified by:
getPrivateKey in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Parameters:
alias - The alias of the private key to be retrieved
storePassword - The password used to access the keystore
keyPassword - The password to use to protect the new key
Returns:
PrivateKey with the alias specified
Throws:
org.apache.geronimo.management.geronimo.KeyNotFoundException
org.apache.geronimo.management.geronimo.KeystoreException
org.apache.geronimo.management.geronimo.KeystoreIsLocked

getCertificate

public Certificate getCertificate(String alias,
                                  char[] storePassword)
                           throws org.apache.geronimo.management.geronimo.KeystoreIsLocked,
                                  org.apache.geronimo.management.geronimo.KeyNotFoundException,
                                  org.apache.geronimo.management.geronimo.KeystoreException
Gets a particular certificate from the keystore. This may be a trust certificate or the certificate corresponding to a particular private key. This only works if the keystore is unlocked.

Specified by:
getCertificate in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Parameters:
alias - The certificate to look at
Throws:
org.apache.geronimo.management.geronimo.KeyNotFoundException
KeyStoreException
org.apache.geronimo.management.geronimo.KeystoreIsLocked
org.apache.geronimo.management.geronimo.KeystoreException

getCertificateAlias

public String getCertificateAlias(Certificate cert,
                                  char[] storePassword)
                           throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
getCertificateAlias in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException

getCertificateChain

public Certificate[] getCertificateChain(String alias,
                                         char[] storePassword)
                                  throws org.apache.geronimo.management.geronimo.KeystoreException
Specified by:
getCertificateChain in interface org.apache.geronimo.management.geronimo.KeystoreInstance
Throws:
org.apache.geronimo.management.geronimo.KeystoreException


Copyright © 2006 Apache Software Foundation. All Rights Reserved.