Leosac  0.8.0
Open Source Access Control
UserGroupMembership.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/Group_odb.h"
22 #include "core/auth/User_odb.h"
23 #include "tools/log.hpp"
24 
25 using namespace Leosac;
26 using namespace Leosac::Auth;
27 
29  : id_(0)
30  , version_(0)
31 {
32  timestamp_ = boost::posix_time::second_clock::local_time();
34 }
35 
37 {
38  return id_;
39 }
40 
42 {
43  return user_;
44 }
45 
47 {
48  user_ = user;
49 }
50 
52 {
53  return group_;
54 }
55 
57 {
58  group_ = group;
59 }
60 
61 const boost::posix_time::ptime &UserGroupMembership::timestamp() const
62 {
63  return timestamp_;
64 }
65 
67 {
68  return rank_;
69 }
70 
72 {
73  rank_ = rank;
74 }
75 
77 {
78  return user_.object_id();
79 }
80 
82 {
83  return group_.object_id();
84 }
85 
88 {
89  if (m1->user_id() == 0 || m1->group_id() == 0 || m2->user_id() == 0 ||
90  m2->group_id() == 0)
91  return std::addressof(m1) < std::addressof(m2);
92 
93  return std::make_pair(m1->user_id(), m1->group_id()) <
94  std::make_pair(m2->user_id(), m2->group_id());
95 }
Leosac::Auth::UserGroupMembership::group
const GroupLWPtr group() const
Definition: UserGroupMembership.cpp:51
Leosac::Auth
Holds classes relevant to the Authentication and Authorization subsystem.
Definition: AccessPoint.hpp:27
Leosac::Auth::UserGroupMembership::id_
UserGroupMembershipId id_
Definition: UserGroupMembership.hpp:61
Leosac::Auth::UserGroupMembership::user
const UserLWPtr & user() const
Definition: UserGroupMembership.cpp:41
Leosac::Auth::GroupRank::MEMBER
@ MEMBER
Leosac::Auth::UserGroupMembership::user
void user(UserPtr user)
Definition: UserGroupMembership.cpp:46
Leosac::Auth::UserGroupMembership::group_id
GroupId group_id() const
Definition: UserGroupMembership.cpp:81
Leosac::Auth::UserLWPtr
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33
Leosac::Auth::UserPtr
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Leosac::Auth::UserGroupMembership::timestamp_
boost::posix_time::ptime timestamp_
Definition: UserGroupMembership.hpp:72
Leosac::Auth::UserGroupMembership::user_id
UserId user_id() const
Definition: UserGroupMembership.cpp:76
Leosac::Auth::UserGroupMembership::rank_
GroupRank rank_
Definition: UserGroupMembership.hpp:75
UserGroupMembership.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Auth::UserGroupMembership::UserGroupMembership
UserGroupMembership()
Definition: UserGroupMembership.cpp:28
Leosac::Auth::UserGroupMembershipId
unsigned long UserGroupMembershipId
Definition: AuthFwd.hpp:82
Leosac::Auth::GroupPtr
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Leosac::Auth::UserGroupMembership::timestamp
const boost::posix_time::ptime & timestamp() const
Definition: UserGroupMembership.cpp:61
Leosac::Auth::UserGroupMembershipPtr
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
Definition: AuthFwd.hpp:81
Leosac::Auth::UserGroupMembershipComparator::operator()
bool operator()(const UserGroupMembershipPtr &m1, const UserGroupMembershipPtr &m2) const
Definition: UserGroupMembership.cpp:87
Leosac::Auth::UserGroupMembership::rank
GroupRank rank() const
Definition: UserGroupMembership.cpp:66
Leosac::Auth::GroupId
unsigned long GroupId
Definition: AuthFwd.hpp:41
log.hpp
Leosac::Auth::UserGroupMembership::user_
UserLWPtr user_
Definition: UserGroupMembership.hpp:65
Leosac::Auth::UserGroupMembership::group_
GroupLWPtr group_
Definition: UserGroupMembership.hpp:69
Leosac::Auth::UserId
unsigned long UserId
Definition: AuthFwd.hpp:34
Leosac::Auth::GroupRank
GroupRank
The rank of an User inside a Group.
Definition: AuthFwd.hpp:49
Leosac::Auth::GroupLWPtr
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
Leosac::Auth::UserGroupMembership::id
const UserGroupMembershipId & id() const
Definition: UserGroupMembership.cpp:36