Interface KeyManagementService<T>

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable

    public interface KeyManagementService<T>
    extends java.io.Closeable
    Interface that defines the Key management service. KMS is responsible for maintaining keys for every unique pair of AccountId and ContainerId that is registered with the KMS Every caller is expected to register before making any getKey(short, short) calls. T refers to the Key type that this KeyManagementService will generate and return. Ensure that CryptoService implementation is compatible with the key type that KeyManagementService generates
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T getKey​(short accountId, short containerId)
      Fetches the key associated with the pair of AccountId and ContainerId.
      T getKey​(java.lang.String context)
      Fetches the key associated with the specified context.
      T getRandomKey()
      Generate and return a random key (of type T)
      void register​(short accountId, short containerId)
      Registers with KMS to create key for a unique pair of AccountId and ContainerId
      void register​(java.lang.String context)
      Registers with KMS to create key for a unique context.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • register

        void register​(short accountId,
                      short containerId)
               throws java.security.GeneralSecurityException
        Registers with KMS to create key for a unique pair of AccountId and ContainerId
        Parameters:
        accountId - refers to the id of the Account to register
        containerId - refers to the id of the Container to register
        Throws:
        java.security.GeneralSecurityException
      • register

        void register​(java.lang.String context)
               throws java.security.GeneralSecurityException
        Registers with KMS to create key for a unique context.
        Parameters:
        context - refers to the key context to register
        Throws:
        java.security.GeneralSecurityException
      • getKey

        T getKey​(short accountId,
                 short containerId)
          throws java.security.GeneralSecurityException
        Fetches the key associated with the pair of AccountId and ContainerId. User is expected to have registered using register(short, short) for this pair before fetching keys.
        Parameters:
        accountId - refers to the id of the Account for which key is expected
        containerId - refers to the id of the Container for which key is expected
        Returns:
        T the key associated with the accountId and containerId
        Throws:
        java.security.GeneralSecurityException
      • getKey

        T getKey​(java.lang.String context)
          throws java.security.GeneralSecurityException
        Fetches the key associated with the specified context. User is expected to have registered using register(String) for this context before fetching keys.
        Parameters:
        context - refers to the context for which key is expected
        Returns:
        T the key associated with the context
        Throws:
        java.security.GeneralSecurityException
      • getRandomKey

        T getRandomKey()
                throws java.security.GeneralSecurityException
        Generate and return a random key (of type T)
        Returns:
        a random key (of type T)
        Throws:
        java.security.GeneralSecurityException