Implements OAuth 1 signature methods. 更多...
头: | #include <QOAuth1Signature> |
qmake: | QT += networkauth |
Since: | Qt 5.8 |
该类在 Qt 5.8 引入。
enum class | HttpRequestMethod { Head, Get, Put, Post, Delete, …, Unknown } |
QOAuth1Signature (QOAuth1Signature && other ) | |
QOAuth1Signature (const QOAuth1Signature & other ) | |
QOAuth1Signature (const QUrl & url , const QString & clientSharedKey , const QString & tokenSecret , QOAuth1Signature::HttpRequestMethod method = HttpRequestMethod::Post, const QVariantMap & 参数 = QVariantMap()) | |
QOAuth1Signature (const QUrl & url = QUrl(), QOAuth1Signature::HttpRequestMethod method = HttpRequestMethod::Post, const QVariantMap & 参数 = QVariantMap()) | |
QOAuth1Signature & | operator= (QOAuth1Signature && other ) |
~QOAuth1Signature () | |
void | addRequestBody (const QUrlQuery & body ) |
QString | clientSharedKey () const |
QByteArray | customMethodString () const |
QByteArray | hmacSha1 () const |
QOAuth1Signature::HttpRequestMethod | httpRequestMethod () const |
void | insert (const QString & key , const QVariant & value ) |
QList<QString> | keys () const |
QVariantMap | 参数 () const |
QByteArray | plainText () const |
QByteArray | rsaSha1 () const |
void | setClientSharedKey (const QString & secret ) |
void | setCustomMethodString (const QByteArray & verb ) |
void | setHttpRequestMethod (QOAuth1Signature::HttpRequestMethod method ) |
void | setParameters (const QVariantMap & 参数 ) |
void | setTokenSecret (const QString & secret ) |
void | setUrl (const QUrl & url ) |
void | swap (QOAuth1Signature & other ) |
QVariant | take (const QString & key ) |
QString | tokenSecret () const |
QUrl | url () const |
QVariant | value (const QString & key , const QVariant & defaultValue = QVariant()) const |
QByteArray | plainText (const QString & clientSharedKey , const QString & tokenSecret ) |
OAuth-authenticated requests can have two sets of credentials: those passed via the "oauth_consumer_key" parameter and those in the "oauth_token" parameter. In order for the server to verify the authenticity of the request and prevent unauthorized access, the client needs to prove that it is the rightful owner of the credentials. This is accomplished using the shared-secret (or RSA key) part of each set of credentials.
OAuth specifies three methods for the client to establish its rightful ownership of the credentials: "HMAC-SHA1", "RSA-SHA1", and "PLAINTEXT". Each generates a "signature" with which the request is "signed"; the first two use a digest of the data signed in generating this, though the last does not. The "RSA-SHA1" method is not supported here; it would use an RSA key rather than the shared-secret associated with the client credentials.
Indicates the HTTP request method.
常量 | 值 | 描述 |
---|---|---|
QOAuth1Signature::HttpRequestMethod::Head
|
1
|
HEAD method. |
QOAuth1Signature::HttpRequestMethod::Get
|
2
|
GET method. |
QOAuth1Signature::HttpRequestMethod::Put
|
3
|
PUT method. |
QOAuth1Signature::HttpRequestMethod::Post
|
4
|
POST method. |
QOAuth1Signature::HttpRequestMethod::Delete
|
5
|
DELETE method. |
QOAuth1Signature::HttpRequestMethod::Custom
|
6
|
Identifies a custom method. |
QOAuth1Signature::HttpRequestMethod::Unknown
|
0
|
Method not set. |
Move-constructs a QOAuth1Signature instance, taking over the private data other was using.
创建副本为 other .
Creates a QOAuth1Signature using
Creates a QOAuth1Signature using
移动赋值运算符。
销毁 QOAuth1Signature .
Adds the request body to the signature. When a POST request body contains arguments they should be included in the signed data.
Returns the user secret used to generate the signature.
另请参阅 setClientSharedKey ().
Returns the custom method string.
该函数在 Qt 5.13 引入。
另请参阅 setCustomMethodString () 和 httpRequestMethod ().
Generates the HMAC-SHA1 signature using the client shared secret and, where available, token secret.
Returns the request method.
另请参阅 setHttpRequestMethod ().
Inserts a new pair key , value into the signature. When a POST request body contains arguments they should be included in the signed data.
Retrieves the list of keys of parameters included in the signed data.
Returns the parameters.
另请参阅 setParameters ().
Generates the PLAINTEXT signature.
[static]
QByteArray
QOAuth1Signature::
plainText
(const
QString
&
clientSharedKey
, const
QString
&
tokenSecret
)
Generates a PLAINTEXT signature from the client secret clientSharedKey and the token secret tokenSecret .
Generates the RSA-SHA1 signature.
注意: Currently this method is not supported.
设置 secret as the user secret used to generate the signature.
另请参阅 clientSharedKey ().
Sets a custom request method. Will set the httpRequestMethod to QOAuth1Signature::HttpRequestMethod::Custom and store the verb to use it for the generation of the signature.
注意: Using this method is required when working with custom verbs. Setting only the request method will fail, as the signure needs to know the actual verb.
该函数在 Qt 5.13 引入。
另请参阅 customMethodString (), setHttpRequestMethod (),和 HttpRequestMethod .
Sets the request method .
另请参阅 httpRequestMethod ().
设置 参数 .
另请参阅 参数 ().
设置 secret as the negotiated secret used to generate the signature.
另请参阅 tokenSecret ().
Sets the URL to url .
另请参阅 url ().
Swaps signature other with this signature. This operation is very fast and never fails.
移除 key and any associated value from the signed data.
Returns the negotiated secret used to generate the signature.
另请参阅 setTokenSecret ().
Returns the URL.
另请参阅 setUrl ().
Returns the value associated with key , if present in the signed data, otherwise defaultValue .