CredentialStorageCFNet.cpp [plain text]
#include "config.h"
#include "CredentialStorage.h"
#if USE(CFNETWORK)
#include "AuthenticationCF.h"
#include "Credential.h"
#include "ProtectionSpace.h"
#include <wtf/RetainPtr.h>
#if PLATFORM(COCOA)
#include "WebCoreSystemInterface.h"
#elif PLATFORM(WIN)
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#endif
#if PLATFORM(IOS)
#include <CFNetwork/CFURLCredentialStorage.h>
#endif
namespace WebCore {
Credential CredentialStorage::getFromPersistentStorage(const ProtectionSpace& protectionSpace)
{
#if PLATFORM(COCOA)
RetainPtr<CFURLCredentialRef> credentialCF = adoptCF(wkCopyCredentialFromCFPersistentStorage(protectionSpace.cfSpace()));
#else
RetainPtr<CFURLProtectionSpaceRef> protectionSpaceCF = adoptCF(createCF(protectionSpace));
RetainPtr<CFURLCredentialRef> credentialCF = adoptCF(wkCopyCredentialFromCFPersistentStorage(protectionSpaceCF.get()));
#endif
return core(credentialCF.get());
}
#if PLATFORM(IOS)
void CredentialStorage::saveToPersistentStorage(const ProtectionSpace& protectionSpace, const Credential& credential)
{
RetainPtr<CFURLCredentialStorageRef> storageCF = adoptCF(CFURLCredentialStorageCreate(0));
if (credential.persistence() == CredentialPersistenceNone) {
Credential sessionCredential(credential, CredentialPersistenceForSession);
RetainPtr<CFURLCredentialRef> sessionCredentialCF = adoptCF(createCF(sessionCredential));
CFURLCredentialStorageSetDefaultCredentialForProtectionSpace(storageCF.get(), sessionCredentialCF.get(), protectionSpace.cfSpace());
} else {
RetainPtr<CFURLCredentialRef> credentialCF = adoptCF(createCF(credential));
CFURLCredentialStorageSetDefaultCredentialForProtectionSpace(storageCF.get(), credentialCF.get(), protectionSpace.cfSpace());
}
}
#endif
}
#endif // USE(CFNETWORK)