be.fgov.ehealth.technicalconnector.ra.utils

## Class CertificateUtils

- java.lang.Object
- - be.fgov.ehealth.technicalconnector.ra.utils.CertificateUtils

-     public class CertificateUtils
      extends Object

  Utility class containing facilitators for certificate generation.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CertificateUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `createCSR(DistinguishedName distingueshedName, KeyPair keyPair)` Generates a PKCS10 certificate request based on the given `DistinguishedName` and the keypair.
    `static byte[]` | `createCSR(String dn, KeyPair keyPair)` Generates a PKCS10 certificate request based on the given `DistinguishedName` and the keypair.
    `static X509Certificate` | `generateCert(KeyPair pair)` Generates a self signed certificte with a C=Dummy as subject.
    `static X509Certificate` | `generateCert(PublicKey rqPubKey, BigInteger serialNr, Credential cred)` Generates a self signed certificate based on the given `Credential`
    `static KeyPair` | `generateKeyPair()` Generates a RSA 2048 keypair.
    `static BigInteger` | `obtainSerialNumber(PrivateKey key, byte[] challenge)` Extract the serialnumber from the challenge.
    `static X509Certificate` | `toX509Certificate(byte[] cert)` Convert a byte array to a `X509Certificate`

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

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

- - ### Constructor Detail

    - #### CertificateUtils

          public CertificateUtils()

  - ### Method Detail

    - #### generateKeyPair

          public static KeyPair generateKeyPair()

      Generates a RSA 2048 keypair.

    - #### createCSR

          public static byte[] createCSR(DistinguishedName distingueshedName,
                                         KeyPair keyPair)

      Generates a PKCS10 certificate request based on the given `DistinguishedName` and the keypair.

      The `DistinguishedName` is used for subject generation.

    - #### createCSR

          public static byte[] createCSR(String dn,
                                         KeyPair keyPair)

      Generates a PKCS10 certificate request based on the given `DistinguishedName` and the keypair.

      The `DistinguishedName` is used for subject generation.

    - #### generateCert

          public static X509Certificate generateCert(PublicKey rqPubKey,
                                                     BigInteger serialNr,
                                                     Credential cred)
                                              throws TechnicalConnectorException

      Generates a self signed certificate based on the given `Credential`
      Throws:
        `TechnicalConnectorException`

    - #### generateCert

          public static X509Certificate generateCert(KeyPair pair)

      Generates a self signed certificte with a C=Dummy as subject.

    - #### obtainSerialNumber

          public static BigInteger obtainSerialNumber(PrivateKey key,
                                                      byte[] challenge)
                                               throws TechnicalConnectorException

      Extract the serialnumber from the challenge.
      Throws:
        `TechnicalConnectorException`

    - #### toX509Certificate

          public static X509Certificate toX509Certificate(byte[] cert)

      Convert a byte array to a `X509Certificate`

Connector Packaging TECHNICAL 4.5.4 API
Copyright © {inceptionYear}-2024 eHealth. All Rights Reserved.