Identifier
, Comparable<Identifier>
, net.minidev.json.JSONAware
public class IdentifierWithHMAC extends BaseIdentifier
Modifier and Type | Field | Description |
---|---|---|
static int |
DEFAULT_BYTE_LENGTH |
The default byte length of generated identifiers.
|
SECURE_RANDOM
Constructor | Description |
---|---|
IdentifierWithHMAC(byte[] value,
SecretKey hmacKey) |
Creates a new identifier protected with a SHA-256 based HMAC.
|
IdentifierWithHMAC(SecretKey hmacKey) |
Generates a new 128-bite secure random identifier and protects it
with a SHA-256 based HMAC.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(Object object) |
Overrides
Object.equals() . |
static IdentifierWithHMAC |
parseAndValidate(String value,
SecretKey hmacKey) |
Parses and validates the specified identifier with HMAC protection.
|
compareTo, hashCode, toJSONString, toString
public static final int DEFAULT_BYTE_LENGTH
public IdentifierWithHMAC(byte[] value, SecretKey hmacKey)
value
- The identifier value. Must not empty or null
.hmacKey
- The HMAC key. Must be at least 128 bits long.public IdentifierWithHMAC(SecretKey hmacKey)
hmacKey
- The HMAC key. Must be at least 128 bits long.RuntimeException
- If HMAC computation failed.public boolean equals(Object object)
BaseIdentifier
Object.equals()
.equals
in class BaseIdentifier
object
- The object to compare to.true
if the objects have the same value, otherwise
false
.public static IdentifierWithHMAC parseAndValidate(String value, SecretKey hmacKey) throws InvalidIdentifierException
value
- The identifier value to parse and validate. Must not
be null
.hmacKey
- The HMAC key. Must be at least 128 bits long.InvalidIdentifierException
- If the identifier format is
illegal or the HMAC is invalid.RuntimeException
- If HMAC computation failed.Copyright © 2018 Connect2id. All rights reserved.