Class HmacTrustedDeviceTokenSigner
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.HmacTrustedDeviceTokenSigner
- All Implemented Interfaces:
TrustedDeviceTokenSigner
@Component
public class HmacTrustedDeviceTokenSigner
extends Object
implements TrustedDeviceTokenSigner
TrustedDeviceTokenSigner that signs the trusted-device cookie with HMAC-SHA256, under a key derived from the
key-encryption secret for this purpose only (PurposeKeyDerivation). The value is
token.signature, the signature Base64url encoded without padding; it is compared in constant time.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringName of the MAC algorithm.private final SecretKeySpecThe signing key.static final StringLabel of the purpose the key is derived for.private static final charSeparator between the token and its signature. -
Constructor Summary
ConstructorsConstructorDescriptionHmacTrustedDeviceTokenSigner(PurposeKeyDerivation derivation) Derives the signing key. -
Method Summary
-
Field Details
-
PURPOSE
Label of the purpose the key is derived for.- See Also:
-
SEPARATOR
private static final char SEPARATORSeparator between the token and its signature.- See Also:
-
ALGORITHM
Name of the MAC algorithm.- See Also:
-
key
The signing key.
-
-
Constructor Details
-
HmacTrustedDeviceTokenSigner
Derives the signing key.- Parameters:
derivation- derives the key of a purpose from the key-encryption secret.
-
-
Method Details
-
sign
- Specified by:
signin interfaceTrustedDeviceTokenSigner
-
verify
- Specified by:
verifyin interfaceTrustedDeviceTokenSigner
-
mac
Computes the signature of a token.- Parameters:
token- the token.- Returns:
- the HMAC-SHA256 of its UTF-8 bytes.
-