public class SingleKeyManagementService
extends java.lang.Object
implements com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
KeyManagementService
which returns a default key SecretKeySpec
for any
getKey(short, short)
calls, but a different random key for any getRandomKey()
calls.Constructor and Description |
---|
SingleKeyManagementService(com.github.ambry.config.KMSConfig config,
java.lang.String defaultContainerKey)
Instantiates
SingleKeyManagementService with KMSConfig and a default container key which is hex string. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
javax.crypto.spec.SecretKeySpec |
getKey(short accountId,
short containerId)
Fetches the key associated with the pair of AccountId and ContainerId.
|
javax.crypto.spec.SecretKeySpec |
getKey(java.lang.String context) |
javax.crypto.spec.SecretKeySpec |
getRandomKey() |
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) |
public SingleKeyManagementService(com.github.ambry.config.KMSConfig config, java.lang.String defaultContainerKey) throws java.security.GeneralSecurityException
SingleKeyManagementService
with KMSConfig
and a default container key which is hex string.config
- KMSConfig
to fetch configs fromdefaultContainerKey
- the default container key that will be returned for all getKey(short, short)
callsjava.security.GeneralSecurityException
public void register(short accountId, short containerId)
register
in interface com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
accountId
- refers to the id of the Account
to registercontainerId
- refers to the id of the Container
to registerpublic void register(java.lang.String context) throws java.security.GeneralSecurityException
register
in interface com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
java.security.GeneralSecurityException
public javax.crypto.spec.SecretKeySpec getKey(short accountId, short containerId) throws java.security.GeneralSecurityException
SingleKeyManagementService
returns
the default key for all getKey(short, short)
}getKey
in interface com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
accountId
- refers to the id of the Account
for which key is expectedcontainerId
- refers to the id of the Container
for which key is expectedSecretKeySpec
the key associated with the accountId and containerIdjava.security.GeneralSecurityException
public javax.crypto.spec.SecretKeySpec getKey(java.lang.String context) throws java.security.GeneralSecurityException
getKey
in interface com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
java.security.GeneralSecurityException
public javax.crypto.spec.SecretKeySpec getRandomKey() throws java.security.GeneralSecurityException
getRandomKey
in interface com.github.ambry.router.KeyManagementService<javax.crypto.spec.SecretKeySpec>
java.security.GeneralSecurityException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException