Skip to content

Commit 6673444

Browse files
authored
Merge pull request #280 from JesperTerkelsen/client-tls-and-auth
JENKINS-46445 Add support for both client TLS and basic authentication.
2 parents f1e9a71 + a0d23e8 commit 6673444

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ReleaseNotes.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
## Release 0.3.8 (NOT RELEASED YET)
44

5-
* [Refactor Issue 291][issue-291]
5+
* [JENKINS-46445](https://issues.jenkins-ci.org/browse/JENKINS-46445)
6+
7+
Add support for both client TLS and basic authentication.
8+
9+
```java
10+
HttpClientBuilder builder = HttpClientBuilder.create();
11+
builder.setSslcontext(sslContext);
12+
JenkinsHttpClient client = new JenkinsHttpClient(uri, builder, username, password);
13+
JenkinsServer jenkins = new JenkinsServer(client);
14+
```
15+
16+
* [Refactor Issue 291][issue-291]
617

718
Useful utility methods refactored into utility classes.
819

jenkins-client/src/main/java/com/offbytwo/jenkins/client/JenkinsHttpClient.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,19 @@ public JenkinsHttpClient(URI uri) {
116116
* @param password Password or auth token to use when connecting
117117
*/
118118
public JenkinsHttpClient(URI uri, String username, String password) {
119-
this(uri, addAuthentication(HttpClientBuilder.create(), uri, username, password));
119+
this(uri, HttpClientBuilder.create(), username, password);
120+
}
121+
122+
/**
123+
* Create an authenticated Jenkins HTTP client
124+
*
125+
* @param uri Location of the jenkins server (ex. http://localhost:8080)
126+
* @param builder Configured HttpClientBuilder to be used
127+
* @param username Username to use when connecting
128+
* @param password Password or auth token to use when connecting
129+
*/
130+
public JenkinsHttpClient(URI uri, HttpClientBuilder builder, String username, String password) {
131+
this(uri, addAuthentication(builder, uri, username, password));
120132
if (isNotBlank(username)) {
121133
localContext = new BasicHttpContext();
122134
localContext.setAttribute("preemptive-auth", new BasicScheme());

0 commit comments

Comments
 (0)