Upgrading
  • 02 Jul 2023
  • Dark
    Light

Upgrading

  • Dark
    Light

Article Summary

SDK > v4.x

To upgrade to the latest Enforcer version, run:

mvn versions:display-dependency-updates

Open the project’s pom.xml and change the version number to the latest version number.

Your Enforcer version is now upgraded to the latest enforcer version.

SDK < v4.x

On SDK v4.x PXContext was changed. following these changes, the implementation of HUMAN SDK on the java filter must be changed accordingly.

HUMAN SDK reports now if it handled the response instead of reporting if request was verified

As a result of that, PXContext exposes the following method: ctx.isHandledResponse() and not ctx.isVerified() in addition isVerified() is deprecated and from now on, use isRequestLowScore() instead.

isHandledResponse() will return true in the following cases

  1. Request is blocked and HUMAN handled the response by rendering a block page (because of high score)
  2. Response was handled by first party mechanism (not score related).

Following the instructions above, the filter should be changed according the the example below

  // Verify the request
  PXContext ctx = enforcer.pxVerify(req, new HttpServletResponseWrapper(resp);

  // Notice that isVerified() changed to isHandledResponse()
  if (ctx != null && ctx.isHandledResponse()) {

     // Optional: check why response was handled
     if (ctx.isFirstPartyRequest()) {
       System.out.println("Incoming request was first party request");
     }

     if (!ctx.isRequestLowScore()) {
       System.out.println("Request score was higher than threshold");
     }

    // Must return and not continue to filterChain.doFilter
    return;

 }

 filterChain.doFilter(servletRequest, servletResponse);

Once the filter is changed, follow the instructions above.

For more information, contact HUMAN Support.


Was this article helpful?