[Issue #942] [Issue #943] Don't attempt to use URL-encoded credentials in connection:didReceiveAuthenticationChallenge:, since any included credentials would have to be invalid to have an authentication challenge be issued

Signed-off-by: Mattt Thompson <m@mattt.me>
This commit is contained in:
xjdrew 2013-05-10 11:23:25 -07:00 committed by Mattt Thompson
parent df51831c15
commit 6f6c888055

View file

@ -668,25 +668,8 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
self.authenticationChallenge(connection, challenge); self.authenticationChallenge(connection, challenge);
} else { } else {
if ([challenge previousFailureCount] == 0) { if ([challenge previousFailureCount] == 0) {
NSURLCredential *credential = nil; if (self.credential) {
[[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge];
NSString *user = [[self.request URL] user];
NSString *password = [[self.request URL] password];
if (user && password) {
credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone];
} else if (user) {
credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:user];
} else {
credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
}
if (!credential) {
credential = self.credential;
}
if (credential) {
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
} else { } else {
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
} }