Package org.forgerock.secrets
Class Purpose<T extends Secret>
java.lang.Object
org.forgerock.secrets.Purpose<T>
- Type Parameters:
T
- the type of secret that this purpose requires.
A purpose encapsulates both a name for a function that requires access to secrets, together with a hint as
to the intended usage of those secrets. A purpose by itself may not uniquely identify a particular secret, as the
secret for that purpose may change over time. A collection of general purposes are exposed by this class, but
application developers are encouraged to create specific purpose instances that better describe the usage of a
secret or key.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Purpose<DataDecryptionKey>
Indicates a key intended for decrypting data.static final Purpose<DataEncryptionKey>
Indicates a key intended for encrypting data.static final Purpose<KeyAgreementKey>
Indicates a key intended for an interactive key agreement protocol, such as Diffie-Hellman (DH) or the elliptic curve equivalent (ECDH).static final Purpose<KeyDecryptionKey>
Indicates a key intended for decrypting ("unwrapping") other keys.static final Purpose<KeyEncryptionKey>
Indicates a key intended for encrypting ("wrapping") other keys.static final Pattern
The regular expression to use when validating purpose labels.static final Purpose<GenericSecret>
Indicates a secret intended to be used as a password for authentication to some service.static final Purpose<SigningKey>
Indicates a key intended for creating digital signatures or message authentication codes (MACs).static final Purpose<VerificationKey>
Indicates a key intended for verifying digital signatures or message authentication codes.static final Purpose<CertificateVerificationKey>
Indicates a key intended for verifying certificate signatures. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Set<SecretConstraint<? super T>>
Returns the set of constraints that should apply to any secrets that match this purpose.getLabel()
Returns a symbolic label for this purpose that can be used in routing requests for secrets.Returns the type of secrets that this purpose requires.int
hashCode()
boolean
isSatisfiedBy
(T secret) Determines whether all of the constraints for this purpose are satisfied by the given secret.Constructs a purpose object.purpose
(String label, Class<T> type, SecretConstraint<? super T>... constraints) Constructs a purpose object.toString()
withConstraints
(SecretConstraint<? super T>... constraints) Constructs a new purpose that is identical to this purpose but which imposes additional constraints on the secrets that can satisfy it.
-
Field Details
-
LABEL_PATTERN
The regular expression to use when validating purpose labels. -
SIGN
Indicates a key intended for creating digital signatures or message authentication codes (MACs). -
VERIFY
Indicates a key intended for verifying digital signatures or message authentication codes. -
VERIFY_CERTIFICATE
Indicates a key intended for verifying certificate signatures. -
DATA_ENCRYPTION
Indicates a key intended for encrypting data. -
DATA_DECRYPTION
Indicates a key intended for decrypting data. -
KEY_ENCRYPTION
Indicates a key intended for encrypting ("wrapping") other keys. Often used to encrypt a temporary symmetric session key with a public key. -
KEY_DECRYPTION
Indicates a key intended for decrypting ("unwrapping") other keys. -
KEY_AGREEMENT
Indicates a key intended for an interactive key agreement protocol, such as Diffie-Hellman (DH) or the elliptic curve equivalent (ECDH). Note that the agreed key should not be used directly, but typically passed through some key derivation process. -
PASSWORD
Indicates a secret intended to be used as a password for authentication to some service.
-
-
Method Details
-
purpose
@SafeVarargs public static <T extends Secret> Purpose<T> purpose(String label, Class<T> type, SecretConstraint<? super T>... constraints) Constructs a purpose object.- Type Parameters:
T
- the type of secret.- Parameters:
label
- the symbolic label to identify this purpose. Must consist only of alphanumeric and dot characters.type
- the type of secret that this purpose requires.constraints
- constraints on the secrets that can be used for this purpose.- Returns:
- the purpose object.
-
purpose
Constructs a purpose object.- Type Parameters:
T
- the type of secret.- Parameters:
label
- the symbolic label to identify this purpose. Must consist only of alphanumeric and dot characters.type
- the type of secret that this purpose requires.- Returns:
- the purpose object.
-
getSecretType
Returns the type of secrets that this purpose requires.- Returns:
- the type of secrets.
-
getLabel
Returns a symbolic label for this purpose that can be used in routing requests for secrets.- Returns:
- the symbolic label for this purpose.
-
getConstraints
Returns the set of constraints that should apply to any secrets that match this purpose.- Returns:
- the set of constraints to apply for this purpose.
-
withConstraints
Constructs a new purpose that is identical to this purpose but which imposes additional constraints on the secrets that can satisfy it.- Parameters:
constraints
- the additional constraints to apply.- Returns:
- a new purpose with the additional constraints applied.
-
isSatisfiedBy
Determines whether all of the constraints for this purpose are satisfied by the given secret.- Parameters:
secret
- the secret.- Returns:
true
if the secret satisfies all constraints for this purpose.
-
equals
-
hashCode
public int hashCode() -
toString
-