My Project
authservice.h
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2009-2010 Nokia Corporation.
5  * Copyright (C) 2012-2016 Canonical Ltd.
6  *
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
28 #ifndef AUTHSERVICE_H
29 #define AUTHSERVICE_H
30 
31 #include <QObject>
32 #include <QStringList>
33 #include <QMap>
34 
35 #include "libsignoncommon.h"
36 #include "identityinfo.h"
37 #include "signonerror.h"
38 
39 namespace SignOn {
40 
49 class SIGNON_EXPORT AuthService: public QObject
50 {
51  Q_OBJECT
52  Q_DISABLE_COPY(AuthService)
53 
54  friend class AuthServiceImpl;
55 
56 public:
62  enum ServiceError {
63  UnknownError = 1,
64  InternalServerError = 2,
65  InternalCommunicationError = 3,
66  PermissionDeniedError = 4,
67  AuthServiceErr = 100, /* Placeholder to rearrange enumeration */
70  InvalidQueryError
71  };
72 
78  typedef enum {
79  AuthMethod = 0,
80  Username,
81  Realm,
82  Caption
83  } IdentityFilterCriteria;
84 
93  {
94  public:
99  IdentityRegExp(const QString &pattern);
100 
106 
111  bool isValid() const;
112 
117  QString pattern() const;
118 
119  private:
120  QString m_pattern;
121  };
122 
123 public:
128  typedef QMap<IdentityFilterCriteria, IdentityRegExp> IdentityFilter;
129 
134  AuthService(QObject *parent = 0);
135 
139  ~AuthService();
140 
150  void queryMethods();
151 
165  void queryMechanisms(const QString &method);
166 
183  void queryIdentities(const IdentityFilter &filter = IdentityFilter());
184 
196  void clear();
197 
198 Q_SIGNALS:
199 
210  void error(const SignOn::Error &err);
211 
218  void methodsAvailable(const QStringList &methods);
219 
227  void mechanismsAvailable(const QString &method, const QStringList &mechanisms);
228 
235  void identities(const QList<SignOn::IdentityInfo> &identityList);
236 
241  void cleared();
242 
243 private:
244  class AuthServiceImpl *impl;
245 };
246 
247 } // namespace SignOn
248 
249 #endif // AUTHSERVICE_H
The class represents a regular expression.
Definition: authservice.h:93
IdentityRegExp(const IdentityRegExp &src)
Copy constructor, creates a copy of src.
QString pattern() const
Returns the pattern of regular expression as string.
bool isValid() const
Returns the validity of regular expression.
IdentityRegExp(const QString &pattern)
Constructor creates an IdentityRegExp, as a specified by pattern.
Represents signon for client application.
Definition: authservice.h:50
QMap< IdentityFilterCriteria, IdentityRegExp > IdentityFilter
Map to hold different filtering options.
Definition: authservice.h:128
void cleared()
Database is cleared and reset to initial state.
ServiceError
Codes for errors that may be reported by AuthService objects.
Definition: authservice.h:62
void mechanismsAvailable(const QString &method, const QStringList &mechanisms)
Emitted when the list of available mechanisms have been obtained from the service.
void identities(const QList< SignOn::IdentityInfo > &identityList)
Lists identities available on the server matching query parameters.
void error(const SignOn::Error &err)
Emitted when an error occurs while using the AuthService.
void methodsAvailable(const QStringList &methods)
Emitted when the list of available authentication methods have been obtained from the service.
definition for Signon error handling.
Definition: signonerror.h:53