be.ehealth.technicalconnector.utils

## Class ConnectorCryptoUtils

- java.lang.Object
- - be.ehealth.technicalconnector.utils.ConnectorCryptoUtils

-     public final class ConnectorCryptoUtils
      extends Object

  Utility class to that generates a symmectric key.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONNECTORCRYPTO_ALGO_NAME_KEY` Property to change the default algoritm used to generate a key.
    `static String` | `CONNECTORCRYPTO_KEYSIZE_KEY` Property to change the default keysize used to generate a key.
    `static String` | `CONNECTORCRYPTO_MOCK_KEY` Property to allow the use of a static key when generating a symmetric key.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `calculateDigest(String digestAlgo, byte[] content)` Helper method to calculate a Digest
    `static byte[]` | `decrypt(Key key, byte[] encryptedBytes)` Decrypt the encryptedBytes bases on the key.
    `static byte[]` | `decrypt(Key key, String algo, byte[] encryptedBytes)` Decrypt the encryptedBytes bases on the key and the given algoritm.
    `static SecretKey` | `generateKey()` Generate a key based using th default algoritm and keysize.
    `static SecretKey` | `generateKey(int keySize)` Generate a key based on the default algoritm and the keysize given as input.
    `static SecretKey` | `generateKey(String algo, int keySize)` Generate a key based on the algoritm and keysize given as input.
    `static void` | `setKeyGenerator(KeyGenerator keyGenerator)` Setting the KeyGenerator to use for generating a SecretKey

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

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

- - ### Field Detail

    - #### CONNECTORCRYPTO_ALGO_NAME_KEY

          public static final String CONNECTORCRYPTO_ALGO_NAME_KEY

      Property to change the default algoritm used to generate a key. Default value is AES
      See Also:
        Constant Field Values

    - #### CONNECTORCRYPTO_KEYSIZE_KEY

          public static final String CONNECTORCRYPTO_KEYSIZE_KEY

      Property to change the default keysize used to generate a key. Default value is 128
      See Also:
        Constant Field Values

    - #### CONNECTORCRYPTO_MOCK_KEY

          public static final String CONNECTORCRYPTO_MOCK_KEY

      Property to allow the use of a static key when generating a symmetric key. Only using for testing purpose
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### generateKey

          public static SecretKey generateKey()
                                       throws TechnicalConnectorException

      Generate a key based using th default algoritm and keysize.
      Throws:
        `TechnicalConnectorException`

    - #### generateKey

          public static SecretKey generateKey(int keySize)
                                       throws TechnicalConnectorException

      Generate a key based on the default algoritm and the keysize given as input.
      Throws:
        `TechnicalConnectorException`

    - #### generateKey

          public static SecretKey generateKey(String algo,
                                              int keySize)
                                       throws TechnicalConnectorException

      Generate a key based on the algoritm and keysize given as input.
      Throws:
        `TechnicalConnectorException`

    - #### decrypt

          public static byte[] decrypt(Key key,
                                       byte[] encryptedBytes)
                                throws TechnicalConnectorException

      Decrypt the encryptedBytes bases on the key. It recovers the algoritm using the key.getAlgorithm().
      Throws:
        `TechnicalConnectorException`

    - #### decrypt

          public static byte[] decrypt(Key key,
                                       String algo,
                                       byte[] encryptedBytes)
                                throws TechnicalConnectorException

      Decrypt the encryptedBytes bases on the key and the given algoritm.
      Throws:
        `TechnicalConnectorException`

    - #### setKeyGenerator

          public static void setKeyGenerator(KeyGenerator keyGenerator)

      Setting the KeyGenerator to use for generating a SecretKey
      Parameters:
        `keyGenerator` -

    - #### calculateDigest

          public static byte[] calculateDigest(String digestAlgo,
                                               byte[] content)
                                        throws TechnicalConnectorException

      Helper method to calculate a Digest
      Throws:
        `TechnicalConnectorException`

Connector Packaging OTMOBILITYIMPROVEMENT 4.9.5 API
Copyright © {inceptionYear}-2026 eHealth. All Rights Reserved.