Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose addAuthentication and local context to subclasses #163

Merged
merged 3 commits into from
Jul 18, 2016

Conversation

mcqueenorama
Copy link

This is not an urgent or even necessary request. Since it indicates something that's hard to do with the existing client implementation, I thought I should show you. No problem if you want to close this.

I needed to change the SSL client, and found I could not change it while keeping basic auth in place. With this PR its possible to extend the JenkinsHttpClient, and keep the authentication. I needed the SSL client to skip cert validation, but still do basic auth.

Here's an ugly example. Its quite ugly, and there's got to be a better way to do it.

https://gist.github.com/mcqueenorama/78ee0bd2cc3d2c993c6ec1585eb30af0

@mcqueenorama
Copy link
Author

mcqueenorama commented May 27, 2016

It looks like it would be good if localContext were an HttpContext, instead of a BasicHttpContext. Then the subclassing would be more general. Here's another gist with an attempt at putting in an auth cache. This is with a localContext of type HttpContext.

https://gist.github.com/mcqueenorama/13275d42331fb1c5188d797b65eebfe9

@khmarbaise khmarbaise added this to the Release 0.3.6 milestone Jul 3, 2016
@rpionke
Copy link
Member

rpionke commented Jul 8, 2016

@khmarbaise can you merge this PR, so we can setup a proxy with HttpClients.custom()?
Or is there any unseen method to configure the proxy usage?

@mcqueenorama
Copy link
Author

I'd like to see this merged too. I've got some people who want to use it.

@mcqueenorama
Copy link
Author

When I pushed this out, it was for discussion, so it was incomplete. I've included a more complete patch here. Its still fine to just discuss it.

@@ -161,7 +162,11 @@ public JenkinsHttpClient(URI uri, String username, String password) {
*/
public <T extends BaseModel> T get(String path, Class<T> cls) throws IOException {
HttpGet getMethod = new HttpGet(api(path));

System.out.println(getMethod.getURI());
System.out.println(getMethod.getRequestLine());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System.out is never good idea in production code...better use logging..? I have introduced a logging in cf65279#diff-f14ef3181c6e40c08aac9c02ba835778....

@khmarbaise khmarbaise merged commit ea311c6 into jenkinsci:master Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants