org.apache.geronimo.security.keystore
Class FileKeystoreInstance

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

public class FileKeystoreInstance
extends Object
implements KeystoreInstance, 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).

Version:
$Rev: 1144307 $ $Date: 2011-07-08 21:24:09 +0800 (Fri, 08 Jul 2011) $

Field Summary
static GBeanInfo GBEAN_INFO
           
 
Constructor Summary
FileKeystoreInstance(ServerInfo serverInfo, URI keystorePath, String keystoreName, String keystorePassword, String keystoreType, String keyPasswords, Kernel kernel, AbstractName abstractName)
           
 
Method Summary
 void changeKeyPassword(String alias, char[] storePassword, char[] keyPassword, char[] newKeyPassword)
          Changes the password for a private key entry in the keystore.
 void changeKeystorePassword(char[] storePassword, char[] newPassword)
          Changes the keystore password.
 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)
          Gets a particular certificate from the keystore.
 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 GBeanInfo getGBeanInfo()
           
 KeyManager[] getKeyManager(String algorithm, String alias, char[] storePassword)
           
 String getKeystoreName()
           
 String getKeystoreType()
           
 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 GBeanInfo GBEAN_INFO
Constructor Detail

FileKeystoreInstance

public FileKeystoreInstance(ServerInfo serverInfo,
                            URI keystorePath,
                            String keystoreName,
                            String keystorePassword,
                            String keystoreType,
                            String keyPasswords,
                            Kernel kernel,
                            AbstractName abstractName)
Method Detail

doStart

public void doStart()
             throws Exception
Specified by:
doStart in interface GBeanLifecycle
Throws:
Exception

doStop

public void doStop()
            throws Exception
Specified by:
doStop in interface GBeanLifecycle
Throws:
Exception

doFail

public void doFail()
Specified by:
doFail in interface GBeanLifecycle

getGBeanInfo

public static GBeanInfo getGBeanInfo()

getKeystoreName

public String getKeystoreName()
Specified by:
getKeystoreName in interface KeystoreInstance

getKeystoreType

public String getKeystoreType()
Specified by:
getKeystoreType in interface KeystoreInstance

unlockKeystore

public void unlockKeystore(char[] password)
                    throws KeystoreException
Specified by:
unlockKeystore in interface KeystoreInstance
Throws:
KeystoreException

setKeystorePassword

public void setKeystorePassword(String password)

lockKeystore

public void lockKeystore(char[] password)
                  throws KeystoreException
Specified by:
lockKeystore in interface KeystoreInstance
Throws:
KeystoreException

isKeystoreLocked

public boolean isKeystoreLocked()
Specified by:
isKeystoreLocked in interface KeystoreInstance

listPrivateKeys

public String[] listPrivateKeys(char[] storePassword)
                         throws KeystoreException
Specified by:
listPrivateKeys in interface KeystoreInstance
Throws:
KeystoreException

unlockPrivateKey

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

getUnlockedKeys

public String[] getUnlockedKeys(char[] storePassword)
                         throws KeystoreException
Specified by:
getUnlockedKeys in interface KeystoreInstance
Throws:
KeystoreException

isTrustStore

public boolean isTrustStore(char[] storePassword)
                     throws KeystoreException
Specified by:
isTrustStore in interface KeystoreInstance
Throws:
KeystoreException

lockPrivateKey

public void lockPrivateKey(String alias,
                           char[] storePassword)
                    throws KeystoreException
Specified by:
lockPrivateKey in interface KeystoreInstance
Throws:
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 KeystoreInstance

listTrustCertificates

public String[] listTrustCertificates(char[] storePassword)
                               throws KeystoreException
Specified by:
listTrustCertificates in interface KeystoreInstance
Throws:
KeystoreException

importTrustCertificate

public void importTrustCertificate(Certificate cert,
                                   String alias,
                                   char[] storePassword)
                            throws KeystoreException
Specified by:
importTrustCertificate in interface KeystoreInstance
Throws:
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 KeystoreException
Specified by:
generateKeyPair in interface KeystoreInstance
Throws:
KeystoreException

generateCSR

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

importPKCS7Certificate

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

deleteEntry

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

getKeyManager

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

getTrustManager

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

getPrivateKey

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

Specified by:
getPrivateKey in interface 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:
KeyNotFoundException
KeystoreException
KeystoreIsLocked

getCertificate

public Certificate getCertificate(String alias,
                                  char[] storePassword)
                           throws KeystoreIsLocked,
                                  KeyNotFoundException,
                                  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 KeystoreInstance
Parameters:
alias - The certificate to look at
Throws:
KeyNotFoundException
KeyStoreException
KeystoreIsLocked
KeystoreException

getCertificateAlias

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

getCertificateChain

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

getCertificate

public Certificate getCertificate(String alias)
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 KeystoreInstance
Parameters:
alias - The certificate to look at

changeKeystorePassword

public void changeKeystorePassword(char[] storePassword,
                                   char[] newPassword)
                            throws KeystoreException
Changes the keystore password.

Specified by:
changeKeystorePassword in interface KeystoreInstance
Parameters:
storePassword - Current password for the keystore
newPassword - New password for the keystore
Throws:
KeystoreException

changeKeyPassword

public void changeKeyPassword(String alias,
                              char[] storePassword,
                              char[] keyPassword,
                              char[] newKeyPassword)
                       throws KeystoreException
Changes the password for a private key entry in the keystore.

Specified by:
changeKeyPassword in interface KeystoreInstance
Parameters:
storePassword - Password for the keystore
keyPassword - Current password for the private key
newKeyPassword - New password for the private key
Throws:
KeystoreException


Copyright © 2003-2011 The Apache Geronimo development community. All Rights Reserved.