private String getJwtResponse(Object httpRequestObject) { String jwtResponse; if (HttpRequest.class.isAssignableFrom(httpRequestObject.getClass())) { HttpRequest httpRequest = (HttpRequest) httpRequestObject; Assert.isTrue( httpRequest.getMethod() == HttpMethod.GET, "Only Http GET method is supported."); jwtResponse = httpRequest.getParameter(JWT_RESPONSE); } else { // This must never happen, if the object request is of HttpServletRequest type the // HTTP_SERVLET_REQUEST_WRAPPER_CLASS // must be already loaded and therefore cannot be null. if (HTTP_SERVLET_REQUEST_WRAPPER_CLASS == null) { throw new RuntimeException( "DefaultHttpServletRequestWrapper not loaded error occurred while handling httpRequest of type: " + httpRequestObject.getClass().getName()); } Constructor<? extends HttpServletRequestWrapper> ctor = Classes.getConstructor(HTTP_SERVLET_REQUEST_WRAPPER_CLASS, Object.class); HttpServletRequestWrapper httpServletRequestWrapper = Classes.instantiate(ctor, httpRequestObject); HttpMethod method = HttpMethod.fromName(httpServletRequestWrapper.getMethod()); Assert.isTrue(HttpMethod.GET == method, "Only Http GET method is supported."); jwtResponse = httpServletRequestWrapper.getParameter(JWT_RESPONSE); } if (!Strings.hasText(jwtResponse)) { throw new InvalidJwtException(InvalidJwtException.JWT_REQUIRED_ERROR); } return jwtResponse; }