Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46445

Support for client TLS and authentication in java-client-api

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • java-client-api
    • None

      Currently you can enable client TLS like this.

      HttpClientBuilder builder = HttpClientBuilder.create();
      builder.setSslcontext(sslContext);
      JenkinsHttpClient client = new JenkinsHttpClient(uri, builder);
      

      Or add authentication credentials like this

      JenkinsServer jenkins = new JenkinsServer(uri, username, password); 

      But not both, because the last constructor contains this small peace of code.

      public JenkinsHttpClient(URI uri, String username, String password) {
        this(uri, addAuthentication(HttpClientBuilder.create(), uri, username, password));
        if (isNotBlank(username)) {
          localContext = new BasicHttpContext();
          localContext.setAttribute("preemptive-auth", new BasicScheme());
        }
      }
      

      localContext not a accessible outside of JenkinsHttpClient

      It would be nice with a constructor that takes both a builder and the username and password like this. 

      public JenkinsHttpClient(HttpClientBuilder builder, URI uri, String username, String password)

       That way the client could support both client TLS and authentication at the same time, like this.

       

      HttpClientBuilder builder = HttpClientBuilder.create();
      builder.setSslcontext(sslContext);
      JenkinsHttpClient client = new JenkinsHttpClient(uri, builder, username, password);
      JenkinsServer jenkins = new JenkinsServer(client);
      

      Possible workarounds

      None that i know of except for forking the codebase.

            khmarbaise Karl-Heinz Marbaise
            jnt Jesper Terkelsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: