Move tryUsePlatformCertificateInfoForChallenge from AuthenticationManager to Platform...
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 22:57:23 +0000 (22:57 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 22:57:23 +0000 (22:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102718

Reviewed by Sam Weinig.

Add the shared PlatformCertificateInfo version of the method:
* Shared/mac/PlatformCertificateInfo.h:
* Shared/mac/PlatformCertificateInfo.mm:
(WebKit::tryUsePlatformCertificateInfoForChallenge):

Use the new shared version:
* WebProcess/Authentication/AuthenticationManager.cpp:

Remove the old member version:
* WebProcess/Authentication/AuthenticationManager.h:
* WebProcess/Authentication/mac/AuthenticationManager.mac.mm: Removed.
* WebKit2.xcodeproj/project.pbxproj:

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/PlatformCertificateInfo.h
Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h
Source/WebKit2/WebProcess/Authentication/mac/AuthenticationManager.mac.mm [deleted file]

index 76b2e53..5442bb8 100644 (file)
@@ -1,3 +1,23 @@
+2012-11-19  Brady Eidson  <beidson@apple.com>
+
+        Move tryUsePlatformCertificateInfoForChallenge from AuthenticationManager to PlatformCertificateInfo.
+        https://bugs.webkit.org/show_bug.cgi?id=102718
+
+        Reviewed by Sam Weinig.
+
+        Add the shared PlatformCertificateInfo version of the method:
+        * Shared/mac/PlatformCertificateInfo.h:
+        * Shared/mac/PlatformCertificateInfo.mm:
+        (WebKit::tryUsePlatformCertificateInfoForChallenge):
+
+        Use the new shared version:
+        * WebProcess/Authentication/AuthenticationManager.cpp:
+
+        Remove the old member version:
+        * WebProcess/Authentication/AuthenticationManager.h:
+        * WebProcess/Authentication/mac/AuthenticationManager.mac.mm: Removed.
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2012-11-19  Huang Dongsung  <luxtella@company100.net>
 
         Coordinated Graphics: refactor syncCanvas to handle the lifecycle clearly.
index 93f09f3..844b093 100644 (file)
@@ -34,6 +34,10 @@ namespace CoreIPC {
     class ArgumentEncoder;
 }
 
+namespace WebCore {
+    class AuthenticationChallenge;
+}
+
 namespace WebKit {
 
 class PlatformCertificateInfo {
@@ -55,6 +59,8 @@ private:
     RetainPtr<CFArrayRef> m_certificateChain;
 };
 
+bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&);
+
 } // namespace WebKit
 
 #endif // PlatformCertificateInfo_h
index ecffbe6..d59042c 100644 (file)
@@ -29,6 +29,7 @@
 #import "ArgumentCodersCF.h"
 #import "ArgumentDecoder.h"
 #import "ArgumentEncoder.h"
+#import <WebCore/AuthenticationChallenge.h>
 #import <WebKitSystemInterface.h>
 
 using namespace WebCore;
@@ -89,4 +90,32 @@ void PlatformCertificateInfo::dump() const
 }
 #endif
 
+bool tryUsePlatformCertificateInfoForChallenge(const AuthenticationChallenge& challenge, const PlatformCertificateInfo& certificateInfo)
+{
+    CFArrayRef chain = certificateInfo.certificateChain();
+    if (!chain)
+        return false;
+        
+    ASSERT(CFArrayGetCount(chain));
+
+    // The passed-in certificate chain includes the identity certificate at index 0, and additional certificates starting at index 1.
+    SecIdentityRef identity;
+    OSStatus result = SecIdentityCreateWithCertificate(NULL, (SecCertificateRef)CFArrayGetValueAtIndex(chain, 0), &identity);
+    if (result != errSecSuccess) {
+        LOG_ERROR("Unable to create SecIdentityRef with certificate - %i", result);
+        [challenge.sender() cancelAuthenticationChallenge:challenge.nsURLAuthenticationChallenge()];
+        return true;
+    }
+
+    CFIndex chainCount = CFArrayGetCount(chain);
+    NSArray *nsChain = chainCount > 1 ? [(NSArray *)chain subarrayWithRange:NSMakeRange(1, chainCount - 1)] : nil;
+
+    NSURLCredential *credential = [NSURLCredential credentialWithIdentity:identity
+                                                             certificates:nsChain
+                                                              persistence:NSURLCredentialPersistenceNone];
+
+    [challenge.sender() useCredential:credential forAuthenticationChallenge:challenge.nsURLAuthenticationChallenge()];
+    return true;
+}
+
 } // namespace WebKit
index 76e2d2a..3cbac0a 100644 (file)
                51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; };
                51B3005012529D0E000B5CA0 /* WebBackForwardListCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */; };
                51B3005112529D0E000B5CA0 /* WebPageProxyCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */; };
-               51C4032C136749D800DC972D /* AuthenticationManager.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51C4032B136749D800DC972D /* AuthenticationManager.mac.mm */; };
                51CBBA0F165219B6005BE8FD /* NetworkResourceLoadParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CBBA0D165219B6005BE8FD /* NetworkResourceLoadParameters.cpp */; };
                51CBBA10165219B6005BE8FD /* NetworkResourceLoadParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBBA0E165219B6005BE8FD /* NetworkResourceLoadParameters.h */; };
                51D02F64132EC5B900BEAA96 /* WebIconDatabaseMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D02F63132EC5B900BEAA96 /* WebIconDatabaseMessageReceiver.cpp */; };
                51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EnvironmentUtilities.h; path = unix/EnvironmentUtilities.h; sourceTree = "<group>"; };
                51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebBackForwardListCF.cpp; path = cf/WebBackForwardListCF.cpp; sourceTree = "<group>"; };
                51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPageProxyCF.cpp; path = cf/WebPageProxyCF.cpp; sourceTree = "<group>"; };
