public final class KeysetManager extends Object
Keyset proto, with convenience methods that rotate, disable, enable or destroy
keys.| Modifier and Type | Method and Description |
|---|---|
KeysetManager |
add(com.google.crypto.tink.proto.KeyTemplate keyTemplate)
Deprecated.
This method takes a KeyTemplate proto, which is an internal implementation detail.
Please use the add method that takes a
KeyTemplate POJO. |
KeysetManager |
add(KeyTemplate keyTemplate)
Generates and adds a fresh key generated using
keyTemplate. |
int |
addNewKey(com.google.crypto.tink.proto.KeyTemplate keyTemplate,
boolean asPrimary)
Deprecated.
Please use
add(com.google.crypto.tink.proto.KeyTemplate). This method adds a new key and when asPrimary is
true immediately promotes it to primary. However, when you do keyset rotation, you almost
never want to make the new key primary, because old binaries don't know the new key yet. |
KeysetManager |
delete(int keyId)
Deletes the key with
keyId. |
KeysetManager |
destroy(int keyId)
Destroys the key material associated with the
keyId. |
KeysetManager |
disable(int keyId)
Disables the key with
keyId. |
KeysetManager |
enable(int keyId)
Enables the key with
keyId. |
KeysetHandle |
getKeysetHandle() |
KeysetManager |
promote(int keyId)
Deprecated.
use
setPrimary |
KeysetManager |
rotate(com.google.crypto.tink.proto.KeyTemplate keyTemplate)
Deprecated.
Please use
add(com.google.crypto.tink.proto.KeyTemplate). This method adds a new key and immediately promotes it to
primary. However, when you do keyset rotation, you almost never want to make the new key
primary, because old binaries don't know the new key yet. |
KeysetManager |
setPrimary(int keyId)
Sets the key with
keyId as primary. |
static KeysetManager |
withEmptyKeyset() |
static KeysetManager |
withKeysetHandle(KeysetHandle val) |
public static KeysetManager withKeysetHandle(KeysetHandle val)
KeysetManager for the keyset manged by valpublic static KeysetManager withEmptyKeyset()
KeysetManager for an empty keyset.public KeysetHandle getKeysetHandle() throws GeneralSecurityException
KeysetHandle of the managed keysetGeneralSecurityException@Deprecated public KeysetManager rotate(com.google.crypto.tink.proto.KeyTemplate keyTemplate) throws GeneralSecurityException
add(com.google.crypto.tink.proto.KeyTemplate). This method adds a new key and immediately promotes it to
primary. However, when you do keyset rotation, you almost never want to make the new key
primary, because old binaries don't know the new key yet.keyTemplate, and sets the new key as the
primary key.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplate@Deprecated public KeysetManager add(com.google.crypto.tink.proto.KeyTemplate keyTemplate) throws GeneralSecurityException
KeyTemplate POJO.keyTemplate.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplatepublic KeysetManager add(KeyTemplate keyTemplate) throws GeneralSecurityException
keyTemplate.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplate@Deprecated public int addNewKey(com.google.crypto.tink.proto.KeyTemplate keyTemplate, boolean asPrimary) throws GeneralSecurityException
add(com.google.crypto.tink.proto.KeyTemplate). This method adds a new key and when asPrimary is
true immediately promotes it to primary. However, when you do keyset rotation, you almost
never want to make the new key primary, because old binaries don't know the new key yet.keyTemplate and returns the keyId of it. In case
asPrimary is true the generated key will be the new primary.GeneralSecurityExceptionpublic KeysetManager setPrimary(int keyId) throws GeneralSecurityException
keyId as primary.GeneralSecurityException - if the key is not found or not enabled@Deprecated public KeysetManager promote(int keyId) throws GeneralSecurityException
setPrimarykeyId as primary.GeneralSecurityException - if the key is not found or not enabledpublic KeysetManager enable(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not foundpublic KeysetManager disable(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary keypublic KeysetManager delete(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary keypublic KeysetManager destroy(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary key