You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Hiran CHAUDHURI <hi...@amadeus.com> on 2017/06/07 12:25:21 UTC

Preemtive Authentication for Artifactory

Hello there.

Trying to fire REST api commands to JFrog Artifactory, I am successful related to upload and delete.
Now I want to implement copy and move operations but seem to get "409 Conflict" or "405 Method not allowed" responses, although they might stem from the user not being authorized.

Ha, the user! HttpClient 4.5.3 does not even feel challenged and thus never sends the credentials. On copy and delete operations I traced that the server responds with a 403 which triggers HttpClient to resend the request including credentials.

How can I have the credentials sent in the first request anyway? The example at
http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/authentication.html#d5e717
does not work for me. But then I am using POST requests...

Hiran


Hiran Chaudhuri
Principal Support Engineer
NSH Web Hosting services
Amadeus Data Processing GmbH
Berghamer Strasse 6
85435 Erding
T: +49-8122-43x3662
hiran.chaudhuri@amadeus.com
http://amadeus.com<http://amadeus.com/>
[cid:image001.png@01D2DF99.A0F5F670]

IMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system . Amadeus Data Processing GmbH Gesch?ftsf?hrer: Dr. Wolfgang Krips Sitz der Gesellschaft: Erding HR M?nchen 48 199 Berghamer Strasse 6 85435 Erding Germany

RE: Preemtive Authentication for Artifactory

Posted by Hiran CHAUDHURI <hi...@amadeus.com>.
So it seems I was able to resolve the issue. While the documentation seems very sparse, what helped me was a hint from the mailing list archives towards the example ClientPreemptiveBasicAuthentication.java class.

http://httpcomponents.10934.n7.nabble.com/Preemptive-authentication-examples-wrong-td13173.html#a13176

--------------------------------------
This code should work with all version of HttpClient 4.x. However, as of
version 4.1 the same can be done in a much simpler way by pre-populating
the auth cache:

http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java

Hope this helps

Oleg
---------------------------------------


Hiran

From: Hiran CHAUDHURI [mailto:hiran.chaudhuri@amadeus.com]
Sent: 07 June 2017 14:25
To: httpclient-users@hc.apache.org
Subject: Preemtive Authentication for Artifactory

Hello there.

Trying to fire REST api commands to JFrog Artifactory, I am successful related to upload and delete.
Now I want to implement copy and move operations but seem to get "409 Conflict" or "405 Method not allowed" responses, although they might stem from the user not being authorized.

Ha, the user! HttpClient 4.5.3 does not even feel challenged and thus never sends the credentials. On copy and delete operations I traced that the server responds with a 403 which triggers HttpClient to resend the request including credentials.

How can I have the credentials sent in the first request anyway? The example at
http://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/authentication.html#d5e717
does not work for me. But then I am using POST requests...

Hiran


Hiran Chaudhuri
Principal Support Engineer
NSH Web Hosting services
Amadeus Data Processing GmbH
Berghamer Strasse 6
85435 Erding
T: +49-8122-43x3662
hiran.chaudhuri@amadeus.com
http://amadeus.com<http://amadeus.com/>
[cid:image001.png@01D2DF99.A0F5F670]

IMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system . Amadeus Data Processing GmbH Geschäftsführer: Dr. Wolfgang Krips Sitz der Gesellschaft: Erding HR München 48 199 Berghamer Strasse 6 85435 Erding Germany
IMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system . Amadeus Data Processing GmbH Geschäftsführer: Dr. Wolfgang Krips Sitz der Gesellschaft: Erding HR München 48 199 Berghamer Strasse 6 85435 Erding Germany