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

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

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          jnt Jesper Terkelsen added a comment -
          Show
          jnt Jesper Terkelsen added a comment - I opened a PR on this:  https://github.com/jenkinsci/java-client-api/pull/280

            People

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

              Dates

              • Created:
                Updated: