test_class.declarator: httpServletRequest
test_class.modifier: private
test_class.original_string: private HttpServletRequest httpServletRequest;
test_class.type: HttpServletRequest
test_class.var_name: httpServletRequest
test_class.file: everrest-core/src/test/java/org/everrest/core/servlet/ServletContainerRequestTest.java
test_class.identifier: ServletContainerRequestTest
test_case.body: @Test
      public void getsSecurityContextFromServletRequest() throws Exception {
          when(httpServletRequest.getUserPrincipal()).thenReturn(new SimplePrincipal("andrew"));
          when(httpServletRequest.isUserInRole("user")).thenReturn(true);
          when(httpServletRequest.isSecure()).thenReturn(false);
          when(httpServletRequest.getAuthType()).thenReturn("BASIC_AUTH");
  
          ServletContainerRequest servletContainerRequest = ServletContainerRequest.create(httpServletRequest);
  
          assertEquals("BASIC_AUTH", servletContainerRequest.getAuthenticationScheme());
          assertEquals("andrew", servletContainerRequest.getUserPrincipal().getName());
          assertFalse(servletContainerRequest.isSecure());
          assertTrue(servletContainerRequest.isUserInRole("user"));
      }
test_case.class_method_signature: ServletContainerRequestTest.getsSecurityContextFromServletRequest()
test_case.full_signature: @Test public void getsSecurityContextFromServletRequest()
test_case.identifier: getsSecurityContextFromServletRequest
test_case.invocations: thenReturn when getUserPrincipal thenReturn when isUserInRole thenReturn when isSecure thenReturn when getAuthType create assertEquals getAuthenticationScheme assertEquals getName getUserPrincipal assertFalse isSecure assertTrue isUserInRole
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getsSecurityContextFromServletRequest()
focal_class.declarator: LOG = LoggerFactory.getLogger(ServletContainerRequest.class)
focal_class.modifier: private static final
focal_class.original_string: private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ServletContainerRequest.class);
focal_class.type: org.slf4j.Logger
focal_class.var_name: LOG
focal_class.file: everrest-core/src/main/java/org/everrest/core/servlet/ServletContainerRequest.java
focal_class.identifier: ServletContainerRequest
focal_class.class_method_signature: ServletContainerRequest.create(final HttpServletRequest req)
focal_class.full_signature: public static ServletContainerRequest create(final HttpServletRequest req)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (final HttpServletRequest req)
focal_class.return: ServletContainerRequest
focal_class.signature: ServletContainerRequest create(final HttpServletRequest req)
focal_class.class_method_signature: ServletContainerRequest.ServletContainerRequest(String method, URI requestUri, URI baseUri, InputStream entityStream,
                                      MultivaluedMap<String, String> httpHeaders, SecurityContext securityContext)
focal_class.full_signature: private  ServletContainerRequest(String method, URI requestUri, URI baseUri, InputStream entityStream,
                                      MultivaluedMap<String, String> httpHeaders, SecurityContext securityContext)
focal_class.identifier: ServletContainerRequest
focal_class.modifiers: private
focal_class.parameters: (String method, URI requestUri, URI baseUri, InputStream entityStream,
                                      MultivaluedMap<String, String> httpHeaders, SecurityContext securityContext)
focal_class.signature:  ServletContainerRequest(String method, URI requestUri, URI baseUri, InputStream entityStream,
                                      MultivaluedMap<String, String> httpHeaders, SecurityContext securityContext)
