public class KeyStoreManager extends Object
Modifier and Type | Field and Description |
---|---|
static String |
_caPrivKeyAlias |
KeyPairGenerator |
_dsaKpg |
KeyPairGenerator |
_rsaKpg |
String |
DSA_KEYGEN_ALGO |
String |
RSA_KEYGEN_ALGO |
Constructor and Description |
---|
KeyStoreManager(File root,
String certificateRevocationList) |
Modifier and Type | Method and Description |
---|---|
void |
addCertAndPrivateKey(String hostname,
X509Certificate cert,
PrivateKey privKey)
Stores a new certificate and its associated private key in the keystore.
|
protected void |
createKeystore()
Creates, writes and loads a new keystore and CA root certificate.
|
X509Certificate |
getCertificateByAlias(String alias)
Returns the aliased certificate.
|
X509Certificate |
getCertificateByHostname(String hostname)
Returns the aliased certificate.
|
KeyStore |
getKeyStore() |
X509Certificate |
getMappedCertificateForHostname(String hostname)
This method returns the mapped certificate for a hostname, or generates a "standard" SSL server
certificate issued by the CA to the supplied subject if no mapping has been created.
|
KeyPair |
getRSAKeyPair() |
X509Certificate |
getSigningCert()
Gets the authority root signing cert.
|
PrivateKey |
getSigningPrivateKey()
Gets the authority private signing key.
|
void |
persist()
Writes the keystore and certificate/keypair mappings to disk.
|
public static final String _caPrivKeyAlias
public final String RSA_KEYGEN_ALGO
public final String DSA_KEYGEN_ALGO
public final KeyPairGenerator _rsaKpg
public final KeyPairGenerator _dsaKpg
protected void createKeystore()
public void addCertAndPrivateKey(String hostname, X509Certificate cert, PrivateKey privKey) throws KeyStoreException, CertificateException, NoSuchAlgorithmException
hostname
- host namecert
- certificateprivKey
- private keyKeyStoreException
- key store exceptionCertificateException
- certificate exceptionNoSuchAlgorithmException
- no such algorithmpublic void persist() throws KeyStoreException, NoSuchAlgorithmException, CertificateException
KeyStoreException
- key store exceptionCertificateException
- certificate exceptionNoSuchAlgorithmException
- no such algorithmpublic X509Certificate getCertificateByAlias(String alias) throws KeyStoreException
alias
- aliasKeyStoreException
- keystore exceptionThumbprintUtil
public X509Certificate getCertificateByHostname(String hostname) throws KeyStoreException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, UnrecoverableKeyException
hostname
- host nameKeyStoreException
- keystoreUnrecoverableKeyException
- unrecoverable keyNoSuchProviderException
- no such providerNoSuchAlgorithmException
- no such algorithmCertificateException
- certificateSignatureException
- signatureCertificateNotYetValidException
- certificate not yet validCertificateExpiredException
- certificate expiredInvalidKeyException
- invalid keyCertificateParsingException
- certificate parsingThumbprintUtil
public X509Certificate getSigningCert() throws KeyStoreException
KeyStoreException
- keystorepublic PrivateKey getSigningPrivateKey() throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException
KeyStoreException
- key store exceptionUnrecoverableKeyException
- unrecoverable keyNoSuchAlgorithmException
- no such algorithmpublic X509Certificate getMappedCertificateForHostname(String hostname) throws InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, KeyStoreException, UnrecoverableKeyException
hostname
- host nameKeyStoreException
- keystoreUnrecoverableKeyException
- unrecoverable keyNoSuchProviderException
- no such providerNoSuchAlgorithmException
- no such algorithmCertificateException
- certificateSignatureException
- signatureInvalidKeyException
- invalid keypublic KeyPair getRSAKeyPair()
public KeyStore getKeyStore()
Copyright © 2015. All rights reserved.