Class KeysetHandle.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • addAnnotations

        @CanIgnoreReturnValue
        public <T extends AnnotationsKeysetHandle.Builder addAnnotations​(java.lang.Class<T> clazz,
                                                                           T annotations)
        Adds some annotations to the keyset.

        The annotations object needs to be a subclass of Annotations, and it can later be retrieved from the keyset by calling KeysetHandle.getAnnotationsOrNull(java.lang.Class<T>). These annotations are ignored when creating a KeysetHandle.Builder from a Keyset, when comparing two keyset using equalsKeyset, or any other situation.

      • size

        public int size()
        Returns the number of entries in this builder.
      • getAt

        public KeysetHandle.Builder.Entry getAt​(int i)
        Returns the entry at index i, 0 <= i < size().
        Throws:
        java.lang.IndexOutOfBoundsException - if i < 0 or i >= size();
      • removeAt

        @CanIgnoreReturnValue
        @Deprecated
        public KeysetHandle.Builder.Entry removeAt​(int i)
        Deprecated.
        Use deleteAt(int) or getAt(int) instead.
        Removes the entry at index i and returns that entry. Shifts any subsequent entries to the left (subtracts one from their indices).
      • deleteAt

        @CanIgnoreReturnValue
        public KeysetHandle.Builder deleteAt​(int i)
        Deletes the entry at index i. Shifts any subsequent entries to the left (subtracts one from their indices).
      • build

        public KeysetHandle build()
                           throws java.security.GeneralSecurityException
        Creates a new KeysetHandle.

        Throws a GeneralSecurityException if one of the following holds

        • No entry was marked as primary
        • There is an entry in which the ID has not been set and which did not have a predefined ID (see KeysetHandle.Builder.Entry).
        • There is a withRandomId-entry which is followed by a non withRandomId-entry
        • There are two entries with the same withFixedId (including pre-existing keys and imported keys which have an id requirement).
        • build() was previously called for withRandomId entries, and hence calling build() twice would result in a keyset with different key IDs.
        • The primary key is not enabled
        Throws:
        java.security.GeneralSecurityException