test_class.declarator: jettyServer
test_class.modifier: private
test_class.original_string: private Server jettyServer;
test_class.type: Server
test_class.var_name: jettyServer
test_class.declarator: url
test_class.modifier: private
test_class.original_string: private String url;
test_class.type: String
test_class.var_name: url
test_class.file: agent/jvm/src/test/java/org/jolokia/jvmagent/security/DelegatingAuthenticatorTest.java
test_class.identifier: DelegatingAuthenticatorTest
test_class.superclass: extends BaseAuthenticatorTest
test_case.body: @Test
      public void invalidPath() {
          String  data[] = new String[] { "json:never/find/me", "never",
                                          "json:metadata/name/yet/deeper", "deeper" };
          for (int i = 0; i < data.length; i +=2) {
              DelegatingAuthenticator authenticator = new DelegatingAuthenticator("jolokia", url, data[i], false);
              HttpExchange exchange = createHttpExchange(new Headers(), "Authorization", "Bearer blub");
              Authenticator.Result result = authenticator.authenticate(exchange);
              Authenticator.Failure failure = (Authenticator.Failure) result;
              assertEquals(failure.getResponseCode(), 400);
              String error = exchange.getResponseHeaders().getFirst("X-Error-Details");
              assertTrue(error.contains(data[i+1]));
          }
      }
