View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
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.directory.Attributes;
29  import javax.naming.directory.DirContext;
30  import javax.naming.directory.ModificationItem;
31  import javax.naming.directory.SearchControls;
32  import javax.naming.ldap.Control;
33  import javax.naming.ldap.ExtendedRequest;
34  import javax.naming.ldap.ExtendedResponse;
35  import javax.naming.ldap.LdapContext;
36  
37  import org.apache.ldap.common.exception.LdapServiceUnavailableException;
38  import org.apache.ldap.common.message.ResultCodeEnum;
39  import org.apache.ldap.server.configuration.SyncConfiguration;
40  
41  
42  /***
43   * A do nothing placeholder context whose methods throw ConfigurationExceptions.
44   * JNDI provider returns this context when your specify {@link SyncConfiguration}
45   * in JNDI environment.  By returning a non-null Context we prevent an unnecessary
46   * exception being thrown by {@link InitialContext} and any one of its subclasses.
47   *
48   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
49   * @version $Rev: 264732 $, $Date: 2005-08-30 04:04:51 -0400 (Tue, 30 Aug 2005) $
50   */
51  class DeadContext implements LdapContext
52  {
53      private final String EXCEPTION_MSG = "Context operation unavailable when " +
54              "invoked after Eve provider has been shutdown";
55  
56  
57      public Control[] getConnectControls() throws NamingException
58      {
59          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
60      }
61  
62  
63      public Control[] getRequestControls() throws NamingException
64      {
65          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
66      }
67  
68  
69      public Control[] getResponseControls() throws NamingException
70      {
71          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
72      }
73  
74  
75      public void reconnect( Control[] connCtls ) throws NamingException
76      {
77          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
78      }
79  
80  
81      public void setRequestControls( Control[] requestControls ) throws NamingException
82      {
83          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
84      }
85  
86  
87      public ExtendedResponse extendedOperation( ExtendedRequest request ) throws NamingException
88      {
89          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
90      }
91  
92  
93      public LdapContext newInstance( Control[] requestControls ) throws NamingException
94      {
95          throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
96      }
97  
98  
99      public Attributes getAttributes( String name ) throws NamingException
100     {
101         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
102     }
103 
104 
105     public void modifyAttributes( String name, int mod_op, Attributes attrs ) throws NamingException
106     {
107         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
108     }
109 
110 
111     public Attributes getAttributes( Name name ) throws NamingException
112     {
113         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
114     }
115 
116 
117     public void modifyAttributes( Name name, int mod_op, Attributes attrs ) throws NamingException
118     {
119         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
120     }
121 
122 
123     public DirContext getSchema( String name ) throws NamingException
124     {
125         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
126     }
127 
128 
129     public DirContext getSchemaClassDefinition( String name ) throws NamingException
130     {
131         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
132     }
133 
134 
135     public DirContext getSchema( Name name ) throws NamingException
136     {
137         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
138     }
139 
140 
141     public DirContext getSchemaClassDefinition( Name name ) throws NamingException
142     {
143         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
144     }
145 
146 
147     public void modifyAttributes( String name, ModificationItem[] mods ) throws NamingException
148     {
149         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
150     }
151 
152 
153     public void modifyAttributes( Name name, ModificationItem[] mods ) throws NamingException
154     {
155         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
156     }
157 
158 
159     public NamingEnumeration search( String name, Attributes matchingAttributes ) throws NamingException
160     {
161         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
162     }
163 
164 
165     public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException
166     {
167         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
168     }
169 
170 
171     public void bind( String name, Object obj, Attributes attrs ) throws NamingException
172     {
173         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
174     }
175 
176 
177     public void rebind( String name, Object obj, Attributes attrs ) throws NamingException
178     {
179         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
180     }
181 
182 
183     public void bind( Name name, Object obj, Attributes attrs ) throws NamingException
184     {
185         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
186     }
187 
188 
189     public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException
190     {
191         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
192     }
193 
194 
195     public Attributes getAttributes( String name, String[] attrIds ) throws NamingException
196     {
197         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
198     }
199 
200 
201     public Attributes getAttributes( Name name, String[] attrIds ) throws NamingException
202     {
203         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
204     }
205 
206 
207     public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException
208     {
209         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
210     }
211 
212 
213     public DirContext createSubcontext( Name name, Attributes attrs ) throws NamingException
214     {
215         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
216     }
217 
218 
219     public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
220     {
221         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
222     }
223 
224 
225     public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
226     {
227         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
228     }
229 
230 
231     public NamingEnumeration search( String name, String filter, SearchControls cons ) throws NamingException
232     {
233         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
234     }
235 
236 
237     public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws NamingException
238     {
239         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
240     }
241 
242 
243     public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException
244     {
245         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
246     }
247 
248 
249     public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException
250     {
251         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
252     }
253 
254 
255     public void close() throws NamingException
256     {
257         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
258     }
259 
260 
261     public String getNameInNamespace() throws NamingException
262     {
263         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
264     }
265 
266 
267     public void destroySubcontext( String name ) throws NamingException
268     {
269         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
270     }
271 
272 
273     public void unbind( String name ) throws NamingException
274     {
275         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
276     }
277 
278 
279     public Hashtable getEnvironment() throws NamingException
280     {
281         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
282     }
283 
284 
285     public void destroySubcontext( Name name ) throws NamingException
286     {
287         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
288     }
289 
290 
291     public void unbind( Name name ) throws NamingException
292     {
293         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
294     }
295 
296 
297     public Object lookup( String name ) throws NamingException
298     {
299         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
300     }
301 
302 
303     public Object lookupLink( String name ) throws NamingException
304     {
305         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
306     }
307 
308 
309     public Object removeFromEnvironment( String propName ) throws NamingException
310     {
311         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
312     }
313 
314 
315     public void bind( String name, Object obj ) throws NamingException
316     {
317         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
318     }
319 
320 
321     public void rebind( String name, Object obj ) throws NamingException
322     {
323         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
324     }
325 
326 
327     public Object lookup( Name name ) throws NamingException
328     {
329         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
330     }
331 
332 
333     public Object lookupLink( Name name ) throws NamingException
334     {
335         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
336     }
337 
338 
339     public void bind( Name name, Object obj ) throws NamingException
340     {
341         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
342     }
343 
344 
345     public void rebind( Name name, Object obj ) throws NamingException
346     {
347         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
348     }
349 
350 
351     public void rename( String oldName, String newName ) throws NamingException
352     {
353         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
354     }
355 
356 
357     public Context createSubcontext( String name ) throws NamingException
358     {
359         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
360     }
361 
362 
363     public Context createSubcontext( Name name ) throws NamingException
364     {
365         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
366     }
367 
368 
369     public void rename( Name oldName, Name newName ) throws NamingException
370     {
371         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
372     }
373 
374 
375     public NameParser getNameParser( String name ) throws NamingException
376     {
377         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
378     }
379 
380 
381     public NameParser getNameParser( Name name ) throws NamingException
382     {
383         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
384     }
385 
386 
387     public NamingEnumeration list( String name ) throws NamingException
388     {
389         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
390     }
391 
392 
393     public NamingEnumeration listBindings( String name ) throws NamingException
394     {
395         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
396     }
397 
398 
399     public NamingEnumeration list( Name name ) throws NamingException
400     {
401         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
402     }
403 
404 
405     public NamingEnumeration listBindings( Name name ) throws NamingException
406     {
407         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
408     }
409 
410 
411     public Object addToEnvironment( String propName, Object propVal ) throws NamingException
412     {
413         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
414     }
415 
416 
417     public String composeName( String name, String prefix ) throws NamingException
418     {
419         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
420     }
421 
422 
423     public Name composeName( Name name, Name prefix ) throws NamingException
424     {
425         throw new LdapServiceUnavailableException( EXCEPTION_MSG, ResultCodeEnum.UNAVAILABLE );
426     }
427 }