View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    * 
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   * 
19   */
20  package org.apache.directory.ldap.client.api;
21  
22  
23  import java.io.IOException;
24  import java.util.List;
25  
26  import org.apache.directory.api.asn1.util.Oid;
27  import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector;
28  import org.apache.directory.api.ldap.codec.api.LdapApiService;
29  import org.apache.directory.api.ldap.model.cursor.EntryCursor;
30  import org.apache.directory.api.ldap.model.cursor.SearchCursor;
31  import org.apache.directory.api.ldap.model.entry.Entry;
32  import org.apache.directory.api.ldap.model.entry.Modification;
33  import org.apache.directory.api.ldap.model.entry.ModificationOperation;
34  import org.apache.directory.api.ldap.model.entry.Value;
35  import org.apache.directory.api.ldap.model.exception.LdapException;
36  import org.apache.directory.api.ldap.model.message.AbandonRequest;
37  import org.apache.directory.api.ldap.model.message.AddRequest;
38  import org.apache.directory.api.ldap.model.message.AddResponse;
39  import org.apache.directory.api.ldap.model.message.BindRequest;
40  import org.apache.directory.api.ldap.model.message.BindResponse;
41  import org.apache.directory.api.ldap.model.message.CompareRequest;
42  import org.apache.directory.api.ldap.model.message.CompareResponse;
43  import org.apache.directory.api.ldap.model.message.Control;
44  import org.apache.directory.api.ldap.model.message.DeleteRequest;
45  import org.apache.directory.api.ldap.model.message.DeleteResponse;
46  import org.apache.directory.api.ldap.model.message.ExtendedRequest;
47  import org.apache.directory.api.ldap.model.message.ExtendedResponse;
48  import org.apache.directory.api.ldap.model.message.ModifyDnRequest;
49  import org.apache.directory.api.ldap.model.message.ModifyDnResponse;
50  import org.apache.directory.api.ldap.model.message.ModifyRequest;
51  import org.apache.directory.api.ldap.model.message.ModifyResponse;
52  import org.apache.directory.api.ldap.model.message.SearchRequest;
53  import org.apache.directory.api.ldap.model.message.SearchScope;
54  import org.apache.directory.api.ldap.model.name.Dn;
55  import org.apache.directory.api.ldap.model.name.Rdn;
56  import org.apache.directory.api.ldap.model.schema.SchemaManager;
57  
58  
59  /**
60   * Provides a base implementation of a {@link Wrapper} for {@link LdapConnection}
61   * objects.  All methods are passed through to the wrapped 
62   * <code>LdapConnection</code>.
63   *
64   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
65   */
66  public class LdapConnectionWrapper implements LdapConnection, Wrapper<LdapConnection>
67  {
68      /** The wrapped connection */
69      protected LdapConnection connection;
70  
71  
72      /**
73       * Creates a new LdapConnectionWrapper instance
74       * 
75       * @param connection The wrapped connection
76       */
77      protected LdapConnectionWrapper( LdapConnection connection )
78      {
79          this.connection = connection;
80      }
81  
82  
83      /**
84       * {@inheritDoc}
85       */
86      @Override
87      public LdapConnection wrapped()
88      {
89          return connection;
90      }
91  
92  
93      /**
94       * {@inheritDoc}
95       */
96      @Override
97      public boolean isConnected()
98      {
99          return connection.isConnected();
100     }
101 
102 
103     /**
104      * {@inheritDoc}
105      */
106     @Override
107     public boolean isAuthenticated()
108     {
109         return connection.isAuthenticated();
110     }
111 
112 
113     /**
114      * {@inheritDoc}
115      */
116     @Override
117     public boolean connect() throws LdapException
118     {
119         return connection.connect();
120     }
121 
122 
123     /**
124      * {@inheritDoc}
125      */
126     @Override
127     public void close() throws IOException
128     {
129         connection.close();
130     }
131 
132 
133     /**
134      * {@inheritDoc}
135      */
136     @Override
137     public void add( Entry entry ) throws LdapException
138     {
139         connection.add( entry );
140     }
141 
142 
143     /**
144      * {@inheritDoc}
145      */
146     @Override
147     public AddResponse add( AddRequest addRequest ) throws LdapException
148     {
149         return connection.add( addRequest );
150     }
151 
152 
153     /**
154      * {@inheritDoc}
155      */
156     @Override
157     public void abandon( int messageId )
158     {
159         connection.abandon( messageId );
160     }
161 
162 
163     /**
164      * {@inheritDoc}
165      */
166     @Override
167     public void abandon( AbandonRequest abandonRequest )
168     {
169         connection.abandon( abandonRequest );
170     }
171 
172 
173     /**
174      * {@inheritDoc}
175      */
176     @Override
177     public void bind() throws LdapException
178     {
179         connection.bind();
180     }
181 
182 
183     /**
184      * {@inheritDoc}
185      */
186     @Override
187     public void anonymousBind() throws LdapException
188     {
189         connection.anonymousBind();
190     }
191 
192 
193     /**
194      * {@inheritDoc}
195      */
196     @Override
197     public void bind( String name ) throws LdapException
198     {
199         connection.bind( name );
200     }
201 
202 
203     /**
204      * {@inheritDoc}
205      */
206     @Override
207     public void bind( String name, String credentials ) throws LdapException
208     {
209         connection.bind( name, credentials );
210     }
211 
212 
213     /**
214      * {@inheritDoc}
215      */
216     @Override
217     public void bind( Dn name ) throws LdapException
218     {
219         connection.bind( name );
220     }
221 
222 
223     /**
224      * {@inheritDoc}
225      */
226     @Override
227     public void bind( Dn name, String credentials ) throws LdapException
228     {
229         connection.bind( name, credentials );
230     }
231 
232 
233     /**
234      * {@inheritDoc}
235      */
236     @Override
237     public BindResponse bind( BindRequest bindRequest ) throws LdapException
238     {
239         return connection.bind( bindRequest );
240     }
241 
242 
243     /**
244      * {@inheritDoc}
245      */
246     @Override
247     public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
248         throws LdapException
249     {
250         return connection.search( baseDn, filter, scope, attributes );
251     }
252 
253 
254     /**
255      * {@inheritDoc}
256      */
257     @Override
258     public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
259         throws LdapException
260     {
261         return connection.search( baseDn, filter, scope, attributes );
262     }
263 
264 
265     /**
266      * {@inheritDoc}
267      */
268     @Override
269     public SearchCursor search( SearchRequest searchRequest ) throws LdapException
270     {
271         return connection.search( searchRequest );
272     }
273 
274 
275     /**
276      * {@inheritDoc}
277      */
278     @Override
279     public void unBind() throws LdapException
280     {
281         connection.unBind();
282     }
283 
284 
285     /**
286      * {@inheritDoc}
287      */
288     @Override
289     public void setTimeOut( long timeOut )
290     {
291         connection.setTimeOut( timeOut );
292     }
293 
294 
295     /**
296      * {@inheritDoc}
297      */
298     @Override
299     public void modify( Dn dn, Modification... modifications ) throws LdapException
300     {
301         connection.modify( dn, modifications );
302     }
303 
304 
305     /**
306      * {@inheritDoc}
307      */
308     @Override
309     public void modify( String dn, Modification... modifications ) throws LdapException
310     {
311         connection.modify( dn, modifications );
312     }
313 
314 
315     /**
316      * {@inheritDoc}
317      */
318     @Override
319     public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
320     {
321         connection.modify( entry, modOp );
322     }
323 
324 
325     /**
326      * {@inheritDoc}
327      */
328     @Override
329     public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
330     {
331         return connection.modify( modRequest );
332     }
333 
334 
335     /**
336      * {@inheritDoc}
337      */
338     @Override
339     public void rename( String entryDn, String newRdn ) throws LdapException
340     {
341         connection.rename( entryDn, newRdn );
342     }
343 
344 
345     /**
346      * {@inheritDoc}
347      */
348     @Override
349     public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
350     {
351         connection.rename( entryDn, newRdn );
352     }
353 
354 
355     /**
356      * {@inheritDoc}
357      */
358     @Override
359     public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
360     {
361         connection.rename( entryDn, newRdn, deleteOldRdn );
362     }
363 
364 
365     /**
366      * {@inheritDoc}
367      */
368     @Override
369     public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
370     {
371         connection.rename( entryDn, newRdn, deleteOldRdn );
372     }
373 
374 
375     /**
376      * {@inheritDoc}
377      */
378     @Override
379     public void move( String entryDn, String newSuperiorDn ) throws LdapException
380     {
381         connection.move( entryDn, newSuperiorDn );
382     }
383 
384 
385     /**
386      * {@inheritDoc}
387      */
388     @Override
389     public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
390     {
391         connection.move( entryDn, newSuperiorDn );
392     }
393 
394 
395     /**
396      * {@inheritDoc}
397      */
398     @Override
399     public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
400     {
401         connection.moveAndRename( entryDn, newDn );
402     }
403 
404 
405     /**
406      * {@inheritDoc}
407      */
408     @Override
409     public void moveAndRename( String entryDn, String newDn ) throws LdapException
410     {
411         connection.moveAndRename( entryDn, newDn );
412     }
413 
414 
415     /**
416      * {@inheritDoc}
417      */
418     @Override
419     public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
420     {
421         connection.moveAndRename( entryDn, newDn, deleteOldRdn );
422     }
423 
424 
425     /**
426      * {@inheritDoc}
427      */
428     @Override
429     public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
430     {
431         connection.moveAndRename( entryDn, newDn, deleteOldRdn );
432     }
433 
434 
435     /**
436      * {@inheritDoc}
437      */
438     @Override
439     public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
440     {
441         return connection.modifyDn( modDnRequest );
442     }
443 
444 
445     /**
446      * {@inheritDoc}
447      */
448     @Override
449     public void delete( String dn ) throws LdapException
450     {
451         connection.delete( dn );
452     }
453 
454 
455     /**
456      * {@inheritDoc}
457      */
458     @Override
459     public void delete( Dn dn ) throws LdapException
460     {
461         connection.delete( dn );
462     }
463 
464 
465     /**
466      * {@inheritDoc}
467      */
468     @Override
469     public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
470     {
471         return connection.delete( deleteRequest );
472     }
473 
474 
475     /**
476      * {@inheritDoc}
477      */
478     @Override
479     public boolean compare( String dn, String attributeName, String value ) throws LdapException
480     {
481         return connection.compare( dn, attributeName, value );
482     }
483 
484 
485     /**
486      * {@inheritDoc}
487      */
488     @Override
489     public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
490     {
491         return connection.compare( dn, attributeName, value );
492     }
493 
494 
495     /**
496      * {@inheritDoc}
497      */
498     @Override
499     public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
500     {
501         return connection.compare( dn, attributeName, value );
502     }
503 
504 
505     /**
506      * {@inheritDoc}
507      */
508     @Override
509     public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
510     {
511         return connection.compare( dn, attributeName, value );
512     }
513 
514 
515     /**
516      * {@inheritDoc}
517      */
518     @Override
519     public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
520     {
521         return connection.compare( dn, attributeName, value );
522     }
523 
524 
525     /**
526      * {@inheritDoc}
527      */
528     @Override
529     public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
530     {
531         return connection.compare( dn, attributeName, value );
532     }
533 
534 
535     /**
536      * {@inheritDoc}
537      */
538     @Override
539     public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
540     {
541         return connection.compare( compareRequest );
542     }
543 
544 
545     /**
546      * {@inheritDoc}
547      */
548     @Override
549     public ExtendedResponse extended( String oid ) throws LdapException
550     {
551         return connection.extended( oid );
552     }
553 
554 
555     /**
556      * {@inheritDoc}
557      */
558     @Override
559     public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
560     {
561         return connection.extended( oid, value );
562     }
563 
564 
565     /**
566      * {@inheritDoc}
567      */
568     @Override
569     public ExtendedResponse extended( Oid oid ) throws LdapException
570     {
571         return connection.extended( oid );
572     }
573 
574 
575     /**
576      * {@inheritDoc}
577      */
578     @Override
579     public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
580     {
581         return connection.extended( oid, value );
582     }
583 
584 
585     /**
586      * {@inheritDoc}
587      */
588     @Override
589     public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
590     {
591         return connection.extended( extendedRequest );
592     }
593 
594 
595     /**
596      * {@inheritDoc}
597      */
598     @Override
599     public boolean exists( String dn ) throws LdapException
600     {
601         return connection.exists( dn );
602     }
603 
604 
605     /**
606      * {@inheritDoc}
607      */
608     @Override
609     public boolean exists( Dn dn ) throws LdapException
610     {
611         return connection.exists( dn );
612     }
613 
614 
615     /**
616      * {@inheritDoc}
617      */
618     @Override
619     public Entry getRootDse() throws LdapException
620     {
621         return connection.getRootDse();
622     }
623 
624 
625     /**
626      * {@inheritDoc}
627      */
628     @Override
629     public Entry getRootDse( String... attributes ) throws LdapException
630     {
631         return connection.getRootDse( attributes );
632     }
633 
634 
635     /**
636      * {@inheritDoc}
637      */
638     @Override
639     public Entry lookup( Dn dn ) throws LdapException
640     {
641         return connection.lookup( dn );
642     }
643 
644 
645     /**
646      * {@inheritDoc}
647      */
648     @Override
649     public Entry lookup( String dn ) throws LdapException
650     {
651         return connection.lookup( dn );
652     }
653 
654 
655     /**
656      * {@inheritDoc}
657      */
658     @Override
659     public Entry lookup( Dn dn, String... attributes ) throws LdapException
660     {
661         return connection.lookup( dn, attributes );
662     }
663 
664 
665     /**
666      * {@inheritDoc}
667      */
668     @Override
669     public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
670     {
671         return connection.lookup( dn, controls, attributes );
672     }
673 
674 
675     /**
676      * {@inheritDoc}
677      */
678     @Override
679     public Entry lookup( String dn, String... attributes ) throws LdapException
680     {
681         return connection.lookup( dn, attributes );
682     }
683 
684 
685     /**
686      * {@inheritDoc}
687      */
688     @Override
689     public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
690     {
691         return connection.lookup( dn, controls, attributes );
692     }
693 
694 
695     /**
696      * {@inheritDoc}
697      */
698     @Override
699     public boolean isControlSupported( String controlOID ) throws LdapException
700     {
701         return connection.isControlSupported( controlOID );
702     }
703 
704 
705     /**
706      * {@inheritDoc}
707      */
708     @Override
709     public List<String> getSupportedControls() throws LdapException
710     {
711         return connection.getSupportedControls();
712     }
713 
714 
715     /**
716      * {@inheritDoc}
717      */
718     @Override
719     public void loadSchema() throws LdapException
720     {
721         connection.loadSchema();
722     }
723 
724 
725     /**
726      * {@inheritDoc}
727      */
728     @Override
729     public SchemaManager getSchemaManager()
730     {
731         return connection.getSchemaManager();
732     }
733 
734 
735     /**
736      * {@inheritDoc}
737      */
738     @Override
739     public LdapApiService getCodecService()
740     {
741         return connection.getCodecService();
742     }
743 
744 
745     /**
746      * {@inheritDoc}
747      */
748     @Override
749     public boolean isRequestCompleted( int messageId )
750     {
751         return connection.isRequestCompleted( messageId );
752     }
753 
754 
755     /**
756      * {@inheritDoc}
757      */
758     @Override
759     public boolean doesFutureExistFor( int messageId )
760     {
761         return connection.isRequestCompleted( messageId );
762     }
763 
764 
765     /**
766      * {@inheritDoc}
767      */
768     @Override
769     public BinaryAttributeDetector getBinaryAttributeDetector()
770     {
771         return connection.getBinaryAttributeDetector();
772     }
773 
774 
775     /**
776      * {@inheritDoc}
777      */
778     @Override
779     public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter )
780     {
781         connection.setBinaryAttributeDetector( binaryAttributeDetecter );
782     }
783 
784 
785     /**
786      * {@inheritDoc}
787      */
788     @Override
789     public void setSchemaManager( SchemaManager schemaManager )
790     {
791         connection.setSchemaManager( schemaManager );
792     }
793 
794 
795     /**
796      * {@inheritDoc}
797      */
798     @Override
799     public void loadSchemaRelaxed() throws LdapException
800     {
801         connection.loadSchemaRelaxed();
802     }
803 }