View Javadoc
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   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   */
38  public class MaxImmSubItem extends ProtectedItem
39  {
40      /** The maximum number of allowed subordinates */
41      private final int value;
42  
43      /**
44       * Creates a new instance.
45       * 
46       * @param value The maximum number of immediate subordinates
47       */
48      public MaxImmSubItem( int value )
49      {
50          this.value = value;
51      }
52  
53  
54      /**
55       * Gets the maximum number of immediate subordinates.
56       *
57       * @return the maximum number of immediate subordinates
58       */
59      public int getValue()
60      {
61          return value;
62      }
63  
64  
65      /**
66       * {@inheritDoc}
67       */
68      @Override
69      public int hashCode()
70      {
71          int hash = 37;
72          hash = hash * 17 + value;
73          
74          return hash;
75      }
76  
77  
78      /**
79       * {@inheritDoc}
80       */
81      @Override
82      public boolean equals( Object o )
83      {
84          if ( this == o )
85          {
86              return true;
87          }
88  
89          if ( o instanceof MaxImmSubItem )
90          {
91              MaxImmSubItem that = ( MaxImmSubItem ) o;
92              
93              return this.value == that.value;
94          }
95  
96          return false;
97      }
98  
99  
100     /**
101      * {@inheritDoc}
102      */
103     @Override
104     public String toString()
105     {
106         return "maxImmSub " + value;
107     }
108 }