Leosac  0.8.0
Open Source Access Control
SimpleAccessProfile.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "core/auth/AuthFwd.hpp"
23 #include "core/auth/AuthTarget.hpp"
26 #include <chrono>
27 #include <map>
28 #include <memory>
29 #include <vector>
30 
31 namespace Leosac
32 {
33 namespace Auth
34 {
35 
40 {
41  public:
42  virtual bool isAccessGranted(const std::chrono::system_clock::time_point &date,
43  AuthTargetPtr target) override;
44 
48  virtual void addAccessSchedule(AuthTargetPtr target,
49  const Tools::IScheduleCPtr &sched);
50 
51  virtual const std::vector<Tools::IScheduleCPtr> &defaultSchedules() const;
52 
56  virtual const std::map<std::string, std::vector<Tools::IScheduleCPtr>> &
57  schedules() const;
58 
62  virtual size_t schedule_count() const override;
63 
64  protected:
68  std::map<std::string, std::vector<Tools::IScheduleCPtr>> schedules_;
69 
73  std::vector<Tools::IScheduleCPtr> default_schedule_;
74 };
75 }
76 }
AuthTarget.hpp
AuthFwd.hpp
Leosac::Auth::SimpleAccessProfile::schedules_
std::map< std::string, std::vector< Tools::IScheduleCPtr > > schedules_
Map target name to target's schedules.
Definition: SimpleAccessProfile.hpp:68
Leosac::Auth::SimpleAccessProfile::defaultSchedules
virtual const std::vector< Tools::IScheduleCPtr > & defaultSchedules() const
Definition: SimpleAccessProfile.cpp:71
Leosac::Auth::SimpleAccessProfile::default_schedule_
std::vector< Tools::IScheduleCPtr > default_schedule_
Schedule for default target.
Definition: SimpleAccessProfile.hpp:73
Leosac::Auth::AuthTargetPtr
std::shared_ptr< AuthTarget > AuthTargetPtr
Definition: AuthFwd.hpp:93
Leosac::Auth::SimpleAccessProfile::addAccessSchedule
virtual void addAccessSchedule(AuthTargetPtr target, const Tools::IScheduleCPtr &sched)
Adds a schedule where access to a given target is allowed.
Definition: SimpleAccessProfile.cpp:55
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Tools::IScheduleCPtr
std::shared_ptr< const ISchedule > IScheduleCPtr
Definition: ToolsFwd.hpp:38
Leosac::Auth::SimpleAccessProfile
Concrete implementation of a simple access control class.
Definition: SimpleAccessProfile.hpp:39
Leosac::Auth::SimpleAccessProfile::schedules
virtual const std::map< std::string, std::vector< Tools::IScheduleCPtr > > & schedules() const
Returns the map of schedule for each target (except the default target)
Definition: SimpleAccessProfile.cpp:65
Leosac::Auth::SimpleAccessProfile::schedule_count
virtual size_t schedule_count() const override
Returns the number of schedule associated with the profile.
Definition: SimpleAccessProfile.cpp:76
Leosac::Auth::SimpleAccessProfile::isAccessGranted
virtual bool isAccessGranted(const std::chrono::system_clock::time_point &date, AuthTargetPtr target) override
Does the profile allow access to the user.
Definition: SimpleAccessProfile.cpp:27
Leosac::Auth::IAccessProfile
Holds information about access permission.
Definition: IAccessProfile.hpp:36
IAccessProfile.hpp
SingleTimeFrame.hpp