The body interface has changed to require an explicit read of data before invoking methods to obtain that data. Previously, methods to obtain the data would result in an implicit read of the data. The following code examples illustrate this change in semantics.
com.pingidentity.pa.sdk.http.Body
As the updated Javadocs for the body interface indicates, plugins should avoid interrogating a body object unless absolutely necessary because reading a body object's data into memory can impact the scalability of PingAccess. As the plugin code is updated, evaluate whether the body object needs to be used by the plugin.- Using the Body#read method
- Before PingAccess 5.0:
private void invokeRead(Body body) throws IOException { body.read(); }
- Using the Body#getContent method
- Before PingAccess
5.0:
private void invokeGetContent(Body body) throws IOException { byte[] content = body.getContent(); }
- Using the Body#getBodyAsStream method
- Before PingAccess
5.0:
private void invokeGetBodyAsStream(Body body) throws IOException { InputStream stream = body.getBodyAsStream(); }
- Using the Body#write method
- Before PingAccess
5.0:
private void invokeWrite(Body body, BodyTransferrer bodyTransferrer) throws IOException { body.write(bodyTransferrer); }
- Using the Body#getLength method
- Before PingAccess
5.0:
private void invokeGetLength(Body body) throws IOException { int length = body.getLength(); }
- Using the Body#getRaw method
- Before PingAccess
5.0:
private void invokeGetRaw(Body body) throws IOException { byte[] rawBody = body.getRaw(); }
com.pingidentity.pa.sdk.http.BodyFactory
- Using the BodyFactory#continuousBody method
- Before PingAccess
5.0:
private void invokeContinuousBody(BodyFactory bodyFactory, byte[] content) { Body body = bodyFactory.continuousBody(content); }
com.pingidentity.pa.sdk.http.Constants
The constants available from this class have been removed from the SDK. Plugins using these constants should maintain their own constants with the needed values.
com.pingidentity.pa.sdk.http.Exchange
A handful of methods have been removed from the Exchange.
Further, the mechanism for storing data on the exchange through properties has been enhanced to make it easier to write type-safe code when working with Exchange properties.
- Using the Exchange#getCreationTime method
- Before PingAccess
5.0:
Calendar creationTime = exchange.getCreationTime();
- Using the Exchange#getDestinations method
- Before PingAccess
5.0:
List<String> destinations = exchange.getDestinations();
- Using the Exchange#getOriginalHostHeader method
- Before PingAccess
5.0:
String originalHostHeader = exchange.getOriginalHostHeader();
- Using the Exchange#getOriginalHostHeaderHost method
- Before PingAccess
5.0:
String host = exchange.getOriginalHostHeaderHost();
- Using the Exchange#getOriginalHostHeaderPort method
- Before PingAccess
5.0:
String port = exchange.getOriginalHostHeaderPort();
- Using the Exchange#getOriginalRequestBaseUri method
- Before PingAccess
5.0:
String originalRequestBaseUri = exchange.getOriginalRequestBaseUri();
- Using the Exchange#getProperties method
- Before PingAccess
5.0:
Map<String, String> properties = exchange.getProperties();
- Using the Exchange#getRequestBaseUri method
- Before PingAccess
5.0:
String requestBaseUri = exchange.getRequestBaseUri();
- Using the Exchange#getRequestScheme method
- Before PingAccess
5.0:
String requestScheme = exchange.getRequestScheme();
- Using the Exchange#getUser method
- Before PingAccess
5.0:
private void invokeSetUser(Exchange exchange, User user) { exchange.setUser(user); }
- Using the Exchange#setUser method
- Before PingAccess
5.0:
private void invokeSetUser(Exchange exchange, User user) { exchange.setUser(user); }
- Using the Exchange#setSourceIp method
- Before PingAccess
5.0:
private void invokeSetSourceIp(Exchange exchange, String sourceIp) { exchange.setSourceIp(sourceIp); }
- Using the Exchange#setProperty method
- Before PingAccess
5.0:
private void invokeSetProperty(Exchange exchange, String propertyKey, String value) { exchange.setProperty(propertyKey, value); }
- Using the Exchange#getProperty method
- Before PingAccess
5.0:
private void invokeGetProperty(Exchange exchange, String propertyKey) { Object propertyValueObj = exchange.getProperty(propertyKey); if (propertyValueObj instanceof String) { String propertyValue = (String) propertyValueObj; } }
com.pingidentity.pa.sdk.http.Header
This deprecated class has been replaced by the Headers interface. A Headers object can be created using a HeadersFactory obtained from the ServiceFactory#headersFactory method. The majority of methods on Header have counterparts on the Headers interface. See the Javadocs for the Headers interface for more information.
com.pingidentity.pa.sdk.http.HeaderField
This class is now final and cannot be extended.
- Constructing a HeaderField
- Before PingAccess
5.0:
private HeaderField createHeaderField(String line) { return new HeaderField(line); }
- Using the HeaderField#setHeaderName method
- Before PingAccess
5.0:
private void invokeSetHeaderName(HeaderField field) { field.setHeaderName(new HeaderName("X-Custom")); }
- Using the HeaderField#getApproximateSize method
- Before PingAccess
5.0:
int approximateSize = field.getApproximateSize();
com.pingidentity.pa.sdk.http.Headers
A few methods on the Headers interface have been updated to use the instant class, instead of date.
- Using the Headers#getDate method
- Before PingAccess 5.0:
Date date = headers.getDate();
- Using the Headers#setDate method
- Before PingAccess
5.0:
private void invokeSetDate(Headers headers, Date date) { headers.setDate(date); }
- Using the Headers#getLastModified method
- Before PingAccess
5.0:
SimpleDateFormat format = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); String lastModified = headers.getLastModified(); if (lastModified != null) { Date lastModifiedDate = format.parse(lastModified); }
- Using the Headers#setLastModified method
- Before PingAccess
5.0:
private void invokeSetLastModified(Headers headers, Date date) { SimpleDateFormat format = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); headers.setLastModified(format.format(date)); }
com.pingidentity.pa.sdk.http.HeadersFactory
- Using the HeadersFactory#createFromRawHeaderFields method
- Before PingAccess
5.0:
private void invokeCreateFromRawHeaderFields(HeadersFactory factory, List<String> fields) throws ParseException { Headers headers = factory.createFromRawHeaderFields(fields); }
com.pingidentity.pa.sdk.http.HttpStatus
The HttpStatus enum was converted to a final class. Common HttpStatus instances are defined as constants on HttpStatus.
- Using the HttpStatus#getLocalizationKey method
- Before PingAccess
5.0:
String localizationKey = status.getLocalizationKey();
com.pingidentity.pa.sdk.http.MimeType
The constants available in this class are now available as constant MediaType instances in the class com.pingidentity.pa.sdk.http.CommonMediaTypes.
com.pingidentity.pa.sdk.http.MediaType
This class is now final and cannot be extended.
- Constructing a MediaType
- Before PingAccess
5.0:
private void createMediaType(String mediaTypeString) { MediaType mediaType = new MediaType(mediaTypeString); }
com.pingidentity.pa.sdk.http.Message
A number of methods have been removed from the Message interface.
- Using the Message#getBodyAsStream method
- Before PingAccess
5.0:
InputStream bodyStream = message.getBodyAsStream();
- Using the Message#getCharset method
- Before PingAccess 5.0:
Charset charset = message.getCharset();
- Using the Message#getHeader method
- Before PingAccess 5.0:
Header header = message.getHeader();
- Using the Message#setHeader method
- Before PingAccess
5.0:
private void invokeSetHeader(Message message, Header header) { message.setHeader(header); }
- Using the Message#isDeflate method
- Before PingAccess 5.0:
boolean deflate = message.isDeflate();
- Using the Message#isGzip method
- Before PingAccess 5.0:
boolean gzip = message.isGzip();
- Using the Message#isHTTP10 method
- Before PingAccess 5.0:
boolean http10 = message.isHTTP10();
- Using the Message#isHTTP11 method
- Before PingAccess 5.0:
boolean http11 = message.isHTTP11();
- Using the Message#read method
- Before PingAccess
5.0:
private void invokeRead(Message message, InputStream inputStream, boolean createBody) throws IOException { message.read(inputStream, createBody); }
- Using the Message#setVersion method
- Before PingAccess
5.0:
private void invokeSetVersion(Message message, String version) { message.setVersion(version); }
- Using the Message#write method
- Before PingAccess
5.0:
private void invokeWrite(Message message, OutputStream output) throws IOException { message.write(output); }
com.pingidentity.pa.sdk.http.Method
The method interface has been converted to a final class. Additionally, the related methods enum has been merged into the method class. The method class provides common method instances as class-level constants.
- Obtaining a common Method instance
- Before PingAccess 5.0:
Method get = Methods.GET
- Using the Method#getMethodName method
- Before PingAccess
5.0:
String methodName = method.getMethodName();
com.pingidentity.pa.sdk.http.Request
A few methods have been removed from the request interface.
- Using the Request#getPostParams method
- Before PingAccess
5.0:
private void invokeGetPostParams(Request request) throws IOException { Map<String, String[]> postParams = request.getPostParams(); }
- Using the Request#isMultipartFormPost method
- Before PingAccess
5.0:
boolean multipartFormPost = request.isMultipartFormPost();
com.pingidentity.pa.sdk.http.ResponseBuilder
A handful of methods were removed from ResponseBuilder. Additionally, a handful of methods have changed their semantics, particularly those that included an HTML message payload. See the updated Javadocs for ResponseBuilder for more info.
- Using the ResponseBuilder#badRequestText method
- Before PingAccess
5.0:
Response response = ResponseBuilder.badRequestText(message).build();
- Using the ResponseBuilder#contentLength method
- Before PingAccess
5.0:
Response response = ResponseBuilder.newInstance().contentLength(length).build();
- Using the ResponseBuilder#continue100 method
- Before PingAccess
5.0:
Response response = ResponseBuilder.continue100().build();
- Using the ResponseBuilder#forbiddenText method
- Before PingAccess
5.0:
Response response = ResponseBuilder.forbiddenText().build();
- Using the ResponseBuilder#forbiddenWithoutBody method
- Before PingAccess
5.0:
Response response = ResponseBuilder.forbiddenWithoutBody().build();
- Using the ResponseBuilder#htmlMessage method
- Before PingAccess
5.0:
String message = ResponseBuilder.htmlMessage(caption, text);
- Using the ResponseBuilder#internalServerError method
- Before PingAccess
5.0:
Response response = ResponseBuilder.internalServerError(message).build();
- Using the ResponseBuilder#internalServerErrorWithoutBody method
- Before PingAccess
5.0:
Response response = ResponseBuilder.internalServerErrorWithoutBody().build();
- Using the ResponseBuilder#newInstance method
-
The no-arg newInstance method has been removed. A HttpStatus is required to create an instance of ResponseBuilder, and the required HttpStatus object should be passed to the newInstance method that accepts a HttpStatus.
- Using the ResponseBuilder#noContent method
- Before PingAccess
5.0:
Response response = ResponseBuilder.noContent().build();
- Using the ResponseBuilder#notFoundWithoutBody method
- Before PingAccess
5.0:
Response response = ResponseBuilder.notFoundWithoutBody().build();
- Using the ResponseBuilder#serverUnavailable method
- Before PingAccess
5.0:
Response response = ResponseBuilder.serverUnavailable(message).build();
- Using the ResponseBuilder#serviceUnavailableWithoutBody method
- Before PingAccess
5.0:
Response response = ResponseBuilder.serverUnavailableWithoutBody().build();
- Using the ResponseBuilder#status method
-
The status methods have been removed. Instead the status should be specified to the newInstance method as it is now required.
- Using the ResponseBuilder#unauthorizedWithoutBody method
- Before PingAccess
5.0:
Response response = ResponseBuilder.unauthorizedWithoutBody().build();
com.pingidentity.pa.sdk.http.Response
A few methods were removed from the response interface.
- Using the Response#isRedirect method
- Before PingAccess 5.0:
boolean redirect = response.isRedirect();
- Using the Response#setStatusCode method
- Before PingAccess
5.0:
response.setStatusCode(HttpStatus.OK.getCode());
- Using the Response#setStatusMessage method
- Before PingAccess
5.0:
response.setStatusMessage(HttpStatus.OK.getMessage());