Leosac  0.8.0
Open Source Access Control
UserGroupMembershipEvent.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 "AuditEntry.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
34  public AuditEntry
35 {
36  private:
37  UserGroupMembershipEvent() = default;
38 
39  friend class Factory;
40 
45 
46  public:
47  virtual ~UserGroupMembershipEvent() = default;
48 
49  virtual void target_user(Auth::UserPtr user) override;
50 
51  virtual void target_group(Auth::GroupPtr grp) override;
52 
53  Auth::UserId target_user_id() const override;
54 
55  Auth::GroupId target_group_id() const override;
56 
57  std::string generate_description() const override;
58 
59  private:
60  std::string generate_target_user_description() const;
61  std::string generate_target_group_description() const;
62 
63 #pragma db on_delete(set_null)
65 
66 #pragma db on_delete(set_null)
68 
76 
81 
82  friend class odb::access;
83 };
84 }
85 }
Leosac::Audit::UserGroupMembershipEvent::target_user_id_
Auth::UserId target_user_id_
Set to target_user_->id()
Definition: UserGroupMembershipEvent.hpp:80
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
AuditEntry.hpp
Leosac::Auth::UserLWPtr
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33
Leosac::Audit::UserGroupMembershipEvent::generate_target_group_description
std::string generate_target_group_description() const
Definition: UserGroupMembershipEvent.cpp:110
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::Auth::UserPtr
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::Audit::UserGroupMembershipEvent::generate_description
std::string generate_description() const override
Generate a description for this event.
Definition: UserGroupMembershipEvent.cpp:83
Leosac::Audit::UserGroupMembershipEvent::target_group_
Auth::GroupLWPtr target_group_
Definition: UserGroupMembershipEvent.hpp:64
Leosac::Audit::UserGroupMembershipEvent::target_user_
Auth::UserLWPtr target_user_
Definition: UserGroupMembershipEvent.hpp:67
Leosac::Audit::UserGroupMembershipEvent::target_group
virtual void target_group(Auth::GroupPtr grp) override
The group that gained or lost an user.
Definition: UserGroupMembershipEvent.cpp:35
Leosac::Audit::UserGroupMembershipEvent
Provides an implementation of IUserGroupMembershipEvent.
Definition: UserGroupMembershipEvent.hpp:33
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::UserGroupMembershipEvent::create
static UserGroupMembershipEventPtr create(const DBPtr &database, Auth::GroupPtr target_group, Auth::UserPtr target_user, AuditEntryPtr parent)
Definition: UserGroupMembershipEvent.cpp:42
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Auth::GroupPtr
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::UserGroupMembershipEvent::access
friend class odb::access
Definition: UserGroupMembershipEvent.hpp:82
IUserGroupMembershipEvent.hpp
Leosac::Audit::UserGroupMembershipEvent::~UserGroupMembershipEvent
virtual ~UserGroupMembershipEvent()=default
Leosac::Audit::UserGroupMembershipEvent::target_group_id
Auth::GroupId target_group_id() const override
Definition: UserGroupMembershipEvent.cpp:76
Leosac::Audit::UserGroupMembershipEvent::target_group_id_
Auth::GroupId target_group_id_
This is equals to target_group_->id().
Definition: UserGroupMembershipEvent.hpp:75
Leosac::Audit::UserGroupMembershipEvent::target_user_id
Auth::UserId target_user_id() const override
Definition: UserGroupMembershipEvent.cpp:69
Leosac::Auth::GroupId
unsigned long GroupId
Definition: AuthFwd.hpp:41
Leosac::Audit::UserGroupMembershipEvent::generate_target_user_description
std::string generate_target_user_description() const
Definition: UserGroupMembershipEvent.cpp:98
Leosac::Auth::UserId
unsigned long UserId
Definition: AuthFwd.hpp:34
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Auth::GroupLWPtr
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
Leosac::Audit::UserGroupMembershipEventPtr
std::shared_ptr< UserGroupMembershipEvent > UserGroupMembershipEventPtr
Definition: AuditFwd.hpp:99
Leosac::Audit::IUserGroupMembershipEvent
Interface to audit object that take care of tracking user/group membership change.
Definition: IUserGroupMembershipEvent.hpp:33
Leosac::Audit::UserGroupMembershipEvent::target_user
virtual void target_user(Auth::UserPtr user) override
The user that joined or left the group.
Definition: UserGroupMembershipEvent.cpp:29
Leosac::Audit::UserGroupMembershipEvent::UserGroupMembershipEvent
UserGroupMembershipEvent()=default