@Override public String getMethod() { return httpRequest.getMethod().name(); }
@Override public HttpMethod getMethod() { return HttpMethod.fromName(request.getMethod()); }
/** * Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header. * <p>Returns an empty set when the allowed methods are unspecified. * * @return the allowed methods */ public Set<HttpMethod> getAllow() { String value = getFirst(ALLOW); if (value != null) { List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5); String[] tokens = value.split(",\\s*"); for (String token : tokens) { allowedMethod.add(HttpMethod.valueOf(token)); } return EnumSet.copyOf(allowedMethod); } else { return EnumSet.noneOf(HttpMethod.class); } }
/** * Returns the {@code HttpMethod} instance associated with the specified String name. * * @param name The name of the {@code HttpMethod} instance to retrieve. * @return the {@code HttpMethod} instance associated with the specified String name. * @throws IllegalArgumentException if {@code name} is null or does not match (case insensitive) an HttpMethod * value. */ public static HttpMethod fromName(String name) { for (HttpMethod method : values()) { if (method.name().equalsIgnoreCase(name)) { return method; } } throw new IllegalArgumentException("Unrecognized method name: " + name); } }
String method = request.getMethod().toString(); String canonicalResourcePath = canonicalizeResourcePath(uri.getPath()); String canonicalQueryString = canonicalizeQueryString(request);
String method = request.getMethod().toString(); String canonicalResourcePath = canonicalizeResourcePath(uri.getPath()); String canonicalQueryString = canonicalizeQueryString(request);
@Override public String getMethod() { return httpRequest.getMethod().name(); }
@Override public HttpMethod getMethod() { return HttpMethod.fromName(request.getMethod()); }
/** * Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header. * <p>Returns an empty set when the allowed methods are unspecified. * * @return the allowed methods */ public Set<HttpMethod> getAllow() { String value = getFirst(ALLOW); if (value != null) { List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5); String[] tokens = value.split(",\\s*"); for (String token : tokens) { allowedMethod.add(HttpMethod.valueOf(token)); } return EnumSet.copyOf(allowedMethod); } else { return EnumSet.noneOf(HttpMethod.class); } }
@Override public ViewModel handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean isClientCredentialsRequest = CLIENT_CREDENTIALS_GRANT_TYPE.equals(request.getParameter(GRANT_TYPE_PARAM_NAME)); String method = request.getMethod(); if (HttpMethod.POST.name().equalsIgnoreCase(method) && isClientCredentialsRequest) { return doPost(request, response); } return super.handleRequest(request, response); }
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; }
@Override public ViewModel handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { boolean isClientCredentialsRequest = CLIENT_CREDENTIALS_GRANT_TYPE.equals(request.getParameter(GRANT_TYPE_PARAM_NAME)); String method = request.getMethod(); if (HttpMethod.POST.name().equalsIgnoreCase(method) && isClientCredentialsRequest) { return doPost(request, response); } return super.handleRequest(request, response); }
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; }
@Override public ViewModel handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String method = request.getMethod(); if (HttpMethod.POST.name().equalsIgnoreCase(method)) { return doPost(request, response); } return super.handleRequest(request, response); }
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; }
@Override public ViewModel handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String method = request.getMethod(); if (HttpMethod.POST.name().equalsIgnoreCase(method)) { return doPost(request, response); } return super.handleRequest(request, response); }
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; }
protected void setCsrfToken(HttpServletRequest request, HttpServletResponse response, Form form) throws IllegalArgumentException { if (!isJsonPreferred(request, response)) { Assert.isInstanceOf(DefaultForm.class, form, "Form implementation class must equal or extend DefaultForm"); String val = fieldValueResolver.getValue(request, csrfTokenManager.getTokenName()); if (HttpMethod.POST.name().equalsIgnoreCase(request.getMethod())) { //This is a POST so we need to set the submitted CSRF token in the form form.addField(createCsrfTokenField(val)); } else if (HttpMethod.GET.name().equalsIgnoreCase(request.getMethod())) { //This is a GET so we need to generate a new CSRF token for the form form.addField(createCsrfTokenField(csrfTokenManager.createCsrfToken(request, response))); } } }
protected void setCsrfToken(HttpServletRequest request, HttpServletResponse response, Form form) throws IllegalArgumentException { if (!isJsonPreferred(request, response)) { Assert.isInstanceOf(DefaultForm.class, form, "Form implementation class must equal or extend DefaultForm"); String val = fieldValueResolver.getValue(request, csrfTokenManager.getTokenName()); if (HttpMethod.POST.name().equalsIgnoreCase(request.getMethod())) { //This is a POST so we need to set the submitted CSRF token in the form form.addField(createCsrfTokenField(val)); } else if (HttpMethod.GET.name().equalsIgnoreCase(request.getMethod())) { //This is a GET so we need to generate a new CSRF token for the form form.addField(createCsrfTokenField(csrfTokenManager.createCsrfToken(request, response))); } } }
if (request.getMethod().equals(HttpMethod.GET.name())) { errors.add(ErrorModel.builder().setStatus(HttpServletResponse.SC_OK).setMessage(errorMsg).build());