Class BearerToken
java.lang.Object
co.ankatech.ankasecure.sdk.security.BearerToken
Holder for a JWT bearer token represented as
char[] rather than String, with
a redacted toString() so accidental log statements do not leak the token verbatim.
The contract takes ownership of the supplied char[] — the caller must NOT retain
a reference. Call clear() when the token is no longer needed; subsequent
chars() calls throw IllegalStateException.
toString() returns:
"[REDACTED]"when the token has been cleared, or when the token's length is less than 10 (no useful prefix to display).<first6>…[REDACTED]otherwise, where<first6>is the first six characters of the JWT (typically"eyJhbG"— the URL-safe base64 prefix of the JWS header).
clear() is idempotent.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
BearerToken
public BearerToken(char[] owned) Takes ownership of the supplied char array.- Throws:
NullPointerException- ifownedisnull
-
-
Method Details
-
chars
public char[] chars()- Returns:
- the underlying token characters
- Throws:
IllegalStateException- ifclear()has been called
-
clear
public void clear()Zeroizes the underlying token viaZeroization.zeroize(char[])(space-fill). Idempotent. After this call,chars()throws andtoString()returns"[REDACTED]". -
isCleared
public boolean isCleared()- Returns:
trueifclear()has been called
-
toString
Returns a redacted representation of the token. Never reveals the full token value.
-