001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2009 Sun Microsystems, Inc. 025 * Portions Copyright 2011-2015 ForgeRock AS 026 */ 027package org.opends.server.protocols.internal; 028 029import java.net.InetAddress; 030import java.util.*; 031import java.util.concurrent.atomic.AtomicInteger; 032import java.util.concurrent.atomic.AtomicLong; 033 034import org.forgerock.i18n.LocalizableMessage; 035import org.forgerock.i18n.slf4j.LocalizedLogger; 036import org.forgerock.opendj.ldap.ByteString; 037import org.forgerock.opendj.ldap.ResultCode; 038import org.opends.server.api.ClientConnection; 039import org.opends.server.api.ConnectionHandler; 040import org.opends.server.core.*; 041import org.opends.server.types.*; 042import org.opends.server.util.AddChangeRecordEntry; 043import org.opends.server.util.DeleteChangeRecordEntry; 044import org.opends.server.util.ModifyChangeRecordEntry; 045import org.opends.server.util.ModifyDNChangeRecordEntry; 046 047import static org.opends.messages.ProtocolMessages.*; 048import static org.opends.server.config.ConfigConstants.*; 049import static org.opends.server.util.CollectionUtils.*; 050import static org.opends.server.util.ServerConstants.*; 051import static org.opends.server.util.StaticUtils.*; 052 053/** 054 * This class defines a pseudo-connection object that can be used for 055 * performing internal operations. 056 */ 057@org.opends.server.types.PublicAPI( 058 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 059 mayInstantiate=true, 060 mayExtend=false, 061 mayInvoke=true) 062public final class InternalClientConnection 063 extends ClientConnection 064{ 065 private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); 066 067 /** 068 * The protocol version string that will be used for internal bind 069 * operations. Since this is modeled after LDAPv3 binds, it will 070 * use a version number string of "3". 071 */ 072 public static final String PROTOCOL_VERSION = "3"; 073 074 075 076 /** The message ID counter to use for internal connections. */ 077 private static AtomicInteger nextMessageID; 078 079 /** The connection ID counter to use for internal connections. */ 080 private static AtomicLong nextConnectionID; 081 082 /** The operation ID counter to use for operations on this connection. */ 083 private static AtomicLong nextOperationID; 084 085 /** The static connection for root-based connections. */ 086 private static InternalClientConnection rootConnection; 087 088 /** The connection ID for this client connection. */ 089 private final long connectionID; 090 091 092 093 static 094 { 095 nextMessageID = new AtomicInteger(1); 096 nextConnectionID = new AtomicLong(-1); 097 nextOperationID = new AtomicLong(0); 098 } 099 100 101 102 /** 103 * Creates a new internal client connection that will be 104 * authenticated as a root user for which access control will not be 105 * enforced. 106 */ 107 private InternalClientConnection() 108 { 109 super(); 110 111 // This connection will be authenticated as a root user so that no 112 // access control will be enforced. 113 String commonName = "Internal Client"; 114 String shortDNString = "cn=" + commonName; 115 String fullDNString = shortDNString + ",cn=Root DNs,cn=config"; 116 try 117 { 118 LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(); 119 put(objectClasses, DirectoryServer.getTopObjectClass()); 120 put(objectClasses, DirectoryServer.getObjectClass(OC_PERSON, true)); 121 put(objectClasses, DirectoryServer.getObjectClass(OC_ROOT_DN, true)); 122 123 LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); 124 put(userAttrs, ATTR_COMMON_NAME, commonName); 125 put(userAttrs, ATTR_SN, commonName); 126 put(userAttrs, ATTR_ROOTDN_ALTERNATE_BIND_DN, shortDNString); 127 128 AttributeType privType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PRIVILEGE_NAME); 129 AttributeBuilder builder = new AttributeBuilder(privType); 130 for (Privilege p : Privilege.getDefaultRootPrivileges()) 131 { 132 builder.add(p.getName()); 133 } 134 135 LinkedHashMap<AttributeType, List<Attribute>> operationalAttrs = new LinkedHashMap<>(); 136 operationalAttrs.put(privType, builder.toAttributeList()); 137 138 139 DN internalUserDN = DN.valueOf(fullDNString); 140 Entry internalUserEntry = new Entry( 141 internalUserDN, objectClasses, userAttrs, operationalAttrs); 142 143 this.authenticationInfo = new AuthenticationInfo(internalUserEntry, true); 144 super.setAuthenticationInfo(authenticationInfo); 145 super.setSizeLimit(0); 146 super.setTimeLimit(0); 147 super.setIdleTimeLimit(0); 148 super.setLookthroughLimit(0); 149 } 150 catch (DirectoryException de) 151 { 152 logger.traceException(de); 153 154 logger.error(ERR_INTERNAL_CANNOT_DECODE_DN, fullDNString, getExceptionMessage(de)); 155 } 156 157 connectionID = nextConnectionID.getAndDecrement(); 158 } 159 160 private void put(Map<ObjectClass, String> objectClasses, ObjectClass oc) 161 { 162 objectClasses.put(oc, oc.getPrimaryName()); 163 } 164 165 private void put(Map<AttributeType, List<Attribute>> Attrs, String attrName, String value) 166 { 167 List<Attribute> attrs = newLinkedList(Attributes.create(attrName, value)); 168 Attrs.put(DirectoryServer.getAttributeTypeOrDefault(attrName), attrs); 169 } 170 171 /** 172 * Creates a new internal client connection that will be 173 * authenticated as the specified user. 174 * 175 * @param authInfo The authentication information to use for the 176 * connection. 177 */ 178 public InternalClientConnection(AuthenticationInfo authInfo) 179 { 180 super(); 181 182 // Don't call super.setAuthenticationInfo() since this will register this 183 // connection in the authenticated users table, which is unnecessary and 184 // will also cause the connection to be leaked since internal connections 185 // are never closed/disconnected. 186 if (authInfo == null) 187 { 188 this.authenticationInfo = new AuthenticationInfo(); 189 updatePrivileges(null, false); 190 } 191 else 192 { 193 this.authenticationInfo = authInfo; 194 updatePrivileges(authInfo.getAuthorizationEntry(), authInfo.isRoot()); 195 } 196 197 super.setSizeLimit(0); 198 super.setTimeLimit(0); 199 super.setIdleTimeLimit(0); 200 super.setLookthroughLimit(0); 201 202 connectionID = nextConnectionID.getAndDecrement(); 203 } 204 205 206 207 /** 208 * Creates a new internal client connection that will be 209 * authenticated as the specified user. 210 * 211 * @param userDN The DN of the entry to use as the 212 * authentication and authorization identity. 213 * 214 * @throws DirectoryException If a problem occurs while trying to 215 * get the entry for the provided user 216 * DN. 217 */ 218 public InternalClientConnection(DN userDN) 219 throws DirectoryException 220 { 221 this(getAuthInfoForDN(userDN)); 222 } 223 224 /** 225 * Creates an authentication information object for the user with 226 * the specified DN. 227 * 228 * @param userDN The DN of the user for whom to create an 229 * authentication information object. 230 * 231 * @return The appropriate authentication information object. 232 * 233 * @throws DirectoryException If a problem occurs while trying to 234 * create the authentication 235 * information object, or there is no 236 * such user in the directory. 237 */ 238 private static AuthenticationInfo getAuthInfoForDN(DN userDN) 239 throws DirectoryException 240 { 241 if (userDN == null || userDN.isRootDN()) 242 { 243 return new AuthenticationInfo(); 244 } 245 246 DN rootUserDN = DirectoryServer.getActualRootBindDN(userDN); 247 if (rootUserDN != null) 248 { 249 userDN = rootUserDN; 250 } 251 252 Entry userEntry = DirectoryServer.getEntry(userDN); 253 if (userEntry == null) 254 { 255 LocalizableMessage m = 256 ERR_INTERNALCONN_NO_SUCH_USER.get(userDN); 257 throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m); 258 } 259 260 boolean isRoot = DirectoryServer.isRootDN(userDN); 261 return new AuthenticationInfo(userEntry, isRoot); 262 } 263 264 265 266 /** 267 * Retrieves a shared internal client connection that is 268 * authenticated as a root user. 269 * 270 * @return A shared internal client connection that is 271 * authenticated as a root user. 272 */ 273 public static InternalClientConnection getRootConnection() 274 { 275 if (rootConnection == null) 276 { 277 rootConnection = new InternalClientConnection(); 278 } 279 280 return rootConnection; 281 } 282 283 284 285 /** 286 * Retrieves the operation ID that should be used for the next 287 * internal operation. 288 * 289 * @return The operation ID that should be used for the next 290 * internal operation. 291 */ 292 public static long nextOperationID() 293 { 294 long opID = nextOperationID.getAndIncrement(); 295 if (opID < 0) 296 { 297 synchronized (nextOperationID) 298 { 299 if (nextOperationID.get() < 0) 300 { 301 nextOperationID.set(1); 302 return 0; 303 } 304 else 305 { 306 return nextOperationID.getAndIncrement(); 307 } 308 } 309 } 310 311 return opID; 312 } 313 314 315 316 /** 317 * Retrieves the message ID that should be used for the next 318 * internal operation. 319 * 320 * @return The message ID that should be used for the next internal 321 * operation. 322 */ 323 public static int nextMessageID() 324 { 325 int msgID = nextMessageID.getAndIncrement(); 326 if (msgID < 0) 327 { 328 synchronized (nextMessageID) 329 { 330 if (nextMessageID.get() < 0) 331 { 332 nextMessageID.set(2); 333 return 1; 334 } 335 else 336 { 337 return nextMessageID.getAndIncrement(); 338 } 339 } 340 } 341 342 return msgID; 343 } 344 345 346 347 /** 348 * Retrieves the unique identifier that has been assigned to this 349 * connection. 350 * 351 * @return The unique identifier that has been assigned to this 352 * connection. 353 */ 354 @Override 355 public long getConnectionID() 356 { 357 return connectionID; 358 } 359 360 361 362 /** 363 * Retrieves the connection handler that accepted this client 364 * connection. 365 * 366 * @return The connection handler that accepted this client 367 * connection. 368 */ 369 @org.opends.server.types.PublicAPI( 370 stability=org.opends.server.types.StabilityLevel.PRIVATE, 371 mayInstantiate=false, 372 mayExtend=false, 373 mayInvoke=false) 374 @Override 375 public ConnectionHandler<?> getConnectionHandler() 376 { 377 return InternalConnectionHandler.getInstance(); 378 } 379 380 381 382 /** 383 * Retrieves the protocol that the client is using to communicate 384 * with the Directory Server. 385 * 386 * @return The protocol that the client is using to communicate 387 * with the Directory Server. 388 */ 389 @Override 390 public String getProtocol() 391 { 392 return "internal"; 393 } 394 395 396 397 /** 398 * Retrieves a string representation of the address of the client. 399 * 400 * @return A string representation of the address of the client. 401 */ 402 @Override 403 public String getClientAddress() 404 { 405 return "internal"; 406 } 407 408 409 410 /** 411 * Retrieves the port number for this connection on the client 412 * system. 413 * 414 * @return The port number for this connection on the client system. 415 */ 416 @Override 417 public int getClientPort() 418 { 419 return -1; 420 } 421 422 423 424 /** 425 * Retrieves a string representation of the address on the server to 426 * which the client connected. 427 * 428 * @return A string representation of the address on the server to 429 * which the client connected. 430 */ 431 @Override 432 public String getServerAddress() 433 { 434 return "internal"; 435 } 436 437 438 439 /** 440 * Retrieves the port number for this connection on the server 441 * system if available. 442 * 443 * @return The port number for this connection on the server system 444 * or -1 if there is no server port associated with this 445 * connection (e.g. internal client). 446 */ 447 @Override 448 public int getServerPort() 449 { 450 return -1; 451 } 452 453 454 455 /** 456 * Retrieves the <CODE>java.net.InetAddress</CODE> associated with 457 * the remote client system. 458 * 459 * @return The <CODE>java.net.InetAddress</CODE> associated with 460 * the remote client system. It may be <CODE>null</CODE> 461 * if the client is not connected over an IP-based 462 * connection. 463 */ 464 @Override 465 public InetAddress getRemoteAddress() 466 { 467 return null; 468 } 469 470 471 472 /** 473 * Retrieves the <CODE>java.net.InetAddress</CODE> for the Directory 474 * Server system to which the client has established the connection. 475 * 476 * @return The <CODE>java.net.InetAddress</CODE> for the Directory 477 * Server system to which the client has established the 478 * connection. It may be <CODE>null</CODE> if the client 479 * is not connected over an IP-based connection. 480 */ 481 @Override 482 public InetAddress getLocalAddress() 483 { 484 return null; 485 } 486 487 488 489 /** 490 * Specifies the size limit that will be enforced for searches 491 * performed using this client connection. This method does nothing 492 * because connection-level size limits will never be enforced for 493 * internal client connections. 494 * 495 * @param sizeLimit The size limit that will be enforced for 496 * searches performed using this client 497 * connection. 498 */ 499 @Override 500 public void setSizeLimit(int sizeLimit) 501 { 502 // No implementation required. We never want to set a nonzero 503 // size limit for internal client connections. 504 } 505 506 507 508 /** 509 * Specifies the default maximum number of entries that should 510 * be checked for matches during a search. This method does nothing 511 * because connection-level lookthrough limits will never be 512 * enforced for internal client connections 513 * 514 * @param lookthroughLimit The default maximum number of 515 * entries that should be check for 516 * matches during a search. 517 */ 518 @Override 519 public void setLookthroughLimit(int lookthroughLimit) 520 { 521 // No implementation required. We never want to set a nonzero 522 // lookthrough limit for internal client connections. 523 } 524 525 526 527 /** 528 * Specifies the maximum length of time in milliseconds that this 529 * client connection will be allowed to remain idle before it should 530 * be disconnected. This method does nothing because internal 531 * client connections will not be terminated due to an idle time 532 * limit. 533 * 534 * @param idleTimeLimit The maximum length of time in milliseconds 535 * that this client connection will be 536 * allowed to remain idle before it should be 537 * disconnected. 538 */ 539 @Override 540 public void setIdleTimeLimit(long idleTimeLimit) 541 { 542 // No implementation required. We never want to set a nonzero 543 // idle time limit for internal client connections. 544 } 545 546 547 548 /** 549 * Specifies the time limit that will be enforced for searches 550 * performed using this client connection. This method does nothing 551 * because connection-level time limits will never be enforced for 552 * internal client connections. 553 * 554 * @param timeLimit The time limit that will be enforced for 555 * searches performed using this client 556 * connection. 557 */ 558 @Override 559 public void setTimeLimit(int timeLimit) 560 { 561 // No implementation required. We never want to set a nonzero 562 // time limit for internal client connections. 563 } 564 565 /** {@inheritDoc} */ 566 @Override 567 public boolean isConnectionValid() 568 { 569 // This connection is always valid 570 return true; 571 } 572 573 /** 574 * Indicates whether this client connection is currently using a 575 * secure mechanism to communicate with the server. Note that this 576 * may change over time based on operations performed by the client 577 * or server (e.g., it may go from <CODE>false</CODE> to 578 * <CODE>true</CODE> if the client uses the StartTLS extended 579 * operation). 580 * 581 * @return <CODE>true</CODE> if the client connection is currently 582 * using a secure mechanism to communicate with the server, 583 * or <CODE>false</CODE> if not. 584 */ 585 @Override 586 public boolean isSecure() 587 { 588 return true; 589 } 590 591 592 593 /** 594 * Sends a response to the client based on the information in the 595 * provided operation. 596 * 597 * @param operation The operation for which to send the response. 598 */ 599 @org.opends.server.types.PublicAPI( 600 stability=org.opends.server.types.StabilityLevel.PRIVATE, 601 mayInstantiate=false, 602 mayExtend=false, 603 mayInvoke=false) 604 @Override 605 public void sendResponse(Operation operation) 606 { 607 // There will not be any response sent by this method, since there 608 // is not an actual connection. 609 } 610 611 612 613 /** 614 * This method has no effect, as the authentication info for 615 * internal client connections is set when the connection is created 616 * and cannot be changed after the fact. 617 * 618 * @param authenticationInfo Information about the authentication 619 * that has been performed for this 620 * connection. It should not be 621 * <CODE>null</CODE>. 622 */ 623 @org.opends.server.types.PublicAPI( 624 stability=org.opends.server.types.StabilityLevel.PRIVATE, 625 mayInstantiate=false, 626 mayExtend=false, 627 mayInvoke=false) 628 @Override 629 public void setAuthenticationInfo(AuthenticationInfo 630 authenticationInfo) 631 { 632 // No implementation required. 633 } 634 635 636 637 /** 638 * This method has no effect, as the authentication info for 639 * internal client connections is set when the connection is created 640 * and cannot be changed after the fact. 641 */ 642 @org.opends.server.types.PublicAPI( 643 stability=org.opends.server.types.StabilityLevel.PRIVATE, 644 mayInstantiate=false, 645 mayExtend=false, 646 mayInvoke=false) 647 @Override 648 public void setUnauthenticated() 649 { 650 // No implementation required. 651 } 652 653 654 655 /** 656 * Processes an internal add operation with the provided 657 * information. 658 * 659 * @param rawEntryDN The DN to use for the entry to add. 660 * @param rawAttributes The set of attributes to include in the 661 * entry to add. 662 * 663 * @return A reference to the add operation that was processed and 664 * contains information about the result of the processing. 665 */ 666 public AddOperation processAdd(String rawEntryDN, 667 List<RawAttribute> rawAttributes) 668 { 669 return processAdd(ByteString.valueOfUtf8(rawEntryDN), rawAttributes, null); 670 } 671 672 673 674 /** 675 * Processes an internal add operation with the provided 676 * information. 677 * 678 * @param rawEntryDN The DN to use for the entry to add. 679 * @param rawAttributes The set of attributes to include in the 680 * entry to add. 681 * 682 * @return A reference to the add operation that was processed and 683 * contains information about the result of the processing. 684 */ 685 public AddOperation processAdd(ByteString rawEntryDN, 686 List<RawAttribute> rawAttributes) 687 { 688 return processAdd(rawEntryDN, rawAttributes, null); 689 } 690 691 692 693 /** 694 * Processes an internal add operation with the provided 695 * information. 696 * 697 * @param rawEntryDN The DN to use for the entry to add. 698 * @param rawAttributes The set of attributes to include in the 699 * entry to add. 700 * @param controls The set of controls to include in the 701 * request. 702 * 703 * @return A reference to the add operation that was processed and 704 * contains information about the result of the processing. 705 */ 706 public AddOperation processAdd(ByteString rawEntryDN, 707 List<RawAttribute> rawAttributes, 708 List<Control> controls) 709 { 710 AddOperationBasis addOperation = 711 new AddOperationBasis(this, nextOperationID(), 712 nextMessageID(), controls, rawEntryDN, 713 rawAttributes); 714 addOperation.setInternalOperation(true); 715 716 addOperation.run(); 717 return addOperation; 718 } 719 720 721 722 /** 723 * Processes an internal add operation with the provided 724 * information. 725 * 726 * @param entryDN The entry DN for the add 727 * operation. 728 * @param objectClasses The set of object classes for the 729 * add operation. 730 * @param userAttributes The set of user attributes for the 731 * add operation. 732 * @param operationalAttributes The set of operational attributes 733 * for the add operation. 734 * 735 * @return A reference to the add operation that was processed and 736 * contains information about the result of the processing. 737 */ 738 public AddOperation processAdd(DN entryDN, 739 Map<ObjectClass,String> objectClasses, 740 Map<AttributeType,List<Attribute>> 741 userAttributes, 742 Map<AttributeType,List<Attribute>> 743 operationalAttributes) 744 { 745 return processAdd(entryDN, objectClasses, userAttributes, 746 operationalAttributes, null); 747 } 748 749 750 751 /** 752 * Processes an internal add operation with the provided 753 * information. 754 * 755 * @param entryDN The entry DN for the add 756 * operation. 757 * @param objectClasses The set of object classes for the 758 * add operation. 759 * @param userAttributes The set of user attributes for the 760 * add operation. 761 * @param operationalAttributes The set of operational attributes 762 * for the add operation. 763 * @param controls The set of controls to include in 764 * the request. 765 * 766 * @return A reference to the add operation that was processed and 767 * contains information about the result of the processing. 768 */ 769 public AddOperation processAdd(DN entryDN, 770 Map<ObjectClass,String> objectClasses, 771 Map<AttributeType,List<Attribute>> 772 userAttributes, 773 Map<AttributeType,List<Attribute>> 774 operationalAttributes, 775 List<Control> controls) 776 { 777 AddOperationBasis addOperation = 778 new AddOperationBasis(this, nextOperationID(), 779 nextMessageID(), controls, entryDN, 780 objectClasses, userAttributes, 781 operationalAttributes); 782 addOperation.setInternalOperation(true); 783 784 addOperation.run(); 785 return addOperation; 786 } 787 788 789 790 /** 791 * Processes an internal add operation with the provided 792 * information. 793 * 794 * @param entry The entry to be added. 795 * 796 * @return A reference to the add operation that was processed and 797 * contains information about the result of the processing. 798 */ 799 public AddOperation processAdd(Entry entry) 800 { 801 return processAdd(entry, null); 802 } 803 804 805 806 /** 807 * Processes an internal add operation with the provided 808 * information. 809 * 810 * @param entry The entry to be added. 811 * @param controls The set of controls to include in the request. 812 * 813 * @return A reference to the add operation that was processed and 814 * contains information about the result of the processing. 815 */ 816 public AddOperation processAdd(Entry entry, List<Control> controls) 817 { 818 return processAdd(entry.getName(), entry.getObjectClasses(), 819 entry.getUserAttributes(), 820 entry.getOperationalAttributes(), 821 controls); 822 } 823 824 825 826 /** 827 * Processes an internal add operation based on the provided add 828 * change record entry. 829 * 830 * @param addRecord The add change record entry to be processed. 831 * 832 * @return A reference to the add operation that was processed and 833 * contains information about the result of the processing. 834 */ 835 public AddOperation processAdd(AddChangeRecordEntry addRecord) 836 { 837 LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(); 838 LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); 839 LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(); 840 841 Entry e = new Entry(addRecord.getDN(), objectClasses, userAttrs, opAttrs); 842 843 ArrayList<ByteString> duplicateValues = new ArrayList<>(); 844 for (Attribute a : addRecord.getAttributes()) 845 { 846 if (a.getAttributeType().isObjectClass()) 847 { 848 for (ByteString v : a) 849 { 850 String ocName = v.toString(); 851 String lowerName = toLowerCase(ocName); 852 ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true); 853 objectClasses.put(oc, ocName); 854 } 855 } 856 else 857 { 858 e.addAttribute(a, duplicateValues); 859 } 860 } 861 862 return processAdd(addRecord.getDN(), objectClasses, userAttrs, opAttrs); 863 } 864 865 866 867 /** 868 * Processes an internal bind operation with the provided 869 * information. Note that regardless of whether the bind is 870 * successful, the authentication state for this internal connection 871 * will not be altered in any way. 872 * 873 * @param rawBindDN The bind DN for the operation. 874 * @param password The bind password for the operation. 875 * 876 * @return A reference to the bind operation that was processed and 877 * contains information about the result of the processing. 878 */ 879 public BindOperation processSimpleBind(String rawBindDN, 880 String password) 881 { 882 return processSimpleBind(ByteString.valueOfUtf8(rawBindDN), 883 ByteString.valueOfUtf8(password), null); 884 } 885 886 887 888 /** 889 * Processes an internal bind operation with the provided 890 * information. Note that regardless of whether the bind is 891 * successful, the authentication state for this internal connection 892 * will not be altered in any way. 893 * 894 * @param rawBindDN The bind DN for the operation. 895 * @param password The bind password for the operation. 896 * @param controls The set of controls to include in the 897 * request. 898 * 899 * @return A reference to the bind operation that was processed and 900 * contains information about the result of the processing. 901 */ 902 public BindOperation processSimpleBind(String rawBindDN, 903 String password, 904 List<Control> controls) 905 { 906 return processSimpleBind(ByteString.valueOfUtf8(rawBindDN), 907 ByteString.valueOfUtf8(password), controls); 908 } 909 910 911 912 /** 913 * Processes an internal bind operation with the provided 914 * information. Note that regardless of whether the bind is 915 * successful, the authentication state for this internal connection 916 * will not be altered in any way. 917 * 918 * @param rawBindDN The bind DN for the operation. 919 * @param password The bind password for the operation. 920 * 921 * @return A reference to the bind operation that was processed and 922 * contains information about the result of the processing. 923 */ 924 public BindOperation processSimpleBind(ByteString rawBindDN, 925 ByteString password) 926 { 927 return processSimpleBind(rawBindDN, password, null); 928 } 929 930 931 932 /** 933 * Processes an internal bind operation with the provided 934 * information. Note that regardless of whether the bind is 935 * successful, the authentication state for this internal connection 936 * will not be altered in any way. 937 * 938 * @param rawBindDN The bind DN for the operation. 939 * @param password The bind password for the operation. 940 * @param controls The set of controls to include in the request. 941 * 942 * @return A reference to the bind operation that was processed and 943 * contains information about the result of the processing. 944 */ 945 public BindOperation processSimpleBind(ByteString rawBindDN, 946 ByteString password, 947 List<Control> controls) 948 { 949 BindOperationBasis bindOperation = 950 new BindOperationBasis(this, nextOperationID(), 951 nextMessageID(), controls, 952 PROTOCOL_VERSION, rawBindDN, password); 953 bindOperation.setInternalOperation(true); 954 955 bindOperation.run(); 956 return bindOperation; 957 } 958 959 960 961 /** 962 * Processes an internal bind operation with the provided 963 * information. Note that regardless of whether the bind is 964 * successful, the authentication state for this internal connection 965 * will not be altered in any way. 966 * 967 * @param bindDN The bind DN for the operation. 968 * @param password The bind password for the operation. 969 * 970 * @return A reference to the bind operation that was processed and 971 * contains information about the result of the processing. 972 */ 973 public BindOperation processSimpleBind(DN bindDN, 974 ByteString password) 975 { 976 return processSimpleBind(bindDN, password, null); 977 } 978 979 980 981 /** 982 * Processes an internal bind operation with the provided 983 * information. Note that regardless of whether the bind is 984 * successful, the authentication state for this internal connection 985 * will not be altered in any way. 986 * 987 * @param bindDN The bind DN for the operation. 988 * @param password The bind password for the operation. 989 * @param controls The set of controls to include in the request. 990 * 991 * @return A reference to the bind operation that was processed and 992 * contains information about the result of the processing. 993 */ 994 public BindOperation processSimpleBind(DN bindDN, 995 ByteString password, 996 List<Control> controls) 997 { 998 BindOperationBasis bindOperation = 999 new BindOperationBasis(this, nextOperationID(), 1000 nextMessageID(), controls, 1001 PROTOCOL_VERSION, bindDN, password); 1002 bindOperation.setInternalOperation(true); 1003 1004 bindOperation.run(); 1005 return bindOperation; 1006 } 1007 1008 1009 1010 /** 1011 * Processes an internal bind operation with the provided 1012 * information. Note that regardless of whether the bind is 1013 * successful, the authentication state for this internal connection 1014 * will not be altered in any way. 1015 * 1016 * @param rawBindDN The bind DN for the operation. 1017 * @param saslMechanism The SASL mechanism for the operation. 1018 * @param saslCredentials The SASL credentials for the operation. 1019 * 1020 * @return A reference to the bind operation that was processed and 1021 * contains information about the result of the processing. 1022 */ 1023 public BindOperation processSASLBind(ByteString rawBindDN, 1024 String saslMechanism, 1025 ByteString saslCredentials) 1026 { 1027 return processSASLBind(rawBindDN, saslMechanism, saslCredentials, 1028 null); 1029 } 1030 1031 1032 1033 /** 1034 * Processes an internal bind operation with the provided 1035 * information. Note that regardless of whether the bind is 1036 * successful, the authentication state for this internal connection 1037 * will not be altered in any way. 1038 * 1039 * @param rawBindDN The bind DN for the operation. 1040 * @param saslMechanism The SASL mechanism for the operation. 1041 * @param saslCredentials The SASL credentials for the operation. 1042 * @param controls The set of controls to include in the 1043 * request. 1044 * 1045 * @return A reference to the bind operation that was processed and 1046 * contains information about the result of the processing. 1047 */ 1048 public BindOperation processSASLBind(ByteString rawBindDN, 1049 String saslMechanism, 1050 ByteString saslCredentials, 1051 List<Control> controls) 1052 { 1053 BindOperationBasis bindOperation = 1054 new BindOperationBasis(this, nextOperationID(), 1055 nextMessageID(), controls, 1056 PROTOCOL_VERSION, rawBindDN, saslMechanism, 1057 saslCredentials); 1058 bindOperation.setInternalOperation(true); 1059 1060 bindOperation.run(); 1061 return bindOperation; 1062 } 1063 1064 1065 1066 /** 1067 * Processes an internal bind operation with the provided 1068 * information. Note that regardless of whether the bind is 1069 * successful, the authentication state for this internal connection 1070 * will not be altered in any way. 1071 * 1072 * @param bindDN The bind DN for the operation. 1073 * @param saslMechanism The SASL mechanism for the operation. 1074 * @param saslCredentials The SASL credentials for the operation. 1075 * 1076 * @return A reference to the bind operation that was processed and 1077 * contains information about the result of the processing. 1078 */ 1079 public BindOperation processSASLBind(DN bindDN, 1080 String saslMechanism, 1081 ByteString saslCredentials) 1082 { 1083 return processSASLBind(bindDN, saslMechanism, saslCredentials, 1084 null); 1085 } 1086 1087 1088 1089 /** 1090 * Processes an internal bind operation with the provided 1091 * information. Note that regardless of whether the bind is 1092 * successful, the authentication state for this internal connection 1093 * will not be altered in any way. 1094 * 1095 * @param bindDN The bind DN for the operation. 1096 * @param saslMechanism The SASL mechanism for the operation. 1097 * @param saslCredentials The SASL credentials for the operation. 1098 * @param controls The set of controls to include in the 1099 * request. 1100 * 1101 * @return A reference to the bind operation that was processed and 1102 * contains information about the result of the processing. 1103 */ 1104 public BindOperation processSASLBind(DN bindDN, 1105 String saslMechanism, 1106 ByteString saslCredentials, 1107 List<Control> controls) 1108 { 1109 BindOperationBasis bindOperation = 1110 new BindOperationBasis(this, nextOperationID(), 1111 nextMessageID(), controls, 1112 PROTOCOL_VERSION, bindDN, saslMechanism, 1113 saslCredentials); 1114 bindOperation.setInternalOperation(true); 1115 1116 bindOperation.run(); 1117 return bindOperation; 1118 } 1119 1120 1121 1122 /** 1123 * Processes an internal compare operation with the provided 1124 * information. 1125 * 1126 * @param rawEntryDN The entry DN for the compare operation. 1127 * @param attributeType The attribute type for the compare 1128 * operation. 1129 * @param assertionValue The assertion value for the compare 1130 * operation. 1131 * 1132 * @return A reference to the compare operation that was processed 1133 * and contains information about the result of the 1134 * processing. 1135 */ 1136 public CompareOperation processCompare(String rawEntryDN, 1137 String attributeType, 1138 String assertionValue) 1139 { 1140 return processCompare(ByteString.valueOfUtf8(rawEntryDN), attributeType, 1141 ByteString.valueOfUtf8(assertionValue), null); 1142 } 1143 1144 1145 1146 /** 1147 * Processes an internal compare operation with the provided 1148 * information. 1149 * 1150 * @param rawEntryDN The entry DN for the compare operation. 1151 * @param attributeType The attribute type for the compare 1152 * operation. 1153 * @param assertionValue The assertion value for the compare 1154 * operation. 1155 * @param controls The set of controls to include in the 1156 * request. 1157 * 1158 * @return A reference to the compare operation that was processed 1159 * and contains information about the result of the 1160 * processing. 1161 */ 1162 public CompareOperation processCompare(String rawEntryDN, 1163 String attributeType, 1164 String assertionValue, 1165 List<Control> controls) 1166 { 1167 return processCompare(ByteString.valueOfUtf8(rawEntryDN), attributeType, 1168 ByteString.valueOfUtf8(assertionValue), controls); 1169 } 1170 1171 1172 1173 /** 1174 * Processes an internal compare operation with the provided 1175 * information. 1176 * 1177 * @param rawEntryDN The entry DN for the compare operation. 1178 * @param attributeType The attribute type for the compare 1179 * operation. 1180 * @param assertionValue The assertion value for the compare 1181 * operation. 1182 * 1183 * @return A reference to the compare operation that was processed 1184 * and contains information about the result of the 1185 * processing. 1186 */ 1187 public CompareOperation processCompare(ByteString rawEntryDN, 1188 String attributeType, 1189 ByteString assertionValue) 1190 { 1191 return processCompare(rawEntryDN, attributeType, assertionValue, 1192 null); 1193 } 1194 1195 1196 1197 /** 1198 * Processes an internal compare operation with the provided 1199 * information. 1200 * 1201 * @param rawEntryDN The entry DN for the compare operation. 1202 * @param attributeType The attribute type for the compare 1203 * operation. 1204 * @param assertionValue The assertion value for the compare 1205 * operation. 1206 * @param controls The set of controls to include in the 1207 * request. 1208 * 1209 * @return A reference to the compare operation that was processed 1210 * and contains information about the result of the 1211 * processing. 1212 */ 1213 public CompareOperation processCompare(ByteString rawEntryDN, 1214 String attributeType, 1215 ByteString assertionValue, 1216 List<Control> controls) 1217 { 1218 CompareOperationBasis compareOperation = 1219 new CompareOperationBasis(this, nextOperationID(), 1220 nextMessageID(), controls, rawEntryDN, 1221 attributeType, assertionValue); 1222 compareOperation.setInternalOperation(true); 1223 1224 compareOperation.run(); 1225 return compareOperation; 1226 } 1227 1228 1229 1230 /** 1231 * Processes an internal compare operation with the provided 1232 * information. 1233 * 1234 * @param entryDN The entry DN for the compare operation. 1235 * @param attributeType The attribute type for the compare 1236 * operation. 1237 * @param assertionValue The assertion value for the compare 1238 * operation. 1239 * 1240 * @return A reference to the compare operation that was processed 1241 * and contains information about the result of the 1242 * processing. 1243 */ 1244 public CompareOperation processCompare(DN entryDN, 1245 AttributeType attributeType, 1246 ByteString assertionValue) 1247 { 1248 return processCompare(entryDN, attributeType, assertionValue, 1249 null); 1250 } 1251 1252 1253 1254 /** 1255 * Processes an internal compare operation with the provided 1256 * information. 1257 * 1258 * @param entryDN The entry DN for the compare operation. 1259 * @param attributeType The attribute type for the compare 1260 * operation. 1261 * @param assertionValue The assertion value for the compare 1262 * operation. 1263 * @param controls The set of controls to include in the 1264 * request. 1265 * 1266 * @return A reference to the compare operation that was processed 1267 * and contains information about the result of the 1268 * processing. 1269 */ 1270 public CompareOperation processCompare(DN entryDN, 1271 AttributeType attributeType, 1272 ByteString assertionValue, 1273 List<Control> controls) 1274 { 1275 CompareOperationBasis compareOperation = 1276 new CompareOperationBasis(this, nextOperationID(), 1277 nextMessageID(), controls, entryDN, 1278 attributeType, assertionValue); 1279 compareOperation.setInternalOperation(true); 1280 1281 compareOperation.run(); 1282 return compareOperation; 1283 } 1284 1285 1286 1287 /** 1288 * Processes an internal delete operation with the provided 1289 * information. 1290 * 1291 * @param rawEntryDN The entry DN for the delete operation. 1292 * 1293 * @return A reference to the delete operation that was processed 1294 * and contains information about the result of the 1295 * processing. 1296 */ 1297 public DeleteOperation processDelete(String rawEntryDN) 1298 { 1299 return processDelete(ByteString.valueOfUtf8(rawEntryDN), null); 1300 } 1301 1302 1303 1304 /** 1305 * Processes an internal delete operation with the provided 1306 * information. 1307 * 1308 * @param rawEntryDN The entry DN for the delete operation. 1309 * @param controls The set of controls to include in the 1310 * request. 1311 * 1312 * @return A reference to the delete operation that was processed 1313 * and contains information about the result of the 1314 * processing. 1315 */ 1316 public DeleteOperation processDelete(String rawEntryDN, 1317 List<Control> controls) 1318 { 1319 return processDelete(ByteString.valueOfUtf8(rawEntryDN), controls); 1320 } 1321 1322 1323 1324 /** 1325 * Processes an internal delete operation with the provided 1326 * information. 1327 * 1328 * @param rawEntryDN The entry DN for the delete operation. 1329 * 1330 * @return A reference to the delete operation that was processed 1331 * and contains information about the result of the 1332 * processing. 1333 */ 1334 public DeleteOperation processDelete(ByteString rawEntryDN) 1335 { 1336 return processDelete(rawEntryDN, null); 1337 } 1338 1339 1340 1341 /** 1342 * Processes an internal delete operation with the provided 1343 * information. 1344 * 1345 * @param rawEntryDN The entry DN for the delete operation. 1346 * @param controls The set of controls to include in the 1347 * request. 1348 * 1349 * @return A reference to the delete operation that was processed 1350 * and contains information about the result of the 1351 * processing. 1352 */ 1353 public DeleteOperation processDelete(ByteString rawEntryDN, 1354 List<Control> controls) 1355 { 1356 DeleteOperationBasis deleteOperation = 1357 new DeleteOperationBasis(this, nextOperationID(), 1358 nextMessageID(), controls, rawEntryDN); 1359 deleteOperation.setInternalOperation(true); 1360 1361 deleteOperation.run(); 1362 return deleteOperation; 1363 } 1364 1365 1366 1367 /** 1368 * Processes an internal delete operation with the provided 1369 * information. 1370 * 1371 * @param entryDN The entry DN for the delete operation. 1372 * 1373 * @return A reference to the delete operation that was processed 1374 * and contains information about the result of the 1375 * processing. 1376 */ 1377 public DeleteOperation processDelete(DN entryDN) 1378 { 1379 return processDelete(entryDN, null); 1380 } 1381 1382 1383 1384 /** 1385 * Processes an internal delete operation with the provided 1386 * information. 1387 * 1388 * @param entryDN The entry DN for the delete operation. 1389 * @param controls The set of controls to include in the request. 1390 * 1391 * @return A reference to the delete operation that was processed 1392 * and contains information about the result of the 1393 * processing. 1394 */ 1395 public DeleteOperation processDelete(DN entryDN, 1396 List<Control> controls) 1397 { 1398 DeleteOperationBasis deleteOperation = 1399 new DeleteOperationBasis(this, nextOperationID(), 1400 nextMessageID(), controls, entryDN); 1401 deleteOperation.setInternalOperation(true); 1402 1403 deleteOperation.run(); 1404 return deleteOperation; 1405 } 1406 1407 1408 1409 /** 1410 * Processes an internal delete operation with the provided 1411 * information. 1412 * 1413 * @param deleteRecord The delete change record entry to be 1414 * processed. 1415 * 1416 * @return A reference to the delete operation that was processed 1417 * and contains information about the result of the 1418 * processing. 1419 */ 1420 public DeleteOperation processDelete( 1421 DeleteChangeRecordEntry deleteRecord) 1422 { 1423 return processDelete(deleteRecord.getDN()); 1424 } 1425 1426 1427 1428 /** 1429 * Processes an internal extended operation with the provided 1430 * information. 1431 * 1432 * @param requestOID The OID for the extended request. 1433 * @param requestValue The encoded value for the extended 1434 * operation, or <CODE>null</CODE> if there is 1435 * no value. 1436 * 1437 * @return A reference to the extended operation that was processed 1438 * and contains information about the result of the 1439 * processing. 1440 */ 1441 public ExtendedOperation processExtendedOperation( 1442 String requestOID, 1443 ByteString requestValue) 1444 { 1445 return processExtendedOperation(requestOID, requestValue, null); 1446 } 1447 1448 1449 1450 /** 1451 * Processes an internal extended operation with the provided 1452 * information. 1453 * 1454 * @param requestOID The OID for the extended request. 1455 * @param requestValue The encoded value for the extended 1456 * operation, or <CODE>null</CODE> if there is 1457 * no value. 1458 * @param controls The set of controls to include in the 1459 * request. 1460 * 1461 * @return A reference to the extended operation that was processed 1462 * and contains information about the result of the 1463 * processing. 1464 */ 1465 public ExtendedOperation processExtendedOperation( 1466 String requestOID, 1467 ByteString requestValue, 1468 List<Control> controls) 1469 { 1470 ExtendedOperationBasis extendedOperation = 1471 new ExtendedOperationBasis(this, nextOperationID(), 1472 nextMessageID(), controls, requestOID, 1473 requestValue); 1474 extendedOperation.setInternalOperation(true); 1475 extendedOperation.run(); 1476 return extendedOperation; 1477 } 1478 1479 1480 1481 /** 1482 * Processes an internal modify operation with the provided 1483 * information. 1484 * 1485 * @param rawEntryDN The raw entry DN for this modify 1486 * operation. 1487 * @param rawModifications The set of modifications for this 1488 * modify operation. 1489 * 1490 * @return A reference to the modify operation that was processed 1491 * and contains information about the result of the 1492 * processing. 1493 */ 1494 public ModifyOperation processModify(String rawEntryDN, 1495 List<RawModification> rawModifications) 1496 { 1497 return processModify(ByteString.valueOfUtf8(rawEntryDN), 1498 rawModifications, null); 1499 } 1500 1501 1502 1503 /** 1504 * Processes an internal modify operation with the provided 1505 * information. 1506 * 1507 * @param rawEntryDN The raw entry DN for this modify 1508 * operation. 1509 * @param rawModifications The set of modifications for this 1510 * modify operation. 1511 * @param controls The set of controls to include in the 1512 * request. 1513 * 1514 * @return A reference to the modify operation that was processed 1515 * and contains information about the result of the 1516 * processing. 1517 */ 1518 public ModifyOperation processModify(String rawEntryDN, 1519 List<RawModification> rawModifications, 1520 List<Control> controls) 1521 { 1522 return processModify(ByteString.valueOfUtf8(rawEntryDN), 1523 rawModifications, controls); 1524 } 1525 1526 1527 1528 /** 1529 * Processes an internal modify operation with the provided 1530 * information. 1531 * 1532 * @param rawEntryDN The raw entry DN for this modify 1533 * operation. 1534 * @param rawModifications The set of modifications for this 1535 * modify operation. 1536 * 1537 * @return A reference to the modify operation that was processed 1538 * and contains information about the result of the 1539 * processing. 1540 */ 1541 public ModifyOperation processModify(ByteString rawEntryDN, 1542 List<RawModification> rawModifications) 1543 { 1544 return processModify(rawEntryDN, rawModifications, null); 1545 } 1546 1547 1548 1549 /** 1550 * Processes an internal modify operation with the provided 1551 * information. 1552 * 1553 * @param rawEntryDN The raw entry DN for this modify 1554 * operation. 1555 * @param rawModifications The set of modifications for this 1556 * modify operation. 1557 * @param controls The set of controls to include in the 1558 * request. 1559 * 1560 * @return A reference to the modify operation that was processed 1561 * and contains information about the result of the 1562 * processing. 1563 */ 1564 public ModifyOperation processModify(ByteString rawEntryDN, 1565 List<RawModification> rawModifications, 1566 List<Control> controls) 1567 { 1568 ModifyOperationBasis modifyOperation = 1569 new ModifyOperationBasis(this, nextOperationID(), 1570 nextMessageID(), controls, rawEntryDN, 1571 rawModifications); 1572 modifyOperation.setInternalOperation(true); 1573 modifyOperation.run(); 1574 return modifyOperation; 1575 } 1576 1577 1578 1579 /** 1580 * Processes an internal modify operation with the provided 1581 * information. 1582 * 1583 * @param entryDN The entry DN for this modify operation. 1584 * @param modifications The set of modifications for this modify 1585 * operation. 1586 * 1587 * @return A reference to the modify operation that was processed 1588 * and contains information about the result of the 1589 * processing. 1590 */ 1591 public ModifyOperation processModify(DN entryDN, 1592 List<Modification> modifications) 1593 { 1594 return processModify(entryDN, modifications, null); 1595 } 1596 1597 1598 1599 /** 1600 * Processes an internal modify operation with the provided 1601 * information. 1602 * 1603 * @param entryDN The entry DN for this modify operation. 1604 * @param modifications The set of modifications for this modify 1605 * operation. 1606 * @param controls The set of controls to include in the 1607 * request. 1608 * 1609 * @return A reference to the modify operation that was processed 1610 * and contains information about the result of the 1611 * processing. 1612 */ 1613 public ModifyOperation processModify(DN entryDN, 1614 List<Modification> modifications, 1615 List<Control> controls) 1616 { 1617 ModifyOperationBasis modifyOperation = 1618 new ModifyOperationBasis(this, nextOperationID(), 1619 nextMessageID(), controls, entryDN, 1620 modifications); 1621 modifyOperation.setInternalOperation(true); 1622 modifyOperation.run(); 1623 return modifyOperation; 1624 } 1625 1626 1627 1628 /** 1629 * Processes an internal modify operation with the provided 1630 * information. 1631 * 1632 * @param modifyRecord The modify change record entry with 1633 * information about the changes to perform. 1634 * 1635 * @return A reference to the modify operation that was processed 1636 * and contains information about the result of the 1637 * processing. 1638 */ 1639 public ModifyOperation processModify( 1640 ModifyChangeRecordEntry modifyRecord) 1641 { 1642 return processModify(modifyRecord.getDN().toString(), 1643 modifyRecord.getModifications()); 1644 } 1645 1646 1647 1648 /** 1649 * Processes an internal modify DN operation with the provided 1650 * information. 1651 * 1652 * @param rawEntryDN The current DN of the entry to rename. 1653 * @param rawNewRDN The new RDN to use for the entry. 1654 * @param deleteOldRDN The flag indicating whether the old RDN 1655 * value is to be removed from the entry. 1656 * 1657 * @return A reference to the modify DN operation that was 1658 * processed and contains information about the result of 1659 * the processing. 1660 */ 1661 public ModifyDNOperation processModifyDN(String rawEntryDN, 1662 String rawNewRDN, 1663 boolean deleteOldRDN) 1664 { 1665 return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), 1666 ByteString.valueOfUtf8(rawNewRDN), 1667 deleteOldRDN, null, null); 1668 } 1669 1670 1671 1672 /** 1673 * Processes an internal modify DN operation with the provided 1674 * information. 1675 * 1676 * @param rawEntryDN The current DN of the entry to rename. 1677 * @param rawNewRDN The new RDN to use for the entry. 1678 * @param deleteOldRDN The flag indicating whether the old RDN 1679 * value is to be removed from the entry. 1680 * @param controls The set of controls to include in the 1681 * request. 1682 * 1683 * @return A reference to the modify DN operation that was 1684 * processed and contains information about the result of 1685 * the processing. 1686 */ 1687 public ModifyDNOperation processModifyDN(String rawEntryDN, 1688 String rawNewRDN, 1689 boolean deleteOldRDN, 1690 List<Control> controls) 1691 { 1692 return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), 1693 ByteString.valueOfUtf8(rawNewRDN), 1694 deleteOldRDN, null, controls); 1695 } 1696 1697 1698 1699 /** 1700 * Processes an internal modify DN operation with the provided 1701 * information. 1702 * 1703 * @param rawEntryDN The current DN of the entry to rename. 1704 * @param rawNewRDN The new RDN to use for the entry. 1705 * @param deleteOldRDN The flag indicating whether the old RDN 1706 * value is to be removed from the entry. 1707 * 1708 * @return A reference to the modify DN operation that was 1709 * processed and contains information about the result of 1710 * the processing. 1711 */ 1712 public ModifyDNOperation processModifyDN(ByteString rawEntryDN, 1713 ByteString rawNewRDN, 1714 boolean deleteOldRDN) 1715 { 1716 return processModifyDN(rawEntryDN, rawNewRDN, deleteOldRDN, null, 1717 null); 1718 } 1719 1720 1721 1722 /** 1723 * Processes an internal modify DN operation with the provided 1724 * information. 1725 * 1726 * @param rawEntryDN The current DN of the entry to rename. 1727 * @param rawNewRDN The new RDN to use for the entry. 1728 * @param deleteOldRDN The flag indicating whether the old RDN 1729 * value is to be removed from the entry. 1730 * @param rawNewSuperior The new superior for the modify DN 1731 * operation, or <CODE>null</CODE> if the 1732 * entry will remain below the same parent. 1733 * 1734 * @return A reference to the modify DN operation that was 1735 * processed and contains information about the result of 1736 * the processing. 1737 */ 1738 public ModifyDNOperation processModifyDN(String rawEntryDN, 1739 String rawNewRDN, 1740 boolean deleteOldRDN, 1741 String rawNewSuperior) 1742 { 1743 return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), 1744 ByteString.valueOfUtf8(rawNewRDN), deleteOldRDN, 1745 ByteString.valueOfUtf8(rawNewSuperior), null); 1746 } 1747 1748 1749 1750 /** 1751 * Processes an internal modify DN operation with the provided 1752 * information. 1753 * 1754 * @param rawEntryDN The current DN of the entry to rename. 1755 * @param rawNewRDN The new RDN to use for the entry. 1756 * @param deleteOldRDN The flag indicating whether the old RDN 1757 * value is to be removed from the entry. 1758 * @param rawNewSuperior The new superior for the modify DN 1759 * operation, or <CODE>null</CODE> if the 1760 * entry will remain below the same parent. 1761 * @param controls The set of controls to include in the 1762 * request. 1763 * 1764 * @return A reference to the modify DN operation that was 1765 * processed and contains information about the result of 1766 * the processing. 1767 */ 1768 public ModifyDNOperation processModifyDN(String rawEntryDN, 1769 String rawNewRDN, 1770 boolean deleteOldRDN, 1771 String rawNewSuperior, 1772 List<Control> controls) 1773 { 1774 return processModifyDN(ByteString.valueOfUtf8(rawEntryDN), 1775 ByteString.valueOfUtf8(rawNewRDN), deleteOldRDN, 1776 ByteString.valueOfUtf8(rawNewSuperior), controls); 1777 } 1778 1779 1780 1781 /** 1782 * Processes an internal modify DN operation with the provided 1783 * information. 1784 * 1785 * @param rawEntryDN The current DN of the entry to rename. 1786 * @param rawNewRDN The new RDN to use for the entry. 1787 * @param deleteOldRDN The flag indicating whether the old RDN 1788 * value is to be removed from the entry. 1789 * @param rawNewSuperior The new superior for the modify DN 1790 * operation, or <CODE>null</CODE> if the 1791 * entry will remain below the same parent. 1792 * 1793 * @return A reference to the modify DN operation that was 1794 * processed and contains information about the result of 1795 * the processing. 1796 */ 1797 public ModifyDNOperation processModifyDN(ByteString rawEntryDN, 1798 ByteString rawNewRDN, 1799 boolean deleteOldRDN, 1800 ByteString rawNewSuperior) 1801 { 1802 return processModifyDN(rawEntryDN, rawNewRDN, deleteOldRDN, 1803 rawNewSuperior, null); 1804 } 1805 1806 1807 1808 /** 1809 * Processes an internal modify DN operation with the provided 1810 * information. 1811 * 1812 * @param rawEntryDN The current DN of the entry to rename. 1813 * @param rawNewRDN The new RDN to use for the entry. 1814 * @param deleteOldRDN The flag indicating whether the old RDN 1815 * value is to be removed from the entry. 1816 * @param rawNewSuperior The new superior for the modify DN 1817 * operation, or <CODE>null</CODE> if the 1818 * entry will remain below the same parent. 1819 * @param controls The set of controls to include in the 1820 * request. 1821 * 1822 * @return A reference to the modify DN operation that was 1823 * processed and contains information about the result of 1824 * the processing. 1825 */ 1826 public ModifyDNOperation processModifyDN(ByteString rawEntryDN, 1827 ByteString rawNewRDN, 1828 boolean deleteOldRDN, 1829 ByteString rawNewSuperior, 1830 List<Control> controls) 1831 { 1832 ModifyDNOperationBasis modifyDNOperation = 1833 new ModifyDNOperationBasis(this, nextOperationID(), 1834 nextMessageID(), controls, rawEntryDN, 1835 rawNewRDN, deleteOldRDN, 1836 rawNewSuperior); 1837 modifyDNOperation.setInternalOperation(true); 1838 1839 modifyDNOperation.run(); 1840 return modifyDNOperation; 1841 } 1842 1843 1844 1845 /** 1846 * Processes an internal modify DN operation with the provided 1847 * information. 1848 * 1849 * @param entryDN The current DN of the entry to rename. 1850 * @param newRDN The new RDN to use for the entry. 1851 * @param deleteOldRDN The flag indicating whether the old RDN 1852 * value is to be removed from the entry. 1853 * 1854 * @return A reference to the modify DN operation that was 1855 * processed and contains information about the result of 1856 * the processing. 1857 */ 1858 public ModifyDNOperation processModifyDN(DN entryDN, 1859 RDN newRDN, 1860 boolean deleteOldRDN) 1861 { 1862 return processModifyDN(entryDN, newRDN, deleteOldRDN, null, null); 1863 } 1864 1865 1866 1867 /** 1868 * Processes an internal modify DN operation with the provided 1869 * information. 1870 * 1871 * @param entryDN The current DN of the entry to rename. 1872 * @param newRDN The new RDN to use for the entry. 1873 * @param deleteOldRDN The flag indicating whether the old RDN 1874 * value is to be removed from the entry. 1875 * @param newSuperior The new superior for the modify DN 1876 * operation, or <CODE>null</CODE> if the 1877 * entry will remain below the same parent. 1878 * 1879 * @return A reference to the modify DN operation that was 1880 * processed and contains information about the result of 1881 * the processing. 1882 */ 1883 public ModifyDNOperation processModifyDN(DN entryDN, 1884 RDN newRDN, 1885 boolean deleteOldRDN, 1886 DN newSuperior) 1887 { 1888 return processModifyDN(entryDN, newRDN, deleteOldRDN, newSuperior, 1889 null); 1890 } 1891 1892 1893 1894 /** 1895 * Processes an internal modify DN operation with the provided 1896 * information. 1897 * 1898 * @param entryDN The current DN of the entry to rename. 1899 * @param newRDN The new RDN to use for the entry. 1900 * @param deleteOldRDN The flag indicating whether the old RDN 1901 * value is to be removed from the entry. 1902 * @param newSuperior The new superior for the modify DN 1903 * operation, or <CODE>null</CODE> if the 1904 * entry will remain below the same parent. 1905 * @param controls The set of controls to include in the 1906 * request. 1907 * 1908 * @return A reference to the modify DN operation that was 1909 * processed and contains information about the result of 1910 * the processing. 1911 */ 1912 public ModifyDNOperation processModifyDN(DN entryDN, 1913 RDN newRDN, 1914 boolean deleteOldRDN, 1915 DN newSuperior, 1916 List<Control> controls) 1917 { 1918 ModifyDNOperationBasis modifyDNOperation = 1919 new ModifyDNOperationBasis(this, nextOperationID(), 1920 nextMessageID(), controls, entryDN, 1921 newRDN, deleteOldRDN, newSuperior); 1922 modifyDNOperation.setInternalOperation(true); 1923 1924 modifyDNOperation.run(); 1925 return modifyDNOperation; 1926 } 1927 1928 1929 1930 /** 1931 * Processes an internal modify DN operation with the provided 1932 * information. 1933 * 1934 * @param modifyDNRecord The modify DN change record entry with 1935 * information about the processing to 1936 * perform. 1937 * 1938 * @return A reference to the modify DN operation that was 1939 * processed and contains information about the result of 1940 * the processing. 1941 */ 1942 public ModifyDNOperation processModifyDN( 1943 ModifyDNChangeRecordEntry modifyDNRecord) 1944 { 1945 return processModifyDN(modifyDNRecord.getDN(), 1946 modifyDNRecord.getNewRDN(), 1947 modifyDNRecord.deleteOldRDN(), 1948 modifyDNRecord.getNewSuperiorDN()); 1949 } 1950 1951 /** 1952 * Processes an internal search operation with the provided 1953 * information. 1954 * 1955 * @param request The search request. 1956 * @return A reference to the internal search operation that was 1957 * processed and contains information about the result of 1958 * the processing. 1959 */ 1960 public InternalSearchOperation processSearch(final SearchRequest request) 1961 { 1962 return processSearch(request, null); 1963 } 1964 1965 1966 1967 /** 1968 * Processes an internal search operation with the provided 1969 * information. 1970 * 1971 * @param request The search request. 1972 * @param searchListener The internal search listener that should 1973 * be used to handle the matching entries 1974 * and references. 1975 * @return A reference to the internal search operation that was 1976 * processed and contains information about the result of 1977 * the processing. 1978 */ 1979 public InternalSearchOperation processSearch(final SearchRequest request, InternalSearchListener searchListener) 1980 { 1981 // FIXME uncomment this after we move to the SDK: 1982 // if (Filter.objectClassPresent().equals(filter)) { 1983 // filter = Filter.alwaysTrue(); 1984 // } 1985 InternalSearchOperation searchOperation = 1986 new InternalSearchOperation(this, nextOperationID(), nextMessageID(), request, searchListener); 1987 searchOperation.run(); 1988 return searchOperation; 1989 } 1990 1991 1992 1993 /** 1994 * Sends the provided search result entry to the client. 1995 * 1996 * @param searchOperation The search operation with which the 1997 * entry is associated. 1998 * @param searchEntry The search result entry to be sent to 1999 * the client. 2000 * 2001 * @throws DirectoryException If a problem occurs while processing 2002 * the entry and the search should be 2003 * terminated. 2004 */ 2005 @org.opends.server.types.PublicAPI( 2006 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2007 mayInstantiate=false, 2008 mayExtend=false, 2009 mayInvoke=false) 2010 @Override 2011 public void sendSearchEntry(SearchOperation searchOperation, 2012 SearchResultEntry searchEntry) 2013 throws DirectoryException 2014 { 2015 ((InternalSearchOperation) searchOperation). 2016 addSearchEntry(searchEntry); 2017 } 2018 2019 2020 2021 /** 2022 * Sends the provided search result reference to the client. 2023 * 2024 * @param searchOperation The search operation with which the 2025 * reference is associated. 2026 * @param searchReference The search result reference to be sent 2027 * to the client. 2028 * 2029 * @return <CODE>true</CODE> if the client is able to accept 2030 * referrals, or <CODE>false</CODE> if the client cannot 2031 * handle referrals and no more attempts should be made to 2032 * send them for the associated search operation. 2033 * 2034 * @throws DirectoryException If a problem occurs while processing 2035 * the entry and the search should be 2036 * terminated. 2037 */ 2038 @org.opends.server.types.PublicAPI( 2039 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2040 mayInstantiate=false, 2041 mayExtend=false, 2042 mayInvoke=false) 2043 @Override 2044 public boolean sendSearchReference(SearchOperation searchOperation, 2045 SearchResultReference searchReference) 2046 throws DirectoryException 2047 { 2048 ((InternalSearchOperation) 2049 searchOperation).addSearchReference(searchReference); 2050 return true; 2051 } 2052 2053 2054 2055 2056 /** 2057 * Sends the provided intermediate response message to the client. 2058 * 2059 * @param intermediateResponse The intermediate response message 2060 * to be sent. 2061 * 2062 * @return <CODE>true</CODE> if processing on the associated 2063 * operation should continue, or <CODE>false</CODE> if not. 2064 */ 2065 @org.opends.server.types.PublicAPI( 2066 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2067 mayInstantiate=false, 2068 mayExtend=false, 2069 mayInvoke=false) 2070 @Override 2071 protected boolean sendIntermediateResponseMessage( 2072 IntermediateResponse intermediateResponse) 2073 { 2074 // FIXME -- Do we need to support internal intermediate responses? 2075 // If so, then implement this. 2076 return false; 2077 } 2078 2079 2080 2081 2082 /** 2083 * Closes the connection to the client, optionally sending it a 2084 * message indicating the reason for the closure. Note that the 2085 * ability to send a notice of disconnection may not be available 2086 * for all protocols or under all circumstances. 2087 * 2088 * @param disconnectReason The disconnect reason that provides the 2089 * generic cause for the disconnect. 2090 * @param sendNotification Indicates whether to try to provide 2091 * notification to the client that the 2092 * connection will be closed. 2093 * @param message The message to send to the client. It 2094 * may be <CODE>null</CODE> if no 2095 * notification is to be sent. 2096 */ 2097 @org.opends.server.types.PublicAPI( 2098 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2099 mayInstantiate=false, 2100 mayExtend=false, 2101 mayInvoke=false) 2102 @Override 2103 public void disconnect(DisconnectReason disconnectReason, 2104 boolean sendNotification, 2105 LocalizableMessage message) 2106 { 2107 // No implementation is required since there is nothing to 2108 // disconnect. Further, since there is no real disconnect, we can 2109 // wait to have the garbage collector call 2110 // finalizeConnectionInternal whenever this internal connection is 2111 // garbage collected. 2112 } 2113 2114 2115 2116 /** 2117 * Retrieves the set of operations in progress for this client 2118 * connection. This list must not be altered by any caller. 2119 * 2120 * @return The set of operations in progress for this client 2121 * connection. 2122 */ 2123 @org.opends.server.types.PublicAPI( 2124 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2125 mayInstantiate=false, 2126 mayExtend=false, 2127 mayInvoke=false) 2128 @Override 2129 public Collection<Operation> getOperationsInProgress() 2130 { 2131 return Collections.emptyList(); 2132 } 2133 2134 2135 2136 /** 2137 * Retrieves the operation in progress with the specified message 2138 * ID. 2139 * 2140 * @param messageID The message ID of the operation to retrieve. 2141 * 2142 * @return The operation in progress with the specified message ID, 2143 * or <CODE>null</CODE> if no such operation could be 2144 * found. 2145 */ 2146 @org.opends.server.types.PublicAPI( 2147 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2148 mayInstantiate=false, 2149 mayExtend=false, 2150 mayInvoke=false) 2151 @Override 2152 public Operation getOperationInProgress(int messageID) 2153 { 2154 // Internal operations will not be tracked. 2155 return null; 2156 } 2157 2158 2159 2160 /** 2161 * Removes the provided operation from the set of operations in 2162 * progress for this client connection. Note that this does not 2163 * make any attempt to cancel any processing that may already be in 2164 * progress for the operation. 2165 * 2166 * @param messageID The message ID of the operation to remove from 2167 * the set of operations in progress. 2168 * 2169 * @return <CODE>true</CODE> if the operation was found and removed 2170 * from the set of operations in progress, or 2171 * <CODE>false</CODE> if not. 2172 */ 2173 @org.opends.server.types.PublicAPI( 2174 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2175 mayInstantiate=false, 2176 mayExtend=false, 2177 mayInvoke=false) 2178 @Override 2179 public boolean removeOperationInProgress(int messageID) 2180 { 2181 // No implementation is required, since internal operations will 2182 // not be tracked. 2183 return false; 2184 } 2185 2186 2187 2188 /** 2189 * Attempts to cancel the specified operation. 2190 * 2191 * @param messageID The message ID of the operation to cancel. 2192 * @param cancelRequest An object providing additional information 2193 * about how the cancel should be processed. 2194 * 2195 * @return A cancel result that either indicates that the cancel 2196 * was successful or provides a reason that it was not. 2197 */ 2198 @org.opends.server.types.PublicAPI( 2199 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2200 mayInstantiate=false, 2201 mayExtend=false, 2202 mayInvoke=false) 2203 @Override 2204 public CancelResult cancelOperation(int messageID, 2205 CancelRequest cancelRequest) 2206 { 2207 // Internal operations cannot be cancelled. 2208 // TODO: i18n 2209 return new CancelResult(ResultCode.CANNOT_CANCEL, 2210 LocalizableMessage.raw("Internal operations cannot be cancelled")); 2211 } 2212 2213 2214 2215 /** 2216 * Attempts to cancel all operations in progress on this connection. 2217 * 2218 * @param cancelRequest An object providing additional information 2219 * about how the cancel should be processed. 2220 */ 2221 @org.opends.server.types.PublicAPI( 2222 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2223 mayInstantiate=false, 2224 mayExtend=false, 2225 mayInvoke=false) 2226 @Override 2227 public void cancelAllOperations(CancelRequest cancelRequest) 2228 { 2229 // No implementation is required since internal operations cannot 2230 // be cancelled. 2231 } 2232 2233 2234 2235 /** 2236 * Attempts to cancel all operations in progress on this connection 2237 * except the operation with the specified message ID. 2238 * 2239 * @param cancelRequest An object providing additional information 2240 * about how the cancel should be processed. 2241 * @param messageID The message ID of the operation that 2242 * should not be canceled. 2243 */ 2244 @org.opends.server.types.PublicAPI( 2245 stability=org.opends.server.types.StabilityLevel.PRIVATE, 2246 mayInstantiate=false, 2247 mayExtend=false, 2248 mayInvoke=false) 2249 @Override 2250 public void cancelAllOperationsExcept(CancelRequest cancelRequest, 2251 int messageID) 2252 { 2253 // No implementation is required since internal operations cannot 2254 // be cancelled. 2255 } 2256 2257 2258 2259 /** 2260 * Retrieves a one-line summary of this client connection in a form 2261 * that is suitable for including in the monitor entry for the 2262 * associated connection handler. It should be in a format that is 2263 * both human readable and machine parseable (e.g., a 2264 * space-delimited name-value list, with quotes around the values). 2265 * 2266 * @return A one-line summary of this client connection in a form 2267 * that is suitable for including in the monitor entry for 2268 * the associated connection handler. 2269 */ 2270 @Override 2271 public String getMonitorSummary() 2272 { 2273 StringBuilder buffer = new StringBuilder(); 2274 buffer.append("connID=\""); 2275 buffer.append(connectionID); 2276 buffer.append("\" authDN=\""); 2277 buffer.append(getAuthenticationInfo().getAuthenticationDN()); 2278 buffer.append("\""); 2279 2280 return buffer.toString(); 2281 } 2282 2283 2284 2285 /** 2286 * Appends a string representation of this client connection to the 2287 * provided buffer. 2288 * 2289 * @param buffer The buffer to which the information should be 2290 * appended. 2291 */ 2292 @Override 2293 public void toString(StringBuilder buffer) 2294 { 2295 buffer.append("InternalClientConnection(connID="); 2296 buffer.append(connectionID); 2297 buffer.append(", authDN=\""); 2298 2299 if (getAuthenticationInfo() != null) 2300 { 2301 buffer.append(getAuthenticationInfo().getAuthenticationDN()); 2302 } 2303 2304 buffer.append("\")"); 2305 } 2306 2307 /** 2308 * Called near the end of server shutdown. This ensures that a new 2309 * InternalClientConnection is created if the server is immediately 2310 * restarted as part of an in-core restart. 2311 */ 2312 static void clearRootClientConnectionAtShutdown() 2313 { 2314 rootConnection = null; 2315 } 2316 2317 /** 2318 * To be implemented. 2319 * 2320 * @return number of operations performed on this connection 2321 */ 2322 @Override 2323 public long getNumberOfOperations() { 2324 // Internal operations will not be limited. 2325 return 0; 2326 } 2327 2328 /** {@inheritDoc} */ 2329 @Override 2330 public int getSSF() { 2331 //Always return strongest value. 2332 return 256; 2333 } 2334}