Connection Manager 3.6.3 Javadoc

org.jivesoftware.util
Class CertificateManager

java.lang.Object
  extended by org.jivesoftware.util.CertificateManager

public class CertificateManager
extends java.lang.Object

Utility class that provides similar functionality to the keytool tool. Generated certificates conform to the XMPP spec where domains are kept in the subject alternative names extension.

Author:
Gaston Dombiak

Constructor Summary
CertificateManager()
           
 
Method Summary
static void addListener(CertificateEventListener listener)
          Registers a listener to receive events.
static java.security.cert.X509Certificate createDSACert(java.security.KeyStore ksKeys, java.lang.String keyPassword, java.lang.String alias, java.lang.String issuerDN, java.lang.String subjectDN, java.lang.String domain)
          Creates a new X509 certificate using the DSA algorithm.
static java.security.cert.X509Certificate createRSACert(java.security.KeyStore ksKeys, java.lang.String keyPassword, java.lang.String alias, java.lang.String issuerDN, java.lang.String subjectDN, java.lang.String domain)
          Creates a new X509 certificate using the RSA algorithm.
static java.lang.String createSigningRequest(java.security.cert.X509Certificate cert, java.security.PrivateKey privKey)
          Creates and returns the content of a new singing request for the specified certificate.
static void deleteCertificate(java.security.KeyStore ksKeys, java.lang.String alias)
          Deletes the specified certificate from the
static java.util.List<java.lang.String> getPeerIdentities(java.security.cert.X509Certificate x509Certificate)
          Returns the identities of the remote server as defined in the specified certificate.
static boolean installReply(java.security.KeyStore keyStore, java.security.KeyStore trustStore, java.lang.String keyPassword, java.lang.String alias, java.io.InputStream inputStream, boolean trustCACerts, boolean validateRoot)
          Installs the Certificate Authority reply returned as part of the signing request.
static boolean isDSACertificate(java.security.KeyStore ksKeys, java.lang.String domain)
          Returns true if an DSA certificate was found in the specified keystore for the specified domain.
static boolean isDSACertificate(java.security.cert.X509Certificate certificate)
          Returns true if the specified certificate is using the DSA algorithm.
static boolean isRSACertificate(java.security.KeyStore ksKeys, java.lang.String domain)
          Returns true if an RSA certificate was found in the specified keystore for the specified domain.
static void removeListener(CertificateEventListener listener)
          Unregisters a listener to receive events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateManager

public CertificateManager()
Method Detail

createDSACert

public static java.security.cert.X509Certificate createDSACert(java.security.KeyStore ksKeys,
                                                               java.lang.String keyPassword,
                                                               java.lang.String alias,
                                                               java.lang.String issuerDN,
                                                               java.lang.String subjectDN,
                                                               java.lang.String domain)
                                                        throws java.security.GeneralSecurityException,
                                                               java.io.IOException
Creates a new X509 certificate using the DSA algorithm. The new certificate together with its private key are stored in the specified key store. However, the key store is not saved to the disk. This means that it is up to the "caller" to save the key store to disk after new certificates have been added to the store.

Parameters:
ksKeys - key store where the new certificate and private key are going to be stored.
keyPassword - password of the keystore.
alias - name to use when storing the certificate in the key store.
issuerDN - 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 to store in the subject alternative name extension.
Returns:
the new X509 V3 Certificate.
Throws:
java.security.GeneralSecurityException
java.io.IOException

createRSACert

public static java.security.cert.X509Certificate createRSACert(java.security.KeyStore ksKeys,
                                                               java.lang.String keyPassword,
                                                               java.lang.String alias,
                                                               java.lang.String issuerDN,
                                                               java.lang.String subjectDN,
                                                               java.lang.String domain)
                                                        throws java.security.GeneralSecurityException,
                                                               java.io.IOException
Creates a new X509 certificate using the RSA algorithm. The new certificate together with its private key are stored in the specified key store. However, the key store is not saved to the disk. This means that it is up to the "caller" to save the key store to disk after new certificates have been added to the store.

Parameters:
ksKeys - key store where the new certificate and private key are going to be stored.
keyPassword - password of the keystore.
alias - name to use when storing the certificate in the key store.
issuerDN - 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 to store in the subject alternative name extension.
Returns:
the new X509 V3 Certificate.
Throws:
java.security.GeneralSecurityException
java.io.IOException

deleteCertificate

public static void deleteCertificate(java.security.KeyStore ksKeys,
                                     java.lang.String alias)
                              throws java.security.GeneralSecurityException,
                                     java.io.IOException
