Leosac  0.8.0
Open Source Access Control
BaseAuthSource.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 
24 #include <memory>
25 #include <vector>
26 
27 namespace Leosac
28 {
29 namespace Auth
30 {
31 class BaseAuthSource;
32 using BaseAuthSourcePtr = std::shared_ptr<BaseAuthSource>;
33 
35 {
36  public:
38 
39  BaseAuthSource(const std::string &id = "");
40  virtual ~BaseAuthSource() = default;
41  virtual void addAuthSource(IAuthenticationSourcePtr source) override;
42 
43  virtual void owner(UserPtr user) override;
44 
45  virtual UserPtr owner() const override;
46 
51  virtual IAccessProfilePtr profile() const override;
52 
53  virtual void profile(IAccessProfilePtr p) override;
54 
55  virtual const std::string &name() const override;
56 
60  void name(const std::string &n);
61 
62  virtual std::string to_string() const override;
63 
64  virtual const std::string &id() const override;
65 
66  void id(const std::string &cred_id) override;
67 
68  virtual const ValidityInfo &validity() const override;
69 
70  virtual void validity(const ValidityInfo &c) override;
71 
72  protected:
77 
81  std::vector<IAuthenticationSourcePtr> subsources_;
82 
86  std::string source_name_;
87 
91  std::string id_;
92 
94 
96 };
97 }
98 }
Leosac::Auth::BaseAuthSource::validity
virtual const ValidityInfo & validity() const override
Get the object that store info about the credential's validity.
Definition: BaseAuthSource.cpp:74
Leosac::Auth::BaseAuthSource::id_
std::string id_
Credentials ID.
Definition: BaseAuthSource.hpp:91
Leosac::Auth::UserPtr
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Leosac::Auth::BaseAuthSource::owner_
UserPtr owner_
Which user this auth source maps to.
Definition: BaseAuthSource.hpp:76
Leosac::Auth::BaseAuthSource::BaseAuthSource
BaseAuthSource(const std::string &id="")
Definition: BaseAuthSource.cpp:24
Leosac::Auth::IAccessProfilePtr
std::shared_ptr< IAccessProfile > IAccessProfilePtr
Definition: AuthFwd.hpp:88
Leosac::Auth::BaseAuthSource
Definition: BaseAuthSource.hpp:34
ValidityInfo.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Auth::BaseAuthSource::validity_
ValidityInfo validity_
Definition: BaseAuthSource.hpp:93
Leosac::Auth::BaseAuthSource::MAKE_VISITABLE
MAKE_VISITABLE()
Leosac::Auth::IAuthenticationSourcePtr
std::shared_ptr< IAuthenticationSource > IAuthenticationSourcePtr
Definition: AuthFwd.hpp:96
Leosac::Auth::BaseAuthSource::subsources_
std::vector< IAuthenticationSourcePtr > subsources_
Underlying auth source.
Definition: BaseAuthSource.hpp:81
Leosac::Auth::BaseAuthSource::owner
virtual UserPtr owner() const override
Retrieve the user that map to this source.
Definition: BaseAuthSource.cpp:39
Leosac::Auth::BaseAuthSource::source_name_
std::string source_name_
Name of the source (generally the module / device that sent it)
Definition: BaseAuthSource.hpp:86
Leosac::Auth::BaseAuthSource::~BaseAuthSource
virtual ~BaseAuthSource()=default
Leosac::Auth::BaseAuthSource::profile
virtual IAccessProfilePtr profile() const override
This implementation simply return the profile associated with the credential, or null if not availabl...
Definition: BaseAuthSource.cpp:44
Leosac::Auth::IAuthenticationSource
An Auth source is a card id, a pin code, a fingerprint, etc...
Definition: IAuthenticationSource.hpp:40
Leosac::Auth::BaseAuthSourcePtr
std::shared_ptr< BaseAuthSource > BaseAuthSourcePtr
Definition: AuthFwd.hpp:99
Leosac::Auth::BaseAuthSource::name
virtual const std::string & name() const override
Return the name of the source.
Definition: BaseAuthSource.cpp:49
Leosac::Auth::BaseAuthSource::id
virtual const std::string & id() const override
Returns the ID of the credentials.
Definition: BaseAuthSource.cpp:64
Leosac::Auth::BaseAuthSource::profile_
IAccessProfilePtr profile_
Definition: BaseAuthSource.hpp:95
Leosac::Auth::BaseAuthSource::addAuthSource
virtual void addAuthSource(IAuthenticationSourcePtr source) override
Adds a new authentication sources as a subsource of this one.
Definition: BaseAuthSource.cpp:29
Leosac::Auth::BaseAuthSource::to_string
virtual std::string to_string() const override
Returns a string representation of the authentication source content.
Definition: BaseAuthSource.cpp:59
Leosac::Auth::ValidityInfo
A simple class that stores (and can be queried for) the validity of some objects.
Definition: ValidityInfo.hpp:42
IAuthenticationSource.hpp