Cutelyst  2.8.0
roleacl.h
1 /*
2  * Copyright (C) 2014-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of 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 the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef ROLEACL_H
19 #define ROLEACL_H
20 
21 #include <QtCore/QVariantHash>
22 
23 #include <Cutelyst/cutelyst_global.h>
24 #include <Cutelyst/component.h>
25 #include <Cutelyst/context.h>
26 #include <Cutelyst/componentfactory.h>
27 
28 namespace Cutelyst {
29 
30 class RoleACLPrivate;
31 class CUTELYST_PLUGIN_ACTION_ROLEACL_EXPORT RoleACL : public Component
32 {
33  Q_OBJECT
34  Q_DECLARE_PRIVATE(RoleACL)
35 public:
39  explicit RoleACL(QObject *parent = nullptr);
40 
44  virtual Modifiers modifiers() const override;
45 
49  virtual bool init(Application *application, const QVariantHash &args) override;
50 
54  virtual bool aroundExecute(Context *c, QStack<Component *> stack) override;
55 
59  bool canVisit(Context *c) const;
60 
61 protected:
65  virtual bool dispatcherReady(const Dispatcher *dispatcher, Controller *controller) override;
66 };
67 
68 class RoleACLFactory : public QObject, public ComponentFactory
69 {
70  Q_OBJECT
71  Q_PLUGIN_METADATA(IID "org.cutelyst.ComponentFactory" FILE "metadata.json")
72  Q_INTERFACES(Cutelyst::ComponentFactory)
73 public:
74  virtual Component *createComponent(QObject *parent) override { return new RoleACL(parent); }
75 };
76 
77 
78 }
79 
80 #endif // ROLEACL_H
The Cutelyst Component base class.
Definition: component.h:38
The Cutelyst Context.
Definition: context.h:50
Cutelyst Controller base class
Definition: controller.h:102
User role-based authorization action class.
Definition: roleacl.h:31
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
virtual Component * createComponent(QObject *parent) override
Definition: roleacl.h:74
The Cutelyst Application.
Definition: application.h:55
The Cutelyst Dispatcher.
Definition: dispatcher.h:40