QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsaccesscontrol.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsaccesscontrol.h
3  ------------------
4  begin : 22-05-2015
5  copyright : (C) 2008 by Stéphane Brunner
6  email : stephane dot brunner at camptocamp dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSACCESSCONTROL_H
19 #define QGSACCESSCONTROL_H
20 
22 #include "qgsaccesscontrolfilter.h"
23 
24 #include "qgis_server.h"
25 #include "qgis_sip.h"
26 
27 SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
28 
29 
30 
36 class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
37 {
38 #ifdef SIP_RUN
39 #include "qgsaccesscontrolfilter.h"
40 #endif
41 
42  public:
45  {
46  mPluginsAccessControls = new QgsAccessControlFilterMap();
47  mResolved = false;
48  }
49 
52  {
53  mPluginsAccessControls = new QgsAccessControlFilterMap( *copy.mPluginsAccessControls );
54  mFilterFeaturesExpressions = copy.mFilterFeaturesExpressions;
55  mResolved = copy.mResolved;
56  }
57 
58 
59  ~QgsAccessControl() override
60  {
61  delete mPluginsAccessControls;
62  }
63 
65  QgsAccessControl &operator= ( const QgsAccessControl &other )
66  {
67  if ( this != &other )
68  {
69  delete mPluginsAccessControls;
70  mPluginsAccessControls = new QgsAccessControlFilterMap( *other.mPluginsAccessControls );
71  mFilterFeaturesExpressions = other.mFilterFeaturesExpressions;
72  mResolved = other.mResolved;
73  }
74  return *this;
75  }
76 
81  void resolveFilterFeatures( const QList<QgsMapLayer *> &layers );
82 
88  void filterFeatures( const QgsVectorLayer *layer, QgsFeatureRequest &filterFeatures ) const override;
89 
94  QgsFeatureFilterProvider *clone() const override SIP_FACTORY;
95 
101  QString extraSubsetString( const QgsVectorLayer *layer ) const;
102 
108  bool layerReadPermission( const QgsMapLayer *layer ) const;
109 
115  bool layerInsertPermission( const QgsVectorLayer *layer ) const;
116 
122  bool layerUpdatePermission( const QgsVectorLayer *layer ) const;
123 
129  bool layerDeletePermission( const QgsVectorLayer *layer ) const;
130 
137  QStringList layerAttributes( const QgsVectorLayer *layer, const QStringList &attributes ) const;
138 
145  bool allowToEdit( const QgsVectorLayer *layer, const QgsFeature &feature ) const;
146 
152  bool fillCacheKey( QStringList &cacheKey ) const;
153 
159  void registerAccessControl( QgsAccessControlFilter *accessControl, int priority = 0 );
160 
161  private:
162  QString resolveFilterFeatures( const QgsVectorLayer *layer ) const;
163 
165  QgsAccessControlFilterMap *mPluginsAccessControls = nullptr;
166 
167  QMap<QString, QString> mFilterFeaturesExpressions;
168  bool mResolved;
169 };
170 
171 #endif
QgsAccessControl::QgsAccessControl
QgsAccessControl(const QgsAccessControl &copy)
Constructor.
Definition: qgsaccesscontrol.h:51
qgsaccesscontrolfilter.h
QgsAccessControlFilterMap
QMultiMap< int, QgsAccessControlFilter * > QgsAccessControlFilterMap
The registry definition.
Definition: qgsaccesscontrolfilter.h:127
qgsfeaturefilterprovider.h
QgsAccessControl::QgsAccessControl
QgsAccessControl()
Constructor.
Definition: qgsaccesscontrol.h:44
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
QgsAccessControlFilter
Class defining access control interface for QGIS Server plugins.
Definition: qgsaccesscontrolfilter.h:50
qgis_sip.h
QgsAccessControl
A helper class that centralizes restrictions given by all the access control filter plugins.
Definition: qgsaccesscontrol.h:36
SIP_IF_MODULE
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsFeatureFilterProvider
Definition: qgsfeaturefilterprovider.h:40
QgsFeature
Definition: qgsfeature.h:55
QgsAccessControl::~QgsAccessControl
~QgsAccessControl() override
Definition: qgsaccesscontrol.h:59