public static final class KeysetHandle.Builder extends Object
KeysetHandle objects.
A builder can be used to create a new KeysetHandle object. To create a builder with
an empty keyset, one calls KeysetHandle.newBuilder();. To create a builder from an
existing keyset, one calls KeysetHandle.newBuilder(keyset);.
To add a new key to a Builder, one calls addEntry(com.google.crypto.tink.KeysetHandle.Builder.Entry) with a KeysetEntry
object. Such objects can be created
Parameters with KeysetHandle.generateEntryFromParametersName(java.lang.String),
Parameters object, with KeysetHandle.generateEntryFromParameters(com.google.crypto.tink.Parameters),
KeysetHandle.importKey(com.google.crypto.tink.Key)
All these functions return a KeysetBuilder.Entry. It is necessary to assign an ID to
a new entry by calling one of KeysetHandle.Builder.Entry.withFixedId(int) or KeysetHandle.Builder.Entry.withRandomId(). The
exception is when an existing key which has an id requirement is imported (in which case the
required ID is used).
It is possible to set the status of an entry by calling KeysetHandle.Builder.Entry.setStatus(com.google.crypto.tink.KeyStatus). The Status
defaults to ENABLED.
It is possible to set whether an entry is the primary by calling KeysetHandle.Builder.Entry.makePrimary().
The user must ensure that once build() is called, a primary has been set.
| Modifier and Type | Class and Description |
|---|---|
static class |
KeysetHandle.Builder.Entry
One entry, representing a single key, in a Keyset.Builder.
|
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
KeysetHandle.Builder |
addEntry(KeysetHandle.Builder.Entry entry)
Adds an entry to a keyset
|
KeysetHandle |
build()
Creates a new
KeysetHandle. |
KeysetHandle.Builder |
deleteAt(int i)
Deletes the entry at index
i. |
KeysetHandle.Builder.Entry |
getAt(int i)
Returns the entry at index i, 0 <= i < size().
|
KeysetHandle.Builder.Entry |
removeAt(int i)
Deprecated.
Use
deleteAt(int) or getAt(int) instead. |
int |
size()
Returns the number of entries in this builder.
|
@CanIgnoreReturnValue public KeysetHandle.Builder addEntry(KeysetHandle.Builder.Entry entry)
public int size()
public KeysetHandle.Builder.Entry getAt(int i)
IndexOutOfBoundsException - if i < 0 or i >= size();@CanIgnoreReturnValue @Deprecated public KeysetHandle.Builder.Entry removeAt(int i)
deleteAt(int) or getAt(int) instead.i and returns that entry. Shifts any subsequent entries to
the left (subtracts one from their indices).@CanIgnoreReturnValue public KeysetHandle.Builder deleteAt(int i)
i. Shifts any subsequent entries to the left (subtracts
one from their indices).public KeysetHandle build() throws GeneralSecurityException
KeysetHandle.
Throws a GeneralSecurityException if one of the following holds
KeysetHandle.Builder.Entry).
withRandomId-entry which is followed by a non withRandomId-entry
withFixedId (including pre-existing keys
and imported keys which have an id requirement).
GeneralSecurityException