Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (141349 => 141350)
--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp 2013-01-31 01:22:30 UTC (rev 141349)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp 2013-01-31 01:26:22 UTC (rev 141350)
@@ -44,6 +44,8 @@
#include <network/MultipartStream.h>
#include <network/NetworkStreamFactory.h>
+using BlackBerry::Platform::NetworkRequest;
+
namespace WebCore {
static const int s_redirectMaximum = 10;
@@ -268,33 +270,46 @@
handleNotifyMultipartHeaderReceived(key, value);
}
-void NetworkJob::notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType authType, BlackBerry::Platform::NetworkRequest::AuthScheme authScheme, const char* realm, AuthResult result, bool requireCredentials)
+void NetworkJob::notifyAuthReceived(NetworkRequest::AuthType authType, NetworkRequest::AuthProtocol authProtocol, NetworkRequest::AuthScheme authScheme, const char* realm, AuthResult result, bool requireCredentials)
{
- using BlackBerry::Platform::NetworkRequest;
-
ProtectionSpaceServerType serverType;
switch (authType) {
- case NetworkRequest::AuthTypeHTTP:
- serverType = ProtectionSpaceServerHTTP;
+ case NetworkRequest::AuthTypeHost:
+ switch (authProtocol) {
+ case NetworkRequest::AuthProtocolHTTP:
+ serverType = ProtectionSpaceServerHTTP;
+ break;
+ case NetworkRequest::AuthProtocolHTTPS:
+ serverType = ProtectionSpaceServerHTTPS;
+ break;
+ case NetworkRequest::AuthProtocolFTP:
+ serverType = ProtectionSpaceServerFTP;
+ break;
+ case NetworkRequest::AuthProtocolFTPS:
+ serverType = ProtectionSpaceServerFTPS;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
break;
- case NetworkRequest::AuthTypeHTTPS:
- serverType = ProtectionSpaceServerHTTPS;
+ case NetworkRequest::AuthTypeProxy:
+ switch (authProtocol) {
+ case NetworkRequest::AuthProtocolHTTP:
+ serverType = ProtectionSpaceProxyHTTP;
+ break;
+ case NetworkRequest::AuthProtocolHTTPS:
+ serverType = ProtectionSpaceProxyHTTPS;
+ break;
+ case NetworkRequest::AuthProtocolFTP:
+ case NetworkRequest::AuthProtocolFTPS:
+ serverType = ProtectionSpaceProxyFTP;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
break;
- case NetworkRequest::AuthTypeFTP:
- serverType = ProtectionSpaceServerFTP;
- break;
- case NetworkRequest::AuthTypeFTPS:
- serverType = ProtectionSpaceServerFTPS;
- break;
- case NetworkRequest::AuthTypeProxyHTTP:
- serverType = ProtectionSpaceProxyHTTP;
- break;
- case NetworkRequest::AuthTypeProxyHTTPS:
- serverType = ProtectionSpaceProxyHTTPS;
- break;
- case NetworkRequest::AuthTypeProxyFTP:
- serverType = ProtectionSpaceProxyFTP;
- break;
default:
ASSERT_NOT_REACHED();
return;
@@ -329,16 +344,12 @@
purgeCredentials();
else {
// Update the credentials that will be stored to match the scheme that was actually used
- AuthenticationChallenge& challenge = m_handle->getInternal()->m_currentWebChallenge;
- if (!challenge.isNull()) {
+ AuthenticationChallenge& challenge = authType == NetworkRequest::AuthTypeProxy ? m_handle->getInternal()->m_proxyWebChallenge : m_handle->getInternal()->m_hostWebChallenge;
+ if (challenge.hasCredentials()) {
const ProtectionSpace& oldSpace = challenge.protectionSpace();
if (oldSpace.authenticationScheme() != scheme && oldSpace.serverType() == serverType) {
ProtectionSpace newSpace(oldSpace.host(), oldSpace.port(), oldSpace.serverType(), oldSpace.realm(), scheme);
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(newSpace,
- challenge.proposedCredential(),
- challenge.previousFailureCount(),
- challenge.failureResponse(),
- challenge.error());
+ updateCurrentWebChallenge(AuthenticationChallenge(newSpace, challenge.proposedCredential(), challenge.previousFailureCount(), challenge.failureResponse(), challenge.error()));
}
}
storeCredentials();
@@ -653,13 +664,14 @@
newRequest.clearHTTPContentType();
}
- if (!m_handle->getInternal()->m_currentWebChallenge.isNull()) {
- // If this request is challenged, store the credentials now because the credential is correct (otherwise, it won't get here).
- storeCredentials();
- // Do not send existing credentials with the new request.
- m_handle->getInternal()->m_currentWebChallenge.nullify();
- }
+ // If this request is challenged, store the credentials now (if they are null this will do nothing)
+ storeCredentials();
+ // Do not send existing credentials with the new request.
+ m_handle->getInternal()->m_currentWebChallenge.nullify();
+ m_handle->getInternal()->m_proxyWebChallenge.nullify();
+ m_handle->getInternal()->m_hostWebChallenge.nullify();
+
return startNewJobWithRequest(newRequest, true);
}
@@ -817,16 +829,16 @@
Credential credential;
if (!requireCredentials) {
// Don't overwrite any existing credentials with the empty credential
- if (m_handle->getInternal()->m_currentWebChallenge.isNull())
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
+ updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()), /* allowOverwrite */ false);
} else if (!(credential = CredentialStorage::get(protectionSpace)).isEmpty()
#if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
|| !(credential = CredentialStorage::getFromPersistentStorage(protectionSpace)).isEmpty()
#endif
) {
// First search the CredentialStorage and Persistent Credential Storage
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
- m_handle->getInternal()->m_currentWebChallenge.setStored(true);
+ AuthenticationChallenge challenge(protectionSpace, credential, 0, m_response, ResourceError());
+ challenge.setStored(true);
+ updateCurrentWebChallenge(challenge);
} else {
if (m_handle->firstRequest().targetType() == ResourceRequest::TargetIsFavicon) {
// The favicon loading is triggerred after the main resource has been loaded
@@ -856,7 +868,8 @@
if (!m_frame || !m_frame->page())
return false;
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge();
+ // DO overwrite any existing credentials with the empty credential
+ updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()));
m_isAuthenticationChallenging = true;
updateDeferLoadingCount(1);
@@ -868,7 +881,7 @@
credential = Credential(username, password, CredentialPersistenceForSession);
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
+ updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()));
}
notifyChallengeResult(newURL, protectionSpace, AuthenticationChallengeSuccess, credential);
@@ -880,7 +893,12 @@
if (!m_handle)
return;
- AuthenticationChallenge& challenge = m_handle->getInternal()->m_currentWebChallenge;
+ storeCredentials(m_handle->getInternal()->m_hostWebChallenge);
+ storeCredentials(m_handle->getInternal()->m_proxyWebChallenge);
+}
+
+void NetworkJob::storeCredentials(AuthenticationChallenge& challenge)
+{
if (challenge.isNull())
return;
@@ -922,7 +940,12 @@
if (!m_handle)
return;
- AuthenticationChallenge& challenge = m_handle->getInternal()->m_currentWebChallenge;
+ purgeCredentials(m_handle->getInternal()->m_hostWebChallenge);
+ purgeCredentials(m_handle->getInternal()->m_proxyWebChallenge);
+}
+
+void NetworkJob::purgeCredentials(AuthenticationChallenge& challenge)
+{
if (challenge.isNull())
return;
@@ -979,8 +1002,7 @@
if (result != AuthenticationChallengeSuccess)
return;
- if (m_handle->getInternal()->m_currentWebChallenge.isNull())
- m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
+ updateCurrentWebChallenge(AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError()), /* allowOverwrite */ false);
ResourceRequest newRequest = m_handle->firstRequest();
newRequest.setURL(url);
@@ -1001,4 +1023,17 @@
cancelJob();
}
+void NetworkJob::updateCurrentWebChallenge(const AuthenticationChallenge& challenge, bool allowOverwrite)
+{
+ if (allowOverwrite || !m_handle->getInternal()->m_currentWebChallenge.hasCredentials())
+ m_handle->getInternal()->m_currentWebChallenge = challenge;
+ if (challenge.protectionSpace().serverType() == ProtectionSpaceProxyHTTP || challenge.protectionSpace().serverType() == ProtectionSpaceProxyHTTPS) {
+ if (allowOverwrite || !m_handle->getInternal()->m_proxyWebChallenge.hasCredentials())
+ m_handle->getInternal()->m_proxyWebChallenge = challenge;
+ } else {
+ if (allowOverwrite || !m_handle->getInternal()->m_hostWebChallenge.hasCredentials())
+ m_handle->getInternal()->m_hostWebChallenge = challenge;
+ }
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (141349 => 141350)
--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h 2013-01-31 01:22:30 UTC (rev 141349)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h 2013-01-31 01:26:22 UTC (rev 141350)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010, 2011 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -73,7 +73,12 @@
void handleNotifyStatusReceived(int status, const String& message);
virtual void notifyHeadersReceived(const BlackBerry::Platform::NetworkRequest::HeaderList& headers);
virtual void notifyMultipartHeaderReceived(const char* key, const char* value);
- virtual void notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType, BlackBerry::Platform::NetworkRequest::AuthScheme, const char* realm, AuthResult, bool requireCredentials);
+ virtual void notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType,
+ BlackBerry::Platform::NetworkRequest::AuthProtocol,
+ BlackBerry::Platform::NetworkRequest::AuthScheme,
+ const char* realm,
+ AuthResult,
+ bool requireCredentials);
// notifyStringHeaderReceived exists only to resolve ambiguity between char* and String parameters
void notifyStringHeaderReceived(const String& key, const String& value);
void handleNotifyHeaderReceived(const String& key, const String& value);
@@ -135,14 +140,17 @@
bool sendRequestWithCredentials(ProtectionSpaceServerType, ProtectionSpaceAuthenticationScheme, const String& realm, bool requireCredentials = true);
void storeCredentials();
-
+ void storeCredentials(AuthenticationChallenge&);
void purgeCredentials();
+ void purgeCredentials(AuthenticationChallenge&);
bool isError(int statusCode) const
{
return statusCode < 0 || (400 <= statusCode && statusCode < 600);
}
+ void updateCurrentWebChallenge(const AuthenticationChallenge&, bool allowOverwrite = true);
+
private:
int m_playerId;
String m_pageGroupName;
Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp (141349 => 141350)
--- trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp 2013-01-31 01:22:30 UTC (rev 141349)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp 2013-01-31 01:26:22 UTC (rev 141350)
@@ -34,6 +34,8 @@
#include <network/FilterStream.h>
#include <network/NetworkRequest.h>
+using BlackBerry::Platform::NetworkRequest;
+
namespace WebCore {
SINGLETON_INITIALIZER_THREADUNSAFE(NetworkManager)
@@ -55,6 +57,79 @@
return startJob(playerId, page->groupName(), job, request, streamFactory, frame, defersLoading ? 1 : 0);
}
+static void setAuthCredentials(NetworkRequest& platformRequest, const AuthenticationChallenge& challenge)
+{
+ if (challenge.isNull())
+ return;
+
+ Credential credential = challenge.proposedCredential();
+ const ProtectionSpace& protectionSpace = challenge.protectionSpace();
+
+ String username = credential.user();
+ String password = credential.password();
+
+ NetworkRequest::AuthScheme authScheme = NetworkRequest::AuthSchemeNone;
+ switch (protectionSpace.authenticationScheme()) {
+ case ProtectionSpaceAuthenticationSchemeDefault:
+ authScheme = NetworkRequest::AuthSchemeDefault;
+ break;
+ case ProtectionSpaceAuthenticationSchemeHTTPBasic:
+ authScheme = NetworkRequest::AuthSchemeHTTPBasic;
+ break;
+ case ProtectionSpaceAuthenticationSchemeHTTPDigest:
+ authScheme = NetworkRequest::AuthSchemeHTTPDigest;
+ break;
+ case ProtectionSpaceAuthenticationSchemeNegotiate:
+ authScheme = NetworkRequest::AuthSchemeNegotiate;
+ break;
+ case ProtectionSpaceAuthenticationSchemeNTLM:
+ authScheme = NetworkRequest::AuthSchemeNTLM;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ NetworkRequest::AuthType authType = NetworkRequest::AuthTypeNone;
+ NetworkRequest::AuthProtocol authProtocol = NetworkRequest::AuthProtocolNone;
+ switch (protectionSpace.serverType()) {
+ case ProtectionSpaceServerHTTP:
+ authType = NetworkRequest::AuthTypeHost;
+ authProtocol = NetworkRequest::AuthProtocolHTTP;
+ break;
+ case ProtectionSpaceServerHTTPS:
+ authType = NetworkRequest::AuthTypeHost;
+ authProtocol = NetworkRequest::AuthProtocolHTTPS;
+ break;
+ case ProtectionSpaceServerFTP:
+ authType = NetworkRequest::AuthTypeHost;
+ authProtocol = NetworkRequest::AuthProtocolFTP;
+ break;
+ case ProtectionSpaceServerFTPS:
+ authType = NetworkRequest::AuthTypeHost;
+ authProtocol = NetworkRequest::AuthProtocolFTPS;
+ break;
+ case ProtectionSpaceProxyHTTP:
+ authType = NetworkRequest::AuthTypeProxy;
+ authProtocol = NetworkRequest::AuthProtocolHTTP;
+ break;
+ case ProtectionSpaceProxyHTTPS:
+ authType = NetworkRequest::AuthTypeProxy;
+ authProtocol = NetworkRequest::AuthProtocolHTTPS;
+ break;
+ case ProtectionSpaceProxyFTP:
+ authType = NetworkRequest::AuthTypeProxy;
+ authProtocol = NetworkRequest::AuthProtocolFTP;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ if (authType != NetworkRequest::AuthTypeNone && authProtocol != NetworkRequest::AuthProtocolNone && authScheme != NetworkRequest::AuthSchemeNone)
+ platformRequest.setCredentials(authType, authProtocol, authScheme, username.utf8().data(), password.utf8().data());
+}
+
bool NetworkManager::startJob(int playerId, const String& pageGroupName, PassRefPtr<ResourceHandle> job, const ResourceRequest& request, BlackBerry::Platform::NetworkStreamFactory* streamFactory, Frame* frame, int deferLoadingCount, int redirectCount)
{
// Make sure the ResourceHandle doesn't go out of scope while calling callbacks.
@@ -78,68 +153,9 @@
platformRequest.setSecurityOrigin(frame->document()->securityOrigin()->toRawString());
// Attach any applicable auth credentials to the NetworkRequest.
- AuthenticationChallenge& challenge = guardJob->getInternal()->m_currentWebChallenge;
- if (!challenge.isNull()) {
- Credential credential = challenge.proposedCredential();
- const ProtectionSpace& protectionSpace = challenge.protectionSpace();
+ setAuthCredentials(platformRequest, guardJob->getInternal()->m_hostWebChallenge);
+ setAuthCredentials(platformRequest, guardJob->getInternal()->m_proxyWebChallenge);
- String username = credential.user();
- String password = credential.password();
-
- BlackBerry::Platform::NetworkRequest::AuthType authType = BlackBerry::Platform::NetworkRequest::AuthTypeNone;
- switch (protectionSpace.serverType()) {
- case ProtectionSpaceServerHTTP:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeHTTP;
- break;
- case ProtectionSpaceServerHTTPS:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeHTTPS;
- break;
- case ProtectionSpaceServerFTP:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeFTP;
- break;
- case ProtectionSpaceServerFTPS:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeFTPS;
- break;
- case ProtectionSpaceProxyHTTP:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyHTTP;
- break;
- case ProtectionSpaceProxyHTTPS:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyHTTPS;
- break;
- case ProtectionSpaceProxyFTP:
- authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyFTP;
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
-
- BlackBerry::Platform::NetworkRequest::AuthScheme authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNone;
- switch (protectionSpace.authenticationScheme()) {
- case ProtectionSpaceAuthenticationSchemeDefault:
- authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeDefault;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPBasic:
- authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeHTTPBasic;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPDigest:
- authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeHTTPDigest;
- break;
- case ProtectionSpaceAuthenticationSchemeNegotiate:
- authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNegotiate;
- break;
- case ProtectionSpaceAuthenticationSchemeNTLM:
- authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNTLM;
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
-
- if (authType != BlackBerry::Platform::NetworkRequest::AuthTypeNone && authScheme != BlackBerry::Platform::NetworkRequest::AuthSchemeNone)
- platformRequest.setCredentials(username.utf8().data(), password.utf8().data(), authType, authScheme);
- }
-
if (!request.overrideContentType().isEmpty())
platformRequest.setOverrideContentType(request.overrideContentType().latin1().data());