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   *    https://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     public Throwable exceptionCaught()
127     {
128         return connection.exceptionCaught();
129     }
130 
131 
132     /**
133      * {@inheritDoc}
134      */
135     @Override
136     public void close() throws IOException
137     {
138         connection.close();
139     }
140 
141 
142     /**
143      * {@inheritDoc}
144      */
145     @Override
146     public void add( Entry entry ) throws LdapException
147     {
148         connection.add( entry );
149     }
150 
151 
152     /**
153      * {@inheritDoc}
154      */
155     @Override
156     public AddResponse add( AddRequest addRequest ) throws LdapException
157     {
158         return connection.add( addRequest );
159     }
160 
161 
162     /**
163      * {@inheritDoc}
164      */
165     @Override
166     public void abandon( int messageId )
167     {
168         connection.abandon( messageId );
169     }
170 
171 
172     /**
173      * {@inheritDoc}
174      */
175     @Override
176     public void abandon( AbandonRequest abandonRequest )
177     {
178         connection.abandon( abandonRequest );
179     }
180 
181 
182     /**
183      * {@inheritDoc}
184      */
185     @Override
186     public void bind() throws LdapException
187     {
188         connection.bind();
189     }
190 
191 
192     /**
193      * {@inheritDoc}
194      */
195     @Override
196     public void anonymousBind() throws LdapException
197     {
198         connection.anonymousBind();
199     }
200 
201 
202     /**
203      * {@inheritDoc}
204      */
205     @Override
206     public void bind( String name ) throws LdapException
207     {
208         connection.bind( name );
209     }
210 
211 
212     /**
213      * {@inheritDoc}
214      */
215     @Override
216     public void bind( String name, String credentials ) throws LdapException
217     {
218         connection.bind( name, credentials );
219     }
220 
221 
222     /**
223      * {@inheritDoc}
224      */
225     @Override
226     public void bind( Dn name ) throws LdapException
227     {
228         connection.bind( name );
229     }
230 
231 
232     /**
233      * {@inheritDoc}
234      */
235     @Override
236     public void bind( Dn name, String credentials ) throws LdapException
237     {
238         connection.bind( name, credentials );
239     }
240 
241 
242     /**
243      * {@inheritDoc}
244      */
245     @Override
246     public BindResponse bind( BindRequest bindRequest ) throws LdapException
247     {
248         return connection.bind( bindRequest );
249     }
250 
251 
252     /**
253      * {@inheritDoc}
254      */
255     @Override
256     public BindResponse bind( SaslRequest saslRequest ) throws LdapException
257     {
258         return connection.bind( saslRequest );
259     }
260 
261 
262     /**
263      * {@inheritDoc}
264      */
265     @Override
266     public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
267         throws LdapException
268     {
269         return connection.search( baseDn, filter, scope, attributes );
270     }
271 
272 
273     /**
274      * {@inheritDoc}
275      */
276     @Override
277     public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
278         throws LdapException
279     {
280         return connection.search( baseDn, filter, scope, attributes );
281     }
282 
283 
284     /**
285      * {@inheritDoc}
286      */
287     @Override
288     public SearchCursor search( SearchRequest searchRequest ) throws LdapException
289     {
290         return connection.search( searchRequest );
291     }
292 
293 
294     /**
295      * {@inheritDoc}
296      */
297     @Override
298     public void unBind() throws LdapException
299     {
300         connection.unBind();
301     }
302 
303 
304     /**
305      * {@inheritDoc}
306      */
307     @Override
308     public void setTimeOut( long timeOut )
309     {
310         connection.setTimeOut( timeOut );
311     }
312 
313 
314     /**
315      * {@inheritDoc}
316      */
317     @Override
318     public void modify( Dn dn, Modification... modifications ) throws LdapException
319     {
320         connection.modify( dn, modifications );
321     }
322 
323 
324     /**
325      * {@inheritDoc}
326      */
327     @Override
328     public void modify( String dn, Modification... modifications ) throws LdapException
329     {
330         connection.modify( dn, modifications );
331     }
332 
333 
334     /**
335      * {@inheritDoc}
336      */
337     @Override
338     public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
339     {
340         connection.modify( entry, modOp );
341     }
342 
343 
344     /**
345      * {@inheritDoc}
346      */
347     @Override
348     public ModifyResponse modify( ModifyRequest modRequest ) throws LdapException
349     {
350         return connection.modify( modRequest );
351     }
352 
353 
354     /**
355      * {@inheritDoc}
356      */
357     @Override
358     public void rename( String entryDn, String newRdn ) throws LdapException
359     {
360         connection.rename( entryDn, newRdn );
361     }
362 
363 
364     /**
365      * {@inheritDoc}
366      */
367     @Override
368     public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
369     {
370         connection.rename( entryDn, newRdn );
371     }
372 
373 
374     /**
375      * {@inheritDoc}
376      */
377     @Override
378     public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
379     {
380         connection.rename( entryDn, newRdn, deleteOldRdn );
381     }
382 
383 
384     /**
385      * {@inheritDoc}
386      */
387     @Override
388     public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
389     {
390         connection.rename( entryDn, newRdn, deleteOldRdn );
391     }
392 
393 
394     /**
395      * {@inheritDoc}
396      */
397     @Override
398     public void move( String entryDn, String newSuperiorDn ) throws LdapException
399     {
400         connection.move( entryDn, newSuperiorDn );
401     }
402 
403 
404     /**
405      * {@inheritDoc}
406      */
407     @Override
408     public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
409     {
410         connection.move( entryDn, newSuperiorDn );
411     }
412 
413 
414     /**
415      * {@inheritDoc}
416      */
417     @Override
418     public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
419     {
420         connection.moveAndRename( entryDn, newDn );
421     }
422 
423 
424     /**
425      * {@inheritDoc}
426      */
427     @Override
428     public void moveAndRename( String entryDn, String newDn ) throws LdapException
429     {
430         connection.moveAndRename( entryDn, newDn );
431     }
432 
433 
434     /**
435      * {@inheritDoc}
436      */
437     @Override
438     public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
439     {
440         connection.moveAndRename( entryDn, newDn, deleteOldRdn );
441     }
442 
443 
444     /**
445      * {@inheritDoc}
446      */
447     @Override
448     public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
449     {
450         connection.moveAndRename( entryDn, newDn, deleteOldRdn );
451     }
452 
453 
454     /**
455      * {@inheritDoc}
456      */
457     @Override
458     public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
459     {
460         return connection.modifyDn( modDnRequest );
461     }
462 
463 
464     /**
465      * {@inheritDoc}
466      */
467     @Override
468     public void delete( String dn ) throws LdapException
469     {
470         connection.delete( dn );
471     }
472 
473 
474     /**
475      * {@inheritDoc}
476      */
477     @Override
478     public void delete( Dn dn ) throws LdapException
479     {
480         connection.delete( dn );
481     }
482 
483 
484     /**
485      * {@inheritDoc}
486      */
487     @Override
488     public DeleteResponse delete( DeleteRequest deleteRequest ) throws LdapException
489     {
490         return connection.delete( deleteRequest );
491     }
492 
493 
494     /**
495      * {@inheritDoc}
496      */
497     @Override
498     public boolean compare( String dn, String attributeName, String value ) throws LdapException
499     {
500         return connection.compare( dn, attributeName, value );
501     }
502 
503 
504     /**
505      * {@inheritDoc}
506      */
507     @Override
508     public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
509     {
510         return connection.compare( dn, attributeName, value );
511     }
512 
513 
514     /**
515      * {@inheritDoc}
516      */
517     @Override
518     public boolean compare( String dn, String attributeName, Value value ) throws LdapException
519     {
520         return connection.compare( dn, attributeName, value );
521     }
522 
523 
524     /**
525      * {@inheritDoc}
526      */
527     @Override
528     public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
529     {
530         return connection.compare( dn, attributeName, value );
531     }
532 
533 
534     /**
535      * {@inheritDoc}
536      */
537     @Override
538     public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
539     {
540         return connection.compare( dn, attributeName, value );
541     }
542 
543 
544     /**
545      * {@inheritDoc}
546      */
547     @Override
548     public boolean compare( Dn dn, String attributeName, Value value ) throws LdapException
549     {
550         return connection.compare( dn, attributeName, value );
551     }
552 
553 
554     /**
555      * {@inheritDoc}
556      */
557     @Override
558     public CompareResponse compare( CompareRequest compareRequest ) throws LdapException
559     {
560         return connection.compare( compareRequest );
561     }
562 
563 
564     /**
565      * {@inheritDoc}
566      */
567     @Override
568     public ExtendedResponse extended( String oid ) throws LdapException
569     {
570         return connection.extended( oid );
571     }
572 
573 
574     /**
575      * {@inheritDoc}
576      */
577     @Override
578     public ExtendedResponse extended( String oid, byte[] value ) throws LdapException
579     {
580         return connection.extended( oid, value );
581     }
582 
583 
584     /**
585      * {@inheritDoc}
586      */
587     @Override
588     public ExtendedResponse extended( Oid oid ) throws LdapException
589     {
590         return connection.extended( oid );
591     }
592 
593 
594     /**
595      * {@inheritDoc}
596      */
597     @Override
598     public ExtendedResponse extended( Oid oid, byte[] value ) throws LdapException
599     {
600         return connection.extended( oid, value );
601     }
602 
603 
604     /**
605      * {@inheritDoc}
606      */
607     @Override
608     public ExtendedResponse extended( ExtendedRequest extendedRequest ) throws LdapException
609     {
610         return connection.extended( extendedRequest );
611     }
612 
613 
614     /**
615      * {@inheritDoc}
616      */
617     @Override
618     public boolean exists( String dn ) throws LdapException
619     {
620         return connection.exists( dn );
621     }
622 
623 
624     /**
625      * {@inheritDoc}
626      */
627     @Override
628     public boolean exists( Dn dn ) throws LdapException
629     {
630         return connection.exists( dn );
631     }
632 
633 
634     /**
635      * {@inheritDoc}
636      */
637     @Override
638     public Entry getRootDse() throws LdapException
639     {
640         return connection.getRootDse();
641     }
642 
643 
644     /**
645      * {@inheritDoc}
646      */
647     @Override
648     public Entry getRootDse( String... attributes ) throws LdapException
649     {
650         return connection.getRootDse( attributes );
651     }
652 
653 
654     /**
655      * {@inheritDoc}
656      */
657     @Override
658     public Entry lookup( Dn dn ) throws LdapException
659     {
660         return connection.lookup( dn );
661     }
662 
663 
664     /**
665      * {@inheritDoc}
666      */
667     @Override
668     public Entry lookup( String dn ) throws LdapException
669     {
670         return connection.lookup( dn );
671     }
672 
673 
674     /**
675      * {@inheritDoc}
676      */
677     @Override
678     public Entry lookup( Dn dn, String... attributes ) throws LdapException
679     {
680         return connection.lookup( dn, attributes );
681     }
682 
683 
684     /**
685      * {@inheritDoc}
686      */
687     @Override
688     public Entry lookup( Dn dn, Control[] controls, String... attributes ) throws LdapException
689     {
690         return connection.lookup( dn, controls, attributes );
691     }
692 
693 
694     /**
695      * {@inheritDoc}
696      */
697     @Override
698     public Entry lookup( String dn, String... attributes ) throws LdapException
699     {
700         return connection.lookup( dn, attributes );
701     }
702 
703 
704     /**
705      * {@inheritDoc}
706      */
707     @Override
708     public Entry lookup( String dn, Control[] controls, String... attributes ) throws LdapException
709     {
710         return connection.lookup( dn, controls, attributes );
711     }
712 
713 
714     /**
715      * {@inheritDoc}
716      */
717     @Override
718     public boolean isControlSupported( String controlOID ) throws LdapException
719     {
720         return connection.isControlSupported( controlOID );
721     }
722 
723 
724     /**
725      * {@inheritDoc}
726      */
727     @Override
728     public List<String> getSupportedControls() throws LdapException
729     {
730         return connection.getSupportedControls();
731     }
732 
733 
734     /**
735      * {@inheritDoc}
736      */
737     @Override
738     public void loadSchema() throws LdapException
739     {
740         connection.loadSchema();
741     }
742 
743 
744     /**
745      * {@inheritDoc}
746      */
747     @Override
748     public SchemaManager getSchemaManager()
749     {
750         return connection.getSchemaManager();
751     }
752 
753 
754     /**
755      * {@inheritDoc}
756      */
757     @Override
758     public LdapApiService getCodecService()
759     {
760         return connection.getCodecService();
761     }
762 
763 
764     /**
765      * {@inheritDoc}
766      */
767     @Override
768     public boolean isRequestCompleted( int messageId )
769     {
770         return connection.isRequestCompleted( messageId );
771     }
772 
773 
774     /**
775      * {@inheritDoc}
776      */
777     @Override
778     public boolean doesFutureExistFor( int messageId )
779     {
780         return connection.isRequestCompleted( messageId );
781     }
782 
783 
784     /**
785      * {@inheritDoc}
786      */
787     @Override
788     public BinaryAttributeDetector getBinaryAttributeDetector()
789     {
790         return connection.getBinaryAttributeDetector();
791     }
792 
793 
794     /**
795      * {@inheritDoc}
796      */
797     @Override
798     public void setBinaryAttributeDetector( BinaryAttributeDetector binaryAttributeDetecter )
799     {
800         connection.setBinaryAttributeDetector( binaryAttributeDetecter );
801     }
802 
803 
804     /**
805      * {@inheritDoc}
806      */
807     @Override
808     public void setSchemaManager( SchemaManager schemaManager )
809     {
810         connection.setSchemaManager( schemaManager );
811     }
812 
813 
814     /**
815      * {@inheritDoc}
816      */
817     @Override
818     public void loadSchemaRelaxed() throws LdapException
819     {
820         connection.loadSchemaRelaxed();
821     }
822 }