Package com.nimbusds.common.id
Class AbstractIdentifierWithHMACGenerator<T>
- java.lang.Object
-
- com.nimbusds.common.id.AbstractIdentifierWithHMACGenerator<T>
-
- All Implemented Interfaces:
IdentifierWithHMACGenerator<T>
@ThreadSafe public abstract class AbstractIdentifierWithHMACGenerator<T> extends Object implements IdentifierWithHMACGenerator<T>
Abstract generator of secure random identifiers with SHA-256 based Message Authentication Code (MAC) protection.
-
-
Constructor Summary
Constructors Constructor Description AbstractIdentifierWithHMACGenerator(SecretKey hmacKey)
Creates a new generator of secure random identifiers with SHA-256 based Message Authentication Code (MAC) protection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.nimbusds.jose.util.Base64URL
extractValue(T identifier)
Extracts the raw value from the specified HMAC protected identifier (to be used as a key in database queries, etc).SecretKey
getHMACKey()
Returns the HMAC key.com.nimbusds.jose.util.Base64URL
validateAndExtractValue(T identifier)
Checks the HMAC of the specified identifier and returns its raw value (to be used as a key in database queries, etc).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.nimbusds.common.id.IdentifierWithHMACGenerator
applyHMAC, generate
-
-
-
-
Constructor Detail
-
AbstractIdentifierWithHMACGenerator
public AbstractIdentifierWithHMACGenerator(SecretKey hmacKey)
Creates a new generator of secure random identifiers with SHA-256 based Message Authentication Code (MAC) protection.- Parameters:
hmacKey
- The HMAC key, must be 256 bits long.
-
-
Method Detail
-
getHMACKey
public SecretKey getHMACKey()
Returns the HMAC key.- Returns:
- The HMAC key.
-
validateAndExtractValue
public com.nimbusds.jose.util.Base64URL validateAndExtractValue(T identifier) throws InvalidIdentifierException
Description copied from interface:IdentifierWithHMACGenerator
Checks the HMAC of the specified identifier and returns its raw value (to be used as a key in database queries, etc).- Specified by:
validateAndExtractValue
in interfaceIdentifierWithHMACGenerator<T>
- Parameters:
identifier
- The identifier with HMAC protection. Must not benull
.- Returns:
- The raw identifier value, BASE64-URL encoded.
- Throws:
InvalidIdentifierException
- If the identifier format is illegal or didn't pass the HMAC check.
-
extractValue
public com.nimbusds.jose.util.Base64URL extractValue(T identifier)
Description copied from interface:IdentifierWithHMACGenerator
Extracts the raw value from the specified HMAC protected identifier (to be used as a key in database queries, etc). The HMAC is not checked!- Specified by:
extractValue
in interfaceIdentifierWithHMACGenerator<T>
- Parameters:
identifier
- The identifier with HMAC protection. Must not benull
.- Returns:
- The raw identifier value, BASE64-URL encoded.
-
-