SuperUserJwtTokenRequestHandler
Inheritance: java.lang.Object
public class SuperUserJwtTokenRequestHandler
JWT Token Request Handler with caching, local validation, and circuit breaker. Tokens are cached for up to 7 days with refresh 6 hours before expiration.
Constructors
| Constructor | Description |
|---|---|
| SuperUserJwtTokenRequestHandler() | Public constructor. |
Methods
| Method | Description |
|---|---|
| beforeSend(HttpURLConnection request, OutputStream streamToSend) | Add authorization header before sending the request. |
| getCachedToken() | Gets the currently cached token for testing purposes. |
| getTokenExpiration() | Gets the token expiration as a Date for testing purposes. |
| getTokenExpirationMillis() | Gets the token expiration time for testing purposes. |
| processResponse(HttpURLConnection response, String resultString, String errorString) | Process the response, handling 401 Unauthorized by refreshing token. |
| processUrl(String url) | Process the URL (ensures token is available). |
| resetForTesting() | Resets all cached token state for testing purposes. |
SuperUserJwtTokenRequestHandler()
public SuperUserJwtTokenRequestHandler()
Public constructor.
beforeSend(HttpURLConnection request, OutputStream streamToSend)
public void beforeSend(HttpURLConnection request, OutputStream streamToSend)
Add authorization header before sending the request.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| request | java.net.HttpURLConnection | The HTTP connection |
| streamToSend | java.io.OutputStream | The output stream (unused) |
getCachedToken()
public static String getCachedToken()
Gets the currently cached token for testing purposes.
Returns: java.lang.String - The cached JWT token or null
getTokenExpiration()
public static Date getTokenExpiration()
Gets the token expiration as a Date for testing purposes.
Returns: java.util.Date - The expiration Date or null if no token
getTokenExpirationMillis()
public static long getTokenExpirationMillis()
Gets the token expiration time for testing purposes.
Returns: long - The expiration time in milliseconds since epoch
processResponse(HttpURLConnection response, String resultString, String errorString)
public void processResponse(HttpURLConnection response, String resultString, String errorString)
Process the response, handling 401 Unauthorized by refreshing token.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| response | java.net.HttpURLConnection | The HTTP response |
| resultString | java.lang.String | The response body |
| errorString | java.lang.String | The error message if any |
processUrl(String url)
public String processUrl(String url)
Process the URL (ensures token is available).
Parameters:
| Parameter | Type | Description |
|---|---|---|
| url | java.lang.String | The URL to process |
Returns: java.lang.String - The URL unchanged
resetForTesting()
public static void resetForTesting()
Resets all cached token state for testing purposes.