Class KeysetHandle.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • setMonitoringAnnotations

        @CanIgnoreReturnValue
        @Alpha
        public KeysetHandle.Builder setMonitoringAnnotations​(MonitoringAnnotations annotations)
        Sets MonitoringAnnotations. If not called, then the default value of MonitoringAnnotations.EMPTY is used.

        When called twice, the last submitted annotations are used to create the keyset. This method is not thread-safe, and in case of multithreaded access it cannot be guaranteed which annotations get set.

      • 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