public final class Token extends Object
Token.equals(Object) method does not leak any information through timing. While one could be
careful with String or byte[] and perform all the comparisons in a secure way, just one
careless call of Object.equals(Object) could expose the secret data to an attacker. For
this reason, we encapsulate it into a class to prevent such accidental exposure.
The Token class does not allow the data to be extracted in the original form. It has limited set
of operation that allow you to learn something about the data:
Token.hashCode() - this might expose part of the hash. Note that some
collection implementations like HashMap might use it and leak this value
through timing attack.Token.toString() might contain whole hash of the sensitive data.Token.hashCode() and Token.toString().
Those operations are explicitly not planned to be ever supported:
Comparable.compareTo(Object) - This could be hardly implemented
in a meaningful way without compromising security.| Modifier and Type | Method and Description |
|---|---|
static Token |
createHashedTokenFromString(String secret) |
boolean |
equals(Object o)
If the other object is not a Token, it immediatelly returns false.
|
int |
hashCode() |
String |
toString()
The String representation of Token might contain hash.
|
public boolean equals(Object o)
public String toString()