本文整理汇总了C++中ProtectionSpace::realm方法的典型用法代码示例。如果您正苦于以下问题:C++ ProtectionSpace::realm方法的具体用法?C++ ProtectionSpace::realm怎么用?C++ ProtectionSpace::realm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtectionSpace
的用法示例。
在下文中一共展示了ProtectionSpace::realm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool operator==(const ProtectionSpace& a, const ProtectionSpace& b)
{
if (a.host() != b.host())
return false;
if (a.port() != b.port())
return false;
if (a.serverType() != b.serverType())
return false;
// Ignore realm for proxies
if (!a.isProxy() && a.realm() != b.realm())
return false;
if (a.authenticationScheme() != b.authenticationScheme())
return false;
return true;
}
示例2: saveCredentialToPersistentStorage
void NetworkStorageSession::saveCredentialToPersistentStorage(const ProtectionSpace& protectionSpace, const Credential& credential)
{
#if USE(LIBSECRET)
if (m_sessionID.isEphemeral())
return;
if (credential.isEmpty())
return;
const String& realm = protectionSpace.realm();
if (realm.isEmpty())
return;
GRefPtr<GHashTable> attributes = adoptGRef(secret_attributes_build(SECRET_SCHEMA_COMPAT_NETWORK,
"domain", realm.utf8().data(),
"server", protectionSpace.host().utf8().data(),
"port", protectionSpace.port(),
"protocol", schemeFromProtectionSpaceServerType(protectionSpace.serverType()),
"authtype", authTypeFromProtectionSpaceAuthenticationScheme(protectionSpace.authenticationScheme()),
nullptr));
if (!attributes)
return;
g_hash_table_insert(attributes.get(), g_strdup("user"), g_strdup(credential.user().utf8().data()));
CString utf8Password = credential.password().utf8();
GRefPtr<SecretValue> newSecretValue = adoptGRef(secret_value_new(utf8Password.data(), utf8Password.length(), "text/plain"));
secret_service_store(nullptr, SECRET_SCHEMA_COMPAT_NETWORK, attributes.get(), SECRET_COLLECTION_DEFAULT, _("WebKitGTK+ password"),
newSecretValue.get(), nullptr, nullptr, nullptr);
#else
UNUSED_PARAM(protectionSpace);
UNUSED_PARAM(credential);
#endif
}
示例3: createCF
CFURLProtectionSpaceRef createCF(const ProtectionSpace& coreSpace)
{
CFURLProtectionSpaceServerType serverType = kCFURLProtectionSpaceServerHTTP;
switch (coreSpace.serverType()) {
case ProtectionSpaceServerHTTP:
serverType = kCFURLProtectionSpaceServerHTTP;
break;
case ProtectionSpaceServerHTTPS:
serverType = kCFURLProtectionSpaceServerHTTPS;
break;
case ProtectionSpaceServerFTP:
serverType = kCFURLProtectionSpaceServerFTP;
break;
case ProtectionSpaceServerFTPS:
serverType = kCFURLProtectionSpaceServerFTPS;
break;
case ProtectionSpaceProxyHTTP:
serverType = kCFURLProtectionSpaceProxyHTTP;
break;
case ProtectionSpaceProxyHTTPS:
serverType = kCFURLProtectionSpaceProxyHTTPS;
break;
case ProtectionSpaceProxyFTP:
serverType = kCFURLProtectionSpaceProxyFTP;
break;
case ProtectionSpaceProxySOCKS:
serverType = kCFURLProtectionSpaceProxySOCKS;
break;
default:
ASSERT_NOT_REACHED();
}
CFURLProtectionSpaceAuthenticationScheme scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
switch (coreSpace.authenticationScheme()) {
case ProtectionSpaceAuthenticationSchemeDefault:
scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
break;
case ProtectionSpaceAuthenticationSchemeHTTPBasic:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic;
break;
case ProtectionSpaceAuthenticationSchemeHTTPDigest:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest;
break;
case ProtectionSpaceAuthenticationSchemeHTMLForm:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTMLForm;
break;
case ProtectionSpaceAuthenticationSchemeNTLM:
scheme = kCFURLProtectionSpaceAuthenticationSchemeNTLM;
break;
case ProtectionSpaceAuthenticationSchemeNegotiate:
scheme = kCFURLProtectionSpaceAuthenticationSchemeNegotiate;
break;
default:
ASSERT_NOT_REACHED();
}
CFStringRef host = coreSpace.host().createCFString();
CFStringRef realm = coreSpace.realm().createCFString();
CFURLProtectionSpaceRef result = CFURLProtectionSpaceCreate(0, host, coreSpace.port(), serverType, realm, scheme);
CFRelease(host);
CFRelease(realm);
return result;
}
示例4: createCF
CFURLProtectionSpaceRef createCF(const ProtectionSpace& coreSpace)
{
CFURLProtectionSpaceServerType serverType = kCFURLProtectionSpaceServerHTTP;
switch (coreSpace.serverType()) {
case ProtectionSpaceServerHTTP:
serverType = kCFURLProtectionSpaceServerHTTP;
break;
case ProtectionSpaceServerHTTPS:
serverType = kCFURLProtectionSpaceServerHTTPS;
break;
case ProtectionSpaceServerFTP:
serverType = kCFURLProtectionSpaceServerFTP;
break;
case ProtectionSpaceServerFTPS:
serverType = kCFURLProtectionSpaceServerFTPS;
break;
case ProtectionSpaceProxyHTTP:
serverType = kCFURLProtectionSpaceProxyHTTP;
break;
case ProtectionSpaceProxyHTTPS:
serverType = kCFURLProtectionSpaceProxyHTTPS;
break;
case ProtectionSpaceProxyFTP:
serverType = kCFURLProtectionSpaceProxyFTP;
break;
case ProtectionSpaceProxySOCKS:
serverType = kCFURLProtectionSpaceProxySOCKS;
break;
default:
ASSERT_NOT_REACHED();
}
CFURLProtectionSpaceAuthenticationScheme scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
switch (coreSpace.authenticationScheme()) {
case ProtectionSpaceAuthenticationSchemeDefault:
scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
break;
case ProtectionSpaceAuthenticationSchemeHTTPBasic:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic;
break;
case ProtectionSpaceAuthenticationSchemeHTTPDigest:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest;
break;
case ProtectionSpaceAuthenticationSchemeHTMLForm:
scheme = kCFURLProtectionSpaceAuthenticationSchemeHTMLForm;
break;
case ProtectionSpaceAuthenticationSchemeNTLM:
scheme = kCFURLProtectionSpaceAuthenticationSchemeNTLM;
break;
case ProtectionSpaceAuthenticationSchemeNegotiate:
scheme = kCFURLProtectionSpaceAuthenticationSchemeNegotiate;
break;
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
case ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
scheme = kCFURLProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
break;
case ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
scheme = kCFURLProtectionSpaceAuthenticationSchemeClientCertificateRequested;
break;
#endif
default:
ASSERT_NOT_REACHED();
}
CFStringRef host = coreSpace.host().createCFString();
CFStringRef realm = coreSpace.realm().createCFString();
CFURLProtectionSpaceRef result = CFURLProtectionSpaceCreate(0, host, coreSpace.port(), serverType, realm, scheme);
CFRelease(host);
CFRelease(realm);
return result;
}
示例5: getCredentialFromPersistentStorage
void NetworkStorageSession::getCredentialFromPersistentStorage(const ProtectionSpace& protectionSpace, Function<void (Credential&&)> completionHandler)
{
#if USE(LIBSECRET)
if (m_sessionID.isEphemeral()) {
completionHandler({ });
return;
}
const String& realm = protectionSpace.realm();
if (realm.isEmpty()) {
completionHandler({ });
return;
}
GRefPtr<GHashTable> attributes = adoptGRef(secret_attributes_build(SECRET_SCHEMA_COMPAT_NETWORK,
"domain", realm.utf8().data(),
"server", protectionSpace.host().utf8().data(),
"port", protectionSpace.port(),
"protocol", schemeFromProtectionSpaceServerType(protectionSpace.serverType()),
"authtype", authTypeFromProtectionSpaceAuthenticationScheme(protectionSpace.authenticationScheme()),
nullptr));
if (!attributes) {
completionHandler({ });
return;
}
m_persisentStorageCancellable = adoptGRef(g_cancellable_new());
m_persisentStorageCompletionHandler = WTFMove(completionHandler);
secret_service_search(nullptr, SECRET_SCHEMA_COMPAT_NETWORK, attributes.get(),
static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS), m_persisentStorageCancellable.get(),
[](GObject* source, GAsyncResult* result, gpointer userData) {
GUniqueOutPtr<GError> error;
GUniquePtr<GList> elements(secret_service_search_finish(SECRET_SERVICE(source), result, &error.outPtr()));
if (g_error_matches (error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
return;
NetworkStorageSession* session = static_cast<NetworkStorageSession*>(userData);
auto completionHandler = std::exchange(session->m_persisentStorageCompletionHandler, nullptr);
if (error || !elements || !elements->data) {
completionHandler({ });
return;
}
GRefPtr<SecretItem> secretItem = adoptGRef(static_cast<SecretItem*>(elements->data));
GRefPtr<GHashTable> attributes = adoptGRef(secret_item_get_attributes(secretItem.get()));
String user = String::fromUTF8(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "user")));
if (user.isEmpty()) {
completionHandler({ });
return;
}
size_t length;
GRefPtr<SecretValue> secretValue = adoptGRef(secret_item_get_secret(secretItem.get()));
const char* passwordData = secret_value_get(secretValue.get(), &length);
completionHandler(Credential(user, String::fromUTF8(passwordData, length), CredentialPersistencePermanent));
}, this);
#else
UNUSED_PARAM(protectionSpace);
completionHandler({ });
#endif
}