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 months,
String issuerDN,
String subjectDN,
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,
String 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(KeyStore keyStore,
String alias)
Returns true if the specified certificate is a self-signed certificate.
|
static boolean |
isSelfSignedCertificate(KeyStore keyStore,
X509Certificate certificate)
Returns true if the specified certificate is a self-signed certificate.
|
static boolean |
isSigningRequestPending(KeyStore keyStore,
String alias)
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)
Deprecated.
Use
parseCertificates(String) instead. |
static Collection<X509Certificate> |
parseCertificates(String pemRepresentation)
Parses a certificate chain from a PEM representation.
|
static PrivateKey |
parsePrivateKey(InputStream pemRepresentation,
String passPhrase)
Deprecated.
Use
parsePrivateKey(String, String) instead. |
static PrivateKey |
parsePrivateKey(String pemRepresentation,
String passPhrase)
Parses a PrivateKey instance from a PEM representation.
|
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.KeyStoreExceptionpublic 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.KeyStoreExceptionpublic static boolean isDSACertificate(X509Certificate certificate) throws KeyStoreException
certificate - the certificate to analyze.KeyStoreExceptionpublic static boolean isSelfSignedCertificate(KeyStore keyStore, String alias) 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 isSelfSignedCertificate(KeyStore keyStore, X509Certificate certificate) throws KeyStoreException
keyStore - key store that holds the certificate to verify.certificate - the certificate in the key store.KeyStoreException - if an error happens while usign the keystorepublic static boolean isSigningRequestPending(KeyStore keyStore, String alias) 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 InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, 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.InvalidKeyExceptionNoSuchAlgorithmExceptionNoSuchProviderExceptionSignatureExceptionIOExceptionpublic static boolean installReply(KeyStore keyStore, KeyStore trustStore, String 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.Exceptionpublic 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.@Deprecated public static PrivateKey parsePrivateKey(InputStream pemRepresentation, String passPhrase) throws IOException
parsePrivateKey(String, String) instead.IOExceptionpublic static PrivateKey parsePrivateKey(String 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@Deprecated public static Collection<X509Certificate> parseCertificates(InputStream pemRepresentation) throws IOException, CertificateException
parseCertificates(String) instead.IOExceptionCertificateExceptionpublic static Collection<X509Certificate> parseCertificates(String pemRepresentation) throws IOException, CertificateException
pemRepresentation - a PEM representation of a certificate or certificate chain (cannot be null or empty)IOExceptionCertificateExceptionpublic 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).CertificateExceptionpublic static X509Certificate createX509V3Certificate(KeyPair kp, int months, String issuerDN, String subjectDN, String domain, String signAlgoritm) throws GeneralSecurityException, IOException
kp - KeyPair that keeps the public and private keys for the new certificate.months - time to liveissuerDN - Issuer string e.g "O=Grid,OU=OGSA,CN=ACME"subjectDN - Subject string e.g "O=Grid,OU=OGSA,CN=John Doe"domain - Domain of the server.signAlgoritm - Signature algorithm. This can be either a name or an OID.GeneralSecurityExceptionIOExceptionCopyright © 2003-2008 Jive Software.