com.pingidentity.pa.sdk.policy.AccessExceptionContext
The nested Builder class has been removed from AccessExceptionContext and instead AccessExceptionContext is a builder that can be initially created with the new AccessExceptionContext#create method.
The LocalizedMessage interface has been introduced to simplify the configuration of a localized message for use in an error template. A LocalizedMessage has three implementations provided in the SDK: FixedMessage, BasicLocalizedMessage and ParameterizedLocalizedMessage. See the following code examples for more information on using these new classes.
- Constructing an AccessExceptionContext
- Before PingAccess
5.0:
private AccessExceptionContext createAccessExceptionContext(HttpStatus httpStatus, Throwable cause) { return AccessExceptionContext.builder() .cause(cause) .httpStatus(httpStatus) .exceptionMessage(httpStatus.getMessage()) .errorDescription(httpStatus.getLocalizationKey()) .errorDescriptionIsKey(true) .errorDescriptionSubstitutions(new String[0]) .build(); }
com.pingidentity.pa.sdk.policy.AccessException
The changes to AccessExceptionContext apply to the creation of AccessException because the creation of an AccessException requires an AccessExceptionContext.
In addition to these changes, obtaining information from AccessException has also changed. See the code examples below for more information.
Finally, AccessException no longer derives from IOException and derives directly from Exception instead.
- Constructing an AccessException
- Before PingAccess
5.0:
private void throwAccessException(String errorDescription, Throwable throwable) throws AccessException { throw new AccessException(errorDescription, throwable); }
- Using the AccessException#getExceptionContext method
- Before PingAccess
5.0:
AccessExceptionContext context = accessException.getExceptionContext();
- Using the AccessException#getHttpStatusCode method
- Before PingAccess
5.0:
int statusCode = accessException.getHttpStatusCode();
- Using the AccessException#getHttpStatusMessage method
- Before PingAccess
5.0:
String statusMessage = accessException.getHttpStatusMessage();
- Using the AccessException#setHttpStatusCode method
- Before PingAccess
5.0:
accessException.setHttpStatusCode(statusCode);
- Using the AccessException#setHttpStatusMessage method
- Before PingAccess
5.0:
accessException.setHttpStatusMessage(statusMessage);
com.pingidentity.pa.sdk.policy.RuleInterceptor
The handleRequest and handleResponse methods on a RuleInterceptor no longer throw an IOException. Instead, they throw an AccessException, which no longer derives from IOException.
- Accounting for the RuleInterceptor#handleRequest method signature change
- Before PingAccess
5.0:
@Override public Outcome handleRequest(Exchange exchange) throws IOException { Outcome outcome = applyPolicy(exchange); return outcome; }
- Account for the RuleInterceptor#handleResponse method signature change
- Before PingAccess
5.0:
@Override public void handleResponse(Exchange exchange) throws IOException { applyPolicyToResponse(exchange.getResponse()); }
com.pingidentity.pa.sdk.policy.error.InternalServerErrorCallback
This class has been removed. Use LocalizedInternalServerErrorCallback instead.