QAuthenticator 类

QAuthenticator 类提供身份验证对象。 更多...

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

注意: 此类的所有函数 可重入 .

公共函数

  QAuthenticator (const QAuthenticator & other )
  QAuthenticator ()
QAuthenticator & operator= (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
bool operator== (const QAuthenticator & other ) const

详细描述

QAuthenticator 类通常用于 authenticationRequired() and proxyAuthenticationRequired() 信号对于 QNetworkAccessManager and QAbstractSocket . The class provides a way to pass back the required authentication information to the socket when accessing services that require authentication.

QAuthenticator 支持下列身份验证方法:

  • 基本
  • NTLM version 2
  • Digest-MD5
  • SPNEGO/Negotiate

选项

In addition to the username and password required for authentication, a QAuthenticator object can also contain additional options. The options () function can be used to query incoming options sent by the server; the setOption () function can be used to set outgoing options, to be processed by the authenticator calculation. The options accepted and provided depend on the authentication type (see method()).

The following tables list known incoming options as well as accepted outgoing options. The list of incoming options is not exhaustive, since servers may include additional information at any time. The list of outgoing options is exhaustive, however, and no unknown options will be treated or sent back to the server.

基本

选项 方向 类型 描述
realm 传入 QString Contains the realm of the authentication, the same as realm ()

The Basic authentication mechanism supports no outgoing options.

NTLM version 2

The NTLM authentication mechanism currently supports no incoming or outgoing options. On Windows, if no user has been set, domain\user credentials will be searched for on the local system to enable Single-Sign-On functionality.

Digest-MD5

选项 方向 类型 描述
realm 传入 QString Contains the realm of the authentication, the same as realm ()

The Digest-MD5 authentication mechanism supports no outgoing options.

SPNEGO/Negotiate

This authentication mechanism currently supports no incoming or outgoing options.

另请参阅 QSslSocket .

成员函数文档编制

QAuthenticator:: QAuthenticator (const QAuthenticator & other )

构造副本为 other .

QAuthenticator:: QAuthenticator ()

构造空身份验证对象。

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

Assigns the contents of other to this authenticator.

QAuthenticator:: ~QAuthenticator ()

销毁对象。

bool QAuthenticator:: isNull () const

返回 true if the object has not been initialized. Returns false if non-const member functions have been called, or the content was constructed or copied from another initialized QAuthenticator 对象。

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

Returns the value related to option opt if it was set by the server. See the Options section for more information on incoming options. If option opt isn't found, an invalid QVariant 将被返回。

另请参阅 setOption (), options (),和 QAuthenticator options .

QVariantHash QAuthenticator:: options () const

Returns all incoming options set in this QAuthenticator object by parsing the server reply. See the Options section for more information on incoming options.

另请参阅 option () 和 QAuthenticator options .

QString QAuthenticator:: password () const

返回用于身份验证的口令。

另请参阅 setPassword ().

QString QAuthenticator:: realm () const

Returns the realm requiring authentication.

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

Sets the outgoing option opt to value value 。见 Options section for more information on outgoing options.

另请参阅 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

Returns the user used for authentication.

另请参阅 setUser ().

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

返回 true 若此身份验证器不同于 other ;否则返回 false .

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

返回 true if this authenticator is identical to other ;否则返回 false .