Leosac  0.8.0
Open Source Access Control
CredentialEvent.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 
26 
27 namespace Leosac
28 {
29 namespace Audit
30 {
34 #pragma db object polymorphic callback(odb_callback)
35 class CredentialEvent : virtual public ICredentialEvent, public AuditEntry
36 {
37  private:
38  CredentialEvent() = default;
39 
40  friend class Factory;
41 
42  static std::shared_ptr<CredentialEvent> create(const DBPtr &database,
43  Cred::ICredentialPtr target_cred,
45 
46  public:
47  static std::shared_ptr<CredentialEvent> create_empty();
48 
49  virtual ~CredentialEvent() = default;
50 
51  virtual void target(Cred::ICredentialPtr cred) override;
52 
53  virtual void before(const std::string &repr) override;
54 
55  virtual void after(const std::string &repr) override;
56 
57  Cred::CredentialId target_id() const override;
58 
59  const std::string &before() const override;
60 
61  const std::string &after() const override;
62 
63  std::string generate_description() const override;
64 
65  private:
66  std::string generate_target_description() const;
67 
68 #pragma db on_delete(set_null)
70 
72 
76  std::string before_;
77 
81  std::string after_;
82 
83  friend class odb::access;
84 };
85 }
86 }
87 
88 #ifdef ODB_COMPILER
90 #endif
Leosac::Audit::CredentialEvent::generate_target_description
std::string generate_target_description() const
Definition: CredentialEvent.cpp:117
Leosac::Audit::CredentialEvent::target_cred_id_
Cred::CredentialId target_cred_id_
Definition: CredentialEvent.hpp:71
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
AuditEntry.hpp
Leosac::Audit::ICredentialEvent
Audit interface to Credential related events.
Definition: ICredentialEvent.hpp:32
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
ICredential.hpp
Leosac::Audit::CredentialEvent::CredentialEvent
CredentialEvent()=default
Leosac::Audit::CredentialEvent::target
virtual void target(Cred::ICredentialPtr cred) override
Set the user that is targeted by the event.
Definition: CredentialEvent.cpp:55
Leosac::Cred::CredentialLWPtr
odb::lazy_weak_ptr< Credential > CredentialLWPtr
Definition: CredentialFwd.hpp:37
Credential.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::CredentialEvent
Provides an implementation of ICredentialEvent.
Definition: CredentialEvent.hpp:35
Leosac::Audit::CredentialEvent::target_id
Cred::CredentialId target_id() const override
Definition: CredentialEvent.cpp:80
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Audit::CredentialEvent::before_
std::string before_
Optional JSON dump of the object before the event took place.
Definition: CredentialEvent.hpp:76
Leosac::Audit::CredentialEvent::target_
Cred::CredentialLWPtr target_
Definition: CredentialEvent.hpp:69
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::CredentialEvent::before
const std::string & before() const override
Definition: CredentialEvent.cpp:89
Leosac::Audit::CredentialEvent::generate_description
std::string generate_description() const override
Generate a description for this event.
Definition: CredentialEvent.cpp:99
Leosac::Audit::CredentialEvent::after_
std::string after_
Optional JSON dump of the object after the event took place.
Definition: CredentialEvent.hpp:81
Leosac::Cred::ICredentialPtr
std::shared_ptr< ICredential > ICredentialPtr
Definition: CredentialFwd.hpp:32
Leosac::Cred::CredentialId
unsigned long CredentialId
Definition: CredentialFwd.hpp:35
Leosac::Audit::CredentialEvent::access
friend class odb::access
Definition: CredentialEvent.hpp:83
Leosac::Audit::CredentialEvent::create_empty
static std::shared_ptr< CredentialEvent > create_empty()
Definition: CredentialEvent.cpp:131
Leosac::Audit::CredentialEvent::create
static std::shared_ptr< CredentialEvent > create(const DBPtr &database, Cred::ICredentialPtr target_cred, AuditEntryPtr parent)
Definition: CredentialEvent.cpp:33
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
CredentialFwd.hpp
Leosac::Audit::CredentialEvent::~CredentialEvent
virtual ~CredentialEvent()=default
ICredentialEvent.hpp
Leosac::Audit::CredentialEvent::after
const std::string & after() const override
Definition: CredentialEvent.cpp:94