Title: [124205] trunk/Source/WebCore
Revision
124205
Author
commit-qu...@webkit.org
Date
2012-07-31 08:41:12 -0700 (Tue, 31 Jul 2012)

Log Message

[BlackBerry] Support Negotiate auth
https://bugs.webkit.org/show_bug.cgi?id=91871

Patch by Joe Mason <jma...@rim.com> on 2012-07-31
Reviewed by George Staikos.

Add Negotiate to the list of auth schemes allowed in the platform request.

Add "success" and "requireCredentials" parameters to notifyAuthReceived (which is now called
with success = true on successful authentication, as well as on failures).

When success is true, update the stored credential to use the auth scheme actually reported
rather than that set in the request. (This is used when Negotiate auth can't get a ticket
and falls back to a different supported auth type.)

When requireCredentials is false, just set the auth type and start a new request using empty
credentials.

RIM PR# 166514
Internally reviewed by Jonathan Dong

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::notifyAuthReceived): Add Negotiate to the auth scheme switch. Handle
success param by updating auth type in stored credentials; pass requireCredentials param on
to sendRequestWithCredentials.
(WebCore::NetworkJob::startNewJobWithRequest): Fix typo in increaseRedirectCount parameter
name.
(WebCore::NetworkJob::sendRequestWithCredentials): Use empty credentials if
requireCredentials is false.
* platform/network/blackberry/NetworkJob.h:
(NetworkJob):
* platform/network/blackberry/NetworkManager.cpp:
(WebCore::NetworkManager::startJob): Add Negotiate to the auth scheme switch.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124204 => 124205)


--- trunk/Source/WebCore/ChangeLog	2012-07-31 15:37:40 UTC (rev 124204)
+++ trunk/Source/WebCore/ChangeLog	2012-07-31 15:41:12 UTC (rev 124205)
@@ -1,3 +1,38 @@
+2012-07-31  Joe Mason  <jma...@rim.com>
+
+        [BlackBerry] Support Negotiate auth
+        https://bugs.webkit.org/show_bug.cgi?id=91871
+
+        Reviewed by George Staikos.
+
+        Add Negotiate to the list of auth schemes allowed in the platform request.
+
+        Add "success" and "requireCredentials" parameters to notifyAuthReceived (which is now called
+        with success = true on successful authentication, as well as on failures).
+
+        When success is true, update the stored credential to use the auth scheme actually reported
+        rather than that set in the request. (This is used when Negotiate auth can't get a ticket
+        and falls back to a different supported auth type.)
+
+        When requireCredentials is false, just set the auth type and start a new request using empty
+        credentials.
+
+        RIM PR# 166514
+        Internally reviewed by Jonathan Dong
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::notifyAuthReceived): Add Negotiate to the auth scheme switch. Handle
+        success param by updating auth type in stored credentials; pass requireCredentials param on
+        to sendRequestWithCredentials.
+        (WebCore::NetworkJob::startNewJobWithRequest): Fix typo in increaseRedirectCount parameter
+        name.
+        (WebCore::NetworkJob::sendRequestWithCredentials): Use empty credentials if
+        requireCredentials is false.
+        * platform/network/blackberry/NetworkJob.h:
+        (NetworkJob):
+        * platform/network/blackberry/NetworkManager.cpp:
+        (WebCore::NetworkManager::startJob): Add Negotiate to the auth scheme switch.
+
 2012-07-31  Alexei Filippov  <alex...@chromium.org>
 
         Web Inspector: take into account the whole security origin instead of just host

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (124204 => 124205)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-07-31 15:37:40 UTC (rev 124204)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-07-31 15:41:12 UTC (rev 124205)
@@ -231,7 +231,7 @@
         handleNotifyMultipartHeaderReceived(key, value);
 }
 
-void NetworkJob::notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType authType, const char* realm)
+void NetworkJob::notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType authType, const char* realm, bool success, bool requireCredentials)
 {
     using BlackBerry::Platform::NetworkRequest;
 
@@ -244,6 +244,9 @@
     case NetworkRequest::AuthHTTPDigest:
         scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest;
         break;
+    case NetworkRequest::AuthNegotiate:
+        scheme = ProtectionSpaceAuthenticationSchemeNegotiate;
+        break;
     case NetworkRequest::AuthHTTPNTLM:
         scheme = ProtectionSpaceAuthenticationSchemeNTLM;
         break;
@@ -258,7 +261,26 @@
         return;
     }
 