-               51C4032B136749D800DC972D /* AuthenticationManager.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManager.mac.mm; path = mac/AuthenticationManager.mac.mm; sourceTree = "<group>"; };
                51CBBA0D165219B6005BE8FD /* NetworkResourceLoadParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkResourceLoadParameters.cpp; path = Network/NetworkResourceLoadParameters.cpp; sourceTree = "<group>"; };
                51CBBA0E165219B6005BE8FD /* NetworkResourceLoadParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkResourceLoadParameters.h; path = Network/NetworkResourceLoadParameters.h; sourceTree = "<group>"; };
                51D02F63132EC5B900BEAA96 /* WebIconDatabaseMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebIconDatabaseMessageReceiver.cpp; sourceTree = "<group>"; };
                512F588612A8834700629530 /* Authentication */ = {
                        isa = PBXGroup;
                        children = (
-                               51C4032A136749C400DC972D /* mac */,
                                512F588712A8836600629530 /* AuthenticationManager.cpp */,
                                512F588812A8836600629530 /* AuthenticationManager.h */,
                                512F588912A8836600629530 /* AuthenticationManager.messages.in */,
                        name = cf;
                        sourceTree = "<group>";
                };
-               51C4032A136749C400DC972D /* mac */ = {
-                       isa = PBXGroup;
-                       children = (
-                               51C4032B136749D800DC972D /* AuthenticationManager.mac.mm */,
-                       );
-                       name = mac;
-                       sourceTree = "<group>";
-               };
                51FBB9C1132E079200F327B4 /* IconDatabase */ = {
                        isa = PBXGroup;
                        children = (
                                512F589612A8838800629530 /* AuthenticationChallengeProxy.cpp in Sources */,
                                512F589812A8838800629530 /* AuthenticationDecisionListener.cpp in Sources */,
                                512F588A12A8836600629530 /* AuthenticationManager.cpp in Sources */,
-                               51C4032C136749D800DC972D /* AuthenticationManager.mac.mm in Sources */,
                                512F58A212A883AD00629530 /* AuthenticationManagerMessageReceiver.cpp in Sources */,
                                1A64256912DE42EC00CAAE2C /* BackingStore.cpp in Sources */,
                                1A64292D12DE5F9800CAAE2C /* BackingStoreMac.mm in Sources */,
index 3850e64..dc11580 100644 (file)
@@ -30,6 +30,7 @@
 #include "Download.h"
 #include "DownloadProxyMessages.h"
 #include "MessageID.h"
+#include "PlatformCertificateInfo.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebPage.h"
index 16708ce..b97cf63 100644 (file)
@@ -65,8 +65,6 @@ private:
     // CoreIPC::MessageReceiver
     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
     void didReceiveAuthenticationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
-
-    bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&);
     
     typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
     AuthenticationChallengeMap m_challenges;
diff --git a/Source/WebKit2/WebProcess/Authentication/mac/AuthenticationManager.mac.mm b/Source/WebKit2/WebProcess/Authentication/mac/AuthenticationManager.mac.mm
deleted file mode 100644 (file)
index 1a772c3..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AuthenticationManager.h"
-
-#if USE(SECURITY_FRAMEWORK)
-
-#include "PlatformCertificateInfo.h"
-#include <Security/SecIdentity.h>
-#include <WebCore/AuthenticationChallenge.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-bool AuthenticationManager::tryUsePlatformCertificateInfoForChallenge(const AuthenticationChallenge& challenge, const PlatformCertificateInfo& certificateInfo)
-{
-    // FIXME (NetworkProcess): This occurs in the WebProcess and therefore won't work.
-    // We need this to happen in the NetworkProcess.
-
-    CFArrayRef chain = certificateInfo.certificateChain();
-    if (!chain)
-        return false;
-        
-    ASSERT(CFArrayGetCount(chain));
-
-    // The passed-in certificate chain includes the identity certificate at index 0, and additional certificates starting at index 1.
-    SecIdentityRef identity;
-    OSStatus result = SecIdentityCreateWithCertificate(NULL, (SecCertificateRef)CFArrayGetValueAtIndex(chain, 0), &identity);
-    if (result != errSecSuccess) {
-        LOG_ERROR("Unable to create SecIdentityRef with certificate - %i", result);
-        [challenge.sender() cancelAuthenticationChallenge:challenge.nsURLAuthenticationChallenge()];
-        return true;
-    }
-
-    CFIndex chainCount = CFArrayGetCount(chain);
-    NSArray *nsChain = chainCount > 1 ? [(NSArray *)chain subarrayWithRange:NSMakeRange(1, chainCount - 1)] : nil;
-
-    NSURLCredential *credential = [NSURLCredential credentialWithIdentity:identity
-                                                             certificates:nsChain
-                                                              persistence:NSURLCredentialPersistenceNone];
-
-    [challenge.sender() useCredential:credential forAuthenticationChallenge:challenge.nsURLAuthenticationChallenge()];
-    return true;
-}
-
-} // namespace WebKit
-
-#endif // USE(SECURITY_FRAMEWORK)