Cutelyst  2.1.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  virtual ~RoleACL();
41 
45  virtual Modifiers modifiers() const override;
46 
50  virtual bool init(Application *application, const QVariantHash &args) override;
51 
55  virtual bool aroundExecute(Context *c, QStack<Component *> stack) override;
56 
60  bool canVisit(Context *c) const;
61 
62 protected:
66  virtual bool dispatcherReady(const Dispatcher *dispatcher, Controller *controller) override;
67 
68  RoleACLPrivate *d_ptr;
69 };
70 
71 class RoleACLFactory : public QObject, public ComponentFactory
72 {
73  Q_OBJECT
74  Q_PLUGIN_METADATA(IID "org.cutelyst.ComponentFactory" FILE "metadata.json")
75  Q_INTERFACES(Cutelyst::ComponentFactory)
76 public:
77  Component *createComponent(QObject *parent) { return new RoleACL(parent); }
78 };
79 
80 
81 }
82 
83 #endif // ROLEACL_H
Component * createComponent(QObject *parent)
Definition: roleacl.h:77
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
The Cutelyst Application.
Definition: application.h:55
The Cutelyst Dispatcher.
Definition: dispatcher.h:40