-    m_newJobWithCredentialsStarted = sendRequestWithCredentials(serverType, scheme, realm);
+    if (success) {
+        // 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()) {
+            const ProtectionSpace& oldSpace = challenge.protectionSpace();
+            if (oldSpace.authenticationScheme() != scheme) {
+                // The scheme might have changed, but the server type shouldn't have!
+                BLACKBERRY_ASSERT(serverType == oldSpace.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());
+            }
+        }
+        return;
+    }
+
+    m_newJobWithCredentialsStarted = sendRequestWithCredentials(serverType, scheme, realm, requireCredentials);
 }
 
 void NetworkJob::notifyStringHeaderReceived(const String& key, const String& value)
@@ -510,7 +532,7 @@
     return startNewJobWithRequest(newRequest);
 }
 
-bool NetworkJob::startNewJobWithRequest(ResourceRequest& newRequest, bool increasRedirectCount)
+bool NetworkJob::startNewJobWithRequest(ResourceRequest& newRequest, bool increaseRedirectCount)
 {
     // m_frame can be null if this is a PingLoader job (See NetworkJob::initialize).
     // In this case we don't start new request.
@@ -538,7 +560,7 @@
         m_streamFactory,
         *m_frame,
         m_deferLoadingCount,
-        increasRedirectCount ? m_redirectCount + 1 : m_redirectCount);
+        increaseRedirectCount ? m_redirectCount + 1 : m_redirectCount);
     return true;
 }
 
@@ -674,7 +696,7 @@
     return true;
 }
 
-bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, ProtectionSpaceAuthenticationScheme scheme, const String& realm)
+bool NetworkJob::sendRequestWithCredentials(ProtectionSpaceServerType type, ProtectionSpaceAuthenticationScheme scheme, const String& realm, bool requireCredentials)
 {
     ASSERT(m_handle);
     if (!m_handle)
@@ -699,9 +721,13 @@
     ProtectionSpace protectionSpace(host, port, type, realm, scheme);
 
     // We've got the scheme and realm. Now we need a username and password.
-    // First search the CredentialStorage.
-    Credential credential = CredentialStorage::get(protectionSpace);
-    if (!credential.isEmpty()) {
+    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());
+    } else if (!(credential = CredentialStorage::get(protectionSpace)).isEmpty()) {
+        // First search the CredentialStorage.
         m_handle->getInternal()->m_currentWebChallenge = AuthenticationChallenge(protectionSpace, credential, 0, m_response, ResourceError());
         m_handle->getInternal()->m_currentWebChallenge.setStored(true);
     } else {

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (124204 => 124205)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-07-31 15:37:40 UTC (rev 124204)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-07-31 15:41:12 UTC (rev 124205)
@@ -67,8 +67,8 @@
     void handleNotifyStatusReceived(int status, const String& message);
     virtual void notifyHeadersReceived(BlackBerry::Platform::NetworkRequest::HeaderList& headers);
     virtual void notifyMultipartHeaderReceived(const char* key, const char* value);
-    // Exists only to resolve ambiguity between char* and String parameters
-    virtual void notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType, const char* realm);
+    virtual void notifyAuthReceived(BlackBerry::Platform::NetworkRequest::AuthType, const char* realm, bool success, 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);
     void handleNotifyMultipartHeaderReceived(const String& key, const String& value);
@@ -120,7 +120,7 @@
 
     // The server needs authentication credentials. Search in the CredentialStorage
     // or prompt the user via dialog, then resend the request with the credentials.
-    bool sendRequestWithCredentials(ProtectionSpaceServerType, ProtectionSpaceAuthenticationScheme, const String& realm);
+    bool sendRequestWithCredentials(ProtectionSpaceServerType, ProtectionSpaceAuthenticationScheme, const String& realm, bool requireCredentials = true);
 
     void storeCredentials();
 

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp (124204 => 124205)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2012-07-31 15:37:40 UTC (rev 124204)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2012-07-31 15:41:12 UTC (rev 124205)
@@ -97,6 +97,9 @@
             case ProtectionSpaceAuthenticationSchemeHTTPDigest:
                 authType = BlackBerry::Platform::NetworkRequest::AuthHTTPDigest;
                 break;
+            case ProtectionSpaceAuthenticationSchemeNegotiate:
+                authType = BlackBerry::Platform::NetworkRequest::AuthNegotiate;
+                break;
             case ProtectionSpaceAuthenticationSchemeNTLM:
                 authType = BlackBerry::Platform::NetworkRequest::AuthHTTPNTLM;
                 break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to