Class KeyManagementSdkException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
QuorumApprovalPendingException,TenantBindingRequiredException
Carries the HTTP status returned by the Auth API or the Admin API when applicable. The message
never contains credential material or bearer-token substrings: it is built from the operation
context, the HTTP status, and the server's own RFC 9457 detail sentence, every
server-supplied value in it rendered by
TerminalSafe.text(String), so it is safe to log or
print verbatim. The raw response body is never kept.
The problem and OAuth fields below hold the server's values as received, for programmatic use
(classification, comparison). Code that prints one renders it through TerminalSafe first.
The cause is unrendered too. For a refused call it is the generated
client's ApiException: its message is the server's HTTP reason phrase, and its getters keep the
response body and headers, the Location of a 3xx included. Neither the cause nor a stack
trace that prints it is written to a terminal or a log without rendering it through TerminalSafe;
this exception's own message and toString() never include it.
When the remote API answered with an RFC 9457 problem+json body, its type,
title, detail, instance and extension members are exposed as first-class
fields. Classify on getProblemType(): the type URI is the stable contract;
the message carries the human sentence and may be reworded by the server at any time.
When the Auth API refused a token request with an OAuth 2.0 error response (RFC 6749
section 5.2, RFC 9449 section 12.2), its error code (invalid_client,
invalid_dpop_proof, invalid_request, ...) is exposed by getOAuthError(), and a
Retry-After the server sent with a 503 by getRetryAfter().
try {
sdk.keys().create(request);
} catch (KeyManagementSdkException e) {
if (e.getHttpStatus() == 409 && e.getProblemType() != null && e.getProblemType().endsWith("/key-id-retired")) {
// the Key ID belonged to a destroyed key of this tenant and is never reused
}
}
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyManagementSdkException(String message, int httpStatus, Throwable cause) Creates an exception with a message, an HTTP status, and an underlying cause.KeyManagementSdkException(String message, int httpStatus, Throwable cause, String problemType, String problemTitle, String problemDetail, String oauthError, Duration retryAfter) Creates an exception for a refused token request, carrying the OAuth 2.0errorcode and the server'sRetry-Afterdelay alongside the problem fields.KeyManagementSdkException(String message, int httpStatus, Throwable cause, String problemType, String problemTitle, String problemDetail, String problemInstance, Map<String, Object> problemExtensions, String oauthError, Duration retryAfter) Creates an exception carrying every RFC 9457 member the response body held.KeyManagementSdkException(String message, Throwable cause) Creates an exception with a message and an underlying cause, without an HTTP status. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the OAuth 2.0errorcode of a refused token request:invalid_client(the workload credential was refused),invalid_dpop_proof(the DPoP proof was refused) orinvalid_request(a token request the authorization server could not accept as formed).Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI).Returns the problem's extension members.Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI).Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI).Returns the RFC 9457typeURI identifying the problem.Returns how long the server asked the caller to wait before retrying, from theRetry-Afterheader of a503answer.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
KeyManagementSdkException
Creates an exception with a message and an underlying cause, without an HTTP status.- Parameters:
message- a log-safe description that MUST NOT contain secret or token materialcause- the underlying cause, ornull
-
KeyManagementSdkException
Creates an exception with a message, an HTTP status, and an underlying cause.- Parameters:
message- a log-safe description that MUST NOT contain secret or token materialhttpStatus- the HTTP status returned by the remote APIcause- the underlying cause, ornull
-
KeyManagementSdkException
public KeyManagementSdkException(String message, int httpStatus, Throwable cause, String problemType, String problemTitle, String problemDetail, String oauthError, Duration retryAfter) Creates an exception for a refused token request, carrying the OAuth 2.0errorcode and the server'sRetry-Afterdelay alongside the problem fields.- Parameters:
message- a log-safe description that MUST NOT contain secret or token materialhttpStatus- the HTTP status returned by the remote APIcause- the underlying cause, ornullproblemType- the problemtypeURI, ornullproblemTitle- the problemtitle, ornullproblemDetail- the problemdetail, ornulloauthError- the OAuth 2.0errorcode, ornullretryAfter- theRetry-Afterdelay the server sent, ornull
-
KeyManagementSdkException
public KeyManagementSdkException(String message, int httpStatus, Throwable cause, String problemType, String problemTitle, String problemDetail, String problemInstance, Map<String, Object> problemExtensions, String oauthError, Duration retryAfter) Creates an exception carrying every RFC 9457 member the response body held.- Parameters:
message- a log-safe description that MUST NOT contain secret or token materialhttpStatus- the HTTP status returned by the remote APIcause- the underlying cause, ornullproblemType- the problemtypeURI, ornullproblemTitle- the problemtitle, ornullproblemDetail- the problemdetail, ornullproblemInstance- the probleminstance, ornullproblemExtensions- the extension members (String,Number,Boolean,ListorMapvalues);nullreads as emptyoauthError- the OAuth 2.0errorcode, ornullretryAfter- theRetry-Afterdelay the server sent, ornull
-
-
Method Details
-
getHttpStatus
public int getHttpStatus()- Returns:
- the HTTP status associated with this failure, or
0when not HTTP-related
-
getProblemType
Returns the RFC 9457typeURI identifying the problem. This is the stable classification key: classify on it rather than onThrowable.getMessage().Server-supplied and unrendered, for programmatic use: a caller that displays it renders it through
TerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the problem type URI, or
nullwhen the response carried no problem body
-
getProblemTitle
Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the RFC 9457
titleof the problem, ornullwhen absent
-
getProblemDetail
Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the RFC 9457
detailof the problem, ornullwhen absent
-
getProblemInstance
Server-supplied and unrendered, for programmatic use: a caller that displays it renders it throughTerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the RFC 9457
instanceof the problem (the request path the server refused), ornullwhen absent
-
getProblemExtensions
Returns the problem's extension members. The Admin API nests them underextensions(for examplerequestId, the correlation id to quote to support, andfield, the member a validation refused); members of that object and any other top-level member beyond the five RFC 9457 members are returned here, by name.Server-supplied and unrendered, for programmatic use: a caller that displays it renders it through
TerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the extension members, never
null; empty when the body carried none
-
getOAuthError
Returns the OAuth 2.0errorcode of a refused token request:invalid_client(the workload credential was refused),invalid_dpop_proof(the DPoP proof was refused) orinvalid_request(a token request the authorization server could not accept as formed).Server-supplied and unrendered, for programmatic use: a caller that displays it renders it through
TerminalSafe.text(String)(orTerminalSafe.uri(String)for a URI). The message never carries it unrendered.- Returns:
- the error code, or
nullwhen the failure was not an OAuth error response
-
getRetryAfter
Returns how long the server asked the caller to wait before retrying, from theRetry-Afterheader of a503answer.- Returns:
- the delay, or empty when the response carried no
Retry-After
-