test_class.declarator: handler
test_class.modifier: private
test_class.original_string: private JolokiaHttpHandler handler;
test_class.type: JolokiaHttpHandler
test_class.var_name: handler
test_class.declarator: debugToggle = false
test_class.modifier: private static
test_class.original_string: private static boolean debugToggle = false;
test_class.type: boolean
test_class.var_name: debugToggle
test_class.file: agent/jvm/src/test/java/org/jolokia/jvmagent/handler/JolokiaHttpHandlerTest.java
test_class.identifier: JolokiaHttpHandlerTest
test_case.body: @Test
      public void invalidMethod() throws URISyntaxException, IOException, ParseException {
          HttpExchange exchange = prepareExchange("http://localhost:8080/");
  
          // Simple GET method
          expect(exchange.getRequestMethod()).andReturn("PUT");
          Headers header = new Headers();
          ByteArrayOutputStream out = prepareResponse(handler, exchange, header);
          handler.doHandle(exchange);
  
          JSONObject resp = (JSONObject) new JSONParser().parse(out.toString());
          assertTrue(resp.containsKey("error"));
          assertEquals(resp.get("error_type"), IllegalArgumentException.class.getName());
          assertTrue(((String) resp.get("error")).contains("PUT"));
      }
test_case.class_method_signature: JolokiaHttpHandlerTest.invalidMethod()
test_case.full_signature: @Test public void invalidMethod()
test_case.identifier: invalidMethod
test_case.invocations: prepareExchange andReturn expect getRequestMethod prepareResponse doHandle parse toString assertTrue containsKey assertEquals get getName assertTrue contains get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void invalidMethod()
focal_class.declarator: backendManager
focal_class.modifier: private
focal_class.original_string: private BackendManager backendManager;
focal_class.type: BackendManager
focal_class.var_name: backendManager
focal_class.declarator: requestHandler
focal_class.modifier: private
focal_class.original_string: private HttpRequestHandler requestHandler;
focal_class.type: HttpRequestHandler
focal_class.var_name: requestHandler
focal_class.declarator: context
focal_class.modifier: private
focal_class.original_string: private String context;
focal_class.type: String
focal_class.var_name: context
focal_class.declarator: contentTypePattern = Pattern.compile(".*;\\s*charset=([^;,]+)\\s*.*")
focal_class.modifier: private
focal_class.original_string: private Pattern contentTypePattern = Pattern.compile(".*;\\s*charset=([^;,]+)\\s*.*");
focal_class.type: Pattern
focal_class.var_name: contentTypePattern
focal_class.declarator: configuration
focal_class.modifier: private
focal_class.original_string: private Configuration configuration;
focal_class.type: Configuration
focal_class.var_name: configuration
focal_class.declarator: logHandler
focal_class.modifier: private final
focal_class.original_string: private final LogHandler logHandler;
focal_class.type: LogHandler
focal_class.var_name: logHandler
focal_class.declarator: discoveryMulticastResponder
focal_class.modifier: private
focal_class.original_string: private DiscoveryMulticastResponder discoveryMulticastResponder;
focal_class.type: DiscoveryMulticastResponder
focal_class.var_name: discoveryMulticastResponder
focal_class.file: agent/jvm/src/main/java/org/jolokia/jvmagent/handler/JolokiaHttpHandler.java
focal_class.identifier: JolokiaHttpHandler
focal_class.interfaces: implements HttpHandler
focal_class.class_method_signature: JolokiaHttpHandler.JolokiaHttpHandler(Configuration pConfig)
focal_class.full_signature: public  JolokiaHttpHandler(Configuration pConfig)
focal_class.identifier: JolokiaHttpHandler
focal_class.modifiers: public
focal_class.parameters: (Configuration pConfig)
focal_class.signature:  JolokiaHttpHandler(Configuration pConfig)
focal_class.class_method_signature: JolokiaHttpHandler.JolokiaHttpHandler(Configuration pConfig, LogHandler pLogHandler)
focal_class.full_signature: public  JolokiaHttpHandler(Configuration pConfig, LogHandler pLogHandler)
focal_class.identifier: JolokiaHttpHandler
focal_class.modifiers: public
focal_class.parameters: (Configuration pConfig, LogHandler pLogHandler)
focal_class.signature:  JolokiaHttpHandler(Configuration pConfig, LogHandler pLogHandler)
focal_class.class_method_signature: JolokiaHttpHandler.start(boolean pLazy)
focal_class.full_signature: public void start(boolean pLazy)
focal_class.identifier: start
focal_class.modifiers: public
focal_class.parameters: (boolean pLazy)
focal_class.return: void
focal_class.signature: void start(boolean pLazy)
focal_class.class_method_signature: JolokiaHttpHandler.createRestrictor()
focal_class.full_signature: protected Restrictor createRestrictor()
focal_class.identifier: createRestrictor
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: Restrictor
focal_class.signature: Restrictor createRestrictor()
focal_class.class_method_signature: JolokiaHttpHandler.listenForDiscoveryMcRequests(Configuration pConfig)
focal_class.full_signature: private boolean listenForDiscoveryMcRequests(Configuration pConfig)
focal_class.identifier: listenForDiscoveryMcRequests
focal_class.modifiers: private
focal_class.parameters: (Configuration pConfig)
focal_class.return: boolean
focal_class.signature: boolean listenForDiscoveryMcRequests(Configuration pConfig)
focal_class.class_method_signature: JolokiaHttpHandler.start(boolean pLazy, String pUrl, boolean pSecured)
focal_class.full_signature: public void start(boolean pLazy, String pUrl, boolean pSecured)
focal_class.identifier: start
focal_class.modifiers: public
focal_class.parameters: (boolean pLazy, String pUrl, boolean pSecured)
focal_class.return: void
focal_class.signature: void start(boolean pLazy, String pUrl, boolean pSecured)
focal_class.class_method_signature: JolokiaHttpHandler.stop()
focal_class.full_signature: public void stop()
focal_class.identifier: stop
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stop()
focal_class.class_method_signature: JolokiaHttpHandler.handle(final HttpExchange pHttpExchange)
focal_class.full_signature: public void handle(final HttpExchange pHttpExchange)
focal_class.identifier: handle
focal_class.modifiers: public
focal_class.parameters: (final HttpExchange pHttpExchange)
focal_class.return: void
focal_class.signature: void handle(final HttpExchange pHttpExchange)
focal_class.class_method_signature: JolokiaHttpHandler.doHandleAs(Subject subject, final HttpExchange pHttpExchange)
focal_class.full_signature: private void doHandleAs(Subject subject, final HttpExchange pHttpExchange)
focal_class.identifier: doHandleAs
focal_class.modifiers: private
focal_class.parameters: (Subject subject, final HttpExchange pHttpExchange)
focal_class.return: void
focal_class.signature: void doHandleAs(Subject subject, final HttpExchange pHttpExchange)
focal_class.class_method_signature: JolokiaHttpHandler.checkAuthentication(HttpExchange pHttpExchange)
focal_class.full_signature: protected void checkAuthentication(HttpExchange pHttpExchange)
focal_class.identifier: checkAuthentication
focal_class.modifiers: protected
focal_class.parameters: (HttpExchange pHttpExchange)
focal_class.return: void
focal_class.signature: void checkAuthentication(HttpExchange pHttpExchange)
focal_class.class_method_signature: JolokiaHttpHandler.doHandle(HttpExchange pExchange)
focal_class.full_signature: @SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause"}) public void doHandle(HttpExchange pExchange)
focal_class.identifier: doHandle
focal_class.modifiers: @SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause"}) public
focal_class.parameters: (HttpExchange pExchange)
focal_class.return: void
focal_class.signature: void doHandle(HttpExchange pExchange)
focal_class.class_method_signature: JolokiaHttpHandler.validateCallbackIfGiven(ParsedUri pUri)
focal_class.full_signature: private void validateCallbackIfGiven(ParsedUri pUri)
focal_class.identifier: validateCallbackIfGiven
focal_class.modifiers: private
focal_class.parameters: (ParsedUri pUri)
focal_class.return: void
focal_class.signature: void validateCallbackIfGiven(ParsedUri pUri)
focal_class.class_method_signature: JolokiaHttpHandler.extractOriginOrReferer(HttpExchange pExchange)
focal_class.full_signature: private String extractOriginOrReferer(HttpExchange pExchange)
focal_class.identifier: extractOriginOrReferer
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange)
focal_class.return: String
focal_class.signature: String extractOriginOrReferer(HttpExchange pExchange)
focal_class.class_method_signature: JolokiaHttpHandler.getHostName(InetSocketAddress address)
focal_class.full_signature: private String getHostName(InetSocketAddress address)
focal_class.identifier: getHostName
focal_class.modifiers: private
focal_class.parameters: (InetSocketAddress address)
focal_class.return: String
focal_class.signature: String getHostName(InetSocketAddress address)
focal_class.class_method_signature: JolokiaHttpHandler.executeGetRequest(ParsedUri parsedUri)
focal_class.full_signature: private JSONAware executeGetRequest(ParsedUri parsedUri)
focal_class.identifier: executeGetRequest
focal_class.modifiers: private
focal_class.parameters: (ParsedUri parsedUri)
focal_class.return: JSONAware
focal_class.signature: JSONAware executeGetRequest(ParsedUri parsedUri)
focal_class.class_method_signature: JolokiaHttpHandler.executePostRequest(HttpExchange pExchange, ParsedUri pUri)
focal_class.full_signature: private JSONAware executePostRequest(HttpExchange pExchange, ParsedUri pUri)
focal_class.identifier: executePostRequest
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange, ParsedUri pUri)
focal_class.return: JSONAware
focal_class.signature: JSONAware executePostRequest(HttpExchange pExchange, ParsedUri pUri)
focal_class.class_method_signature: JolokiaHttpHandler.performCorsPreflightCheck(HttpExchange pExchange)
focal_class.full_signature: private void performCorsPreflightCheck(HttpExchange pExchange)
focal_class.identifier: performCorsPreflightCheck
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange)
focal_class.return: void
focal_class.signature: void performCorsPreflightCheck(HttpExchange pExchange)
focal_class.class_method_signature: JolokiaHttpHandler.setHeaders(HttpExchange pExchange)
focal_class.full_signature: private void setHeaders(HttpExchange pExchange)
focal_class.identifier: setHeaders
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange)
focal_class.return: void
focal_class.signature: void setHeaders(HttpExchange pExchange)
focal_class.class_method_signature: JolokiaHttpHandler.sendForbidden(HttpExchange pExchange, SecurityException securityException)
focal_class.full_signature: private void sendForbidden(HttpExchange pExchange, SecurityException securityException)
focal_class.identifier: sendForbidden
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange, SecurityException securityException)
focal_class.return: void
focal_class.signature: void sendForbidden(HttpExchange pExchange, SecurityException securityException)
focal_class.class_method_signature: JolokiaHttpHandler.sendResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.full_signature: private void sendResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.identifier: sendResponse
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.return: void
focal_class.signature: void sendResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.class_method_signature: JolokiaHttpHandler.sendStreamingResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONStreamAware pJson)
focal_class.full_signature: private void sendStreamingResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONStreamAware pJson)
focal_class.identifier: sendStreamingResponse
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange, ParsedUri pParsedUri, JSONStreamAware pJson)
focal_class.return: void
focal_class.signature: void sendStreamingResponse(HttpExchange pExchange, ParsedUri pParsedUri, JSONStreamAware pJson)
focal_class.class_method_signature: JolokiaHttpHandler.sendAllJSON(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.full_signature: private void sendAllJSON(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.identifier: sendAllJSON
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.return: void
focal_class.signature: void sendAllJSON(HttpExchange pExchange, ParsedUri pParsedUri, JSONAware pJson)
focal_class.class_method_signature: JolokiaHttpHandler.getMimeType(ParsedUri pParsedUri)
focal_class.full_signature: private String getMimeType(ParsedUri pParsedUri)
focal_class.identifier: getMimeType
focal_class.modifiers: private
focal_class.parameters: (ParsedUri pParsedUri)
focal_class.return: String
focal_class.signature: String getMimeType(ParsedUri pParsedUri)
focal_class.class_method_signature: JolokiaHttpHandler.createLogHandler(String pLogHandlerClass, String pDebug)
focal_class.full_signature: private LogHandler createLogHandler(String pLogHandlerClass, String pDebug)
focal_class.identifier: createLogHandler
focal_class.modifiers: private
focal_class.parameters: (String pLogHandlerClass, String pDebug)
focal_class.return: LogHandler
focal_class.signature: LogHandler createLogHandler(String pLogHandlerClass, String pDebug)
focal_class.class_method_signature: JolokiaHttpHandler.formatHeaderDate(Date date)
focal_class.full_signature: private String formatHeaderDate(Date date)
focal_class.identifier: formatHeaderDate
focal_class.modifiers: private
focal_class.parameters: (Date date)
focal_class.return: String
focal_class.signature: String formatHeaderDate(Date date)
focal_method.body: @SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause"})
      public void doHandle(HttpExchange pExchange) throws IOException {
          if (requestHandler == null) {
              throw new IllegalStateException("Handler not yet started");
          }
  
          JSONAware json = null;
          URI uri = pExchange.getRequestURI();
          ParsedUri parsedUri = new ParsedUri(uri, context);
          try {
              // Check access policy
              InetSocketAddress address = pExchange.getRemoteAddress();
              requestHandler.checkAccess(getHostName(address),
                                         address.getAddress().getHostAddress(),
                                         extractOriginOrReferer(pExchange));
              String method = pExchange.getRequestMethod();
  
              // If a callback is given, check this is a valid javascript function name
              validateCallbackIfGiven(parsedUri);
  
              // Dispatch for the proper HTTP request method
              if ("GET".equalsIgnoreCase(method)) {
                  setHeaders(pExchange);
                  json = executeGetRequest(parsedUri);
              } else if ("POST".equalsIgnoreCase(method)) {
                  setHeaders(pExchange);
                  json = executePostRequest(pExchange, parsedUri);
              } else if ("OPTIONS".equalsIgnoreCase(method)) {
                  performCorsPreflightCheck(pExchange);
              } else {
                  throw new IllegalArgumentException("HTTP Method " + method + " is not supported.");
              }
          } catch (Throwable exp) {
              json = requestHandler.handleThrowable(
                      exp instanceof RuntimeMBeanException ? ((RuntimeMBeanException) exp).getTargetException() : exp);
          } finally {
              sendResponse(pExchange, parsedUri, json);
          }
      }
focal_method.class_method_signature: JolokiaHttpHandler.doHandle(HttpExchange pExchange)
focal_method.full_signature: @SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause"}) public void doHandle(HttpExchange pExchange)
focal_method.identifier: doHandle
focal_method.invocations: getRequestURI getRemoteAddress checkAccess getHostName getHostAddress getAddress extractOriginOrReferer getRequestMethod validateCallbackIfGiven equalsIgnoreCase setHeaders executeGetRequest equalsIgnoreCase setHeaders executePostRequest equalsIgnoreCase performCorsPreflightCheck handleThrowable getTargetException sendResponse
focal_method.modifiers: @SuppressWarnings({"PMD.AvoidCatchingThrowable", "PMD.AvoidInstanceofChecksInCatchClause"}) public
focal_method.parameters: (HttpExchange pExchange)
focal_method.return: void
focal_method.signature: void doHandle(HttpExchange pExchange)