]> source.dussan.org Git - jgit.git/commit
TransportHttp: support preemptive Basic authentication 20/173320/3
authorThomas Wolf <thomas.wolf@paranor.ch>
Wed, 2 Dec 2020 22:07:01 +0000 (23:07 +0100)
committerThomas Wolf <thomas.wolf@paranor.ch>
Thu, 14 Jan 2021 15:23:45 +0000 (16:23 +0100)
commit58f4e6e7f8d0f897c99fa1de5970928a826c5eb8
tree93906422672e0d88378bf26dc0451f94f191c556
parent471ad49546eec8850dd7d00b8fc2b8b50e4a9446
TransportHttp: support preemptive Basic authentication

If the caller knows already HTTP Basic authentication will be needed
and if it also already has the username and password, preemptive
authentication is a little bit more efficient since it avoids the
initial 401 response.

Add a setPreemptiveBasicAuthentication(username, password) method
to TransportHttp. Client code could call this for instance in a
TransportConfigCallback. The method throws an IllegalStateException
if it is called after an HTTP request has already been made.

Additionally, a URI can include userinfo. Although it is not
recommended to put passwords in URIs, JGit's URIish and also the
Java URL and URI classes still allow it. The underlying HTTP
connection may omit these fields though. If present, take these
fields as additional source for preemptive Basic authentication if
setPreemptiveBasicAuthentication() has not been called.

No preemptive authentication will be done if the connection is
redirected to a different host.

Add tests.

Bug: 541327
Change-Id: Id00b975e56a15b532de96f7bbce48106d992a22b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java