1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.partition;
21
22
23 import java.util.HashMap;
24 import java.util.Iterator;
25 import java.util.Map;
26 import java.util.Set;
27
28 import javax.naming.InvalidNameException;
29 import javax.naming.ldap.LdapContext;
30
31 import org.apache.directory.server.constants.ServerDNConstants;
32 import org.apache.directory.server.core.entry.ClonedServerEntry;
33 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
34 import org.apache.directory.server.core.interceptor.context.CompareOperationContext;
35 import org.apache.directory.server.core.interceptor.context.GetMatchedNameOperationContext;
36 import org.apache.directory.server.core.interceptor.context.GetRootDSEOperationContext;
37 import org.apache.directory.server.core.interceptor.context.GetSuffixOperationContext;
38 import org.apache.directory.server.core.interceptor.context.ListSuffixOperationContext;
39 import org.apache.directory.server.core.interceptor.context.RemoveContextPartitionOperationContext;
40 import org.apache.directory.shared.ldap.constants.SchemaConstants;
41 import org.apache.directory.shared.ldap.name.LdapDN;
42 import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
43 import org.apache.directory.shared.ldap.schema.OidNormalizer;
44 import org.apache.directory.shared.ldap.util.StringTools;
45
46
47
48
49
50
51
52
53
54
55
56 public abstract class PartitionNexus implements Partition
57 {
58
59 public static final String ADMIN_UID = "admin";
60
61
62 public static final String ADMIN_PASSWORD_STRING = "secret";
63 public static final byte[] ADMIN_PASSWORD_BYTES = StringTools.getBytesUtf8( ADMIN_PASSWORD_STRING );
64
65
66
67
68
69
70
71 public static final LdapDN getAdminName()
72 {
73 LdapDN adminDn = null;
74
75 try
76 {
77 adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN );
78 }
79 catch ( Exception e )
80 {
81 throw new InternalError();
82 }
83
84 try
85 {
86 Map<String, OidNormalizer> oidsMap = new HashMap<String, OidNormalizer>();
87
88 oidsMap.put( SchemaConstants.UID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
89 oidsMap.put( SchemaConstants.USER_ID_AT, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
90 oidsMap.put( SchemaConstants.UID_AT_OID, new OidNormalizer( SchemaConstants.UID_AT_OID, new NoOpNormalizer() ) );
91
92 oidsMap.put( SchemaConstants.OU_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer() ) );
93 oidsMap.put( SchemaConstants.ORGANIZATIONAL_UNIT_NAME_AT, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer() ) );
94 oidsMap.put( SchemaConstants.OU_AT_OID, new OidNormalizer( SchemaConstants.OU_AT_OID, new NoOpNormalizer() ) );
95
96 adminDn.normalize( oidsMap );
97 }
98 catch ( InvalidNameException ine )
99 {
100
101 }
102 catch ( Exception ne )
103 {
104
105 }
106
107 return adminDn;
108 }
109
110
111
112
113
114
115
116 public static final LdapDN getGroupsBaseName()
117 {
118 LdapDN groupsBaseDn = null;
119
120 try
121 {
122 groupsBaseDn = new LdapDN( ServerDNConstants.GROUPS_SYSTEM_DN );
123 }
124 catch ( Exception e )
125 {
126 throw new InternalError();
127 }
128
129 return groupsBaseDn;
130 }
131
132
133
134
135
136
137
138 public static final LdapDN getUsersBaseName()
139 {
140 LdapDN usersBaseDn = null;
141
142 try
143 {
144 usersBaseDn = new LdapDN( ServerDNConstants.USERS_SYSTEM_DN );
145 }
146 catch ( Exception e )
147 {
148 throw new InternalError();
149 }
150
151 return usersBaseDn;
152 }
153
154
155
156
157
158
159
160
161 public abstract LdapContext getLdapContext();
162
163
164
165
166
167
168
169 public abstract ClonedServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception;
170
171
172
173
174
175
176
177
178
179
180
181 public abstract boolean compare( CompareOperationContext compareContext ) throws Exception;
182
183
184 public abstract void addContextPartition( AddContextPartitionOperationContext opContext ) throws Exception;
185
186
187 public abstract void removeContextPartition( RemoveContextPartitionOperationContext opContext ) throws Exception;
188
189
190 public abstract Partition getSystemPartition();
191
192
193
194
195
196
197
198
199
200
201
202
203 public abstract Partition getPartition( LdapDN dn ) throws Exception;
204
205
206
207
208
209
210
211
212
213
214
215
216 public abstract LdapDN getMatchedName ( GetMatchedNameOperationContext getMatchedNameContext ) throws Exception;
217
218
219
220
221
222
223
224
225
226
227
228
229
230 public abstract LdapDN getSuffix ( GetSuffixOperationContext suffixContext ) throws Exception;
231
232
233
234
235
236
237
238
239
240 public abstract Iterator<String> listSuffixes( ListSuffixOperationContext opContext ) throws Exception;
241
242
243
244
245
246
247
248
249 public abstract void registerSupportedExtensions( Set<String> extensionOids ) throws Exception;
250
251
252 public abstract void registerSupportedSaslMechanisms( Set<String> strings ) throws Exception;
253 }