CredentialTransformData::CredentialTransformData(HTMLFormElement* form) : m_userNameElement(0) , m_passwordElement(0) , m_isValid(false) { ASSERT(form); // Get the document URL KURL fullOrigin(ParsedURLString, form->document()->documentURI()); // Calculate the canonical action URL String action = form->action(); if (action.isNull()) action = ""; // missing 'action' attribute implies current URL KURL fullAction = form->document()->completeURL(action); if (!fullAction.isValid()) return; if (!findPasswordFormFields(form)) return; m_url = stripURL(fullOrigin); m_action = stripURL(fullAction); m_protectionSpace = ProtectionSpace(m_url.host(), m_url.port(), ProtectionSpaceServerHTTP, "Form", ProtectionSpaceAuthenticationSchemeHTMLForm); m_credential = Credential(m_userNameElement->value(), m_passwordElement->value(), CredentialPersistencePermanent); m_isValid = true; }
bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, ProtectionSpace& space) { String host; if (!decoder.decode(host)) return false; int port; if (!decoder.decode(port)) return false; String realm; if (!decoder.decode(realm)) return false; ProtectionSpaceAuthenticationScheme authenticationScheme; if (!decoder.decodeEnum(authenticationScheme)) return false; ProtectionSpaceServerType serverType; if (!decoder.decodeEnum(serverType)) return false; space = ProtectionSpace(host, port, serverType, realm, authenticationScheme); return true; }
Boolean SynchronousResourceHandleCFURLConnectionDelegate::canRespondToProtectionSpace(CFURLProtectionSpaceRef protectionSpace) { ASSERT(m_handle); LOG(Network, "CFNet - SynchronousResourceHandleCFURLConnectionDelegate::canRespondToProtectionSpace(handle=%p (%s)", m_handle, m_handle->firstRequest().url().string().utf8().data()); #if PLATFORM(IOS) ProtectionSpace coreProtectionSpace = ProtectionSpace(protectionSpace); if (coreProtectionSpace.authenticationScheme() == ProtectionSpaceAuthenticationSchemeUnknown) return false; return m_handle->canAuthenticateAgainstProtectionSpace(coreProtectionSpace); #else return m_handle->canAuthenticateAgainstProtectionSpace(core(protectionSpace)); #endif }
static ProtectionSpace protectionSpaceFromSoupAuthAndMessage(SoupAuth* soupAuth, SoupMessage* message) { const char* schemeName = soup_auth_get_scheme_name(soupAuth); ProtectionSpaceAuthenticationScheme scheme; if (!g_ascii_strcasecmp(schemeName, "basic")) scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic; else if (!g_ascii_strcasecmp(schemeName, "digest")) scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest; else if (!g_ascii_strcasecmp(schemeName, "ntlm")) scheme = ProtectionSpaceAuthenticationSchemeNTLM; else if (!g_ascii_strcasecmp(schemeName, "negotiate")) scheme = ProtectionSpaceAuthenticationSchemeNegotiate; else scheme = ProtectionSpaceAuthenticationSchemeUnknown; SoupURI* soupURI = soup_message_get_uri(message); return ProtectionSpace(String::fromUTF8(soup_uri_get_host(soupURI)), soup_uri_get_port(soupURI), protectionSpaceServerTypeFromURI(soupURI, soup_auth_is_for_proxy(soupAuth)), String::fromUTF8(soup_auth_get_realm(soupAuth)), scheme); }
static bool initializeProtectionSpace(const char* protocol, const char* host, int port, const char* scheme, const char* realm, ProtectionSpace& protectionSpace) { ProtectionSpaceServerType serverType; if (!strcasecmp(protocol, "http")) serverType = ProtectionSpaceServerHTTP; else if (!strcasecmp(protocol, "https")) serverType = ProtectionSpaceServerHTTPS; else { // We only care about http and https. return false; } ProtectionSpaceAuthenticationScheme authenticationScheme = ProtectionSpaceAuthenticationSchemeDefault; if (serverType == ProtectionSpaceServerHTTP) { if (!strcasecmp(scheme, "basic")) authenticationScheme = ProtectionSpaceAuthenticationSchemeHTTPBasic; else if (!strcmp(scheme, "digest")) authenticationScheme = ProtectionSpaceAuthenticationSchemeHTTPDigest; } protectionSpace = ProtectionSpace(host, port, serverType, realm, authenticationScheme); return true; }
ProtectionSpace core(CFURLProtectionSpaceRef cfSpace) { ProtectionSpaceServerType serverType = ProtectionSpaceServerHTTP; switch (CFURLProtectionSpaceGetServerType(cfSpace)) { case kCFURLProtectionSpaceServerHTTP: break; case kCFURLProtectionSpaceServerHTTPS: serverType = ProtectionSpaceServerHTTPS; break; case kCFURLProtectionSpaceServerFTP: serverType = ProtectionSpaceServerFTP; break; case kCFURLProtectionSpaceServerFTPS: serverType = ProtectionSpaceServerFTPS; break; case kCFURLProtectionSpaceProxyHTTP: serverType = ProtectionSpaceProxyHTTP; break; case kCFURLProtectionSpaceProxyHTTPS: serverType = ProtectionSpaceProxyHTTPS; break; case kCFURLProtectionSpaceProxyFTP: serverType = ProtectionSpaceProxyFTP; break; case kCFURLProtectionSpaceProxySOCKS: serverType = ProtectionSpaceProxySOCKS; break; default: ASSERT_NOT_REACHED(); } ProtectionSpaceAuthenticationScheme scheme = ProtectionSpaceAuthenticationSchemeDefault; switch (CFURLProtectionSpaceGetAuthenticationScheme(cfSpace)) { case kCFURLProtectionSpaceAuthenticationSchemeDefault: scheme = ProtectionSpaceAuthenticationSchemeDefault; break; case kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic: scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic; break; case kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest: scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest; break; case kCFURLProtectionSpaceAuthenticationSchemeHTMLForm: scheme = ProtectionSpaceAuthenticationSchemeHTMLForm; break; case kCFURLProtectionSpaceAuthenticationSchemeNTLM: scheme = ProtectionSpaceAuthenticationSchemeNTLM; break; case kCFURLProtectionSpaceAuthenticationSchemeNegotiate: scheme = ProtectionSpaceAuthenticationSchemeNegotiate; break; default: scheme = ProtectionSpaceAuthenticationSchemeUnknown; ASSERT_NOT_REACHED(); } return ProtectionSpace(CFURLProtectionSpaceGetHost(cfSpace), CFURLProtectionSpaceGetPort(cfSpace), serverType, CFURLProtectionSpaceGetRealm(cfSpace), scheme); }
ProtectionSpace core(CFURLProtectionSpaceRef cfSpace) { ProtectionSpaceServerType serverType = ProtectionSpaceServerHTTP; switch (CFURLProtectionSpaceGetServerType(cfSpace)) { case kCFURLProtectionSpaceServerHTTP: break; case kCFURLProtectionSpaceServerHTTPS: serverType = ProtectionSpaceServerHTTPS; break; case kCFURLProtectionSpaceServerFTP: serverType = ProtectionSpaceServerFTP; break; case kCFURLProtectionSpaceServerFTPS: serverType = ProtectionSpaceServerFTPS; break; case kCFURLProtectionSpaceProxyHTTP: serverType = ProtectionSpaceProxyHTTP; break; case kCFURLProtectionSpaceProxyHTTPS: serverType = ProtectionSpaceProxyHTTPS; break; case kCFURLProtectionSpaceProxyFTP: serverType = ProtectionSpaceProxyFTP; break; case kCFURLProtectionSpaceProxySOCKS: serverType = ProtectionSpaceProxySOCKS; break; default: ASSERT_NOT_REACHED(); } ProtectionSpaceAuthenticationScheme scheme = ProtectionSpaceAuthenticationSchemeDefault; switch (CFURLProtectionSpaceGetAuthenticationScheme(cfSpace)) { case kCFURLProtectionSpaceAuthenticationSchemeDefault: scheme = ProtectionSpaceAuthenticationSchemeDefault; break; case kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic: scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic; break; case kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest: scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest; break; case kCFURLProtectionSpaceAuthenticationSchemeHTMLForm: scheme = ProtectionSpaceAuthenticationSchemeHTMLForm; break; case kCFURLProtectionSpaceAuthenticationSchemeNTLM: scheme = ProtectionSpaceAuthenticationSchemeNTLM; break; case kCFURLProtectionSpaceAuthenticationSchemeNegotiate: scheme = ProtectionSpaceAuthenticationSchemeNegotiate; break; #if USE(PROTECTION_SPACE_AUTH_CALLBACK) case kCFURLProtectionSpaceAuthenticationSchemeClientCertificateRequested: scheme = ProtectionSpaceAuthenticationSchemeClientCertificateRequested; break; case kCFURLProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested: scheme = ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested; break; #endif default: scheme = ProtectionSpaceAuthenticationSchemeUnknown; ASSERT_NOT_REACHED(); } return ProtectionSpace(CFURLProtectionSpaceGetHost(cfSpace), CFURLProtectionSpaceGetPort(cfSpace), serverType, CFURLProtectionSpaceGetRealm(cfSpace), scheme); }