Retry to call credentials provider if http authentication failed
If the user provided wrong credentials or credentials changed we shouldn't give up immediately but retry to get valid credentials from the credentials provider. Reset the credentials provider if authentication failed to avoid it reuses wrong credentials in case it stored them in a persistent store. Bug: 338048 Bug: 342592 Bug: 427735 Change-Id: Ibd62ef3da17be6454991c43f524c8bbc7ca3c37e Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
fc9b1fbf6b
commit
8598fe3d2b
|
@ -471,12 +471,14 @@ private HttpConnection connect(final String service)
|
|||
if (authMethod == HttpAuthMethod.NONE)
|
||||
throw new TransportException(uri, MessageFormat.format(
|
||||
JGitText.get().authenticationNotSupported, uri));
|
||||
if (1 < authAttempts
|
||||
|| !authMethod.authorize(uri,
|
||||
getCredentialsProvider())) {
|
||||
CredentialsProvider credentialsProvider = getCredentialsProvider();
|
||||
if (3 < authAttempts
|
||||
|| !authMethod.authorize(uri, credentialsProvider)) {
|
||||
credentialsProvider.reset(uri);
|
||||
throw new TransportException(uri,
|
||||
JGitText.get().notAuthorized);
|
||||
}
|
||||
credentialsProvider.reset(uri);
|
||||
authAttempts++;
|
||||
continue;
|
||||
|
||||
|
@ -504,7 +506,7 @@ final HttpConnection httpOpen(URL u) throws IOException {
|
|||
|
||||
/**
|
||||
* Open an HTTP connection.
|
||||
*
|
||||
*
|
||||
* @param method
|
||||
* @param u
|
||||
* @return the connection
|
||||
|
|
Loading…
Reference in New Issue