Deletes the specified certificate from the

Parameters:
ksKeys - key store where the certificate is stored.
alias - alias of the certificate to delete.
Throws:
java.security.GeneralSecurityException
java.io.IOException

getPeerIdentities

public static java.util.List<java.lang.String> getPeerIdentities(java.security.cert.X509Certificate x509Certificate)
Returns the identities of the remote server as defined in the specified certificate. The identities are defined in the subjectDN of the certificate and it can also be defined in the subjectAltName extensions of type "xmpp". When the extension is being used then the identities defined in the extension are going to be returned. Otherwise, the value stored in the subjectDN is returned.

Parameters:
x509Certificate - the certificate the holds the identities of the remote server.
Returns:
the identities of the remote server as defined in the specified certificate.

isRSACertificate

public static boolean isRSACertificate(java.security.KeyStore ksKeys,
                                       java.lang.String domain)
                                throws java.security.KeyStoreException
Returns true if an RSA certificate was found in the specified keystore for the specified domain.

Parameters:
ksKeys - the keystore that contains the certificates.
domain - domain of the server signed by the certificate.
Returns:
true if an RSA certificate was found in the specified keystore for the specified domain.
Throws:
java.security.KeyStoreException

isDSACertificate

public static boolean isDSACertificate(java.security.KeyStore ksKeys,
                                       java.lang.String domain)
                                throws java.security.KeyStoreException
Returns true if an DSA certificate was found in the specified keystore for the specified domain.

Parameters:
ksKeys - the keystore that contains the certificates.
domain - domain of the server signed by the certificate.
Returns:
true if an DSA certificate was found in the specified keystore for the specified domain.
Throws:
java.security.KeyStoreException

isDSACertificate

public static boolean isDSACertificate(java.security.cert.X509Certificate certificate)
                                throws java.security.KeyStoreException
Returns true if the specified certificate is using the DSA algorithm. The DSA algorithm is not good for encryption but only for authentication. On the other hand, the RSA algorithm is good for encryption and authentication.

Parameters:
certificate - the certificate to analyze.
Returns:
true if the specified certificate is using the DSA algorithm.
Throws:
java.security.KeyStoreException

createSigningRequest

public static java.lang.String createSigningRequest(java.security.cert.X509Certificate cert,
                                                    java.security.PrivateKey privKey)
                                             throws java.lang.Exception
Creates and returns the content of a new singing request for the specified certificate. Signing requests are required by Certificate Authorities as part of their signing process. The signing request contains information about the certificate issuer, subject DN, subject alternative names and public key. Private keys are not included. After the Certificate Authority verified and signed the certificate a new certificate is going to be returned. Use installReply(java.security.KeyStore, java.security.KeyStore, String, String, java.io.InputStream, boolean, boolean) to import the CA reply.

Parameters:
cert - the certificate to create a signing request.
privKey - the private key of the certificate.
Returns:
the content of a new singing request for the specified certificate.
Throws:
java.lang.Exception

installReply

public static boolean installReply(java.security.KeyStore keyStore,
                                   java.security.KeyStore trustStore,
                                   java.lang.String keyPassword,
                                   java.lang.String alias,
                                   java.io.InputStream inputStream,
                                   boolean trustCACerts,
                                   boolean validateRoot)
                            throws java.lang.Exception
Installs the Certificate Authority reply returned as part of the signing request. The certificate being signed will get its certificate chain updated with the imported certificate(s). An exception will be thrown if the replied certificate does not match a local certificate or if the signing authority is not known by the server (i.e. keystore and truststore files). When trustCACerts is set to true then certificates present in the truststore file will be used to verify the identity of the entity signing the certificate. In case the reply is composed of more than one certificate then you can also specify if you want to verify that the root certificate in the chain can be trusted.

Parameters:
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.
trustCACerts - true if certificates present in the truststore file will be used to verify the identity of the entity signing the certificate.
validateRoot - true if you want to verify that the root certificate in the chain can be trusted based on the truststore.
Returns:
true if the CA reply was successfully processed.
Throws:
java.lang.Exception

addListener

public static void addListener(CertificateEventListener listener)
Registers a listener to receive events.

Parameters:
listener - the listener.

removeListener

public static void removeListener(CertificateEventListener listener)
Unregisters a listener to receive events.

Parameters:
listener - the listener.

Connection Manager 3.6.3 Javadoc

Copyright © 2003-2006 Jive Software.