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