QOAuth 1.0.1
interface.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2009 by Dominik Kapusta <d@ayoy.net> *
3 * *
4 * This library is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Lesser General Public License as *
6 * published by the Free Software Foundation; either version 2.1 of *
7 * the License, or (at your option) any later version. *
8 * *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with this library; if not, write to *
16 * the Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20
28#ifndef INTERFACE_H
29#define INTERFACE_H
30
31#include <QObject>
32
33#include <QtCrypto>
34
35#include "qoauth_global.h"
36#include "qoauth_namespace.h"
37
38class QNetworkAccessManager;
39class QNetworkReply;
40
41namespace QOAuth {
42
43class InterfacePrivate;
44
45class QOAUTH_EXPORT Interface : public QObject
46{
47 Q_OBJECT
48
49 Q_PROPERTY( QByteArray consumerKey READ consumerKey WRITE setConsumerKey )
50 Q_PROPERTY( QByteArray consumerSecret READ consumerSecret WRITE setConsumerSecret )
51 Q_PROPERTY( uint requestTimeout READ requestTimeout WRITE setRequestTimeout )
52 Q_PROPERTY( bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors )
53 Q_PROPERTY( int error READ error )
54
55public:
56 Interface( QObject *parent = 0 );
57 Interface( QNetworkAccessManager *manager, QObject *parent = 0 );
58 virtual ~Interface();
59
60 QNetworkAccessManager* networkAccessManager() const;
61 void setNetworkAccessManager(QNetworkAccessManager *manager);
62
63 bool ignoreSslErrors() const;
64 void setIgnoreSslErrors(bool enabled);
65
66 QByteArray consumerKey() const;
67 void setConsumerKey( const QByteArray &consumerKey );
68
69 QByteArray consumerSecret() const;
70 void setConsumerSecret( const QByteArray &consumerSecret );
71
72 uint requestTimeout() const;
73 void setRequestTimeout( uint msec );
74
75 int error() const;
76
77 bool setRSAPrivateKey( const QString &key,
78 const QCA::SecureArray &passphrase = QCA::SecureArray() );
79 bool setRSAPrivateKeyFromFile( const QString &filename,
80 const QCA::SecureArray &passphrase = QCA::SecureArray() );
81
82
83 ParamMap requestToken( const QString &requestUrl, HttpMethod httpMethod,
84 SignatureMethod signatureMethod = HMAC_SHA1, const ParamMap &params = ParamMap() );
85
86 ParamMap accessToken( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token,
87 const QByteArray &tokenSecret, SignatureMethod signatureMethod = HMAC_SHA1,
88 const ParamMap &params = ParamMap() );
89
90 QByteArray createParametersString( const QString &requestUrl, HttpMethod httpMethod,
91 const QByteArray &token, const QByteArray &tokenSecret,
92 SignatureMethod signatureMethod, const ParamMap &params, ParsingMode mode );
93
94 QByteArray inlineParameters( const ParamMap &params, ParsingMode mode = ParseForRequestContent );
95
96
97protected:
98 InterfacePrivate * const d_ptr;
99
100private:
101 Q_DISABLE_COPY(Interface)
102 Q_DECLARE_PRIVATE(Interface)
103 Q_PRIVATE_SLOT(d_func(), void _q_parseReply(QNetworkReply *reply))
104 Q_PRIVATE_SLOT(d_func(), void _q_setPassphrase(int id, const QCA::Event &event))
105 Q_PRIVATE_SLOT(d_func(), void _q_handleSslErrors( QNetworkReply *reply,
106 const QList<QSslError> &errors ))
107
108#ifdef UNIT_TEST
109 friend class Ut_Interface;
110 friend class Ft_Interface;
111#endif
112};
113
114} // namespace QOAuth
115
116#endif // INTERFACE_H
This class provides means for interaction with network services supporting OAuth authorization scheme...
Definition: interface.h:46
This namespace encapsulates all classes and definitions provided by libqoauth.
Definition: interface.h:41
ParsingMode
This enum type specifies the method of parsing parameters into a parameter string.
Definition: qoauth_namespace.h:106
@ ParseForRequestContent
Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests.
Definition: qoauth_namespace.h:107
QMultiMap< QByteArray, QByteArray > ParamMap
A typedef for the data structure for storing request parameters.
Definition: qoauth_namespace.h:46
SignatureMethod
This enum type describes the signature method used by the request.
Definition: qoauth_namespace.h:59
@ HMAC_SHA1
Sets the signature method to HMAC-SHA1.
Definition: qoauth_namespace.h:60
HttpMethod
This enum type specifies the HTTP method used for creating a Signature Base String and/or sending a r...
Definition: qoauth_namespace.h:80