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(MAC)
#include "WebCoreSystemInterface.h"
#elif PLATFORM(WIN)
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#endif
#include <CFNetwork/CFURLCredentialStorage.h>
namespace WebCore {
Credential CredentialStorage::getFromPersistentStorage(const ProtectionSpace& protectionSpace)
{
RetainPtr<CFURLProtectionSpaceRef> protectionSpaceCF(AdoptCF, createCF(protectionSpace));
RetainPtr<CFURLCredentialRef> credentialCF(AdoptCF, wkCopyCredentialFromCFPersistentStorage(protectionSpaceCF.get()));
return core(credentialCF.get());
}
void CredentialStorage::saveToPersistentStorage(const ProtectionSpace& protectionSpace, const Credential& credential)
{
RetainPtr<CFURLCredentialStorageRef> storageCF(AdoptCF, CFURLCredentialStorageCreate(0));
RetainPtr<CFURLProtectionSpaceRef> protectionSpaceCF(AdoptCF, createCF(protectionSpace));
if (credential.persistence() == CredentialPersistenceNone) {
Credential sessionCredential(credential, CredentialPersistenceForSession);
RetainPtr<CFURLCredentialRef> sessionCredentialCF(AdoptCF, createCF(sessionCredential));
CFURLCredentialStorageSetDefaultCredentialForProtectionSpace(storageCF.get(), sessionCredentialCF.get(), protectionSpaceCF.get());
} else {
RetainPtr<CFURLCredentialRef> credentialCF(AdoptCF, createCF(credential));
CFURLCredentialStorageSetDefaultCredentialForProtectionSpace(storageCF.get(), credentialCF.get(), protectionSpaceCF.get());
}
}
}
#endif // USE(CFNETWORK)