focal_class.class_method_signature: ServletContainerRequest.getMethod(HttpServletRequest servletRequest)
focal_class.full_signature: private static String getMethod(HttpServletRequest servletRequest)
focal_class.identifier: getMethod
focal_class.modifiers: private static
focal_class.parameters: (HttpServletRequest servletRequest)
focal_class.return: String
focal_class.signature: String getMethod(HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.getScheme(HttpServletRequest servletRequest)
focal_class.full_signature: private static String getScheme(HttpServletRequest servletRequest)
focal_class.identifier: getScheme
focal_class.modifiers: private static
focal_class.parameters: (HttpServletRequest servletRequest)
focal_class.return: String
focal_class.signature: String getScheme(HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.getForwardedUrl(HttpServletRequest servletRequest)
focal_class.full_signature: private static URL getForwardedUrl(HttpServletRequest servletRequest)
focal_class.identifier: getForwardedUrl
focal_class.modifiers: private static
focal_class.parameters: (HttpServletRequest servletRequest)
focal_class.return: URL
focal_class.signature: URL getForwardedUrl(HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.parseForwardedHostHeader(String forwardedHostAndPort, HttpServletRequest servletRequest)
focal_class.full_signature: private static URL parseForwardedHostHeader(String forwardedHostAndPort, HttpServletRequest servletRequest)
focal_class.identifier: parseForwardedHostHeader
focal_class.modifiers: private static
focal_class.parameters: (String forwardedHostAndPort, HttpServletRequest servletRequest)
focal_class.return: URL
focal_class.signature: URL parseForwardedHostHeader(String forwardedHostAndPort, HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.getHeaders(HttpServletRequest servletRequest)
focal_class.full_signature: private static MultivaluedMap<String, String> getHeaders(HttpServletRequest servletRequest)
focal_class.identifier: getHeaders
focal_class.modifiers: private static
focal_class.parameters: (HttpServletRequest servletRequest)
focal_class.return: MultivaluedMap<String, String>
focal_class.signature: MultivaluedMap<String, String> getHeaders(HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.getEntityStream(HttpServletRequest servletRequest)
focal_class.full_signature: private static InputStream getEntityStream(HttpServletRequest servletRequest)
focal_class.identifier: getEntityStream
focal_class.modifiers: private static
focal_class.parameters: (HttpServletRequest servletRequest)
focal_class.return: InputStream
focal_class.signature: InputStream getEntityStream(HttpServletRequest servletRequest)
focal_class.class_method_signature: ServletContainerRequest.getSecurityContext(final HttpServletRequest servletRequest)
focal_class.full_signature: private static SecurityContext getSecurityContext(final HttpServletRequest servletRequest)
focal_class.identifier: getSecurityContext
focal_class.modifiers: private static
focal_class.parameters: (final HttpServletRequest servletRequest)
focal_class.return: SecurityContext
focal_class.signature: SecurityContext getSecurityContext(final HttpServletRequest servletRequest)
focal_class.superclass: extends ContainerRequest
focal_method.body: public static ServletContainerRequest create(final HttpServletRequest req) {
          // If the URL is forwarded, obtain the forwarding information
          final URL forwardedUrl = getForwardedUrl(req);
          String host;
          int port;
          if (forwardedUrl == null) {
              host = req.getServerName();
              port = req.getServerPort();
          } else {
              host = forwardedUrl.getHost();
              port = forwardedUrl.getPort();
              if (port < 0) {
                  port = forwardedUrl.getDefaultPort();
              }
              LOG.debug("Assuming forwarded URL: {}", forwardedUrl);
          }
  
          // The common URI prefix for both baseUri and requestUri
          final StringBuilder commonUriBuilder = new StringBuilder();
          final String scheme = getScheme(req);
          commonUriBuilder.append(scheme);
          commonUriBuilder.append("://");
          commonUriBuilder.append(host);
          if (!(port < 0 || (port == 80 && "http".equals(scheme)) || (port == 443 && "https".equals(scheme)))) {
              commonUriBuilder.append(':');
              commonUriBuilder.append(port);
          }
          final String commonUriPrefix = commonUriBuilder.toString();
  
          // The Base URI - up to the servlet path
          final StringBuilder baseUriBuilder = new StringBuilder(commonUriPrefix);
          baseUriBuilder.append(req.getContextPath());
          baseUriBuilder.append(req.getServletPath());
          final URI baseUri = URI.create(baseUriBuilder.toString());
  
          // The RequestURI - everything in the URL
          final StringBuilder requestUriBuilder = new StringBuilder(commonUriPrefix);
          requestUriBuilder.append(req.getRequestURI());
          final String queryString = req.getQueryString();
          if (queryString != null) {
              requestUriBuilder.append('?');
              requestUriBuilder.append(queryString);
          }
          final URI requestUri = URI.create(requestUriBuilder.toString());
          return new ServletContainerRequest(getMethod(req), requestUri, baseUri, getEntityStream(req), getHeaders(req),
                                             getSecurityContext(req));
      }
focal_method.class_method_signature: ServletContainerRequest.create(final HttpServletRequest req)
focal_method.full_signature: public static ServletContainerRequest create(final HttpServletRequest req)
focal_method.identifier: create
focal_method.invocations: getForwardedUrl getServerName getServerPort getHost getPort getDefaultPort debug getScheme append append append equals equals append append toString append getContextPath append getServletPath create toString append getRequestURI getQueryString append append create toString getMethod getEntityStream getHeaders getSecurityContext
focal_method.modifiers: public static
focal_method.parameters: (final HttpServletRequest req)
focal_method.return: ServletContainerRequest
focal_method.signature: ServletContainerRequest create(final HttpServletRequest req)