Package com.github.ambry.router
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 anygetKey(short, short)
calls. T refers to the Key type that thisKeyManagementService
will generate and return. Ensure thatCryptoService
implementation is compatible with the key type thatKeyManagementService
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 ContainerIdvoid
register(java.lang.String context)
Registers with KMS to create key for a unique context.
-
-
-
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
-
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 usingregister(short, short)
for this pair before fetching keys.
-
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 usingregister(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
-
-