1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.jndi;
18
19
20 import java.util.Hashtable;
21
22 import javax.naming.Context;
23 import javax.naming.InitialContext;
24 import javax.naming.Name;
25 import javax.naming.NameParser;
26 import javax.naming.NamingEnumeration;
27 import javax.naming.NamingException;
28 import javax.naming.event.EventDirContext;
29 import javax.naming.event.NamingListener;
30 import javax.naming.directory.Attributes;
31 import javax.naming.directory.DirContext;
32 import javax.naming.directory.ModificationItem;
33 import javax.naming.directory.SearchControls;
34 import javax.naming.ldap.Control;
35 import javax.naming.ldap.ExtendedRequest;
36 import javax.naming.ldap.ExtendedResponse;
37 import javax.naming.ldap.LdapContext;
38
39 import org.apache.ldap.common.exception.LdapServiceUnavailableException;
40 import org.apache.ldap.common.message.ResultCodeEnum;
41 import org.apache.ldap.server.configuration.SyncConfiguration;
42
43
44 /***
45 * A do nothing placeholder context whose methods throw ConfigurationExceptions.
46 * JNDI provider returns this context when your specify {@link SyncConfiguration}
47 * in JNDI environment. By returning a non-null Context we prevent an unnecessary
48 * exception being thrown by {@link InitialContext} and any one of its subclasses.
49 *
50 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
51 * @version $Rev: 307233 $, $Date: 2005-10-07 21:40:39 -0400 (Fri, 07 Oct 2005) $
52 */
53 public class DeadContext implements LdapContext, EventDirContext
54 {
55 private final String EXCEPTION_MSG = "Context operation unavailable when " +
56 "invoked after Eve provider has been shutdown";
57
58
59 public Control[] getConnectControls() throws NamingException
60 {
61 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
62 }
63
64
65 public Control[] getRequestControls() throws NamingException
66 {
67 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
68 }
69
70
71 public Control[] getResponseControls() throws NamingException
72 {
73 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
74 }
75
76
77 public void reconnect( Control[] connCtls ) throws NamingException
78 {
79 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
80 }
81
82
83 public void setRequestControls( Control[] requestControls ) throws NamingException
84 {
85 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
86 }
87
88
89 public ExtendedResponse extendedOperation( ExtendedRequest request ) throws NamingException
90 {
91 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
92 }
93
94
95 public LdapContext newInstance( Control[] requestControls ) throws NamingException
96 {
97 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
98 }
99
100
101 public Attributes getAttributes( String name ) throws NamingException
102 {
103 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
104 }
105
106
107 public void modifyAttributes( String name, int mod_op, Attributes attrs ) throws NamingException
108 {
109 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
110 }
111
112
113 public Attributes getAttributes( Name name ) throws NamingException
114 {
115 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
116 }
117
118
119 public void modifyAttributes( Name name, int mod_op, Attributes attrs ) throws NamingException
120 {
121 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
122 }
123
124
125 public DirContext getSchema( String name ) throws NamingException
126 {
127 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
128 }
129
130
131 public DirContext getSchemaClassDefinition( String name ) throws NamingException
132 {
133 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
134 }
135
136
137 public DirContext getSchema( Name name ) throws NamingException
138 {
139 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
140 }
141
142
143 public DirContext getSchemaClassDefinition( Name name ) throws NamingException
144 {
145 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
146 }
147
148
149 public void modifyAttributes( String name, ModificationItem[] mods ) throws NamingException
150 {
151 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
152 }
153
154
155 public void modifyAttributes( Name name, ModificationItem[] mods ) throws NamingException
156 {
157 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
158 }
159
160
161 public NamingEnumeration search( String name, Attributes matchingAttributes ) throws NamingException
162 {
163 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
164 }
165
166
167 public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException
168 {
169 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
170 }
171
172
173 public void bind( String name, Object obj, Attributes attrs ) throws NamingException
174 {
175 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
176 }
177
178
179 public void rebind( String name, Object obj, Attributes attrs ) throws NamingException
180 {
181 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
182 }
183
184
185 public void bind( Name name, Object obj, Attributes attrs ) throws NamingException
186 {
187 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
188 }
189
190
191 public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException
192 {
193 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
194 }
195
196
197 public Attributes getAttributes( String name, String[] attrIds ) throws NamingException
198 {
199 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
200 }
201
202
203 public Attributes getAttributes( Name name, String[] attrIds ) throws NamingException
204 {
205 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
206 }
207
208
209 public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException
210 {
211 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
212 }
213
214
215 public DirContext createSubcontext( Name name, Attributes attrs ) throws NamingException
216 {
217 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
218 }
219
220
221 public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
222 {
223 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
224 }
225
226
227 public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
228 {
229 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
230 }
231
232
233 public NamingEnumeration search( String name, String filter, SearchControls cons ) throws NamingException
234 {
235 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
236 }
237
238
239 public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws NamingException
240 {
241 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
242 }
243
244
245 public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException
246 {
247 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
248 }
249
250
251 public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException
252 {
253 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
254 }
255
256
257 public void close() throws NamingException
258 {
259 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
260 }
261
262
263 public String getNameInNamespace() throws NamingException
264 {
265 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
266 }
267
268
269 public void destroySubcontext( String name ) throws NamingException
270 {
271 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
272 }
273
274
275 public void unbind( String name ) throws NamingException
276 {
277 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
278 }
279
280
281 public Hashtable getEnvironment() throws NamingException
282 {
283 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
284 }
285
286
287 public void destroySubcontext( Name name ) throws NamingException
288 {
289 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
290 }
291
292
293 public void unbind( Name name ) throws NamingException
294 {
295 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
296 }
297
298
299 public Object lookup( String name ) throws NamingException
300 {
301 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
302 }
303
304
305 public Object lookupLink( String name ) throws NamingException
306 {
307 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
308 }
309
310
311 public Object removeFromEnvironment( String propName ) throws NamingException
312 {
313 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
314 }
315
316
317 public void bind( String name, Object obj ) throws NamingException
318 {
319 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
320 }
321
322
323 public void rebind( String name, Object obj ) throws NamingException
324 {
325 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
326 }
327
328
329 public Object lookup( Name name ) throws NamingException
330 {
331 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
332 }
333
334
335 public Object lookupLink( Name name ) throws NamingException
336 {
337 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
338 }
339
340
341 public void bind( Name name, Object obj ) throws NamingException
342 {
343 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
344 }
345
346
347 public void rebind( Name name, Object obj ) throws NamingException
348 {
349 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
350 }
351
352
353 public void rename( String oldName, String newName ) throws NamingException
354 {
355 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
356 }
357
358
359 public Context createSubcontext( String name ) throws NamingException
360 {
361 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
362 }
363
364
365 public Context createSubcontext( Name name ) throws NamingException
366 {
367 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
368 }
369
370
371 public void rename( Name oldName, Name newName ) throws NamingException
372 {
373 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
374 }
375
376
377 public NameParser getNameParser( String name ) throws NamingException
378 {
379 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
380 }
381
382
383 public NameParser getNameParser( Name name ) throws NamingException
384 {
385 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
386 }
387
388
389 public NamingEnumeration list( String name ) throws NamingException
390 {
391 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
392 }
393
394
395 public NamingEnumeration listBindings( String name ) throws NamingException
396 {
397 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
398 }
399
400
401 public NamingEnumeration list( Name name ) throws NamingException
402 {
403 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
404 }
405
406
407 public NamingEnumeration listBindings( Name name ) throws NamingException
408 {
409 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
410 }
411
412
413 public Object addToEnvironment( String propName, Object propVal ) throws NamingException
414 {
415 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
416 }
417
418
419 public String composeName( String name, String prefix ) throws NamingException
420 {
421 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
422 }
423
424
425 public Name composeName( Name name, Name prefix ) throws NamingException
426 {
427 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
428 }
429
430
431 public void addNamingListener( Name name, String s, SearchControls searchControls, NamingListener namingListener )
432 throws NamingException
433 {
434 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
435 }
436
437
438 public void addNamingListener( String s, String s1, SearchControls searchControls, NamingListener namingListener ) throws NamingException
439 {
440 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
441 }
442
443
444 public void addNamingListener( Name name, String s, Object[] objects, SearchControls searchControls, NamingListener namingListener ) throws NamingException
445 {
446 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
447 }
448
449
450 public void addNamingListener( String s, String s1, Object[] objects, SearchControls searchControls, NamingListener namingListener ) throws NamingException
451 {
452 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
453 }
454
455
456 public void addNamingListener( Name name, int i, NamingListener namingListener ) throws NamingException
457 {
458 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
459 }
460
461
462 public void addNamingListener( String s, int i, NamingListener namingListener ) throws NamingException
463 {
464 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
465 }
466
467
468 public void removeNamingListener( NamingListener namingListener ) throws NamingException
469 {
470 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
471 }
472
473
474 public boolean targetMustExist() throws NamingException
475 {
476 throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
477 }
478 }