Leosac  0.8.0
Open Source Access Control
Credential.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 
21 #include "core/auth/User_odb.h"
23 
24 using namespace Leosac;
25 using namespace Leosac::Cred;
26 
28  : id_(0)
29  , odb_version_(0)
30 {
31 }
32 
34 {
35  return owner_;
36 }
37 
39 {
40  owner_ = ptr;
41 }
42 
43 std::string Credential::alias() const
44 {
45  return alias_;
46 }
47 
49 {
50  return id_;
51 }
52 
53 void Credential::id(const CredentialId &new_id)
54 {
55  id_ = new_id;
56 }
57 
59 {
60  return odb_version_;
61 }
62 
64 {
65  if (owner_)
66  return owner_.object_id();
67  return 0;
68 }
69 
70 void Credential::alias(const std::string &alias)
71 {
73  alias_ = alias;
74 }
75 
76 std::string Credential::description() const
77 {
78  return description_;
79 }
80 
81 void Credential::description(const std::string &str)
82 {
83  description_ = str;
84 }
85 
87 {
88  validity_ = info;
89 }
90 
92 {
93  return validity_;
94 }
95 
96 std::vector<Tools::ScheduleMappingLWPtr> Credential::lazy_schedules_mapping() const
97 {
98  return schedules_mapping_;
99 }
100 
102  const Tools::ScheduleMappingPtr &sched_mapping)
103 {
104  schedules_mapping_.push_back(sched_mapping);
105 }
Leosac::Cred::Credential::owner
virtual Auth::UserLPtr owner() const override
Retrieve the owner of the credential.
Definition: Credential.cpp:33
Leosac::Cred::Credential::description_
std::string description_
Definition: Credential.hpp:82
Leosac::Cred::Credential::odb_version
virtual size_t odb_version() const override
Credentials are "optimistic" object (wrt ODB).
Definition: Credential.cpp:58
Leosac::Cred::Credential::alias_
std::string alias_
Definition: Credential.hpp:80
Leosac::Cred::Credential::id
virtual CredentialId id() const override
Retrieve the identifier of the credential.
Definition: Credential.cpp:48
Leosac::Cred::Credential::lazy_schedules_mapping
virtual std::vector< Tools::ScheduleMappingLWPtr > lazy_schedules_mapping() const override
Retrieve the lazy_weak_ptr to ScheduleMapping that map this credential.
Definition: Credential.cpp:96
Leosac::Cred::Credential::id_
CredentialId id_
Definition: Credential.hpp:76
Leosac::Tools::ScheduleMappingPtr
std::shared_ptr< ScheduleMapping > ScheduleMappingPtr
Definition: ToolsFwd.hpp:41
Credential.hpp
Leosac::Cred::CredentialValidator::validate_alias
static void validate_alias(const std::string &alias)
Definition: CredentialValidator.cpp:32
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Cred::Credential::Credential
Credential()
Definition: Credential.cpp:27
Leosac::Auth::UserLPtr
odb::lazy_shared_ptr< User > UserLPtr
Definition: AuthFwd.hpp:32
Leosac::Cred::Credential::validity
virtual const Auth::ValidityInfo & validity() const override
Retrieve validity status from the credential.
Definition: Credential.cpp:91
Leosac::Cred::Credential::validity_
Auth::ValidityInfo validity_
Definition: Credential.hpp:84
Leosac::Cred::Credential::schedule_mapping_added
void schedule_mapping_added(const Tools::ScheduleMappingPtr &sched_mapping)
The credential has been mapped by a schedule.
Definition: Credential.cpp:101
Leosac::Cred::Credential::owner_
Auth::UserLPtr owner_
Definition: Credential.hpp:78
Leosac::Cred::Credential::alias
virtual std::string alias() const override
An alias for the credential.
Definition: Credential.cpp:43
Leosac::Cred::CredentialId
unsigned long CredentialId
Definition: CredentialFwd.hpp:35
Leosac::Cred
Definition: Credential.hpp:31
Leosac::Auth::UserId
unsigned long UserId
Definition: AuthFwd.hpp:34
Leosac::Cred::Credential::schedules_mapping_
std::vector< Tools::ScheduleMappingLWPtr > schedules_mapping_
Definition: Credential.hpp:87
Leosac::Cred::Credential::odb_version_
size_t odb_version_
Definition: Credential.hpp:90
CredentialValidator.hpp
Leosac::Cred::Credential::owner_id
virtual Auth::UserId owner_id() const override
Returns the id of the owner, or 0 if there is no owner (or the owner has no id).
Definition: Credential.cpp:63
Leosac::Auth::ValidityInfo
A simple class that stores (and can be queried for) the validity of some objects.
Definition: ValidityInfo.hpp:42
Leosac::Cred::Credential::description
virtual std::string description() const override
An optional description / notes for the credential.
Definition: Credential.cpp:76