Enum KeyFlag

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<KeyFlag>

    public enum KeyFlag
    extends java.lang.Enum<KeyFlag>
    Enumeration of different key flags. Key flags denote different capabilities of a key pair.
    See Also:
    RFC4880: Key Flags
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      AUTHENTICATION
      This key may be used for authentication.
      CERTIFY_OTHER
      This key may be used to certify other keys.
      ENCRYPT_COMMS
      This key may be used to encrypt communications.
      ENCRYPT_STORAGE
      This key may be used to encrypt storage.
      SHARED
      The private component of this key may be in the possession of more than one person.
      SIGN_DATA
      This key may be used to sign data.
      SPLIT
      The private component of this key may have been split by a secret-sharing mechanism.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsAny​(int mask, KeyFlag... flags)  
      static java.util.List<KeyFlag> fromBitmask​(int bitmask)
      Convert a bitmask into a list of KeyFlags.
      int getFlag()
      Return the numeric id of the KeyFlag.
      static boolean hasKeyFlag​(int mask, KeyFlag flag)
      Return true if the provided bitmask has the bit for the provided flag set.
      static int toBitmask​(KeyFlag... flags)
      Encode a list of KeyFlags into a bitmask.
      static KeyFlag valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static KeyFlag[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • CERTIFY_OTHER

        public static final KeyFlag CERTIFY_OTHER
        This key may be used to certify other keys.
      • SIGN_DATA

        public static final KeyFlag SIGN_DATA
        This key may be used to sign data.
      • ENCRYPT_COMMS

        public static final KeyFlag ENCRYPT_COMMS
        This key may be used to encrypt communications.
      • ENCRYPT_STORAGE

        public static final KeyFlag ENCRYPT_STORAGE
        This key may be used to encrypt storage.
      • SPLIT

        public static final KeyFlag SPLIT
        The private component of this key may have been split by a secret-sharing mechanism.
      • AUTHENTICATION

        public static final KeyFlag AUTHENTICATION
        This key may be used for authentication.
      • SHARED

        public static final KeyFlag SHARED
        The private component of this key may be in the possession of more than one person.
    • Method Detail

      • values

        public static KeyFlag[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (KeyFlag c : KeyFlag.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static KeyFlag valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getFlag

        public int getFlag()
        Return the numeric id of the KeyFlag.
        Returns:
        numeric id
      • fromBitmask

        public static java.util.List<KeyFlag> fromBitmask​(int bitmask)
        Convert a bitmask into a list of KeyFlags.
        Parameters:
        bitmask - bitmask
        Returns:
        list of key flags encoded by the bitmask
      • toBitmask

        public static int toBitmask​(KeyFlag... flags)
        Encode a list of KeyFlags into a bitmask.
        Parameters:
        flags - list of flags
        Returns:
        bitmask
      • hasKeyFlag

        public static boolean hasKeyFlag​(int mask,
                                         KeyFlag flag)
        Return true if the provided bitmask has the bit for the provided flag set. Return false if the mask does not contain the flag.
        Parameters:
        mask - bitmask
        flag - flag to be tested for
        Returns:
        true if flag is set, false otherwise
      • containsAny

        public static boolean containsAny​(int mask,
                                          KeyFlag... flags)