Qt 4.8
qtransportauth_qws_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QTRANSPORTAUTH_QWS_P_H
43 #define QTRANSPORTAUTH_QWS_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qglobal.h>
57 
58 #ifndef QT_NO_SXE
59 
60 #include "qtransportauth_qws.h"
61 #include "qtransportauthdefs_qws.h"
62 #include "qbuffer.h"
63 
64 #include <qmutex.h>
65 #include <qdatetime.h>
66 #include "private/qobject_p.h"
67 
68 #include <QtCore/qcache.h>
69 
71 
72 // Uncomment to generate debug output
73 // #define QTRANSPORTAUTH_DEBUG 1
74 
75 #ifdef QTRANSPORTAUTH_DEBUG
76 void hexstring( char *buf, const unsigned char* key, size_t sz );
77 #endif
78 
79 // proj id for ftok usage in sxe
80 #define SXE_PROJ 10022
81 
87 void *guaranteed_memset(void *v,int c,size_t n);
88 
89 class QUnixSocketMessage;
90 
96 #define QSXE_HEADER_LEN 24
97 
119 #define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
120 #define AUTH_KEY(k) ((unsigned char *)(k))
121 
122 #define AUTH_DATA(x) (unsigned char *)((x) + QSXE_HEADER_LEN)
123 #define AUTH_SPACE(x) ((x) + QSXE_HEADER_LEN)
124 #define QSXE_LEN_IDX 4
125 #define QSXE_KEY_IDX 6
126 #define QSXE_PROG_IDX 22
127 #define QSXE_SEQ_IDX 23
128 
130 {
131  Q_OBJECT
132 public:
135  bool success() const { return m_success; }
136 private:
137  bool m_success;
139 };
140 
142 {
144 public:
147 
148  const unsigned char *getClientKey( unsigned char progId );
149  void invalidateClientKeyCache();
150 
159 };
160 
170 {
171  public:
172  static FAREnforcer *getInstance();
173  void logAuthAttempt( QDateTime time = QDateTime::currentDateTime() );
174  void reset();
175 
176 #ifndef TEST_FAR_ENFORCER
177  private:
178 #endif
179  FAREnforcer();
180  FAREnforcer( const FAREnforcer & );
181  FAREnforcer &operator=(FAREnforcer const & );
182 
183  static const QString FARMessage;
184  static const int minutelyRate;
185  static const QString SxeTag;
186  static const int minute;
187 
189 };
190 
192 
193 #endif // QT_NO_SXE
194 #endif // QTRANSPORTAUTH_QWS_P_H
195 
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QCache< unsigned char, char > keyCache
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
static const QString SxeTag
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QList< QDateTime > authAttempts
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const int minutelyRate
void * guaranteed_memset(void *v, int c, size_t n)
static const QString FARMessage
#define Q_OBJECT
Definition: qobjectdefs.h:157
Enforces the False Authentication Rate.
QHash< QObject *, QIODevice * > buffersByClient
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
static const int minute
int key
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
Definition: qdatetime.cpp:3138
Authenticate a message transport.
The QUnixSocketMessage class encapsulates a message sent or received through the QUnixSocket class...
Definition: qunixsocket_p.h:92