Search in sources :

Example 1 with ServletRequest

use of com.yahoo.jdisc.http.servlet.ServletRequest in project vespa by vespa-engine.

the class ServletFilterRequestTest method newServletRequest.

private ServletRequest newServletRequest() throws Exception {
    MockHttpServletRequest parent = new MockHttpServletRequest("GET", uri.toString());
    parent.setProtocol(Version.HTTP_1_1.toString());
    parent.setRemoteHost(host);
    parent.setRemotePort(port);
    parent.setParameter(paramName, paramValue);
    parent.setParameter(listParamName, listParamValue);
    parent.addHeader(headerName, headerValue);
    parent.setAttribute(attributeName, attributeValue);
    HttpConnection connection = Mockito.mock(HttpConnection.class);
    when(connection.getCreatedTimeStamp()).thenReturn(System.currentTimeMillis());
    parent.setAttribute("org.eclipse.jetty.server.HttpConnection", connection);
    return new ServletRequest(parent, uri);
}
Also used : ServletRequest(com.yahoo.jdisc.http.servlet.ServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpConnection(org.eclipse.jetty.server.HttpConnection) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest)

Example 2 with ServletRequest

use of com.yahoo.jdisc.http.servlet.ServletRequest in project vespa by vespa-engine.

the class SecurityFilterInvoker method invokeRequestFilterChain.

/**
 * Returns the servlet request to be used in any servlets invoked after this.
 */
@Override
public HttpServletRequest invokeRequestFilterChain(RequestFilter requestFilterChain, URI uri, HttpServletRequest httpRequest, ResponseHandler responseHandler) {
    SecurityRequestFilterChain securityChain = cast(SecurityRequestFilterChain.class, requestFilterChain).orElseThrow(SecurityFilterInvoker::newUnsupportedOperationException);
    ServletRequest wrappedRequest = new ServletRequest(httpRequest, uri);
    securityChain.filter(new ServletFilterRequest(wrappedRequest), responseHandler);
    return wrappedRequest;
}
Also used : ServletRequest(com.yahoo.jdisc.http.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest)

Aggregations

ServletRequest (com.yahoo.jdisc.http.servlet.ServletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpConnection (org.eclipse.jetty.server.HttpConnection)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1