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

Allow custom authentication mechanism for the Java client #141

Closed
rhuss opened this issue May 23, 2014 · 2 comments
Closed

Allow custom authentication mechanism for the Java client #141

rhuss opened this issue May 23, 2014 · 2 comments
Milestone

Comments

@rhuss
Copy link
Member

rhuss commented May 23, 2014

Currently the Java client allows only Basic Authentication. However, the karaf deployed hawt.io uses a different mechanism:

  • A POST with the Basic-Auth included preemptively needs to be sent to /hawtio/auth/login
  • The response then sets the corresponding session-cookie

In order to allow such a custom authentication mechanism, hooks must be added perform this login step in advance.

See also the discussion at the Jolokia Forum

@rhuss rhuss added this to the 1.2.2 milestone May 23, 2014
@rhuss
Copy link
Member Author

rhuss commented May 23, 2014

A base implementation has been already implemented (though not yet pushed). In the meantime one can prepare an HttpClient (i.e. performing the steps above) and the using the public constructor of J4pClient with this client (which then already should have the session cookie).

@rhuss
Copy link
Member Author

rhuss commented May 23, 2014

It turns out, that for hawt.io it is sufficient to simply use preemptive Basic-Authentication.

So the following should do the trick for now

J4pClient j4p = J4pClient.url("..").user("karaf").password("karaf").build();
DefaultHttpClient client = (DefaultHttpClient) j4p.getHttpClient();
client.addRequestInterceptor(new PreemptiveAuthInterceptor());

with the PreemptiveAuthInterceptor taken from Stackoverflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant