Leosac  0.8.0
Open Source Access Control
Credential.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 "LeosacFwd.hpp"
23 #include "core/auth/AuthFwd.hpp"
26 #include "tools/ToolsFwd.hpp"
27 #include <cstddef>
28 
29 namespace Leosac
30 {
31 namespace Cred
32 {
36 #pragma db object polymorphic optimistic
37 class Credential : public virtual ICredential
38 {
39  public:
40  Credential();
41  virtual Auth::UserLPtr owner() const override;
42 
43  virtual void owner(Auth::UserLPtr ptr) override;
44 
45  virtual std::string alias() const override;
46 
47  virtual CredentialId id() const override;
48 
49  virtual void id(const CredentialId &new_id) override;
50 
51  virtual size_t odb_version() const override;
52 
53  virtual Auth::UserId owner_id() const override;
54 
55  virtual void alias(const std::string &id) override;
56 
57  virtual std::string description() const override;
58 
59  virtual void description(const std::string &str) override;
60 
61  virtual void validity(const Auth::ValidityInfo &info) override;
62 
63  virtual const Auth::ValidityInfo &validity() const override;
64 
65  virtual std::vector<Tools::ScheduleMappingLWPtr>
66  lazy_schedules_mapping() const override;
67 
72  void schedule_mapping_added(const Tools::ScheduleMappingPtr &sched_mapping);
73 
74  protected:
75 #pragma db id auto
77 
79 
80  std::string alias_;
81 
82  std::string description_;
83 
85 
86 #pragma db value_not_null inverse(creds_)
87  std::vector<Tools::ScheduleMappingLWPtr> schedules_mapping_;
88 
89 #pragma db version
90  size_t odb_version_;
91 
92  private:
93  friend class odb::access;
94  friend class ::Leosac::TestAccess;
95 };
96 }
97 }
98 
99 #ifdef ODB_COMPILER
100 #include "core/auth/User.hpp"
101 #endif
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
AuthFwd.hpp
LeosacFwd.hpp
User.hpp
ICredential.hpp
Leosac::Cred::Credential::access
friend class odb::access
Definition: Credential.hpp:93
ValidityInfo.hpp
Leosac::Tools::ScheduleMappingPtr
std::shared_ptr< ScheduleMapping > ScheduleMappingPtr
Definition: ToolsFwd.hpp:41
ToolsFwd.hpp
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::ICredential
Base interface for credential objects.
Definition: ICredential.hpp:35
Leosac::Cred::Credential::validity
virtual const Auth::ValidityInfo & validity() const override
Retrieve validity status from the credential.
Definition: Credential.cpp:91
Leosac::Cred::Credential
An ODB enabled credential object.
Definition: Credential.hpp:37
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::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
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