test_case.class_method_signature: DelegatingAuthenticatorTest.invalidPath()
test_case.full_signature: @Test public void invalidPath()
test_case.identifier: invalidPath
test_case.invocations: createHttpExchange authenticate assertEquals getResponseCode getFirst getResponseHeaders assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void invalidPath()
focal_class.declarator: delegateURL
focal_class.modifier: private final
focal_class.original_string: private final URL delegateURL;
focal_class.type: URL
focal_class.var_name: delegateURL
focal_class.declarator: principalExtractor
focal_class.modifier: private final
focal_class.original_string: private final PrincipalExtractor principalExtractor;
focal_class.type: PrincipalExtractor
focal_class.var_name: principalExtractor
focal_class.declarator: realm
focal_class.modifier: private final
focal_class.original_string: private final String realm;
focal_class.type: String
focal_class.var_name: realm
focal_class.declarator: sslSocketFactory
focal_class.modifier: private
focal_class.original_string: private SSLSocketFactory sslSocketFactory;
focal_class.type: SSLSocketFactory
focal_class.var_name: sslSocketFactory
focal_class.declarator: hostnameVerifier
focal_class.modifier: private
focal_class.original_string: private HostnameVerifier hostnameVerifier;
focal_class.type: HostnameVerifier
focal_class.var_name: hostnameVerifier
focal_class.file: agent/jvm/src/main/java/org/jolokia/jvmagent/security/DelegatingAuthenticator.java
focal_class.identifier: DelegatingAuthenticator
focal_class.class_method_signature: DelegatingAuthenticator.DelegatingAuthenticator(String pRealm, String pUrl, String pPrincipalSpec, boolean pDisableCertCheck)
focal_class.full_signature: public  DelegatingAuthenticator(String pRealm, String pUrl, String pPrincipalSpec, boolean pDisableCertCheck)
focal_class.identifier: DelegatingAuthenticator
focal_class.modifiers: public
focal_class.parameters: (String pRealm, String pUrl, String pPrincipalSpec, boolean pDisableCertCheck)
focal_class.signature:  DelegatingAuthenticator(String pRealm, String pUrl, String pPrincipalSpec, boolean pDisableCertCheck)
focal_class.class_method_signature: DelegatingAuthenticator.authenticate(HttpExchange pHttpExchange)
focal_class.full_signature: @Override public Result authenticate(HttpExchange pHttpExchange)
focal_class.identifier: authenticate
focal_class.modifiers: @Override public
focal_class.parameters: (HttpExchange pHttpExchange)
focal_class.return: Result
focal_class.signature: Result authenticate(HttpExchange pHttpExchange)
focal_class.class_method_signature: DelegatingAuthenticator.prepareFailure(HttpExchange pHttpExchange, String pErrorDetails, int pCode)
focal_class.full_signature: private Result prepareFailure(HttpExchange pHttpExchange, String pErrorDetails, int pCode)
focal_class.identifier: prepareFailure
focal_class.modifiers: private
focal_class.parameters: (HttpExchange pHttpExchange, String pErrorDetails, int pCode)
focal_class.return: Result
focal_class.signature: Result prepareFailure(HttpExchange pHttpExchange, String pErrorDetails, int pCode)
focal_class.class_method_signature: DelegatingAuthenticator.createPrincipalExtractor(String pPrincipalExtractorSpec)
focal_class.full_signature: private PrincipalExtractor createPrincipalExtractor(String pPrincipalExtractorSpec)
focal_class.identifier: createPrincipalExtractor
focal_class.modifiers: private
focal_class.parameters: (String pPrincipalExtractorSpec)
focal_class.return: PrincipalExtractor
focal_class.signature: PrincipalExtractor createPrincipalExtractor(String pPrincipalExtractorSpec)
focal_class.class_method_signature: DelegatingAuthenticator.disableSSLCertificateChecking()
focal_class.full_signature: private void disableSSLCertificateChecking()
focal_class.identifier: disableSSLCertificateChecking
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void disableSSLCertificateChecking()
focal_class.superclass: extends Authenticator
focal_method.body: @Override
      public Result authenticate(HttpExchange pHttpExchange) {
          try {
              URLConnection connection = delegateURL.openConnection();
              String authorization = pHttpExchange.getRequestHeaders()
                  .getFirst("Authorization");
              if(authorization == null){//In case middleware strips Authorization, allow alternate header
                  authorization = pHttpExchange.getRequestHeaders()
                      .getFirst(AuthorizationHeaderParser.JOLOKIA_ALTERNATE_AUTHORIZATION_HEADER);
              }
              connection.addRequestProperty("Authorization",
                  authorization);
              connection.setConnectTimeout(2000);
              connection.connect();
              if (connection instanceof HttpURLConnection) {
                  HttpURLConnection httpConnection = (HttpURLConnection) connection;
                  if (connection instanceof HttpsURLConnection) {
                      HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
                      if (sslSocketFactory != null) {
                          httpsConnection.setSSLSocketFactory(sslSocketFactory);
                      }
                      if (hostnameVerifier != null) {
                          httpsConnection.setHostnameVerifier(hostnameVerifier);
                      }
                  }
                  return httpConnection.getResponseCode() == 200 ?
                          new Success(principalExtractor.extract(connection)) :
                          new Failure(401);
              } else {
                  return new Failure(401);
              }
          } catch (final IOException e) {
              return prepareFailure(pHttpExchange, "Cannot call delegate url " + delegateURL + ": " + e, 503);
          } catch (final IllegalArgumentException e) {
              return prepareFailure(pHttpExchange, "Illegal Argument: " + e, 400);
          } catch (ParseException e) {
              return prepareFailure(pHttpExchange, "Invalid JSON response: " + e, 422);
          }
      }
focal_method.class_method_signature: DelegatingAuthenticator.authenticate(HttpExchange pHttpExchange)
focal_method.full_signature: @Override public Result authenticate(HttpExchange pHttpExchange)
focal_method.identifier: authenticate
focal_method.invocations: openConnection getFirst getRequestHeaders getFirst getRequestHeaders addRequestProperty setConnectTimeout connect setSSLSocketFactory setHostnameVerifier getResponseCode extract prepareFailure prepareFailure prepareFailure
focal_method.modifiers: @Override public
focal_method.parameters: (HttpExchange pHttpExchange)
focal_method.return: Result
focal_method.signature: Result authenticate(HttpExchange pHttpExchange)