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.server.core.api.partition;
21  
22  
23  import java.util.Set;
24  
25  import org.apache.directory.api.ldap.model.entry.Entry;
26  import org.apache.directory.api.ldap.model.entry.Value;
27  import org.apache.directory.api.ldap.model.exception.LdapException;
28  import org.apache.directory.api.ldap.model.name.Dn;
29  import org.apache.directory.api.ldap.model.schema.AttributeType;
30  import org.apache.directory.api.util.Strings;
31  import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
32  import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext;
33  
34  
35  /**
36   * A root {@link Partition} that contains all other partitions, and
37   * routes all operations to the child partition that matches to its base suffixes.
38   * It also provides some extended operations such as accessing rootDSE and
39   * listing base suffixes.
40   *
41   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
42   */
43  public interface PartitionNexus extends Partition
44  {
45      /** the admin super user uid */
46      String ADMIN_UID = "admin";
47  
48      /** the initial admin passwd set on startup */
49      String ADMIN_PASSWORD_STRING = "secret";
50  
51      byte[] ADMIN_PASSWORD_BYTES = Strings.getBytesUtf8( ADMIN_PASSWORD_STRING );
52      
53  
54      /**
55       * Get's the RootDSE entry for the DSA.
56       *
57       * @param getRootDseContext The operation context
58       * @return the attributes of the RootDSE
59       */
60      Entry getRootDse( GetRootDseOperationContext getRootDseContext );
61  
62  
63      /**
64       * Get's the RootDSE value associated with an AttributeType
65       * 
66       * @param attributeType The attribute type for which we want a value
67       * @return the values associated with the given attributeType
68       */
69      Value getRootDseValue( AttributeType attributeType );
70  
71  
72      /**
73       * Add a partition to the server.
74       * 
75       * @param partition The Partition to add
76       * @throws LdapException If the addition can't be done
77       */
78      void addContextPartition( Partition partition ) throws LdapException;
79  
80  
81      /**
82       * Remove a partition from the server.
83       * 
84       * @param partitionDn the partition Dn
85       * @throws LdapException If the removal can't be done
86       */
87      void removeContextPartition( String partitionDn ) throws LdapException;
88  
89  
90      /**
91       * Get's the partition corresponding to a distinguished name.  This
92       * name need not be the name of the partition suffix.  When used in
93       * conjunction with get suffix this can properly find the partition
94       * associated with the Dn.  Make sure to use the normalized Dn.
95       * 
96       * @param dn the normalized distinguished name to get a partition for
97       * @return the partition containing the entry represented by the dn
98       * @throws LdapException if there is no partition for the dn
99       */
100     Partition getPartition( Dn dn ) throws LdapException;
101 
102 
103     /**
104      * Finds the distinguished name of the suffix that would hold an entry with
105      * the supplied distinguished name parameter.  If the Dn argument does not
106      * fall under a partition suffix then the empty string Dn is returned.
107      *
108      * @param dn The Dn we want to find the suffix from
109      * @return the suffix portion of dn, or the valid empty string Dn if no
110      * naming context was found for dn.
111      * @throws LdapException If we can't get the suffix Dn
112      */
113     Dn getSuffixDn( Dn dn ) throws LdapException;
114 
115 
116     /**
117      * Gets an iteration over the Name suffixes of the partitions managed by this
118      * DefaultPartitionNexus.
119      *
120      * @return Iteration over ContextPartition suffix names as Names.
121      * @throws LdapException if there are any problems
122      */
123     Set<String> listSuffixes() throws LdapException;
124 
125 
126     /**
127      * Adds a set of supportedExtension (OID Strings) to the RootDSE.
128      * 
129      * @param extensionOids a set of OID strings to add to the supportedExtension
130      * attribute in the RootDSE
131      * @throws LdapException If we cannot register the extensions
132      */
133     void registerSupportedExtensions( Set<String> extensionOids ) throws LdapException;
134 
135 
136     /**
137      * Adds a set of supportedSaslMechanisms (OID Strings) to the RootDSE.
138      * 
139      * @param supportedSaslMechanisms a set of OID strings to add to the supportedSaslMechanisms
140      * attribute in the RootDSE
141      * @throws LdapException If we cannot fetch the supported SASL mechanism
142      */
143     void registerSupportedSaslMechanisms( Set<String> supportedSaslMechanisms ) throws LdapException;
144 
145 
146     /**
147      * The Compare operation
148      *
149      * @param compareContext The context for the compare operation
150      * @return true if the compare operation was successful, false otherwise
151      * @throws LdapException If we had an issue during the operation
152      */
153     boolean compare( CompareOperationContext compareContext ) throws LdapException;
154 }