1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.aci;
21
22
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.Set;
27
28
29
30
31
32
33
34 public abstract class Permission
35 {
36
37 private final Integer precedence;
38
39
40 private final Set<GrantAndDenial> grantsAndDenials;
41
42
43 private final Set<GrantAndDenial> grants;
44
45
46 private final Set<GrantAndDenial> denials;
47
48
49
50
51
52
53
54
55
56
57
58 protected Permission( Integer precedence, Collection<GrantAndDenial> grantsAndDenials )
59 {
60 this.precedence = precedence;
61
62 Set<GrantAndDenial> tmpGrantsAndDenials = new HashSet<GrantAndDenial>();
63 Set<GrantAndDenial> tmpGrants = new HashSet<GrantAndDenial>();
64 Set<GrantAndDenial> tmpDenials = new HashSet<GrantAndDenial>();
65
66 for ( GrantAndDenial gad : grantsAndDenials )
67 {
68 if ( gad.isGrant() )
69 {
70 tmpGrants.add( gad );
71 }
72 else
73 {
74 tmpDenials.add( gad );
75 }
76
77 tmpGrantsAndDenials.add( gad );
78 }
79
80 this.grants = Collections.unmodifiableSet( tmpGrants );
81 this.denials = Collections.unmodifiableSet( tmpDenials );
82 this.grantsAndDenials = Collections.unmodifiableSet( tmpGrantsAndDenials );
83 }
84
85
86
87
88
89
90
91 public Integer getPrecedence()
92 {
93 return precedence;
94 }
95
96
97
98
99
100
101
102 public Set<GrantAndDenial> getGrantsAndDenials()
103 {
104 return grantsAndDenials;
105 }
106
107
108
109
110
111
112
113 public Set<GrantAndDenial> getGrants()
114 {
115 return grants;
116 }
117
118
119
120
121
122
123
124 public Set<GrantAndDenial> getDenials()
125 {
126 return denials;
127 }
128 }