001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.server.core.partition;
021    
022    
023    import java.util.Set;
024    
025    import org.apache.directory.server.core.entry.ClonedServerEntry;
026    import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
027    import org.apache.directory.server.core.interceptor.context.CompareOperationContext;
028    import org.apache.directory.server.core.interceptor.context.GetMatchedNameOperationContext;
029    import org.apache.directory.server.core.interceptor.context.GetRootDSEOperationContext;
030    import org.apache.directory.server.core.interceptor.context.GetSuffixOperationContext;
031    import org.apache.directory.server.core.interceptor.context.ListSuffixOperationContext;
032    import org.apache.directory.server.core.interceptor.context.RemoveContextPartitionOperationContext;
033    import org.apache.directory.shared.ldap.name.DN;
034    import org.apache.directory.shared.ldap.util.StringTools;
035    
036    
037    /**
038     * A root {@link Partition} that contains all other partitions, and
039     * routes all operations to the child partition that matches to its base suffixes.
040     * It also provides some extended operations such as accessing rootDSE and
041     * listing base suffixes.
042     *
043     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
044     * @version $Rev: 927404 $, $Date: 2010-03-25 14:55:18 +0100 (Do, 25. M??r 2010) $
045     */
046    public interface PartitionNexus extends Partition
047    {
048    
049        /** the admin super user uid */
050        public static final String ADMIN_UID = "admin";
051        
052        /** the initial admin passwd set on startup */
053        public static final String ADMIN_PASSWORD_STRING = "secret";
054        
055        public static final byte[] ADMIN_PASSWORD_BYTES = StringTools.getBytesUtf8( ADMIN_PASSWORD_STRING );
056    
057    
058        /**
059         * Get's the RootDSE entry for the DSA.
060         *
061         * @return the attributes of the RootDSE
062         */
063        public ClonedServerEntry getRootDSE( GetRootDSEOperationContext getRootDSEContext );
064    
065    
066        /**
067         * Add a partition to the server.
068         * 
069         * @param opContext The Add Partition context
070         * @throws Exception If the addition can't be done
071         */
072        public void addContextPartition( AddContextPartitionOperationContext opContext ) throws Exception;
073    
074    
075        /**
076         * Remove a partition from the server.
077         * 
078         * @param opContext The Remove Partition context
079         * @throws Exception If the removal can't be done
080         */
081        public void removeContextPartition( RemoveContextPartitionOperationContext removeContextPartition )
082            throws Exception;
083    
084    
085        /**
086         * @return The ou=system partition 
087         */
088        public Partition getSystemPartition();
089    
090    
091        /**
092         * Get's the partition corresponding to a distinguished name.  This 
093         * name need not be the name of the partition suffix.  When used in 
094         * conjunction with get suffix this can properly find the partition 
095         * associated with the DN.  Make sure to use the normalized DN.
096         * 
097         * @param dn the normalized distinguished name to get a partition for
098         * @return the partition containing the entry represented by the dn
099         * @throws Exception if there is no partition for the dn
100         */
101        public Partition getPartition( DN dn ) throws Exception;
102    
103    
104        /**
105         * Gets the most significant Dn that exists within the server for any Dn.
106         *
107         * @param getMatchedNameContext the context containing the  distinguished name 
108         * to use for matching.
109         * @return a distinguished name representing the matching portion of dn,
110         * as originally provided by the user on creation of the matched entry or 
111         * the empty string distinguished name if no match was found.
112         * @throws Exception if there are any problems
113         */
114        public DN getMatchedName( GetMatchedNameOperationContext matchedNameContext ) throws Exception;
115    
116    
117        /**
118         * Gets the distinguished name of the suffix that would hold an entry with
119         * the supplied distinguished name parameter.  If the DN argument does not
120         * fall under a partition suffix then the empty string Dn is returned.
121         *
122         * @param suffixContext the Context containing normalized distinguished
123         * name to use for finding a suffix.
124         * @return the suffix portion of dn, or the valid empty string Dn if no
125         * naming context was found for dn.
126         * @throws Exception if there are any problems
127         */
128        public DN getSuffix( GetSuffixOperationContext getSuffixContext ) throws Exception;
129    
130    
131        /**
132         * Gets an iteration over the Name suffixes of the partitions managed by this
133         * {@link DefaultPartitionNexus}.
134         *
135         * @return Iteration over ContextPartition suffix names as Names.
136         * @throws Exception if there are any problems
137         */
138        public Set<String> listSuffixes( ListSuffixOperationContext emptyContext ) throws Exception;
139    
140    
141        /**
142         * Adds a set of supportedExtension (OID Strings) to the RootDSE.
143         * 
144         * @param extensionOids a set of OID strings to add to the supportedExtension 
145         * attribute in the RootDSE
146         */
147        public void registerSupportedExtensions( Set<String> extensionOids ) throws Exception;
148    
149    
150        /**
151         * Adds a set of supportedSaslMechanisms (OID Strings) to the RootDSE.
152         * 
153         * @param extensionOids a set of OID strings to add to the supportedSaslMechanisms 
154         * attribute in the RootDSE
155         */
156        public void registerSupportedSaslMechanisms( Set<String> supportedSaslMechanisms ) throws Exception;
157    
158    
159        public boolean compare( CompareOperationContext opContext ) throws Exception;
160    }