Source:
<code>public HandlerResult getNormalizedToken( ServletRequest request, ServletResponse response, FilterChain chain, boolean resolve) { HandlerResult handlerResult = new HandlerResult(HandlerResult.Status.NO_ACTION, null); handlerResult.setSource(SOURCE); HttpServletRequest httpRequest = (HttpServletRequest) request; String path = httpRequest.getServletPath(); LOGGER.debug("Doing PKI authentication and authorization for path {}", path); BaseAuthenticationToken token = tokenFactory.getTokenFromCertificates( (X509Certificate[]) httpRequest.getAttribute("javax.servlet.request.X509Certificate")); <START> X509Certificate[] certs = <END> (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); HttpServletResponse httpResponse = response instanceof HttpServletResponse ? (HttpServletResponse) response : null; if (httpResponse == null && resolve) { LOGGER.debug("HTTP Response was null for request {}", path); return handlerResult; } if (token == null) { return handlerResult; } if (crlChecker.passesCrlCheck(certs)) { handlerResult.setToken(token); handlerResult.setStatus(HandlerResult.Status.COMPLETED); } else { if (httpResponse == null) { LOGGER.error( "Error returning revoked certificate request because the HTTP response object is invalid."); } else { try { httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "Your certificate is revoked."); httpResponse.flushBuffer(); LOGGER.info("The certificate used to complete the request has been revoked."); } catch (Exception e) { LOGGER.error("Error returning revoked certificate request."); } } handlerResult.setStatus(HandlerResult.Status.REDIRECTED); } return handlerResult; }</code><technical_language>This statement inverted in order avoid calling httpRequest.getAttribute multiple times: // matter resolve flag is set to, do action BaseAuthenticationToken token = tokenFactory.getTokenFromCertificates( (X509Certificate[]) httpRequest.getAttribute("javax.servlet.request.X509Certificate")); X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); // matter resolve flag is set to, do action BaseAuthenticationToken token = tokenFactory.getTokenFromCertificates(certs);</technical_language>

Target:
public HandlerResult getNormalizedToken( ServletRequest request, ServletResponse response, FilterChain chain, boolean resolve) { HandlerResult handlerResult = new HandlerResult(HandlerResult.Status.NO_ACTION, null); handlerResult.setSource(SOURCE); HttpServletRequest httpRequest = (HttpServletRequest) request; String path = httpRequest.getServletPath(); LOGGER.debug("Doing PKI authentication and authorization for path {}", path); X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); BaseAuthenticationToken token = tokenFactory.fromCertificates(certs); HttpServletResponse httpResponse = response instanceof HttpServletResponse ? (HttpServletResponse) response : null; if (httpResponse == null && resolve) { LOGGER.debug("HTTP Response was null for request {}", path); return handlerResult; } if (token == null) { return handlerResult; } if (crlChecker.passesCrlCheck(certs) && ocspService.passesOcspCheck(certs)) { handlerResult.setToken(token); handlerResult.setStatus(HandlerResult.Status.COMPLETED); } else { if (httpResponse == null) { LOGGER.error( "Error returning revoked certificate request because the HTTP response object is invalid."); } else { try { httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "Your certificate is revoked."); httpResponse.flushBuffer(); LOGGER.info("The certificate used to complete the request has been revoked."); } catch (Exception e) { LOGGER.error("Error returning revoked certificate request."); } } handlerResult.setStatus(HandlerResult.Status.REDIRECTED); } return handlerResult; }