1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.api.ldap.aci.protectedItem;
21
22
23 import org.apache.directory.api.ldap.aci.ProtectedItem;
24
25
26 /**
27 * Restricts the maximum number of immediate subordinates of the superior
28 * entry to an entry being added or imported. It is examined if the
29 * protected item is an entry, the permission sought is add or import, and
30 * the immediate superior entry is in the same DSA as the entry being added
31 * or imported. Immediate subordinates of the superior entry are counted
32 * without regard to context or access control as though the entry addition
33 * or importing were successful. If the number of subordinates exceeds
34 * maxImmSub, the ACI item is treated as not granting add or import access.
35 */
36 public class MaxImmSubItem extends ProtectedItem
37 {
38 /** The maximum number of allowed subordinates */
39 private final int value;
40
41
42 /**
43 * Creates a new instance.
44 *
45 * @param value The maximum number of immediate subordinates
46 */
47 public MaxImmSubItem( int value )
48 {
49 this.value = value;
50 }
51
52
53 /**
54 * Gets the maximum number of immediate subordinates.
55 *
56 * @return the maximum number of immediate subordinates
57 */
58 public int getValue()
59 {
60 return value;
61 }
62
63
64 /**
65 * {@inheritDoc}
66 */
67 @Override
68 public int hashCode()
69 {
70 int hash = 37;
71 hash = hash * 17 + value;
72 return hash;
73 }
74
75
76 /**
77 * {@inheritDoc}
78 */
79 @Override
80 public boolean equals( Object o )
81 {
82 if ( this == o )
83 {
84 return true;
85 }
86
87 if ( o instanceof MaxImmSubItem )
88 {
89 MaxImmSubItem that = ( MaxImmSubItem ) o;
90 return this.value == that.value;
91 }
92
93 return false;
94 }
95
96
97 /**
98 * {@inheritDoc}
99 */
100 @Override
101 public String toString()
102 {
103 return "maxImmSub " + value;
104 }
105 }