public final class KeysetManager extends Object
Keyset proto, with convenience methods that rotate, disable, enable or destroy
keys.
We do not recommend usage of this class. Instead, we recommend you to use a Keyset.Builder which has an improved API (in that it e.g. returns the just added objects,
allowing you to manipulate them further).
| Modifier and Type | Method and Description |
|---|---|
KeysetManager |
add(KeyHandle keyHandle)
Deprecated.
We recommend to use the
KeysetHandle.Builder API. |
KeysetManager |
add(KeyHandle keyHandle,
KeyAccess access)
Deprecated.
We recommend to use the
KeysetHandle.Builder API. |
KeysetManager |
add(KeyTemplate keyTemplate)
Generates and adds a fresh key generated using
keyTemplate. |
KeysetManager |
add(KeyTemplate keyTemplate)
Generates and adds a fresh key generated using
keyTemplate. |
int |
addNewKey(KeyTemplate keyTemplate,
boolean asPrimary)
Generates a fresh key using
keyTemplate and returns the keyId of it. |
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)
Sets the key with
keyId as primary. |
KeysetManager |
rotate(KeyTemplate keyTemplate)
Generates and adds a fresh key generated using
keyTemplate, and sets the new key as the
primary key. |
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@CanIgnoreReturnValue public KeysetManager rotate(KeyTemplate keyTemplate) throws GeneralSecurityException
keyTemplate, and sets the new key as the
primary key.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplate@CanIgnoreReturnValue public KeysetManager add(KeyTemplate keyTemplate) throws GeneralSecurityException
keyTemplate.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplate@CanIgnoreReturnValue public KeysetManager add(KeyTemplate keyTemplate) throws GeneralSecurityException
keyTemplate.GeneralSecurityException - if cannot find any KeyManager that can handle keyTemplate@CanIgnoreReturnValue @Deprecated public KeysetManager add(KeyHandle keyHandle) throws GeneralSecurityException
KeysetHandle.Builder API.KeyHandle to the existing keyset. The KeyStatusType and key ID of the
KeyHandle are used as-is in the keyset.UnsupportedOperationException - if the KeyHandle contains a TinkKey which
is not a ProtoKey.GeneralSecurityException - if the KeyHandle's key ID collides with another key ID
in the keyset.@CanIgnoreReturnValue @Deprecated public KeysetManager add(KeyHandle keyHandle, KeyAccess access) throws GeneralSecurityException
KeysetHandle.Builder API.KeyHandle to the existing keyset with OutputPrefixType.TINK.GeneralSecurityException - if the given KeyAccess does not grant access to the
key contained in the KeyHandle.UnsupportedOperationException - if the KeyHandle contains a TinkKey which
is not a ProtoKey.@CanIgnoreReturnValue public int addNewKey(KeyTemplate keyTemplate, boolean asPrimary) throws GeneralSecurityException
keyTemplate and returns the keyId of it. In case
asPrimary is true the generated key will be the new primary.GeneralSecurityException@CanIgnoreReturnValue public KeysetManager setPrimary(int keyId) throws GeneralSecurityException
keyId as primary.GeneralSecurityException - if the key is not found or not enabled@InlineMe(replacement="this.setPrimary(keyId)") @CanIgnoreReturnValue public KeysetManager promote(int keyId) throws GeneralSecurityException
keyId as primary.GeneralSecurityException - if the key is not found or not enabled@CanIgnoreReturnValue public KeysetManager enable(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found@CanIgnoreReturnValue public KeysetManager disable(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary key@CanIgnoreReturnValue public KeysetManager delete(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary key@CanIgnoreReturnValue public KeysetManager destroy(int keyId) throws GeneralSecurityException
keyId.GeneralSecurityException - if the key is not found or it is the primary key