| 1 |
/** |
| 2 |
* KQOAuth - An OAuth authentication library for Qt. |
| 3 |
* |
| 4 |
* Author: Johan Paul ([email protected]) |
| 5 |
* http://www.johanpaul.com |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* KQOAuth is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
* along with KQOAuth. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
#ifndef KQOAUTHREQUEST_P_H |
| 21 |
#define KQOAUTHREQUEST_P_H |
| 22 |
#include "kqoauthglobals.h" |
| 23 |
#include "kqoauthrequest.h" |
| 24 |
|
| 25 |
#include <QString> |
| 26 |
#include <QUrl> |
| 27 |
#include <QMap> |
| 28 |
#include <QPair> |
| 29 |
#include <QMultiMap> |
| 30 |
#include <QTimer> |
| 31 |
#include <QHttpMultiPart> |
| 32 |
|
| 33 |
class KQOAuthRequestPrivate { |
| 34 |
|
| 35 |
public: |
| 36 |
KQOAuthRequestPrivate(); |
| 37 |
~KQOAuthRequestPrivate(); |
| 38 |
|
| 39 |
// Helper methods to get the values for the OAuth request parameters. |
| 40 |
QString oauthTimestamp() const; |
| 41 |
QString oauthNonce() const; |
| 42 |
QString oauthSignature(); |
| 43 |
|
| 44 |
// Utility methods for making the request happen. |
| 45 |
void prepareRequest(); |
| 46 |
void signRequest(); |
| 47 |
bool validateRequest() const; |
| 48 |
QByteArray requestBaseString(); |
| 49 |
QByteArray encodedParamaterList(const QList< QPair<QString, QString> > &requestParameters); |
| 50 |
void insertAdditionalParams(); |
| 51 |
void insertPostBody(); |
| 52 |
|
| 53 |
QUrl oauthRequestEndpoint; |
| 54 |
KQOAuthRequest::RequestHttpMethod oauthHttpMethod; |
| 55 |
QString oauthHttpMethodString; |
| 56 |
QString oauthConsumerKey; |
| 57 |
QString oauthConsumerSecretKey; |
| 58 |
QString oauthToken; |
| 59 |
QString oauthTokenSecret; |
| 60 |
QString oauthSignatureMethod; |
| 61 |
KQOAuthRequest::RequestSignatureMethod requestSignatureMethod; |
| 62 |
QUrl oauthCallbackUrl; |
| 63 |
QString oauthVersion; |
| 64 |
QString oauthVerifier; |
| 65 |
|
| 66 |
// These will be generated by the helper methods |
| 67 |
QString oauthTimestamp_; |
| 68 |
QString oauthNonce_; |
| 69 |
|
| 70 |
// User specified additional parameters needed for the request. |
| 71 |
QList< QPair<QString, QString> > additionalParameters; |
| 72 |
|
| 73 |
// The raw POST body content as given to the HTTP request. |
| 74 |
QByteArray postBodyContent; |
| 75 |
|
| 76 |
// Protocol parameters. |
| 77 |
// These parameters are used in the "Authorized" header of the HTTP request. |
| 78 |
QList< QPair<QString, QString> > requestParameters; |
| 79 |
|
| 80 |
KQOAuthRequest::RequestType requestType; |
| 81 |
|
| 82 |
//The Content-Type HTTP header |
| 83 |
QString contentType; |
| 84 |
|
| 85 |
//Raw data to post if type is not url-encoded |
| 86 |
QByteArray postRawData; |
| 87 |
|
| 88 |
//Raw data to post if type is not url-encoded |
| 89 |
QHttpMultiPart* httpMultiPart; |
| 90 |
|
| 91 |
// Timeout for this request in milliseconds. |
| 92 |
int timeout; |
| 93 |
QTimer timer; |
| 94 |
|
| 95 |
bool debugOutput; |
| 96 |
|
| 97 |
}; |
| 98 |
#endif // KQOAUTHREQUEST_P_H |