net.sourceforge.jnlp.security

## Class CertificateUtils

- java.lang.Object
- - net.sourceforge.jnlp.security.CertificateUtils

-     public class CertificateUtils
      extends java.lang.Object

  Common utilities to manipulate certificates. Provides methods to add Certificates to a KeyStores, check if certificates already exist in a KeyStore and printing certificates.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CertificateUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addPKCS12ToKeyStore(java.security.cert.Certificate[] certChain, java.security.Key key, java.security.KeyStore ks)`
    `static void` | `addPKCS12ToKeyStore(java.io.File file, java.security.KeyStore ks, char[] password)`
    `static void` | `addToKeyStore(java.io.File file, java.security.KeyStore ks)` Adds the X509Certficate in the file to the KeyStore.
    `static void` | `addToKeyStore(java.security.cert.X509Certificate cert, java.security.KeyStore ks)` Adds an X509Certificate to the KeyStore.
    `static void` | `dump(java.security.cert.Certificate cert, java.io.PrintStream out)` Writes the certificate in base64 encoded from to the print stream.
    `static void` | `dumpPKCS12(java.lang.String alias, java.io.File file, java.security.KeyStore ks, char[] password)`
    `static boolean` | `inKeyStores(java.security.cert.X509Certificate c, java.security.KeyStore[] keyStores)` Checks whether an X509Certificate is already in one of the keystores

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CertificateUtils

          public CertificateUtils()

  - ### Method Detail

    - #### addToKeyStore

          public static final void addToKeyStore(java.io.File file,
                                                 java.security.KeyStore ks)
                                          throws java.security.cert.CertificateException,
                                                 java.io.IOException,
                                                 java.security.KeyStoreException

      Adds the X509Certficate in the file to the KeyStore. Note that it does not update the copy of the KeyStore on disk.
      Parameters:
        `file` - file with certificate
        `ks` - keystore to save to
      Throws:
        `java.security.cert.CertificateException` - if certificate is wrong
        `java.io.IOException` - if IO fails
        `java.security.KeyStoreException` - if keystore fails

    - #### addToKeyStore

          public static final void addToKeyStore(java.security.cert.X509Certificate cert,
                                                 java.security.KeyStore ks)
                                          throws java.security.KeyStoreException

      Adds an X509Certificate to the KeyStore. Note that it does not update the copy of the KeyStore on disk.
      Parameters:
        `cert` - certificate to import
        `ks` - keystore to save to
      Throws:
        `java.security.KeyStoreException` - if keystore fails

    - #### addPKCS12ToKeyStore

          public static void addPKCS12ToKeyStore(java.io.File file,
                                                 java.security.KeyStore ks,
                                                 char[] password)
                                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### addPKCS12ToKeyStore

          public static void addPKCS12ToKeyStore(java.security.cert.Certificate[] certChain,
                                                 java.security.Key key,
                                                 java.security.KeyStore ks)
                                          throws java.security.KeyStoreException

      Throws:
        `java.security.KeyStoreException`

    - #### inKeyStores

          public static final boolean inKeyStores(java.security.cert.X509Certificate c,
                                                  java.security.KeyStore[] keyStores)

      Checks whether an X509Certificate is already in one of the keystores
      Parameters:
        `c` - the certificate
        `keyStores` - the KeyStores to check in
      Returns:
        true if the certificate is present in one of the keystores, false otherwise

    - #### dump

          public static void dump(java.security.cert.Certificate cert,
                                  java.io.PrintStream out)
                           throws java.io.IOException,
                                  java.security.cert.CertificateException

      Writes the certificate in base64 encoded from to the print stream. See http://tools.ietf.org/html/rfc4945#section-6.1 for more information
      Parameters:
        `cert` - sertifcate to export
        `out` - stream to print it to
      Throws:
        `java.io.IOException` - if io fails
        `java.security.cert.CertificateException` - if certificate fails

    - #### dumpPKCS12

          public static void dumpPKCS12(java.lang.String alias,
                                        java.io.File file,
                                        java.security.KeyStore ks,
                                        char[] password)
                                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Submit a bug or feature