@Override public String getServerName() { return getRequest().getHttpServletRequest().getServerName(); }
@Override public String getHeader(String name) { return request.getHeader(name); }
public RequestResponse createRequestResponse(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { Request request = new Request(httpServletRequest, application); Response response = new Response(httpServletResponse, application); return new RequestResponse(request, response); }
private HttpServletRequest getHttpServletRequest() { return Request.get().getHttpServletRequest(); }
private Set<String> getContentTypes(Request request) { Set<String> types = new LinkedHashSet<>(); types.addAll(getContentTypes(request.getContentType())); types.addAll(getContentTypes(request.getHttpServletRequest().getContentType())); return types; }
private Set<String> getAcceptTypes(Request request) { Set<String> types = new LinkedHashSet<>(); types.addAll(getContentTypes(request.getAcceptType())); types.addAll(getContentTypes(request.getHttpServletRequest().getHeader(HttpConstants.Header.ACCEPT))); return types; }
@Override public void handle(Context context) { String httpSerlvetRequestMethod = context.getRequest().getHttpServletRequest().getMethod(); if (HttpMethod.POST.equals(httpSerlvetRequestMethod)) { String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';'); if (!guardedTypes.contains(contentType)) { log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(), String requestToken = context.getRequest().getHeader(HEADER); if ("nocheck".equals(requestToken)) { log.debug("Ignoring 'nocheck' request for {} '{}'", context.getRequestMethod(), context.getRequestUri());
if (!context.getContentTypes().contains(TEXT_XML)) { log.warn("{} request from {} did not specify {}, ignoring", context.getRequestUri(), context.getRequest().getClientIp(), TEXT_XML); context.next(); return; try (InputStream is = context.getRequest().getHttpServletRequest().getInputStream()) { XmlRpcRequest request = new XmlRpcRequest(); request.parse(is);
@Override public void handle(RouteContext context) { String rawMethod = context.getRequest().getHttpServletRequest().getMethod(); if (HttpConstants.Method.POST.equals(rawMethod)) { String contentType = new ParameterValue(context.getRequest().getLocale(), context.getHeader("Content-Type")).toString("").toLowerCase(); contentType = StringUtils.getPrefix(contentType, ';').trim(); if (!guardedTypes.contains(contentType)) {
public <T> T createEntityFromBody(Class<T> entityClass) { try { String body = getBody(); if (StringUtils.isNullOrEmpty(body)) { log.warn("Can not create entity '{}' from null or empty request body!", entityClass.getName()); String contentType = getContentType(); if (StringUtils.isNullOrEmpty(contentType)) { contentType = getAcceptType();
if ("*/*".equals(request.getAcceptType())) { ContentTypeEngine engine = contentTypeEngines.getContentTypeEngine(request.getAcceptType()); if (engine != null) { log.debug("Negotiated '{}' from request Accept header", engine.getContentType()); } else if (!StringUtils.isNullOrEmpty(request.getContentType())) { engine = contentTypeEngines.getContentTypeEngine(request.getContentType()); if (engine != null) { log.debug("Negotiated '{}' from request Content-Type header", engine.getContentType()); request.getAcceptType(), request.getContentType()); return this;
@Override public void handle(Context context) { if (!SecurityUtils.getSubject().isAuthenticated()) { // unauthenticated session, save request & redirect to login url String requestUri = context.getRequest().getApplicationUriWithQuery(); context.setSession(DESTINATION_ATTRIBUTE, requestUri); context.redirect(loginUrl); log.info("Unauthenticated request for {}, redirecting to {}", context.getRequestUri(), loginUrl); } else { // session already authenticated context.next(); } } }
@Override public String getRemoteAddr() { return getRequest().getClientIp(); }
if (!StringUtils.isNullOrEmpty(routeContext.getRequest().getAcceptType())) { String acceptType = routeContext.getRequest().getAcceptType(); if (acceptType.startsWith(HttpConstants.ContentType.TEXT_HTML) || acceptType.startsWith(HttpConstants.ContentType.TEXT_XHTML)) {
private Set<String> getContentTypes(Request request) { Set<String> types = new LinkedHashSet<>(); types.addAll(getContentTypes(request.getContentType())); types.addAll(getContentTypes(request.getHttpServletRequest().getContentType())); return types; }
private Set<String> getAcceptTypes(Request request) { Set<String> types = new LinkedHashSet<>(); types.addAll(getContentTypes(request.getAcceptType())); types.addAll(getContentTypes(request.getHttpServletRequest().getHeader(HttpConstants.Header.ACCEPT))); return types; }
@Override public void handle(Context context) { String httpSerlvetRequestMethod = context.getRequest().getHttpServletRequest().getMethod(); if (HttpMethod.POST.equals(httpSerlvetRequestMethod)) { String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';'); if (!guardedTypes.contains(contentType)) { log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(), String requestToken = context.getRequest().getHeader(HEADER); if ("nocheck".equals(requestToken)) { log.debug("Ignoring 'nocheck' request for {} '{}'", context.getRequestMethod(), context.getRequestUri());
if (!context.getContentTypes().contains(TEXT_XML)) { log.warn("{} request from {} did not specify {}, ignoring", context.getRequestUri(), context.getRequest().getClientIp(), TEXT_XML); context.next(); return; try (InputStream is = context.getRequest().getHttpServletRequest().getInputStream()) { XmlRpcRequest request = new XmlRpcRequest(); request.parse(is);
private HttpServletRequest getHttpServletRequest() { return Request.get().getHttpServletRequest(); }
@Override public void handle(Context context) { if (context.getSession(AuthConstants.ACCOUNT_ATTRIBUTE) == null) { // unauthenticated session, save request & redirect to login url String requestUri = context.getRequest().getApplicationUriWithQuery(); context.setSession(AuthConstants.DESTINATION_ATTRIBUTE, requestUri); context.redirect(loginPath); log.info("Unauthenticated request for {}, redirecting to {}", context.getRequestUri(), loginPath); } else { // session already authenticated context.next(); } } }