QAuthenticator Class

QAuthenticator クラスは、認証オブジェクトを提供します。詳細...

ヘッダ #include <QAuthenticator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

注意:このクラスの関数はすべてリエントラントです。

パブリック関数

QAuthenticator()
QAuthenticator(const QAuthenticator &other)
~QAuthenticator()
bool isNull() const
QVariant option(const QString &opt) const
QVariantHash options() const
QString password() const
QString realm() const
void setOption(const QString &opt, const QVariant &value)
void setPassword(const QString &password)
void setUser(const QString &user)
QString user() const
bool operator!=(const QAuthenticator &other) const
QAuthenticator &operator=(const QAuthenticator &other)
bool operator==(const QAuthenticator &other) const

詳細説明

QAuthenticator クラスは、通常QNetworkAccessManagerQAbstractSocketauthenticationRequired() とproxyAuthenticationRequired() シグナルで使用されます。このクラスは、認証を必要とするサービスにアクセスする際に、必要な認証情報をソケットに返す方法を提供します。

QAuthenticator は以下の認証方法をサポートしています:

  • ベーシック
  • NTLM バージョン 2
  • ダイジェストMD5
  • SPNEGO/Negotiate

オプション

認証に必要なユーザ名とパスワードの他に、QAuthenticator オブジェクトには追加のオプションを含めることができる。options() 関数を使用すると、 サーバから送られてくるオプションを問い合わせることができます。setOption() 関数を使用すると、 認証処理で使用する送信オプションを設定することができます。受け付けるオプションや指定するオプションは、 認証の種類によって異なります (method() を参照ください)。

以下の表に、既知の受信オプションと、使用可能な送信オプションを示します。サーバはいつでも追加情報を含めることができるからです。しかし、送信オプションの一覧は完全なものであり、 未知のオプションが扱われたりサーバに返されたりすることはありません。

基本

オプション方向タイプ内容
realm着信QString認証のレルムを含む。realm() と同じ。

Basic 認証機構は、送信オプションをサポートしていません。

NTLM バージョン 2

NTLM 認証機構は現在、送受信オプションをサポートしていない。Windows では、user が設定されていない場合、シングルサインオン機能を有効にするために、ドメインユーザ認証情報がローカルシステム上で検索される。

ダイジェスト-MD5

オプション方向タイプ説明
realm着信QString認証のレルムを含む。realm() と同じ。

Digest-MD5 認証の仕組みは、送信オプションをサポートしていません。

SPNEGO/Negotiate

オプション方向タイプ説明
spn発信QStringカスタムSPNを提供する。

この認証メカニズムは現在、着信オプションをサポートしていない。

spn プロパティは、SSPI ライブラリを使用する Windows クライアントで使用される。このプロパティが設定されていない場合は、既定の SPN が使用されます。Windows での既定の SPN はHTTP/<hostname> です。

他のオペレーティング・システムではGSSAPIライブラリが使用される。そのため、KDC がセットアップされ、そこから認証情報を取得できることが期待される。バックエンドは常にHTTPS@<hostname> をSPNとして使用する。

QSslSocketも参照のこと

メンバー関数ドキュメント

QAuthenticator::QAuthenticator()

空の認証オブジェクトを構築します。

QAuthenticator::QAuthenticator(const QAuthenticator &other)

other のコピーを作成する。

[noexcept] QAuthenticator::~QAuthenticator()

オブジェクトを破壊する。

bool QAuthenticator::isNull() const

オブジェクトが初期化されていない場合はtrue を返す。constでないメンバ関数が呼び出された場合、または内容が他の初期化されたQAuthenticator オブジェクトから構築またはコピーされた場合は、false を返します。

QVariant QAuthenticator::option(const QString &opt) const

オプションopt がサーバによって設定されていた場合、それに関連する値を返す。受信オプションの詳細についてはOptions section を参照。オプションopt が見つからない場合は、無効なQVariant が返される。

setOption()、options()、QAuthenticator optionsも参照

QVariantHash QAuthenticator::options() const

サーバーからの応答を解析して、このQAuthenticator オブジェクトに設定されているすべての受信オプションを返します。受信オプションについての詳細はOptions section を参照。

option() およびQAuthenticator optionsも参照

QString QAuthenticator::password() const

認証に使用したパスワードを返します。

setPassword()も参照

QString QAuthenticator::realm() const

認証を必要とするレルムを返します。

void QAuthenticator::setOption(const QString &opt, const QVariant &value)

発信オプションopt を値value に設定する。発信オプションの詳細についてはOptions section を参照のこと。

options()、option()、QAuthenticator optionsも参照

void QAuthenticator::setPassword(const QString &password)

認証に使用するpassword を設定する。

password() およびQNetworkAccessManager::authenticationRequired()も参照

void QAuthenticator::setUser(const QString &user)

認証に使用するuser を設定する。

user() およびQNetworkAccessManager::authenticationRequired()も参照

QString QAuthenticator::user() const

認証に使用したユーザーを返します。

setUser()も参照ください

bool QAuthenticator::operator!=(const QAuthenticator &other) const

この認証子がother と異なる場合はtrue を返し、そうでない場合はfalse を返す。

QAuthenticator &QAuthenticator::operator=(const QAuthenticator &other)

other の内容をこの認証子に割り当てます。

bool QAuthenticator::operator==(const QAuthenticator &other) const

この認証子がother と同一であればtrue を返し、そうでなければfalse を返す。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.