void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) { ASSERT(!challenge.isNull()); if (challenge != d->m_currentWebChallenge) return; if (credential.isEmpty()) { receivedRequestToContinueWithoutCredential(challenge); return; } KURL urlToStore; urlToStore = d->m_request.url(); CredentialStorage::set(credential, challenge.protectionSpace(), urlToStore); clearAuthentication(); // Clone our ResourceHandle and add it so that it is send with the credential. // FIXME: We should have a way of cloning an handle. RefPtr<ResourceHandle> newHandle = ResourceHandle::create(request(), client(), 0, d->m_defersLoading, shouldContentSniff()); setClient(0); // Clear the client to avoid it being cleared by WebCore. AuthenticationChallenge newAuthenticationChallenge(challenge.protectionSpace(), credential, challenge.previousFailureCount() + 1, challenge.failureResponse(), challenge.error()); // Store the new authentication challenge. newHandle->getInternal()->m_currentWebChallenge = newAuthenticationChallenge; d->m_cancelled = true; }
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) { LOG(Network, "CFNet - receivedCredential()"); ASSERT(!challenge.isNull()); ASSERT(challenge.cfURLAuthChallengeRef()); if (challenge != d->m_currentWebChallenge) return; // FIXME: Support empty credentials. Currently, an empty credential cannot be stored in WebCore credential storage, as that's empty value for its map. if (credential.isEmpty()) { receivedRequestToContinueWithoutCredential(challenge); return; } if (credential.persistence() == CredentialPersistenceForSession) { // Manage per-session credentials internally, because once NSURLCredentialPersistencePerSession is used, there is no way // to ignore it for a particular request (short of removing it altogether). Credential webCredential(credential.user(), credential.password(), CredentialPersistenceNone); RetainPtr<CFURLCredentialRef> cfCredential = adoptCF(createCF(webCredential)); URL urlToStore; if (challenge.failureResponse().httpStatusCode() == 401) urlToStore = challenge.failureResponse().url(); CredentialStorage::set(webCredential, challenge.protectionSpace(), urlToStore); CFURLConnectionUseCredential(d->m_connection.get(), cfCredential.get(), challenge.cfURLAuthChallengeRef()); } else { RetainPtr<CFURLCredentialRef> cfCredential = adoptCF(createCF(credential)); CFURLConnectionUseCredential(d->m_connection.get(), cfCredential.get(), challenge.cfURLAuthChallengeRef()); } clearAuthentication(); }
void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) { LOG(Network, "CFNet - didReceiveAuthenticationChallenge()"); ASSERT(d->m_currentWebChallenge.isNull()); // Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef, // we make sure that is actually present ASSERT(challenge.cfURLAuthChallengeRef()); ASSERT(challenge.authenticationClient() == this); // Should be already set. #if !PLATFORM(WIN) // Proxy authentication is handled by CFNetwork internally. We can get here if the user cancels // CFNetwork authentication dialog, and we shouldn't ask the client to display another one in that case. if (challenge.protectionSpace().isProxy()) { // Cannot use receivedRequestToContinueWithoutCredential(), because current challenge is not yet set. CFURLConnectionUseCredential(d->m_connection.get(), 0, challenge.cfURLAuthChallengeRef()); return; } #endif if (tryHandlePasswordBasedAuthentication(challenge)) return; d->m_currentWebChallenge = challenge; if (client()) client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); else { clearAuthentication(); CFURLConnectionPerformDefaultHandlingForChallenge(d->m_connection.get(), challenge.cfURLAuthChallengeRef()); } }
void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) { // Do nothing as curl will automatically continue its transfer. ASSERT(!challenge.isNull()); if (challenge != d->m_currentWebChallenge) return; clearAuthentication(); }
void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) { if (challenge != d->m_currentWebChallenge) return; String userpass = ""; curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, userpass.utf8().data()); clearAuthentication(); }
void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge) { LOG(Network, "CFNet - receivedRequestToContinueWithoutCredential()"); ASSERT(!challenge.isNull()); ASSERT(challenge.cfURLAuthChallengeRef()); if (challenge != d->m_currentWebChallenge) return; CFURLConnectionUseCredential(d->m_connection.get(), 0, challenge.cfURLAuthChallengeRef()); clearAuthentication(); }
void ResourceHandle::receivedChallengeRejection(const AuthenticationChallenge& challenge) { LOG(Network, "CFNet - receivedChallengeRejection()"); ASSERT(!challenge.isNull()); ASSERT(challenge.cfURLAuthChallengeRef()); if (challenge != d->m_currentWebChallenge) return; CFURLConnectionRejectChallenge(d->m_connection.get(), challenge.cfURLAuthChallengeRef()); clearAuthentication(); }
void ResourceHandle::receivedRequestToPerformDefaultHandling(const AuthenticationChallenge& challenge) { LOG(Network, "CFNet - receivedRequestToPerformDefaultHandling()"); ASSERT(!challenge.isNull()); ASSERT(challenge.cfURLAuthChallengeRef()); if (challenge != d->m_currentWebChallenge) return; CFURLConnectionPerformDefaultHandlingForChallenge(d->m_connection.get(), challenge.cfURLAuthChallengeRef()); clearAuthentication(); }
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) { LOG(Network, "CFNet - receivedCredential()"); ASSERT(!challenge.isNull()); ASSERT(challenge.cfURLAuthChallengeRef()); if (challenge != d->m_currentWebChallenge) return; CFURLCredentialRef cfCredential = createCF(credential); CFURLConnectionUseCredential(d->m_connection.get(), cfCredential, challenge.cfURLAuthChallengeRef()); CFRelease(cfCredential); clearAuthentication(); }
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) { if (challenge != d->m_currentWebChallenge) return; if (credential.isEmpty()) { receivedRequestToContinueWithoutCredential(challenge); return; } if (shouldUseCredentialStorage()) { if (challenge.failureResponse().httpStatusCode() == 401) { URL urlToStore = challenge.failureResponse().url(); CredentialStorage::set(credential, challenge.protectionSpace(), urlToStore); } } String userpass = credential.user() + ":" + credential.password(); curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, userpass.utf8().data()); clearAuthentication(); }