Statistics
| Branch: | Tag: | Revision:

one / include / AclRule.h @ bfaabf35

History | View | Annotate | Download (2.66 KB)

1
/* -------------------------------------------------------------------------- */
2
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             */
3
/*                                                                            */
4
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
5
/* not use this file except in compliance with the License. You may obtain    */
6
/* a copy of the License at                                                   */
7
/*                                                                            */
8
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
9
/*                                                                            */
10
/* Unless required by applicable law or agreed to in writing, software        */
11
/* distributed under the License is distributed on an "AS IS" BASIS,          */
12
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
13
/* See the License for the specific language governing permissions and        */
14
/* limitations under the License.                                             */
15
/* -------------------------------------------------------------------------- */
16

    
17
#ifndef ACL_RULE_H_
18
#define ACL_RULE_H_
19

    
20
#include <set>
21

    
22
#include "ObjectSQL.h"
23

    
24
using namespace std;
25

    
26
class AclRule
27
{
28
public:
29

    
30
    static const long long INDIVIDUAL_ID;
31
    static const long long GROUP_ID;
32
    static const long long ALL_ID;
33

    
34
    AclRule(long long _user, long long _resource, long long _rights):
35
        user(_user), resource(_resource), rights(_rights)
36
    {};
37

    
38
    AclRule& operator=(AclRule const& o)
39
    {
40
        user = o.user;
41
        resource = o.resource;
42
        rights = o.rights;
43

    
44
        return *this;
45
    };
46

    
47
    bool operator ==(const AclRule& other) const
48
    {
49
        return (user == other.user &&
50
                resource == other.resource &&
51
                rights == other.rights);
52
    };
53

    
54
    bool operator!=(const AclRule& other) const
55
    {
56
        return !(*this == other);
57
    };
58

    
59
    bool operator <(const AclRule& other) const
60
    {
61
        return user < other.user;
62
    };
63

    
64
    string to_str() const;
65

    
66
    string& to_xml(string& xml) const;
67

    
68
    int user_id() const
69
    {
70
        return user;
71
    };
72

    
73
    long long user_code() const
74
    {
75
        return user & 0xFFFFFFFF00000000LL;
76
    };
77

    
78
    int resource_id() const
79
    {
80
        return resource;
81
    };
82

    
83
    long long resource_code() const
84
    {
85
        return resource & 0xFFFFFFFF00000000LL;
86
    };
87

    
88
private:
89

    
90
    friend class AclManager;
91

    
92
    /**
93
     *
94
     */
95
    long long user;
96

    
97
    /**
98
     *
99
     */
100
    long long resource;
101

    
102
    /**
103
     *
104
     */
105
    long long rights;
106
};
107

    
108
#endif /*ACL_RULE_H*/
109