be.ehealth.technicalconnector.service.kgss

## Class KgssManager

- java.lang.Object
- - be.ehealth.technicalconnector.service.kgss.KgssManager

- All Implemented Interfaces:
    SessionServiceWithCache

      public final class KgssManager
      extends Object
      implements SessionServiceWithCache

  Simplifies the usage of KGSS. It allows for caching of KGSS keys and easy requesting of new keys and existing keys from KGSS Web Service

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PROP_KGSS_IDENTIFIER_APPLICATIONID` Property to specify the applicationId used by the KGSS

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(List<CredentialType> allowedReaders, byte[] myEtk)` Requests a new key from KGSS and adds it to the cache
    `void` | `add(String cacheId, List<CredentialType> allowedReaders, byte[] myEtk)` Requests a new key from KGSS and adds it to the cache
    `boolean` | `containsKey(String key)` Check if the KeyCache contains a certain key, based on the KeyCache ID KeyCache ID's are formatted either: - "(" + keyId + ")" - normal caching - "(" + patientId + "#" + prescriptionType + ")" - prepare prescription keys
    `void` | `flushCache()` Flush cache.
    `KeyResult` | `get(String keyId, byte[] myEtk)` Gets a key from the KeyCache, if the key is not present in the cache it will be retrieved from the KGSS Web Service and added to the KeyCache.
    `static KgssManager` | `getInstance()` Gets the single instance of KeyCacheManager.
    `static KgssManager` | `getInstance(KgssService kgssService)` Gets the single instance of KeyCacheManager.
    `KeyResult` | `getNewKeyFromKgss(List<CredentialType> allowedReaders, byte[] myEtk)` Retrieves a new key from the KGSS Web Service and returns it.
    `KeyResult` | `remove(String key)` Removes the mapping for a key from this map if it is present (optional operation).
    `void` | `setKgssService(KgssService service)`

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

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

- - ### Field Detail

    - #### PROP_KGSS_IDENTIFIER_APPLICATIONID

          public static final String PROP_KGSS_IDENTIFIER_APPLICATIONID

      Property to specify the applicationId used by the KGSS

      Default value: KGSS

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static KgssManager getInstance()

      Gets the single instance of KeyCacheManager.

    - #### getInstance

          public static KgssManager getInstance(KgssService kgssService)

      Gets the single instance of KeyCacheManager.

    - #### get

          public KeyResult get(String keyId,
                               byte[] myEtk)
                        throws TechnicalConnectorException

      Gets a key from the KeyCache, if the key is not present in the cache it will be retrieved from the KGSS Web Service and added to the KeyCache. the format of the KeyCache ID searched : keyId
      Parameters:
        `keyId` - The KeyIdentifier
        `myEtk` - The ETK of the application
      Returns:
        the requested key
      Throws:
        `TechnicalConnectorException` - When a technical exception occurs

    - #### add

          public void add(List<CredentialType> allowedReaders,
                          byte[] myEtk)
                   throws TechnicalConnectorException

      Requests a new key from KGSS and adds it to the cache
      Parameters:
        `allowedReaders` - the allowed readers
        `myEtk` - the my etk
      Throws:
        `TechnicalConnectorException` - the technical connector exception

    - #### add

          public void add(String cacheId,
                          List<CredentialType> allowedReaders,
                          byte[] myEtk)
                   throws TechnicalConnectorException

      Requests a new key from KGSS and adds it to the cache
      Parameters:
        `cacheId` - the cache id
        `allowedReaders` - the allowed readers
        `myEtk` - the my etk
      Throws:
        `TechnicalConnectorException` - the technical connector exception

    - #### remove

          public KeyResult remove(String key)

      Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key `k` to value `v` such that `(key==null ? k==null : key.equals(k))`, that mapping is removed. (The map can contain at most one such mapping.)

      Returns the value to which this map previously associated the key, or `null` if the map contained no mapping for the key.

      If this map permits null values, then a return value of `null` does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to `null`.

      The map will not contain a mapping for the specified key once the call returns.

      Parameters:
        `key` - key whose mapping is to be removed from the map
      Returns:
        the previous value associated with `key`, or `null` if there was no mapping for `key`.

    - #### containsKey

          public boolean containsKey(String key)

      Check if the KeyCache contains a certain key, based on the KeyCache ID KeyCache ID's are formatted either: - "(" + keyId + ")" - normal caching - "(" + patientId + "#" + prescriptionType + ")" - prepare prescription keys

      Returns `true` if this map contains a mapping for the specified key. More formally, returns `true` if and only if this map contains a mapping for a key `k` such that `(key==null ? k==null : key.equals(k))`. (There can be at most one such mapping.)

      Parameters:
        `key` - the KeyCacheId
      Returns:
        true, if successful

    - #### getNewKeyFromKgss

          public KeyResult getNewKeyFromKgss(List<CredentialType> allowedReaders,
                                             byte[] myEtk)
                                      throws TechnicalConnectorException

      Retrieves a new key from the KGSS Web Service and returns it.
      Parameters:
        `allowedReaders` - the allowed readers
        `myEtk` - The ETK of the application
      Returns:
        The generated key from the KGSS Web Service
      Throws:
        `TechnicalConnectorException` - the technical connector exception

    - #### flushCache

          public void flushCache()

      Flush cache.
      Specified by:
        `flushCache` in interface `SessionServiceWithCache`

    - #### setKgssService

          public void setKgssService(KgssService service)

      Parameters:
        `service` - the service to set

Connector Packaging PERSPODOLOGIST 4.3.0-beta-3 API
Copyright © {inceptionYear}-2022 eHealth. All Rights Reserved.