BlackBerry - Support Proxy-Authenticate headers when a proxy is configured
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 01:25:08 +0000 (01:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 01:25:08 +0000 (01:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77361

Though we have a proxy configured, we might not have the auth
credentials it requires. Support Proxy-Authenticate for that case.

Patch by Christopher Hutten-Czapski <chutten@rim.com> on 2012-01-30
Reviewed by George Staikos.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::handleNotifyHeaderReceived):
(WebCore::NetworkJob::handleAuthHeader):
(WebCore::NetworkJob::sendRequestWithCredentials):
* platform/network/blackberry/NetworkJob.h:
* platform/network/blackberry/NetworkManager.cpp:
(WebCore::NetworkManager::startJob):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106307 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/blackberry/NetworkJob.cpp
Source/WebCore/platform/network/blackberry/NetworkJob.h
Source/WebCore/platform/network/blackberry/NetworkManager.cpp

index 96fe320..12782ec 100644 (file)
@@ -1,3 +1,21 @@
+2012-01-30  Christopher Hutten-Czapski  <chutten@rim.com>
+
+        BlackBerry - Support Proxy-Authenticate headers when a proxy is configured
+        https://bugs.webkit.org/show_bug.cgi?id=77361
+
+        Though we have a proxy configured, we might not have the auth
+        credentials it requires. Support Proxy-Authenticate for that case.
+
+        Reviewed by George Staikos.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::handleNotifyHeaderReceived):
+        (WebCore::NetworkJob::handleAuthHeader):
+        (WebCore::NetworkJob::sendRequestWithCredentials):
+        * platform/network/blackberry/NetworkJob.h:
+        * platform/network/blackberry/NetworkManager.cpp:
+        (WebCore::NetworkManager::startJob):
+
 2012-01-27  James Robinson  <jamesr@chromium.org>
 
         [chromium] Remove unnecessary retry logic in LayerRendererChromium initialization for accelerated painting
index 2cf3d17..fc7c416 100644 (file)
@@ -316,7 +316,9 @@ void NetworkJob::handleNotifyHeaderReceived(const String& key, const String& val
     }
 
     if (lowerKey == "www-authenticate")
-        handleAuthHeader(value);
+        handleAuthHeader(ProtectionSpaceServerHTTP, value);
+    else if (lowerKey == "proxy-authenticate" && !BlackBerry::Platform::Client::get()->getProxyAddress().empty())
+        handleAuthHeader(ProtectionSpaceProxyHTTP, value);
 
     if (equalIgnoringCase(key, BlackBerry::Platform::NetworkRequest::HEADER_BLACKBERRY_FTP))
         handleFTPHeader(value);
@@ -701,7 +703,7 @@ void NetworkJob::parseData()
     notifyClose(BlackBerry::Platform::FilterStream::StatusSuccess);
 }
 
-bool NetworkJob::handleAuthHeader(const String& header)
+bool NetworkJob::handleAuthHeader(const ProtectionSpaceServerType space, const String& header)
 {
     if (!m_handle)
         return false;
@@ -713,12 +715,12 @@ bool NetworkJob::handleAuthHeader(const String& header)
         return false;
 
     if (equalIgnoringCase(header, "ntlm"))
-        sendRequestWithCredentials(ProtectionSpaceServerHTTP, ProtectionSpaceAuthenticationSchemeNTLM, "NTLM");
+        sendRequestWithCredentials(space, ProtectionSpaceAuthenticationSchemeNTLM, "NTLM");
 
     // Extract the auth scheme and realm from the header.
     size_t spacePos = header.find(' ');
     if (spacePos == notFound) {
-        LOG(Network, "WWW-Authenticate field '%s' badly formatted: missing scheme.", header.utf8().data());
+        LOG(Network, "%s-Authenticate field '%s' badly formatted: missing scheme.", space == ProtectionSpaceServerHTTP ? "WWW" : "Proxy", header.utf8().data());
         return false;
     }
 
@@ -736,7 +738,7 @@ bool NetworkJob::handleAuthHeader(const String& header)
 
     size_t realmPos = header.findIgnoringCase("realm=", spacePos);
     if (realmPos == notFound) {
-        LOG(Network, "WWW-Authenticate field '%s' badly formatted: missing realm.", header.utf8().data());
+        LOG(Network, "%s-Authenticate field '%s' badly formatted: missing realm.", space == ProtectionSpaceServerHTTP ? "WWW" : "Proxy", header.utf8().data());
         return false;
     }
     size_t beginPos = realmPos + 6;
@@ -745,14 +747,14 @@ bool NetworkJob::handleAuthHeader(const String& header)
         beginPos += 1;
         size_t endPos = header.find("\"", beginPos);
         if (endPos == notFound) {
-            LOG(Network, "WWW-Authenticate field '%s' badly formatted: invalid realm.", header.utf8().data());
+            LOG(Network, "%s-Authenticate field '%s' badly formatted: invalid realm.", space == ProtectionSpaceServerHTTP ? "WWW" : "Proxy", header.utf8().data());
             return false;
         }
         realm = header.substring(beginPos, endPos - beginPos);
     }
 
     // Get the user's credentials and resend the request.
-    sendRequestWithCredentials(ProtectionSpaceServerHTTP, protectionSpaceScheme, realm);
+    sendRequestWithCredentials(space, protectionSpaceScheme, realm);
 
     return true;
 }
@@ -796,7 +798,15 @@ bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, Prot
     if (!newURL.isValid())
         return false;
 
-    ProtectionSpace protectionSpace(m_response.url().host(), m_response.url().port(), type, realm, scheme);
+    int port = 0;
+    if (type == ProtectionSpaceProxyHTTP) {
+        std::stringstream toPort(BlackBerry::Platform::Client::get()->getProxyPort());
+        toPort >> port;
+    } else
+        port = m_response.url().port();
+
+    ProtectionSpace protectionSpace((type == ProtectionSpaceProxyHTTP) ? BlackBerry::Platform::Client::get()->getProxyAddress().c_str() : m_response.url().host()
+            , port, type, realm, scheme);
 
     // We've got the scheme and realm. Now we need a username and password.
     // First search the CredentialStorage.
index 3781610..4d60a6a 100644 (file)
@@ -129,7 +129,7 @@ private:
 
     // The server needs authentication credentials. Search in the
     // CredentialStorage or prompt the user via dialog.
-    bool handleAuthHeader(const String& header);
+    bool handleAuthHeader(const ProtectionSpaceServerType, const String& header);
 
     bool handleFTPHeader(const String& header);
 
index 38f09e6..077b4c2 100644 (file)
@@ -104,6 +104,8 @@ bool NetworkManager::startJob(int playerId, const String& pageGroupName, PassRef
             }
         } else if (type == ProtectionSpaceServerFTP)
             authType = BlackBerry::Platform::NetworkRequest::AuthFTP;
+        else if (type == ProtectionSpaceProxyHTTP)
+            authType = BlackBerry::Platform::NetworkRequest::AuthProxy;
 
         if (authType != BlackBerry::Platform::NetworkRequest::AuthNone)
             platformRequest.setCredentials(username.utf8().data(), password.utf8().data(), authType);