001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.ldap.client.api; 021 022 023import java.io.IOException; 024import java.util.List; 025 026import org.apache.directory.api.asn1.util.Oid; 027import org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector; 028import org.apache.directory.api.ldap.codec.api.LdapApiService; 029import org.apache.directory.api.ldap.model.cursor.EntryCursor; 030import org.apache.directory.api.ldap.model.cursor.SearchCursor; 031import org.apache.directory.api.ldap.model.entry.Entry; 032import org.apache.directory.api.ldap.model.entry.Modification; 033import org.apache.directory.api.ldap.model.entry.ModificationOperation; 034import org.apache.directory.api.ldap.model.entry.Value; 035import org.apache.directory.api.ldap.model.exception.LdapException; 036import org.apache.directory.api.ldap.model.message.AbandonRequest; 037import org.apache.directory.api.ldap.model.message.AddRequest; 038import org.apache.directory.api.ldap.model.message.AddResponse; 039import org.apache.directory.api.ldap.model.message.BindRequest; 040import org.apache.directory.api.ldap.model.message.BindResponse; 041import org.apache.directory.api.ldap.model.message.CompareRequest; 042import org.apache.directory.api.ldap.model.message.CompareResponse; 043import org.apache.directory.api.ldap.model.message.Control; 044import org.apache.directory.api.ldap.model.message.DeleteRequest; 045import org.apache.directory.api.ldap.model.message.DeleteResponse; 046import org.apache.directory.api.ldap.model.message.ExtendedRequest; 047import org.apache.directory.api.ldap.model.message.ExtendedResponse; 048import org.apache.directory.api.ldap.model.message.ModifyDnRequest; 049import org.apache.directory.api.ldap.model.message.ModifyDnResponse; 050import org.apache.directory.api.ldap.model.message.ModifyRequest; 051import org.apache.directory.api.ldap.model.message.ModifyResponse; 052import org.apache.directory.api.ldap.model.message.SearchRequest; 053import org.apache.directory.api.ldap.model.message.SearchScope; 054import org.apache.directory.api.ldap.model.name.Dn; 055import org.apache.directory.api.ldap.model.name.Rdn; 056import org.apache.directory.api.ldap.model.schema.SchemaManager; 057 058 059/** 060 * Provides a base implementation of a {@link Wrapper} for {@link LdapConnection} 061 * objects. All methods are passed through to the wrapped 062 * <code>LdapConnection</code>. 063 * 064 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 065 */ 066public class LdapConnectionWrapper implements LdapConnection, Wrapper<LdapConnection> 067{ 068 /** The wrapped connection */ 069 protected LdapConnection connection; 070 071 072 /** 073 * Creates a new LdapConnectionWrapper instance 074 * 075 * @param connection The wrapped connection 076 */ 077 protected LdapConnectionWrapper( LdapConnection connection ) 078 { 079 this.connection = connection; 080 } 081 082 083 /** 084 * {@inheritDoc} 085 */ 086 @Override 087 public LdapConnection wrapped() 088 { 089 return connection; 090 } 091 092 093 /** 094 * {@inheritDoc} 095 */ 096 @Override 097 public boolean isConnected() 098 { 099 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}