Package com.google.crypto.tink
Class KeysetManager
- java.lang.Object
-
- com.google.crypto.tink.KeysetManager
-
public final class KeysetManager extends java.lang.ObjectManages aKeysetproto, 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.Builderwhich has an improved API (in that it e.g. returns the just added objects, allowing you to manipulate them further).- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description KeysetManageradd(KeyTemplate keyTemplate)Generates and adds a fresh key generated usingkeyTemplate.KeysetManageradd(com.google.crypto.tink.proto.KeyTemplate keyTemplate)Generates and adds a fresh key generated usingkeyTemplate.KeysetManageradd(KeyHandle keyHandle)Deprecated.We recommend to use theKeysetHandle.BuilderAPI.KeysetManageradd(KeyHandle keyHandle, KeyAccess access)Deprecated.We recommend to use theKeysetHandle.BuilderAPI.intaddNewKey(com.google.crypto.tink.proto.KeyTemplate keyTemplate, boolean asPrimary)Generates a fresh key usingkeyTemplateand returns thekeyIdof it.KeysetManagerdelete(int keyId)Deletes the key withkeyId.KeysetManagerdestroy(int keyId)Destroys the key material associated with thekeyId.KeysetManagerdisable(int keyId)Disables the key withkeyId.KeysetManagerenable(int keyId)Enables the key withkeyId.KeysetHandlegetKeysetHandle()KeysetManagerpromote(int keyId)Sets the key withkeyIdas primary.KeysetManagerrotate(com.google.crypto.tink.proto.KeyTemplate keyTemplate)Generates and adds a fresh key generated usingkeyTemplate, and sets the new key as the primary key.KeysetManagersetPrimary(int keyId)Sets the key withkeyIdas primary.static KeysetManagerwithEmptyKeyset()static KeysetManagerwithKeysetHandle(KeysetHandle val)
-
-
-
Method Detail
-
withKeysetHandle
public static KeysetManager withKeysetHandle(KeysetHandle val)
- Returns:
- a
KeysetManagerfor the keyset manged byval
-
withEmptyKeyset
public static KeysetManager withEmptyKeyset()
- Returns:
- a
KeysetManagerfor an empty keyset.
-
getKeysetHandle
public KeysetHandle getKeysetHandle() throws java.security.GeneralSecurityException
- Returns:
- a
KeysetHandleof the managed keyset - Throws:
java.security.GeneralSecurityException
-
rotate
@CanIgnoreReturnValue public KeysetManager rotate(com.google.crypto.tink.proto.KeyTemplate keyTemplate) throws java.security.GeneralSecurityException
Generates and adds a fresh key generated usingkeyTemplate, and sets the new key as the primary key.- Throws:
java.security.GeneralSecurityException- if cannot find anyKeyManagerthat can handlekeyTemplate
-
add
@CanIgnoreReturnValue public KeysetManager add(com.google.crypto.tink.proto.KeyTemplate keyTemplate) throws java.security.GeneralSecurityException
Generates and adds a fresh key generated usingkeyTemplate.- Throws:
java.security.GeneralSecurityException- if cannot find anyKeyManagerthat can handlekeyTemplate
-
add
@CanIgnoreReturnValue public KeysetManager add(KeyTemplate keyTemplate) throws java.security.GeneralSecurityException
Generates and adds a fresh key generated usingkeyTemplate.- Throws:
java.security.GeneralSecurityException- if cannot find anyKeyManagerthat can handlekeyTemplate
-
add
@CanIgnoreReturnValue @Deprecated public KeysetManager add(KeyHandle keyHandle) throws java.security.GeneralSecurityException
Deprecated.We recommend to use theKeysetHandle.BuilderAPI.
-
add
@CanIgnoreReturnValue @Deprecated public KeysetManager add(KeyHandle keyHandle, KeyAccess access) throws java.security.GeneralSecurityException
Deprecated.We recommend to use theKeysetHandle.BuilderAPI.Adds the inputKeyHandleto the existing keyset withOutputPrefixType.TINK.- Throws:
java.security.GeneralSecurityException- if the givenKeyAccessdoes not grant access to the key contained in theKeyHandle.java.lang.UnsupportedOperationException- if theKeyHandlecontains aTinkKeywhich is not aProtoKey.
-
addNewKey
@CanIgnoreReturnValue public int addNewKey(com.google.crypto.tink.proto.KeyTemplate keyTemplate, boolean asPrimary) throws java.security.GeneralSecurityExceptionGenerates a fresh key usingkeyTemplateand returns thekeyIdof it. In caseasPrimaryis true the generated key will be the new primary.- Throws:
java.security.GeneralSecurityException
-
setPrimary
@CanIgnoreReturnValue public KeysetManager setPrimary(int keyId) throws java.security.GeneralSecurityException
Sets the key withkeyIdas primary.- Throws:
java.security.GeneralSecurityException- if the key is not found or not enabled
-
promote
@InlineMe(replacement="this.setPrimary(keyId)") @CanIgnoreReturnValue public KeysetManager promote(int keyId) throws java.security.GeneralSecurityException
Sets the key withkeyIdas primary.- Throws:
java.security.GeneralSecurityException- if the key is not found or not enabled
-
enable
@CanIgnoreReturnValue public KeysetManager enable(int keyId) throws java.security.GeneralSecurityException
Enables the key withkeyId.- Throws:
java.security.GeneralSecurityException- if the key is not found
-
disable
@CanIgnoreReturnValue public KeysetManager disable(int keyId) throws java.security.GeneralSecurityException
Disables the key withkeyId.- Throws:
java.security.GeneralSecurityException- if the key is not found or it is the primary key
-
delete
@CanIgnoreReturnValue public KeysetManager delete(int keyId) throws java.security.GeneralSecurityException
Deletes the key withkeyId.- Throws:
java.security.GeneralSecurityException- if the key is not found or it is the primary key
-
destroy
@CanIgnoreReturnValue public KeysetManager destroy(int keyId) throws java.security.GeneralSecurityException
Destroys the key material associated with thekeyId.- Throws:
java.security.GeneralSecurityException- if the key is not found or it is the primary key
-
-