Leosac  0.8.0
Open Source Access Control
BaseAuthSource.cpp
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 #include "BaseAuthSource.hpp"
21 
22 using namespace Leosac::Auth;
23 
24 BaseAuthSource::BaseAuthSource(const std::string &cred_id)
25  : id_(cred_id)
26 {
27 }
28 
30 {
31  subsources_.push_back(source);
32 }
33 
35 {
36  owner_ = user;
37 }
38 
40 {
41  return owner_;
42 }
43 
45 {
46  return profile_;
47 }
48 
49 const std::string &BaseAuthSource::name() const
50 {
51  return source_name_;
52 }
53 
54 void BaseAuthSource::name(std::string const &n)
55 {
56  source_name_ = n;
57 }
58 
59 std::string BaseAuthSource::to_string() const
60 {
61  return "Base auth source";
62 }
63 
64 const std::string &BaseAuthSource::id() const
65 {
66  return id_;
67 }
68 
69 void BaseAuthSource::id(const std::string &cred_id)
70 {
71  id_ = cred_id;
72 }
73 
75 {
76  return validity_;
77 }
78 
80 {
81  validity_ = c;
82 }
83 
85 {
86  profile_ = p;
87 }
Leosac::Auth
Holds classes relevant to the Authentication and Authorization subsystem.
Definition: AccessPoint.hpp:27
BaseAuthSource.hpp
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::validity_
ValidityInfo validity_
Definition: BaseAuthSource.hpp:93
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::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::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