public class BouncyCastleSecurityProviderTool extends Object implements SecurityProviderTool
| Constructor and Description |
|---|
BouncyCastleSecurityProviderTool() |
| Modifier and Type | Method and Description |
|---|---|
CertificateAndKey |
createCARootCertificate(CertificateInfo certificateInfo,
KeyPair keyPair,
String messageDigest)
Creates a new self-signed CA root certificate, suitable for use signing new server certificates.
|
KeyStore |
createRootCertificateKeyStore(String keyStoreType,
CertificateAndKey rootCertificateAndKey,
String privateKeyAlias,
String password)
Assembles a Java KeyStore containing a CA root certificate and its private key.
|
CertificateAndKey |
createServerCertificate(CertificateInfo certificateInfo,
X509Certificate caRootCertificate,
PrivateKey caPrivateKey,
KeyPair serverKeyPair,
String messageDigest)
Creates a new server X.509 certificate using the serverKeyPair.
|
KeyStore |
createServerKeyStore(String keyStoreType,
CertificateAndKey serverCertificateAndKey,
X509Certificate rootCertificate,
String privateKeyAlias,
String password)
Assembles a Java KeyStore containing a server's certificate, private key, and the certificate authority's certificate,
which can be used to create an
SSLContext. |
X509Certificate |
decodePemEncodedCertificate(Reader certificateReader)
Decodes a PEM-encoded X.509 Certificate into a
X509Certificate. |
PrivateKey |
decodePemEncodedPrivateKey(Reader privateKeyReader,
String password)
Decodes a PEM-encoded private key into a
PrivateKey. |
String |
encodeCertificateAsPem(Certificate certificate)
Encodes a certificate in PEM format.
|
String |
encodePrivateKeyAsPem(PrivateKey privateKey,
String passwordForPrivateKey,
String encryptionAlgorithm)
Encodes a private key in PEM format, encrypting it with the specified password.
|
KeyManager[] |
getKeyManagers(KeyStore keyStore,
String keyStorePassword)
Retrieve the KeyManagers for the specified KeyStore.
|
KeyStore |
loadKeyStore(File file,
String keyStoreType,
String password)
Loads a Java KeyStore object from a file.
|
void |
saveKeyStore(File file,
KeyStore keyStore,
String keystorePassword)
Saves a Java KeyStore to a file, protecting it with the specified password.
|
public CertificateAndKey createServerCertificate(CertificateInfo certificateInfo, X509Certificate caRootCertificate, PrivateKey caPrivateKey, KeyPair serverKeyPair, String messageDigest)
SecurityProviderToolcreateServerCertificate in interface SecurityProviderToolcertificateInfo - basic X.509 certificate info that will be used to create the server certificatecaRootCertificate - root certificate that will be used to populate the issuer field of the server certificatecaPrivateKey - root certificate private key that will be used to sign the server certificateserverKeyPair - server's public and private keysmessageDigest - message digest to use when signing the server certificate, such as SHA512public KeyStore createServerKeyStore(String keyStoreType, CertificateAndKey serverCertificateAndKey, X509Certificate rootCertificate, String privateKeyAlias, String password)
SecurityProviderToolSSLContext.createServerKeyStore in interface SecurityProviderToolkeyStoreType - the KeyStore type, such as JKS or PKCS12serverCertificateAndKey - certificate and private key for the server, which will be placed in the KeyStorerootCertificate - CA root certificate of the private key that signed the server certificateprivateKeyAlias - alias to assign the private key (with accompanying certificate chain) to in the KeyStorepassword - password for the new KeyStore and private keypublic KeyStore createRootCertificateKeyStore(String keyStoreType, CertificateAndKey rootCertificateAndKey, String privateKeyAlias, String password)
SecurityProviderToolcreateRootCertificateKeyStore in interface SecurityProviderToolkeyStoreType - the KeyStore type, such as JKS or PKCS12rootCertificateAndKey - certification authority's root certificate and private key, which will be placed in the KeyStoreprivateKeyAlias - alias to assign the private key (with accompanying certificate chain) to in the KeyStorepassword - password for the new KeyStore and private keypublic CertificateAndKey createCARootCertificate(CertificateInfo certificateInfo, KeyPair keyPair, String messageDigest)
SecurityProviderToolcreateCARootCertificate in interface SecurityProviderToolcertificateInfo - certificate info to populate in the new root certkeyPair - root certificate's public and private keysmessageDigest - digest to use when signing the new root certificate, such as SHA512public String encodePrivateKeyAsPem(PrivateKey privateKey, String passwordForPrivateKey, String encryptionAlgorithm)
SecurityProviderToolencodePrivateKeyAsPem in interface SecurityProviderToolprivateKey - private key to encodepasswordForPrivateKey - password to protect the private keyencryptionAlgorithm - algorithm to use to encrypt the private keypublic String encodeCertificateAsPem(Certificate certificate)
SecurityProviderToolencodeCertificateAsPem in interface SecurityProviderToolcertificate - certificate to encodepublic PrivateKey decodePemEncodedPrivateKey(Reader privateKeyReader, String password)
SecurityProviderToolPrivateKey. The password may be null if the PEM-encoded private key
is not password-encrypted.decodePemEncodedPrivateKey in interface SecurityProviderToolprivateKeyReader - a reader for a PEM-encoded private keypassword - password protecting the private key @return the decoded private keypublic X509Certificate decodePemEncodedCertificate(Reader certificateReader)
SecurityProviderToolX509Certificate.decodePemEncodedCertificate in interface SecurityProviderToolcertificateReader - a reader for a PEM-encoded certificatepublic KeyStore loadKeyStore(File file, String keyStoreType, String password)
SecurityProviderToolloadKeyStore in interface SecurityProviderToolfile - KeyStore file to loadkeyStoreType - KeyStore type (PKCS12, JKS, etc.)password - the KeyStore passwordpublic void saveKeyStore(File file, KeyStore keyStore, String keystorePassword)
SecurityProviderToolsaveKeyStore in interface SecurityProviderToolfile - file to save the KeyStore tokeyStore - KeyStore to savekeystorePassword - password for the KeyStorepublic KeyManager[] getKeyManagers(KeyStore keyStore, String keyStorePassword)
SecurityProviderToolgetKeyManagers in interface SecurityProviderToolkeyStore - the KeyStore to retrieve KeyManagers fromkeyStorePassword - the KeyStore passwordCopyright © 2016. All Rights Reserved.