AuthenticationManager.h [plain text]
#pragma once
#include "DownloadID.h"
#include "MessageReceiver.h"
#include "NetworkProcessSupplement.h"
#include "WebPageProxyIdentifier.h"
#include "WebProcessSupplement.h"
#include <WebCore/AuthenticationChallenge.h>
#include <WebCore/FrameIdentifier.h>
#include <WebCore/PageIdentifier.h>
#include <wtf/CompletionHandler.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/WeakPtr.h>
namespace IPC {
class MessageSender;
}
namespace PAL {
class SessionID;
}
namespace WebCore {
class AuthenticationChallenge;
class Credential;
struct SecurityOriginData;
}
namespace WebKit {
class Download;
class NetworkProcess;
class WebFrame;
enum class NegotiatedLegacyTLS : bool { No, Yes };
enum class AuthenticationChallengeDisposition : uint8_t;
using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
class AuthenticationManager : public NetworkProcessSupplement, public IPC::MessageReceiver, public CanMakeWeakPtr<AuthenticationManager> {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(AuthenticationManager);
public:
explicit AuthenticationManager(NetworkProcess&);
static const char* supplementName();
void didReceiveAuthenticationChallenge(PAL::SessionID, WebPageProxyIdentifier, const WebCore::SecurityOriginData* , const WebCore::AuthenticationChallenge&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&);
void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
void completeAuthenticationChallenge(uint64_t challengeID, AuthenticationChallengeDisposition, WebCore::Credential&&);
void negotiatedLegacyTLS(WebPageProxyIdentifier) const;
private:
struct Challenge {
WebPageProxyIdentifier pageID;
WebCore::AuthenticationChallenge challenge;
ChallengeCompletionHandler completionHandler;
};
#if HAVE(SEC_KEY_PROXY)
void initializeConnection(IPC::Connection*) final;
#endif
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
uint64_t addChallengeToChallengeMap(Challenge&&);
bool shouldCoalesceChallenge(WebPageProxyIdentifier, uint64_t challengeID, const WebCore::AuthenticationChallenge&) const;
Vector<uint64_t> coalesceChallengesMatching(uint64_t challengeID) const;
NetworkProcess& m_process;
HashMap<uint64_t, Challenge> m_challenges;
};
}