authservice.h
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  * Copyright (C) 2012-2016 Canonical Ltd.
00006  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00028 #ifndef AUTHSERVICE_H
00029 #define AUTHSERVICE_H
00030 
00031 #include <QObject>
00032 #include <QStringList>
00033 #include <QMap>
00034 
00035 #include "libsignoncommon.h"
00036 #include "identityinfo.h"
00037 #include "signonerror.h"
00038 
00039 namespace SignOn {
00040 
00049 class SIGNON_EXPORT AuthService: public QObject
00050 {
00051     Q_OBJECT
00052     Q_DISABLE_COPY(AuthService)
00053 
00054     friend class AuthServiceImpl;
00055 
00056 public:
00062     enum ServiceError {
00063         UnknownError = 1,               
00064         InternalServerError = 2,        
00065         InternalCommunicationError = 3, 
00066         PermissionDeniedError = 4,      
00067         AuthServiceErr = 100,           /* Placeholder to rearrange enumeration */
00068         MethodNotKnownError,            
00069         NotAvailableError,              
00070         InvalidQueryError               
00071     };
00072 
00078     typedef enum {
00079         AuthMethod = 0,
00080         Username,
00081         Realm,
00082         Caption
00083     } IdentityFilterCriteria;
00084 
00092     class IdentityRegExp
00093     {
00094     public:
00099         IdentityRegExp(const QString &pattern);
00100 
00105         IdentityRegExp(const IdentityRegExp &src);
00106 
00111         bool isValid() const;
00112 
00117         QString pattern() const;
00118 
00119     private:
00120         QString m_pattern;
00121     };
00122 
00123 public:
00128     typedef QMap<IdentityFilterCriteria, IdentityRegExp> IdentityFilter;
00129 
00134     AuthService(QObject *parent = 0);
00135 
00139     ~AuthService();
00140 
00150     void queryMethods();
00151 
00165     void queryMechanisms(const QString &method);
00166 
00183     void queryIdentities(const IdentityFilter &filter = IdentityFilter());
00184 
00196     void clear();
00197 
00198 Q_SIGNALS:
00199 
00210     void error(const SignOn::Error &err);
00211 
00218     void methodsAvailable(const QStringList &methods);
00219 
00227     void mechanismsAvailable(const QString &method, const QStringList &mechanisms);
00228 
00235     void identities(const QList<SignOn::IdentityInfo> &identityList);
00236 
00241     void cleared();
00242 
00243 private:
00244     class AuthServiceImpl *impl;
00245 };
00246 
00247 } // namespace SignOn
00248 
00249 #endif // AUTHSERVICE_H