Package org.pgpainless.algorithm
Enum KeyFlag
- java.lang.Object
-
- java.lang.Enum<KeyFlag>
-
- org.pgpainless.algorithm.KeyFlag
-
- All Implemented Interfaces:
Serializable
,Comparable<KeyFlag>
public enum KeyFlag extends 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 List<KeyFlag>
fromBitmask(int bitmask)
Convert a bitmask into a list ofKeyFlags
.int
getFlag()
Return the numeric id of theKeyFlag
.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 ofKeyFlags
into a bitmask.static KeyFlag
valueOf(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.
-
-
-
Enum Constant Detail
-
CERTIFY_OTHER
public static final KeyFlag CERTIFY_OTHER
This key may be used to certify other keys.
-
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.
-
-
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(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
fromBitmask
public static List<KeyFlag> fromBitmask(int bitmask)
Convert a bitmask into a list ofKeyFlags
.- Parameters:
bitmask
- bitmask- Returns:
- list of key flags encoded by the bitmask
-
toBitmask
public static int toBitmask(KeyFlag... flags)
Encode a list ofKeyFlags
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
- bitmaskflag
- flag to be tested for- Returns:
- true if flag is set, false otherwise
-
containsAny
public static boolean containsAny(int mask, KeyFlag... flags)
-
-