public class CertificateManager extends Object
Constructor and Description |
---|
CertificateManager() |
Modifier and Type | Method and Description |
---|---|
static void |
addListener(CertificateEventListener listener)
Registers a listener to receive events.
|
static String |
createSigningRequest(X509Certificate cert,
PrivateKey privKey)
Creates and returns the content of a new singing request for the specified certificate.
|
static X509Certificate |
createX509V3Certificate(KeyPair kp,
int days,
String issuerCommonName,
String subjectCommonName,
String domain,
String signAlgoritm)
Creates an X509 version3 certificate.
|
static X509Certificate |
createX509V3Certificate(KeyPair kp,
int days,
org.bouncycastle.asn1.x500.X500NameBuilder issuerBuilder,
org.bouncycastle.asn1.x500.X500NameBuilder subjectBuilder,
String domain,
String signAlgoritm)
Creates an X509 version3 certificate.
|
static List<String> |
getClientIdentities(X509Certificate x509Certificate)
Returns the identities of the remote client as defined in the specified certificate.
|
static X509Certificate |
getEndEntityCertificate(Certificate[] chain,
KeyStore certStore,
KeyStore trustStore)
Decide whether or not to trust the given supplied certificate chain, returning the
End Entity Certificate in this case where it can, and null otherwise.
|
static List<String> |
getServerIdentities(X509Certificate x509Certificate)
Returns the identities of the remote server as defined in the specified certificate.
|
static boolean |
installCert(KeyStore keyStore,
KeyStore trustStore,
String keyPassword,
String alias,
InputStream pkInputStream,
String passPhrase,
InputStream inputStream)
Imports a new signed certificate and its private key into the keystore.
|
static boolean |
installReply(KeyStore keyStore,
KeyStore trustStore,
char[] keyPassword,
String alias,
InputStream inputStream)
Installs the Certificate Authority reply returned as part of the signing request.
|
static boolean |
isDSACertificate(CertificateStore storeConfig,
String domain)
Returns true if an DSA certificate was found in the specified keystore for the specified domain.
|
static boolean |
isDSACertificate(X509Certificate certificate)
Returns true if the specified certificate is using the DSA algorithm.
|
static boolean |
isRSACertificate(CertificateStore storeConfig,
String domain)
Returns true if an RSA certificate was found in the specified keystore for the specified domain.
|
static boolean |
isSelfSignedCertificate(X509Certificate certificate)
Returns true if the specified certificate is a self-signed certificate.
|
static boolean |
isSigningRequestPending(X509Certificate certificate)
Returns true if the specified certificate is ready to be signed by a Certificate Authority.
|
static List<X509Certificate> |
order(Collection<X509Certificate> certificates)
Deprecated.
Moved to CertificateUtils
|
static Collection<X509Certificate> |
parseCertificates(InputStream pemRepresentation)
Parses a certificate chain from a PEM representation.
|
static Collection<X509Certificate> |
parseCertificates(String pemRepresentation) |
static PrivateKey |
parsePrivateKey(InputStream pemRepresentation,
String passPhrase)
Parses a PrivateKey instance from a PEM representation.
|
static PrivateKey |
parsePrivateKey(String pemRepresentation,
String passPhrase) |
static void |
removeListener(CertificateEventListener listener)
Unregisters a listener to receive events.
|
public static X509Certificate getEndEntityCertificate(Certificate[] chain, KeyStore certStore, KeyStore trustStore)
chain
- an array of X509Certificate where the first one is the endEntityCertificate.certStore
- a keystore containing untrusted certificates (including ICAs, etc).trustStore
- a keystore containing Trust Anchors (most-trusted CA certificates).public static List<String> getClientIdentities(X509Certificate x509Certificate)
x509Certificate
- the certificate the holds the identities of the remote server.public static List<String> getServerIdentities(X509Certificate x509Certificate)
x509Certificate
- the certificate the holds the identities of the remote server.public static boolean isRSACertificate(CertificateStore storeConfig, String domain) throws KeyStoreException
storeConfig
- the store to use for searching the certificate.domain
- domain of the server signed by the certificate.KeyStoreException
public static boolean isDSACertificate(CertificateStore storeConfig, String domain) throws KeyStoreException
storeConfig
- the store to use for searching the certificate.domain
- domain of the server signed by the certificate.KeyStoreException
public static boolean isDSACertificate(X509Certificate certificate) throws KeyStoreException
certificate
- the certificate to analyze.KeyStoreException
public static boolean isSelfSignedCertificate(X509Certificate certificate) throws KeyStoreException
keyStore
- key store that holds the certificate to verify.alias
- alias of the certificate in the key store.KeyStoreException
- if an error happens while usign the keystorepublic static boolean isSigningRequestPending(X509Certificate certificate) throws KeyStoreException
keyStore
- key store that holds the certificate to verify.alias
- alias of the certificate in the key store.KeyStoreException
- if an error happens while usign the keystorepublic static String createSigningRequest(X509Certificate cert, PrivateKey privKey) throws org.bouncycastle.operator.OperatorCreationException, IOException
#installReply(java.security.KeyStore, java.security.KeyStore, String, String, java.io.InputStream)
to import the CA reply.cert
- the certificate to create a signing request.privKey
- the private key of the certificate.org.bouncycastle.operator.OperatorCreationException
IOException
public static boolean installReply(KeyStore keyStore, KeyStore trustStore, char[] keyPassword, String alias, InputStream inputStream) throws Exception
keyStore
- key store where the certificate is stored.trustStore
- key store where ca certificates are stored.keyPassword
- password of the keystore.alias
- the alias of the existing certificate being signed.inputStream
- the stream containing the CA reply.Exception
public static boolean installCert(KeyStore keyStore, KeyStore trustStore, String keyPassword, String alias, InputStream pkInputStream, String passPhrase, InputStream inputStream) throws Exception
keyStore
- key store where the certificate will be stored.trustStore
- key store where ca certificates are stored.keyPassword
- password of the keystore.alias
- the alias of the the new signed certificate.pkInputStream
- the stream containing the private key.passPhrase
- is the password phrased used when creating the private key.inputStream
- the stream containing the signed certificate.Exception
- if no certificates were found in the inputStream.public static PrivateKey parsePrivateKey(String pemRepresentation, String passPhrase) throws IOException
IOException
public static PrivateKey parsePrivateKey(InputStream pemRepresentation, String passPhrase) throws IOException
pemRepresentation
- a PEM representation of a private key (cannot be null or empty)passPhrase
- optional pass phrase (must be present if the private key is encrypted).IOException
public static Collection<X509Certificate> parseCertificates(String pemRepresentation) throws IOException, CertificateException
IOException
CertificateException
public static Collection<X509Certificate> parseCertificates(InputStream pemRepresentation) throws IOException, CertificateException
pemRepresentation
- a PEM representation of a certificate or certificate chain (cannot be null or empty)IOException
CertificateException
public static void addListener(CertificateEventListener listener)
listener
- the listener.public static void removeListener(CertificateEventListener listener)
listener
- the listener.@Deprecated public static List<X509Certificate> order(Collection<X509Certificate> certificates) throws CertificateException
certificates
- an unordered collection of certificates (cannot be null).CertificateException
public static X509Certificate createX509V3Certificate(KeyPair kp, int days, String issuerCommonName, String subjectCommonName, String domain, String signAlgoritm) throws GeneralSecurityException, IOException
kp
- KeyPair that keeps the public and private keys for the new certificate.days
- time to liveissuerCommonName
- Issuer CN stringsubjectCommonName
- Subject CN stringdomain
- Domain of the server.signAlgoritm
- Signature algorithm. This can be either a name or an OID.GeneralSecurityException
IOException
public static X509Certificate createX509V3Certificate(KeyPair kp, int days, org.bouncycastle.asn1.x500.X500NameBuilder issuerBuilder, org.bouncycastle.asn1.x500.X500NameBuilder subjectBuilder, String domain, String signAlgoritm) throws GeneralSecurityException, IOException
kp
- KeyPair that keeps the public and private keys for the new certificate.days
- time to liveissuerBuilder
- IssuerDN buildersubjectBuilder
- SubjectDN builderdomain
- Domain of the server.signAlgoritm
- Signature algorithm. This can be either a name or an OID.GeneralSecurityException
IOException
Copyright © 2003-2008 Jive Software.