mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
25.33.2012 263d085885df024dca9250cc03c807912b0a7662
Reformat to comply with new Checkstyle rules.
653 files modified
8 files added
93787 ■■■■■ changed files
opendj3/opendj-ldap-sdk-examples/pom.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java 110 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java 99 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java 367 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java 77 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java 121 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java 128 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java 192 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java 19 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java 397 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java 172 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/package-info.java 12 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/pom.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferReader.java 416 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java 441 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java 102 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPMessageHandler.java 198 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ConnectionSecurityLayerFilter.java 110 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransport.java 144 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/InternalConnection.java 195 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPBindFutureResultImpl.java 47 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPClientFilter.java 559 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPCompareFutureResultImpl.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnection.java 813 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java 209 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConstants.java 32 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPExtendedFutureResultImpl.java 59 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPFutureResultImpl.java 44 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPListenerImpl.java 84 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPMessageHandler.java 127 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java 1181 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPSearchFutureResultImpl.java 74 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java 919 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPUtils.java 441 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPWriter.java 454 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/TimeoutChecker.java 93 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedRequestException.java 37 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedResponseException.java 38 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnsupportedMessageException.java 44 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControl.java 86 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/AccountUsabilityResponseControl.java 265 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/RealAttributesOnlyRequestControl.java 91 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/VirtualAttributesOnlyRequestControl.java 93 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetConnectionIDExtendedRequest.java 132 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetConnectionIDExtendedResult.java 67 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetSymmetricKeyExtendedRequest.java 167 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateExtendedRequest.java 627 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateExtendedResult.java 60 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperation.java 20 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperationContainer.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperationType.java 93 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ASCIICharProp.java 227 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java 244 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Base64.java 82 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ByteSequenceOutputStream.java 63 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Collections2.java 286 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/CompletedFutureResult.java 78 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java 347 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Function.java 22 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Functions.java 287 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/FutureResultTransformer.java 111 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Iterables.java 193 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Iterators.java 291 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Predicate.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/RecursiveFutureResult.java 136 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/SizeLimitInputStream.java 98 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java 581 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StringPrepProfile.java 732 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/SubstringReader.java 82 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Validator.java 112 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java 102 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java 293 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java 449 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java 327 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Reader.java 112 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Writer.java 105 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java 107 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java 85 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AVA.java 567 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java 143 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java 255 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java 383 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java 194 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractFilterVisitor.java 97 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java 253 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java 105 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Assertion.java 20 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AssertionFailureException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java 219 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java 877 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AttributeFactory.java 16 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java 384 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java 123 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticationException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthorizationException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteSequence.java 142 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteSequenceReader.java 273 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteString.java 369 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java 602 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/CancelRequestListener.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/CancelledResultException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConditionResult.java 173 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java 468 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionEventListener.java 34 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java 35 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionSecurityLayer.java 31 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java 205 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConstraintViolationException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java 559 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DecodeException.java 66 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DecodeOptions.java 102 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DereferenceAliasesPolicy.java 112 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java 435 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java 276 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/EntryFactory.java 16 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/EntryNotFoundException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java 142 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultIOException.java 32 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java 71 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Filter.java 1231 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FilterVisitor.java 74 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java 599 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FutureResult.java 74 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java 215 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/IntermediateResponseHandler.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java 58 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/KeyManagers.java 255 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPClientContext.java 54 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java 114 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java 164 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPListenerOptions.java 83 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPOptions.java 166 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPUrl.java 504 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java 620 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedHashMapEntry.java 93 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java 53 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancingAlgorithm.java 16 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Matcher.java 581 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Modification.java 56 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ModificationType.java 95 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MultipleEntriesFoundException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RDN.java 226 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ReferralException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestContext.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandler.java 76 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandlerFactory.java 31 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandlerFactoryAdapter.java 689 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ResultCode.java 528 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ResultHandler.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java 339 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RoundRobinLoadBalancingAlgorithm.java 77 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SSLContextBuilder.java 123 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SchemaResolver.java 36 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchResultHandler.java 44 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchResultReferenceIOException.java 32 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchScope.java 91 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ServerConnection.java 39 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ServerConnectionFactory.java 20 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SortKey.java 408 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TimeoutResultException.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TreeMapEntry.java 93 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TrustManagers.java 355 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AssertionRequestControl.java 112 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AuthorizationIdentityRequestControl.java 98 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AuthorizationIdentityResponseControl.java 107 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/Control.java 50 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ControlDecoder.java 31 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java 221 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/GenericControl.java 99 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/GetEffectiveRightsRequestControl.java 268 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ManageDsaITRequestControl.java 97 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/MatchedValuesRequestControl.java 278 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordExpiredResponseControl.java 88 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordExpiringResponseControl.java 122 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyErrorType.java 39 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyRequestControl.java 87 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyResponseControl.java 192 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyWarningType.java 35 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PermissiveModifyRequestControl.java 98 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PersistentSearchChangeType.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PersistentSearchRequestControl.java 230 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PostReadRequestControl.java 218 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PostReadResponseControl.java 143 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PreReadRequestControl.java 222 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PreReadResponseControl.java 140 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ProxiedAuthV1RequestControl.java 158 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ProxiedAuthV2RequestControl.java 170 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ServerSideSortRequestControl.java 205 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ServerSideSortResponseControl.java 218 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SimplePagedResultsControl.java 204 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SubentriesRequestControl.java 134 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SubtreeDeleteRequestControl.java 90 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/VirtualListViewRequestControl.java 304 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/VirtualListViewResponseControl.java 156 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbandonRequest.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbandonRequestImpl.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractBindRequest.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractExtendedRequest.java 50 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractRequestImpl.java 62 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractSASLBindRequest.java 38 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableBindRequest.java 14 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableExtendedRequest.java 19 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableRequest.java 87 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableSASLBindRequest.java 17 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java 85 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java 169 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequest.java 67 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequestImpl.java 68 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindClient.java 28 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindClientImpl.java 74 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java 49 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequest.java 79 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequestImpl.java 154 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CancelExtendedRequest.java 46 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CancelExtendedRequestImpl.java 129 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java 85 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java 102 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DeleteRequest.java 48 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DeleteRequestImpl.java 59 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequest.java 228 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestImpl.java 341 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExtendedRequest.java 46 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExtendedRequestDecoder.java 32 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequest.java 84 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequestImpl.java 127 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequest.java 202 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestImpl.java 439 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequest.java 94 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequestImpl.java 97 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java 58 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java 155 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyDNRequest.java 116 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyDNRequestImpl.java 100 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyRequest.java 75 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyRequestImpl.java 94 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java 119 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java 260 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequest.java 101 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequestImpl.java 147 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Request.java 45 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java 922 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SASLBindClientImpl.java 211 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SASLBindRequest.java 45 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java 159 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequestImpl.java 144 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SimpleBindRequest.java 76 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SimpleBindRequestImpl.java 81 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/StartTLSExtendedRequest.java 92 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/StartTLSExtendedRequestImpl.java 156 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnbindRequest.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnbindRequestImpl.java 35 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAbandonRequestImpl.java 31 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java 175 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAnonymousSASLBindRequestImpl.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCRAMMD5SASLBindRequestImpl.java 46 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCancelExtendedRequestImpl.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java 74 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableDeleteRequestImpl.java 43 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableDigestMD5SASLBindRequestImpl.java 127 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableExternalSASLBindRequestImpl.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGSSAPISASLBindRequestImpl.java 137 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericBindRequestImpl.java 42 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java 34 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableModifyDNRequestImpl.java 83 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableModifyRequestImpl.java 82 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java 72 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePlainSASLBindRequestImpl.java 57 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableSearchRequestImpl.java 114 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableSimpleBindRequestImpl.java 42 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableStartTLSExtendedRequestImpl.java 56 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableUnbindRequestImpl.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableWhoAmIExtendedRequestImpl.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/WhoAmIExtendedRequest.java 43 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/WhoAmIExtendedRequestImpl.java 127 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractExtendedResult.java 47 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractExtendedResultDecoder.java 94 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractIntermediateResponse.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResponseImpl.java 61 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResultImpl.java 104 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableExtendedResultImpl.java 16 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableIntermediateResponseImpl.java 17 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableResponseImpl.java 90 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableResultImpl.java 81 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/BindResult.java 72 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/BindResultImpl.java 57 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/CompareResult.java 56 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/CompareResultImpl.java 42 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ExtendedResult.java 76 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ExtendedResultDecoder.java 73 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java 80 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java 68 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java 69 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/IntermediateResponse.java 48 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java 70 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java 93 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Response.java 45 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java 262 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Result.java 75 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ResultImpl.java 36 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java 89 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java 160 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultReference.java 36 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultReferenceImpl.java 59 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableBindResultImpl.java 38 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableCompareResultImpl.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java 38 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableResultImpl.java 20 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java 172 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultReferenceImpl.java 32 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableWhoAmIExtendedResultImpl.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/WhoAmIExtendedResult.java 84 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/WhoAmIExtendedResultImpl.java 74 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java 86 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java 65 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java 300 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxImpl.java 44 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java 521 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java 205 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeUsage.java 43 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordExactEqualityMatchingRuleImpl.java 32 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordSyntaxImpl.java 181 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BinarySyntaxImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleImpl.java 48 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxImpl.java 70 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleImpl.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BooleanSyntaxImpl.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleImpl.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleImpl.java 52 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleImpl.java 62 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleImpl.java 42 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleImpl.java 52 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleImpl.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleImpl.java 52 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleImpl.java 62 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListEqualityMatchingRuleImpl.java 55 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListSubstringMatchingRuleImpl.java 79 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleImpl.java 42 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleImpl.java 52 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificateListSyntaxImpl.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificatePairSyntaxImpl.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxImpl.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ConflictingSchemaElementException.java 22 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchema.java 1657 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchemaImpl.java 1139 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CountryStringSyntaxImpl.java 76 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRule.java 430 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java 147 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java 215 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java 132 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DefaultSchema.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DeliveryMethodSyntaxImpl.java 84 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleImpl.java 59 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringSyntaxImpl.java 76 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleImpl.java 138 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameSyntaxImpl.java 50 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DoubleMetaphoneApproximateMatchingRuleImpl.java 440 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java 109 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnumOrderingMatchingRule.java 36 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnumSyntaxImpl.java 102 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EqualLengthApproximateMatchingRuleImpl.java 40 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java 122 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/FaxSyntaxImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeEqualityMatchingRuleImpl.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeOrderingMatchingRuleImpl.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeSyntaxImpl.java 700 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GenerateCoreSchema.java 248 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java 306 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IA5StringSyntaxImpl.java 74 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerEqualityMatchingRuleImpl.java 34 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java 67 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerOrderingMatchingRuleImpl.java 35 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerSyntaxImpl.java 111 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java 78 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java 149 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java 276 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java 51 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java 146 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUse.java 223 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java 145 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameAndOptionalUIDSyntaxImpl.java 90 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameForm.java 284 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java 158 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleImpl.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleImpl.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleImpl.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSyntaxImpl.java 71 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OIDSyntaxImpl.java 64 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java 491 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java 156 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassType.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java 104 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java 52 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringEqualityMatchingRuleImpl.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringOrderingMatchingRuleImpl.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringSubstringMatchingRuleImpl.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringSyntaxImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OtherMailboxSyntaxImpl.java 95 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PostalAddressSyntaxImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressEqualityMatchingRuleImpl.java 42 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressSyntaxImpl.java 63 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PrintableStringSyntaxImpl.java 89 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationEqualityMatchingRuleImpl.java 42 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationSyntaxImpl.java 63 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/RegexSyntaxImpl.java 73 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java 2247 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java 2514 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaConstants.java 413 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaElement.java 73 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaException.java 39 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java 614 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java 250 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SubstringAssertionSyntaxImpl.java 85 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SupportedAlgorithmSyntaxImpl.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java 284 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SyntaxImpl.java 68 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberEqualityMatchingRuleImpl.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSubstringMatchingRuleImpl.java 29 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSyntaxImpl.java 112 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java 141 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java 132 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UTCTimeSyntaxImpl.java 364 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDEqualityMatchingRuleImpl.java 52 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDOrderingMatchingRuleImpl.java 53 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDSyntaxImpl.java 70 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UnknownSchemaElementException.java 22 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordExactEqualityMatchingRuleImpl.java 40 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordSyntaxImpl.java 92 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/WordEqualityMatchingRuleImpl.java 78 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java 619 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFStream.java 88 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFWriter.java 262 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecord.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordReader.java 28 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordVisitor.java 30 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordVisitorWriter.java 80 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordWriter.java 53 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java 147 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java 273 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java 64 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/EntryReader.java 34 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/EntryWriter.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIF.java 567 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordReader.java 576 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordWriter.java 213 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFEntryReader.java 265 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFEntryWriter.java 179 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/RejectedChangeRecordListener.java 148 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/RejectedLDIFListener.java 124 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_de.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_es.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_fr.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_ja.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_ko.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_zh_CN.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_zh_TW.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferReaderTestCase.java 26 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferWriterTestCase.java 41 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransportTestCase.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/LDAPTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java 42 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityResponseControlTestCase.java 60 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/ASCIICharPropTestCase.java 49 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/Base64TestCase.java 125 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/StaticUtilsTestCase.java 98 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/StringPrepProfileTestCase.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/UtilTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReaderTestCase.java 23 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1InputStreamReaderTestCase.java 24 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriterTestCase.java 38 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java 450 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java 315 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnectionTestCase.java 472 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AttributeDescriptionTestCase.java 310 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteSequenceTestCase.java 142 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java 245 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteStringTestCase.java 156 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java 277 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java 502 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/EntriesTestCase.java 40 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/EntryTestCase.java 82 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/FilterTestCase.java 148 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java 838 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java 512 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPUrlTestCase.java 132 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LinkedAttributeTestCase.java 245 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/RDNTestCase.java 227 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/SdkTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/TestCaseUtils.java 90 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/TypesTestCase.java 82 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/controls/ControlsTestCase.java 21 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AbandonRequestTestCase.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AddRequestTestCase.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequestTestCase.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/BindRequestTestCase.java 36 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequestTestCase.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/CompareRequestTestCase.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/DeleteRequestTestCase.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestTestCase.java 59 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ExtendedRequestTestCase.java 22 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequestTestCase.java 37 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestTestCase.java 54 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/GenericBindRequestTestCase.java 45 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ModifyDNRequestTestCase.java 40 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ModifyRequestTestCase.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequestTestCase.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/RequestTestCase.java 54 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/RequestsTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/SimpleBindRequestTestCase.java 34 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/UnbindRequestTestCase.java 34 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/responses/ResponsesTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java 73 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java 47 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxTest.java 28 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeTest.java 286 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleTest.java 33 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleTest.java 45 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleTest.java 33 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleTest.java 33 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java 70 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleTest.java 37 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java 70 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleTest.java 37 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleTest.java 33 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java 73 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleTest.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java 73 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java 22 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxTest.java 71 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleTest.java 101 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java 455 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/EnumSyntaxTestCase.java 90 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeSyntaxTest.java 36 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/GuideSyntaxTest.java 38 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/IA5StringSyntaxTest.java 28 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxTest.java 59 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxTest.java 28 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java 57 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxTest.java 33 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java 76 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/OtherMailboxSyntaxTest.java 31 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/RegexSyntaxTestCase.java 48 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTest.java 249 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java 112 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java 69 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SubstitutionSyntaxTestCase.java 89 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java 140 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java 37 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/TelexSyntaxTest.java 31 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/UTCTimeSyntaxTest.java 74 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/UUIDSyntaxTest.java 28 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java 195 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java 97 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFEntryWriterTestCase.java 51 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/pom.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/bat/ldapsync.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/descriptor.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/libbat/_client-script.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/libbat/_script-util.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/libbat/setcp.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/libbin/_client-script.sh 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/assembly/libbin/_script-util.sh 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/Main.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/ChangeRecordContext.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Filter.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/FilterResult.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Matchers.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Transforms.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/package-info.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/package-info.java 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/pom.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/authrate.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapcompare.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapmodify.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldappasswordmodify.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapsearch.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifdiff.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifmodify.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifsearch.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/modrate.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/bat/searchrate.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/descriptor.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/_client-script.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/_script-util.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/setcp.bat 6 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/libbin/_client-script.sh 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/assembly/libbin/_script-util.sh 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ApplicationKeyManager.java 211 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Argument.java 443 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentException.java 36 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentGroup.java 84 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentParser.java 1133 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java 442 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java 208 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/BooleanArgument.java 58 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/CLIException.java 46 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java 658 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConsoleApplication.java 236 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/DataSource.java 465 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/FileBasedArgument.java 183 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/IntegerArgument.java 666 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java 407 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 540 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 255 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java 964 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java 170 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java 286 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java 241 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java 207 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiChoiceArgument.java 179 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiColumnPrinter.java 214 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java 673 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PromptingTrustManager.java 303 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java 262 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/StringArgument.java 102 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ToolConstants.java 40 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java 567 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/package-info.java 13 ●●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_de.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_es.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_fr.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ja.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ko.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_CN.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_TW.properties 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ToolsTestCase.java 18 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/pom.xml 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/AttributeMapper.java 95 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/CompletionHandler.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java 27 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/EntryContainer.java 46 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/LDAPResource.java 137 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReadRequest.java 37 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/RestRequest.java 24 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Validator.java 41 ●●●●● patch | view | raw | blame | history
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/package-info.java 11 ●●●● patch | view | raw | blame | history
opendj3/pom.xml 13 ●●●● patch | view | raw | blame | history
opendj3/src/site/resources/Example.ldif 11 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk-examples/pom.xml
@@ -7,17 +7,16 @@
  ! (the "License").  You may not use this file except in compliance
  ! with the License.
  !
  ! You can obtain a copy of the license at
  ! trunk/opendj3/legal-notices/CDDLv1_0.txt
  ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
  ! or http://forgerock.org/license/CDDLv1.0.html.
  ! See the License for the specific language governing permissions
  ! and limitations under the License.
  !
  ! When distributing Covered Code, include this CDDL HEADER in each
  ! file and include the License file at
  ! trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
  ! add the following below this CDDL HEADER, with the fields enclosed
  ! by brackets "[]" replaced with your own identifying information:
  ! file and include the License file at legal-notices/CDDLv1_0.txt.
  ! If applicable, add the following below this CDDL HEADER, with the
  ! fields enclosed by brackets "[]" replaced with your own identifying
  ! information:
  !      Portions Copyright [yyyy] [name of copyright owner]
  !
  ! CDDL HEADER END
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,29 +25,26 @@
 */
package org.forgerock.opendj.examples;
import java.io.IOException;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
/**
 * Demonstrates accessing server information about capabilities and schema.
 */
public final class GetInfo
{
public final class GetInfo {
  // Connection information
  private static String host;
  private static int port;
  // The kind of server information to request (all, controls, extops)
  private static String infoType;
  /**
   * Access the directory over LDAP to request information about capabilities
   * and schema.
@@ -56,130 +52,98 @@
   * @param args
   *          The command line arguments
   */
  public static void main(final String[] args)
  {
    public static void main(final String[] args) {
    parseArgs(args);
    connect();
  }
  /**
   * Authenticate over LDAP.
   */
  private static void connect()
  {
    private static void connect() {
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
    Connection connection = null;
    try
    {
        try {
      connection = factory.getConnection();
      connection.bind("", "".toCharArray()); // Anonymous bind
      final String attributeList;
      if (infoType.toLowerCase().equals("controls"))
      {
            if (infoType.toLowerCase().equals("controls")) {
        attributeList = "supportedControl";
      }
      else if (infoType.toLowerCase().equals("extops"))
      {
            } else if (infoType.toLowerCase().equals("extops")) {
        attributeList = "supportedExtension";
      }
      else
      {
            } else {
        attributeList = "+"; // All operational attributes
      }
      final SearchResultEntry entry = connection.searchSingleEntry(
          "",                      // DN is "" for root DSE.
            final SearchResultEntry entry = connection.searchSingleEntry("", // DN
                                                                             // is
                                                                             // ""
                                                                             // for
                                                                             // root
                                                                             // DSE.
          SearchScope.BASE_OBJECT, // Read only the root DSE.
          "objectclass=*",         // Every object matches this filter.
          attributeList);          // Return these requested attributes.
      final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
      writer.writeComment("Root DSE for LDAP server at " + host + ":" + port);
      if (entry != null)
      {
            if (entry != null) {
        writer.writeEntry(entry);
      }
      writer.flush();
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
      return;
    }
    finally
    {
      if (connection != null)
      {
        } finally {
            if (connection != null) {
        connection.close();
      }
    }
  }
  private static void giveUp()
  {
    private static void giveUp() {
    printUsage();
    System.exit(1);
  }
  /**
   * Parse command line arguments.
   *
   * @param args
   *          host port bind-dn bind-password info-type
   */
  private static void parseArgs(final String[] args)
  {
    if (args.length != 3)
    {
    private static void parseArgs(final String[] args) {
        if (args.length != 3) {
      giveUp();
    }
    host = args[0];
    port = Integer.parseInt(args[1]);
    infoType = args[2]; // all, controls, or extops
    if (!(infoType.toLowerCase().equals("all")
        || infoType.toLowerCase().equals("controls")
        || infoType.toLowerCase().equals("extops")))
    {
        if (!(infoType.toLowerCase().equals("all") || infoType.toLowerCase().equals("controls") || infoType
                .toLowerCase().equals("extops"))) {
      giveUp();
    }
  }
  private static void printUsage()
  {
    private static void printUsage() {
    System.err.println("Usage: host port info-type");
    System.err.println("\tAll arguments are required.");
    System.err
        .println("\tinfo-type to get can be either all, controls, or extops.");
        System.err.println("\tinfo-type to get can be either all, controls, or extops.");
  }
  private GetInfo()
  {
    private GetInfo() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,17 +27,18 @@
package org.forgerock.opendj.examples;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldif.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldif.ChangeRecord;
import org.forgerock.opendj.ldif.ConnectionChangeRecordWriter;
import org.forgerock.opendj.ldif.LDIFChangeRecordReader;
/**
 * An example client application which applies update operations to a Directory
@@ -50,22 +50,18 @@
 *  <host> <port> <username> <password> [<ldifFile>]
 * </pre>
 */
public final class Modify
{
public final class Modify {
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: host, port, username, password, LDIF
   *          file name containing the update operations (will use stdin if not
   *          provided).
     *            The command line arguments: host, port, username, password,
     *            LDIF file name containing the update operations (will use
     *            stdin if not provided).
   */
  public static void main(final String[] args)
  {
    if (args.length < 4 || args.length > 5)
    {
      System.err
          .println("Usage: host port username password [ldifFileName]");
    public static void main(final String[] args) {
        if (args.length < 4 || args.length > 5) {
            System.err.println("Usage: host port username password [ldifFileName]");
      System.exit(1);
    }
@@ -78,87 +74,62 @@
    // Create the LDIF reader which will either used the named file, if
    // provided, or stdin.
    InputStream ldif;
    if (args.length > 4)
    {
      try
      {
        if (args.length > 4) {
            try {
        ldif = new FileInputStream(args[4]);
      }
      catch (final FileNotFoundException e)
      {
            } catch (final FileNotFoundException e) {
        System.err.println(e.getMessage());
        System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
        return;
      }
    }
    else
    {
        } else {
      ldif = System.in;
    }
    final LDIFChangeRecordReader reader = new LDIFChangeRecordReader(
        ldif);
        final LDIFChangeRecordReader reader = new LDIFChangeRecordReader(ldif);
    // Connect and bind to the server.
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(
        hostName, port);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(hostName, port);
    Connection connection = null;
    try
    {
        try {
      connection = factory.getConnection();
      connection.bind(userName, password.toCharArray());
      // Write the changes.
      final ConnectionChangeRecordWriter writer =
          new ConnectionChangeRecordWriter(connection);
      while (reader.hasNext())
      {
            while (reader.hasNext()) {
        ChangeRecord changeRecord = reader.readChangeRecord();
        writer.writeChangeRecord(changeRecord);
        System.err.println("Successfully modified entry "
            + changeRecord.getName().toString());
      }
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
      return;
    }
    finally
    {
      if (connection != null)
      {
        } finally {
            if (connection != null) {
        connection.close();
      }
      try
      {
            try {
        reader.close();
      }
      catch (final IOException ignored)
      {
            } catch (final IOException ignored) {
        // Ignore.
      }
    }
  }
  private Modify()
  {
    private Modify() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,20 +27,46 @@
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.controls.*;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.Connections;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.LDAPClientContext;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.LDAPListener;
import org.forgerock.opendj.ldap.LDAPListenerOptions;
import org.forgerock.opendj.ldap.RequestContext;
import org.forgerock.opendj.ldap.RequestHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.RoundRobinLoadBalancingAlgorithm;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.ServerConnectionFactory;
import org.forgerock.opendj.ldap.controls.ProxiedAuthV2RequestControl;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.CancelExtendedRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Request;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
/**
 * An LDAP load balancing proxy which forwards requests to one or more remote
@@ -60,167 +85,111 @@
 *      [&lt;remoteAddress2> &lt;remotePort2> ...]
 * </pre>
 */
public final class Proxy
{
  private static final class ProxyBackend implements
      RequestHandler<RequestContext>
  {
public final class Proxy {
    private static final class ProxyBackend implements RequestHandler<RequestContext> {
    private final ConnectionFactory factory;
    private final ConnectionFactory bindFactory;
    private ProxyBackend(final ConnectionFactory factory,
        final ConnectionFactory bindFactory)
    {
        private ProxyBackend(final ConnectionFactory factory, final ConnectionFactory bindFactory) {
      this.factory = factory;
      this.bindFactory = bindFactory;
    }
    private abstract class AbstractRequestCompletionHandler
        <R extends Result, H extends ResultHandler<? super R>>
        implements ResultHandler<R>
    {
        private abstract class AbstractRequestCompletionHandler<R extends Result, H extends ResultHandler<? super R>>
                implements ResultHandler<R> {
      final H resultHandler;
      final Connection connection;
      AbstractRequestCompletionHandler(final Connection connection,
          final H resultHandler)
      {
            AbstractRequestCompletionHandler(final Connection connection, final H resultHandler) {
        this.connection = connection;
        this.resultHandler = resultHandler;
      }
      @Override
      public final void handleErrorResult(final ErrorResultException error)
      {
            public final void handleErrorResult(final ErrorResultException error) {
        connection.close();
        resultHandler.handleErrorResult(error);
      }
      @Override
      public final void handleResult(final R result)
      {
            public final void handleResult(final R result) {
        connection.close();
        resultHandler.handleResult(result);
      }
    }
    private abstract class ConnectionCompletionHandler<R extends Result>
        implements ResultHandler<Connection>
    {
        private abstract class ConnectionCompletionHandler<R extends Result> implements
                ResultHandler<Connection> {
      private final ResultHandler<? super R> resultHandler;
      ConnectionCompletionHandler(final ResultHandler<? super R> resultHandler)
      {
            ConnectionCompletionHandler(final ResultHandler<? super R> resultHandler) {
        this.resultHandler = resultHandler;
      }
      @Override
      public final void handleErrorResult(final ErrorResultException error)
      {
            public final void handleErrorResult(final ErrorResultException error) {
        resultHandler.handleErrorResult(error);
      }
      @Override
      public abstract void handleResult(Connection connection);
    }
    private final class RequestCompletionHandler<R extends Result> extends
        AbstractRequestCompletionHandler<R, ResultHandler<? super R>>
    {
                AbstractRequestCompletionHandler<R, ResultHandler<? super R>> {
      RequestCompletionHandler(final Connection connection,
          final ResultHandler<? super R> resultHandler)
      {
                    final ResultHandler<? super R> resultHandler) {
        super(connection, resultHandler);
      }
    }
    private final class SearchRequestCompletionHandler extends
        AbstractRequestCompletionHandler<Result, SearchResultHandler> implements
        SearchResultHandler
    {
                SearchResultHandler {
      SearchRequestCompletionHandler(final Connection connection,
          final SearchResultHandler resultHandler)
      {
                    final SearchResultHandler resultHandler) {
        super(connection, resultHandler);
      }
      /**
       * {@inheritDoc}
       */
      @Override
      public final boolean handleEntry(final SearchResultEntry entry)
      {
            public final boolean handleEntry(final SearchResultEntry entry) {
        return resultHandler.handleEntry(entry);
      }
      /**
       * {@inheritDoc}
       */
      @Override
      public final boolean handleReference(
          final SearchResultReference reference)
      {
            public final boolean handleReference(final SearchResultReference reference) {
        return resultHandler.handleReference(reference);
      }
    }
    private volatile ProxiedAuthV2RequestControl proxiedAuthControl = null;
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleAdd(final RequestContext requestContext,
        final AddRequest request,
        public void handleAdd(final RequestContext requestContext, final AddRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<Result> outerHandler =
          new ConnectionCompletionHandler<Result>(resultHandler)
      {
                    new ConnectionCompletionHandler<Result>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final RequestCompletionHandler<Result> innerHandler =
              new RequestCompletionHandler<Result>(connection, resultHandler);
          connection.addAsync(request, intermediateResponseHandler,
              innerHandler);
                            connection.addAsync(request, intermediateResponseHandler, innerHandler);
        }
      };
@@ -228,57 +197,46 @@
      factory.getConnectionAsync(outerHandler);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleBind(final RequestContext requestContext,
        final int version, final BindRequest request,
        public void handleBind(final RequestContext requestContext, final int version,
                final BindRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super BindResult> resultHandler)
    {
                final ResultHandler<? super BindResult> resultHandler) {
      if (request.getAuthenticationType() != ((byte) 0x80))
      {
            if (request.getAuthenticationType() != ((byte) 0x80)) {
        // TODO: SASL authentication not implemented.
        resultHandler.handleErrorResult(newErrorResult(
            ResultCode.PROTOCOL_ERROR,
                resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
            "non-SIMPLE authentication not supported: "
                + request.getAuthenticationType()));
      }
      else
      {
        // Authenticate using a separate bind connection pool, because we
            } else {
                // Authenticate using a separate bind connection pool, because
                // we
        // don't want to change the state of the pooled connection.
        final ConnectionCompletionHandler<BindResult> outerHandler =
            new ConnectionCompletionHandler<BindResult>(resultHandler)
        {
                        new ConnectionCompletionHandler<BindResult>(resultHandler) {
          @Override
          public void handleResult(final Connection connection)
          {
                            public void handleResult(final Connection connection) {
            final ResultHandler<BindResult> innerHandler =
                new ResultHandler<BindResult>()
            {
                                        new ResultHandler<BindResult>() {
              @Override
              public final void handleErrorResult(
                  final ErrorResultException error)
              {
                                                    final ErrorResultException error) {
                connection.close();
                resultHandler.handleErrorResult(error);
              }
              @Override
              public final void handleResult(final BindResult result)
              {
                                            public final void handleResult(final BindResult result) {
                connection.close();
                proxiedAuthControl = ProxiedAuthV2RequestControl
                    .newControl("dn:" + request.getName());
                                                proxiedAuthControl =
                                                        ProxiedAuthV2RequestControl
                                                                .newControl("dn:"
                                                                        + request.getName());
                resultHandler.handleResult(result);
              }
            };
@@ -293,8 +251,6 @@
      }
    }
    /**
     * {@inheritDoc}
     */
@@ -302,16 +258,13 @@
    public void handleCompare(final RequestContext requestContext,
        final CompareRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super CompareResult> resultHandler)
    {
                final ResultHandler<? super CompareResult> resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<CompareResult> outerHandler =
          new ConnectionCompletionHandler<CompareResult>(resultHandler)
      {
                    new ConnectionCompletionHandler<CompareResult>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final RequestCompletionHandler<CompareResult> innerHandler =
              new RequestCompletionHandler<CompareResult>(connection,
                  resultHandler);
@@ -324,25 +277,19 @@
      factory.getConnectionAsync(outerHandler);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleDelete(final RequestContext requestContext,
        final DeleteRequest request,
        public void handleDelete(final RequestContext requestContext, final DeleteRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<Result> outerHandler =
          new ConnectionCompletionHandler<Result>(resultHandler)
      {
                    new ConnectionCompletionHandler<Result>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final RequestCompletionHandler<Result> innerHandler =
              new RequestCompletionHandler<Result>(connection, resultHandler);
          connection.deleteAsync(request, intermediateResponseHandler,
@@ -354,8 +301,6 @@
      factory.getConnectionAsync(outerHandler);
    }
    /**
     * {@inheritDoc}
     */
@@ -363,34 +308,24 @@
    public <R extends ExtendedResult> void handleExtendedRequest(
        final RequestContext requestContext, final ExtendedRequest<R> request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super R> resultHandler)
    {
      if (request.getOID().equals(CancelExtendedRequest.OID))
      {
                final ResultHandler<? super R> resultHandler) {
            if (request.getOID().equals(CancelExtendedRequest.OID)) {
        // TODO: not implemented.
        resultHandler.handleErrorResult(newErrorResult(
            ResultCode.PROTOCOL_ERROR,
                resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
            "Cancel extended request operation not supported"));
      }
      else if (request.getOID().equals(StartTLSExtendedRequest.OID))
      {
            } else if (request.getOID().equals(StartTLSExtendedRequest.OID)) {
        // TODO: not implemented.
        resultHandler.handleErrorResult(newErrorResult(
            ResultCode.PROTOCOL_ERROR,
                resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
            "StartTLS extended request operation not supported"));
      }
      else
      {
            } else {
        // Forward all other extended operations.
        addProxiedAuthControl(request);
        final ConnectionCompletionHandler<R> outerHandler =
            new ConnectionCompletionHandler<R>(resultHandler)
        {
                        new ConnectionCompletionHandler<R>(resultHandler) {
          @Override
          public void handleResult(final Connection connection)
          {
                            public void handleResult(final Connection connection) {
            final RequestCompletionHandler<R> innerHandler =
                new RequestCompletionHandler<R>(connection, resultHandler);
            connection.extendedRequestAsync(request,
@@ -403,25 +338,19 @@
      }
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleModify(final RequestContext requestContext,
        final ModifyRequest request,
        public void handleModify(final RequestContext requestContext, final ModifyRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<Result> outerHandler =
          new ConnectionCompletionHandler<Result>(resultHandler)
      {
                    new ConnectionCompletionHandler<Result>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final RequestCompletionHandler<Result> innerHandler =
              new RequestCompletionHandler<Result>(connection, resultHandler);
          connection.modifyAsync(request, intermediateResponseHandler,
@@ -433,8 +362,6 @@
      factory.getConnectionAsync(outerHandler);
    }
    /**
     * {@inheritDoc}
     */
@@ -442,16 +369,13 @@
    public void handleModifyDN(final RequestContext requestContext,
        final ModifyDNRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<Result> outerHandler =
          new ConnectionCompletionHandler<Result>(resultHandler)
      {
                    new ConnectionCompletionHandler<Result>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final RequestCompletionHandler<Result> innerHandler =
              new RequestCompletionHandler<Result>(connection, resultHandler);
          connection.modifyDNAsync(request, intermediateResponseHandler,
@@ -463,25 +387,19 @@
      factory.getConnectionAsync(outerHandler);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleSearch(final RequestContext requestContext,
        final SearchRequest request,
        public void handleSearch(final RequestContext requestContext, final SearchRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final SearchResultHandler resultHandler)
    {
                final SearchResultHandler resultHandler) {
      addProxiedAuthControl(request);
      final ConnectionCompletionHandler<Result> outerHandler =
          new ConnectionCompletionHandler<Result>(resultHandler)
      {
                    new ConnectionCompletionHandler<Result>(resultHandler) {
        @Override
        public void handleResult(final Connection connection)
        {
                        public void handleResult(final Connection connection) {
          final SearchRequestCompletionHandler innerHandler =
              new SearchRequestCompletionHandler(connection, resultHandler);
          connection.searchAsync(request, intermediateResponseHandler,
@@ -493,32 +411,25 @@
      factory.getConnectionAsync(outerHandler);
    }
    private void addProxiedAuthControl(final Request request)
    {
        private void addProxiedAuthControl(final Request request) {
      final ProxiedAuthV2RequestControl control = proxiedAuthControl;
      if (control != null)
      {
            if (control != null) {
        request.addControl(control);
      }
    }
  }
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: listen address, listen port, remote
   *          address1, remote port1, remote address2, remote port2, ...
     *            The command line arguments: listen address, listen port,
     *            remote address1, remote port1, remote address2, remote port2,
     *            ...
   */
  public static void main(final String[] args)
  {
    if (args.length < 4 || args.length % 2 != 0)
    {
    public static void main(final String[] args) {
        if (args.length < 4 || args.length % 2 != 0) {
      System.err.println("Usage: listenAddress listenPort "
          + "remoteAddress1 remotePort1 remoteAddress2 remotePort2");
      System.exit(1);
@@ -529,65 +440,47 @@
    final int localPort = Integer.parseInt(args[1]);
    // Create load balancer.
    final List<ConnectionFactory> factories =
        new LinkedList<ConnectionFactory>();
    final List<ConnectionFactory> bindFactories =
        new LinkedList<ConnectionFactory>();
    for (int i = 2; i < args.length; i += 2)
    {
        final List<ConnectionFactory> factories = new LinkedList<ConnectionFactory>();
        final List<ConnectionFactory> bindFactories = new LinkedList<ConnectionFactory>();
        for (int i = 2; i < args.length; i += 2) {
      final String remoteAddress = args[i];
      final int remotePort = Integer.parseInt(args[i + 1]);
      factories.add(Connections.newFixedConnectionPool(
          new LDAPConnectionFactory(remoteAddress, remotePort),
          Integer.MAX_VALUE));
      bindFactories.add(Connections.newFixedConnectionPool(
          new LDAPConnectionFactory(remoteAddress, remotePort),
          Integer.MAX_VALUE));
            factories.add(Connections.newFixedConnectionPool(new LDAPConnectionFactory(
                    remoteAddress, remotePort), Integer.MAX_VALUE));
            bindFactories.add(Connections.newFixedConnectionPool(new LDAPConnectionFactory(
                    remoteAddress, remotePort), Integer.MAX_VALUE));
    }
    final RoundRobinLoadBalancingAlgorithm algorithm =
        new RoundRobinLoadBalancingAlgorithm(factories);
    final RoundRobinLoadBalancingAlgorithm bindAlgorithm =
        new RoundRobinLoadBalancingAlgorithm(bindFactories);
    final ConnectionFactory factory = Connections.newLoadBalancer(algorithm);
    final ConnectionFactory bindFactory = Connections
        .newLoadBalancer(bindAlgorithm);
        final ConnectionFactory bindFactory = Connections.newLoadBalancer(bindAlgorithm);
    // Create a server connection adapter.
    final ProxyBackend backend = new ProxyBackend(factory, bindFactory);
    final ServerConnectionFactory<LDAPClientContext, Integer> connectionHandler
      = Connections.newServerConnectionFactory(backend);
        final ServerConnectionFactory<LDAPClientContext, Integer> connectionHandler =
                Connections.newServerConnectionFactory(backend);
    // Create listener.
    final LDAPListenerOptions options = new LDAPListenerOptions()
        .setBacklog(4096);
        final LDAPListenerOptions options = new LDAPListenerOptions().setBacklog(4096);
    LDAPListener listener = null;
    try
    {
      listener = new LDAPListener(localAddress, localPort, connectionHandler,
          options);
        try {
            listener = new LDAPListener(localAddress, localPort, connectionHandler, options);
      System.out.println("Press any key to stop the server...");
      System.in.read();
    }
    catch (final IOException e)
    {
      System.out
          .println("Error listening on " + localAddress + ":" + localPort);
        } catch (final IOException e) {
            System.out.println("Error listening on " + localAddress + ":" + localPort);
      e.printStackTrace();
    }
    finally
    {
      if (listener != null)
      {
        } finally {
            if (listener != null) {
        listener.close();
      }
    }
  }
  private Proxy()
  {
    private Proxy() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,13 +27,17 @@
package org.forgerock.opendj.examples;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.schema.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.Syntax;
/**
 * An example client application which prints a summary of the schema on the
@@ -45,18 +48,15 @@
 *  &lt;host> &lt;port> &lt;username> &lt;password>
 * </pre>
 */
public final class ReadSchema
{
public final class ReadSchema {
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: host, port, username, password.
   */
  public static void main(final String[] args)
  {
    if (args.length != 4)
    {
    public static void main(final String[] args) {
        if (args.length != 4) {
      System.err.println("Usage: host port username password");
      System.exit(1);
    }
@@ -68,12 +68,10 @@
    final String password = args[3];
    // Connect and bind to the server.
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(
        hostName, port);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(hostName, port);
    Connection connection = null;
    try
    {
        try {
      connection = factory.getConnection();
      connection.bind(userName, password.toCharArray());
@@ -81,29 +79,25 @@
      Schema schema = Schema.readSchemaForEntry(connection, DN.rootDN());
      System.out.println("Attribute types");
      for (AttributeType at : schema.getAttributeTypes())
      {
            for (AttributeType at : schema.getAttributeTypes()) {
        System.out.println("  " + at.getNameOrOID());
      }
      System.out.println();
      System.out.println("Object classes");
      for (ObjectClass oc : schema.getObjectClasses())
      {
            for (ObjectClass oc : schema.getObjectClasses()) {
        System.out.println("  " + oc.getNameOrOID());
      }
      System.out.println();
      System.out.println("Matching rules");
      for (MatchingRule mr : schema.getMatchingRules())
      {
            for (MatchingRule mr : schema.getMatchingRules()) {
        System.out.println("  " + mr.getNameOrOID());
      }
      System.out.println();
      System.out.println("Syntaxes");
      for (Syntax s : schema.getSyntaxes())
      {
            for (Syntax s : schema.getSyntaxes()) {
        System.out.println("  " + s.getDescription());
      }
      System.out.println();
@@ -111,37 +105,26 @@
      // Etc...
      System.out.println("WARNINGS");
      for (LocalizableMessage m : schema.getWarnings())
      {
            for (LocalizableMessage m : schema.getWarnings()) {
        System.out.println("  " + m.toString());
      }
      System.out.println();
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    finally
    {
      if (connection != null)
      {
        } finally {
            if (connection != null) {
        connection.close();
      }
    }
  }
  private ReadSchema()
  {
    private ReadSchema() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -47,8 +46,6 @@
import org.forgerock.opendj.ldap.requests.PlainSASLBindRequest;
import org.forgerock.opendj.ldap.requests.Requests;
/**
 * An example client application which performs SASL PLAIN authentication to a
 * directory server over LDAP with StartTLS. This example takes the following
@@ -60,9 +57,8 @@
 * <li>authcid - Authentication identity</li>
 * <li>passwd - Password of the user to authenticate</li>
 * </ul>
 * The host, port, authcid, and passwd are required.
 * SASL PLAIN is described in <a href="http://www.ietf.org/rfc/rfc4616.txt">RFC
 * 4616</a>.
 * The host, port, authcid, and passwd are required. SASL PLAIN is described in
 * <a href="http://www.ietf.org/rfc/rfc4616.txt">RFC 4616</a>.
 * <p>
 * The authzid and authcid are prefixed as described in <a
 * href="http://tools.ietf.org/html/rfc4513#section-5.2.1.8">RFC 4513, section
@@ -72,139 +68,114 @@
 * By default, OpenDJ is set up for SASL PLAIN to use the Exact Match Identity
 * Mapper to find entries by searching uid values for the user ID. In other
 * words, the following examples are equivalent.
 *
 * <pre>
 * dn:uid=bjensen,ou=people,dc=example,dc=com
 * u:bjensen
 * </pre>
 */
public final class SASLAuth
{
public final class SASLAuth {
  /**
   * Authenticate to the directory using SASL PLAIN.
   * @param args The command line arguments
     *
     * @param args
     *            The command line arguments
   */
  public static void main(String[] args)
  {
    public static void main(String[] args) {
    parseArgs(args);
    Connection connection = null;
    try
    {
        try {
      final LDAPConnectionFactory factory =
          new LDAPConnectionFactory(host, port, getTrustAllOptions());
      connection = factory.getConnection();
      PlainSASLBindRequest request = Requests.newPlainSASLBindRequest(
          authcid, passwd.toCharArray());
      if (authzid != null) request.setAuthorizationID(authzid);
            PlainSASLBindRequest request =
                    Requests.newPlainSASLBindRequest(authcid, passwd.toCharArray());
            if (authzid != null) {
                request.setAuthorizationID(authzid);
            }
      connection.bind(request);
      System.out.println("Authenticated as " + authcid + ".");
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    catch (final GeneralSecurityException e)
    {
        } catch (final GeneralSecurityException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
    }
    finally
    {
      if (connection != null)
        } finally {
            if (connection != null) {
        connection.close();
    }
  }
    }
  /**
   * For StartTLS the connection factory needs SSL context options.
   * In the general case, a trust manager in the SSL context serves to check
   * server certificates, and a key manager handles client keys when the server
     * For StartTLS the connection factory needs SSL context options. In the
     * general case, a trust manager in the SSL context serves to check server
     * certificates, and a key manager handles client keys when the server
   * checks certificates from our client.
   *
   * OpenDJ directory server lets you install by default with a self-signed
   * certificate that is not in the system trust store. To simplify this
   * implementation trusts all server certificates.
   */
  private static LDAPOptions getTrustAllOptions()
    throws GeneralSecurityException
  {
    private static LDAPOptions getTrustAllOptions() throws GeneralSecurityException {
    LDAPOptions lo = new LDAPOptions();
    SSLContext sslContext = new SSLContextBuilder()
      .setTrustManager(TrustManagers.trustAll()).getSSLContext();
        SSLContext sslContext =
                new SSLContextBuilder().setTrustManager(TrustManagers.trustAll()).getSSLContext();
    lo.setSSLContext(sslContext);
    lo.setUseStartTLS(true);
    return lo;
  }
  private static String host;
  private static int port;
  private static String authzid;
  private static String authcid;
  private static String passwd;
  /**
   * Parse command line arguments.
   * @param args host port [authzid] authcid passwd
     *
     * @param args
     *            host port [authzid] authcid passwd
   */
  private static void parseArgs(String[] args)
  {
    if (args.length < 4 || args.length > 5) giveUp();
    private static void parseArgs(String[] args) {
        if (args.length < 4 || args.length > 5) {
            giveUp();
        }
    host = args[0];
    port = Integer.parseInt(args[1]);
    if (args.length == 5)
    {
        if (args.length == 5) {
      authzid = args[2];
      authcid = args[3];
      passwd = args[4];
    }
    else
    {
        } else {
      authzid = null;
      authcid = args[2];
      passwd = args[3];
    }
  }
  private static void giveUp()
  {
    private static void giveUp() {
    printUsage();
    System.exit(1);
  }
  private static void printUsage()
  {
    System.err.println(
      "Usage: host port [authzid] authcid passwd");
    System.err.println(
      "\tThe port must be able to handle LDAP with StartTLS.");
    System.err.println(
      "\tSee http://www.ietf.org/rfc/rfc4616.txt for more on SASL PLAIN.");
    private static void printUsage() {
        System.err.println("Usage: host port [authzid] authcid passwd");
        System.err.println("\tThe port must be able to handle LDAP with StartTLS.");
        System.err.println("\tSee http://www.ietf.org/rfc/rfc4616.txt for more on SASL PLAIN.");
  }
  private SASLAuth()
  {
    private SASLAuth() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,16 +27,19 @@
package org.forgerock.opendj.examples;
import java.io.IOException;
import java.util.Arrays;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldif.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.ErrorResultIOException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import org.forgerock.opendj.ldif.ConnectionEntryReader;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
/**
 * An example client application which searches a Directory Server. This example
@@ -48,21 +50,18 @@
 *      &lt;baseDN> &lt;scope> &lt;filter> [&lt;attibute> &lt;attribute> ...]
 * </pre>
 */
public final class Search
{
public final class Search {
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: host, port, username, password, base
   *          DN, scope, filter, and zero or more attributes to be retrieved.
     *            The command line arguments: host, port, username, password,
     *            base DN, scope, filter, and zero or more attributes to be
     *            retrieved.
   */
  public static void main(final String[] args)
  {
    if (args.length < 7)
    {
      System.err
          .println("Usage: host port username password baseDN scope "
    public static void main(final String[] args) {
        if (args.length < 7) {
            System.err.println("Usage: host port username password baseDN scope "
              + "filter [attribute ...]");
      System.exit(1);
    }
@@ -76,34 +75,22 @@
    final String scopeString = args[5];
    final String filter = args[6];
    String[] attributes;
    if (args.length > 7)
    {
        if (args.length > 7) {
      attributes = Arrays.copyOfRange(args, 7, args.length);
    }
    else
    {
        } else {
      attributes = new String[0];
    }
    SearchScope scope;
    if (scopeString.equalsIgnoreCase("base"))
    {
        if (scopeString.equalsIgnoreCase("base")) {
      scope = SearchScope.BASE_OBJECT;
    }
    else if (scopeString.equalsIgnoreCase("one"))
    {
        } else if (scopeString.equalsIgnoreCase("one")) {
      scope = SearchScope.SINGLE_LEVEL;
    }
    else if (scopeString.equalsIgnoreCase("sub"))
    {
        } else if (scopeString.equalsIgnoreCase("sub")) {
      scope = SearchScope.WHOLE_SUBTREE;
    }
    else if (scopeString.equalsIgnoreCase("subordinates"))
    {
        } else if (scopeString.equalsIgnoreCase("subordinates")) {
      scope = SearchScope.SUBORDINATES;
    }
    else
    {
        } else {
      System.err.println("Unknown scope: " + scopeString);
      System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
      return;
@@ -113,76 +100,53 @@
    final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
    // Connect and bind to the server.
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(
        hostName, port);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(hostName, port);
    Connection connection = null;
    try
    {
        try {
      connection = factory.getConnection();
      connection.bind(userName, password.toCharArray());
      // Read the entries and output them as LDIF.
      final ConnectionEntryReader reader = connection.search(baseDN,
          scope, filter, attributes);
      while (reader.hasNext())
      {
        if (!reader.isReference())
        {
            final ConnectionEntryReader reader =
                    connection.search(baseDN, scope, filter, attributes);
            while (reader.hasNext()) {
                if (!reader.isReference()) {
          final SearchResultEntry entry = reader.readEntry();
          writer.writeComment("Search result entry: "
              + entry.getName().toString());
                    writer.writeComment("Search result entry: " + entry.getName().toString());
          writer.writeEntry(entry);
        }
        else
        {
                } else {
          final SearchResultReference ref = reader.readReference();
          // Got a continuation reference.
          writer.writeComment("Search result reference: "
              + ref.getURIs().toString());
                    writer.writeComment("Search result reference: " + ref.getURIs().toString());
        }
      }
      writer.flush();
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final ErrorResultIOException e)
    {
        } catch (final ErrorResultIOException e) {
      System.err.println(e.getMessage());
      System
          .exit(e.getCause().getResult().getResultCode().intValue());
            System.exit(e.getCause().getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
      return;
    }
    finally
    {
      if (connection != null)
      {
        } finally {
            if (connection != null) {
        connection.close();
      }
    }
  }
  private Search()
  {
    private Search() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,18 +27,25 @@
package org.forgerock.opendj.examples;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldif.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
/**
 * An example client application which searches a Directory Server using the
@@ -50,95 +56,70 @@
 *      &lt;baseDN> &lt;scope> &lt;filter> [&lt;attibute> &lt;attribute> ...]
 * </pre>
 */
public final class SearchAsync
{
  private static final class BindResultHandlerImpl implements
      ResultHandler<BindResult>
  {
public final class SearchAsync {
    private static final class BindResultHandlerImpl implements ResultHandler<BindResult> {
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      System.err.println(error.getMessage());
      resultCode = error.getResult().getResultCode().intValue();
      COMPLETION_LATCH.countDown();
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleResult(final BindResult result)
    {
        public void handleResult(final BindResult result) {
      // Bind succeeded: initiate search.
      final SearchRequest request = Requests.newSearchRequest(baseDN,
          scope, filter, attributes);
            final SearchRequest request =
                    Requests.newSearchRequest(baseDN, scope, filter, attributes);
      connection.searchAsync(request, null, new SearchResultHandlerImpl());
    }
  }
  private static final class ConnectResultHandlerImpl implements
      ResultHandler<Connection>
  {
    private static final class ConnectResultHandlerImpl implements ResultHandler<Connection> {
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      System.err.println(error.getMessage());
      resultCode = error.getResult().getResultCode().intValue();
      COMPLETION_LATCH.countDown();
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleResult(final Connection connection)
    {
        public void handleResult(final Connection connection) {
      // Connect succeeded: save connection and initiate bind.
      SearchAsync.connection = connection;
      final BindRequest request = Requests.newSimpleBindRequest(
          userName, password.toCharArray());
            final BindRequest request =
                    Requests.newSimpleBindRequest(userName, password.toCharArray());
      connection.bindAsync(request, null, new BindResultHandlerImpl());
    }
  }
  private static final class SearchResultHandlerImpl implements
      SearchResultHandler
  {
    private static final class SearchResultHandlerImpl implements SearchResultHandler {
    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized boolean handleEntry(
        final SearchResultEntry entry)
    {
      try
      {
        WRITER.writeComment("Search result entry: "
            + entry.getName().toString());
        public synchronized boolean handleEntry(final SearchResultEntry entry) {
            try {
                WRITER.writeComment("Search result entry: " + entry.getName().toString());
        WRITER.writeEntry(entry);
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        System.err.println(e.getMessage());
        resultCode = ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue();
        COMPLETION_LATCH.countDown();
@@ -147,35 +128,24 @@
      return true;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      System.err.println(error.getMessage());
      resultCode = error.getResult().getResultCode().intValue();
      COMPLETION_LATCH.countDown();
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized boolean handleReference(
        final SearchResultReference reference)
    {
      try
      {
        WRITER.writeComment("Search result reference: "
            + reference.getURIs().toString());
      }
      catch (final IOException e)
      {
        public synchronized boolean handleReference(final SearchResultReference reference) {
            try {
                WRITER.writeComment("Search result reference: " + reference.getURIs().toString());
            } catch (final IOException e) {
        System.err.println(e.getMessage());
        resultCode = ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue();
        COMPLETION_LATCH.countDown();
@@ -184,26 +154,19 @@
      return true;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      resultCode = result.getResultCode().intValue();
      COMPLETION_LATCH.countDown();
    }
  }
  private static final CountDownLatch COMPLETION_LATCH = new CountDownLatch(
      1);
  private static final LDIFEntryWriter WRITER = new LDIFEntryWriter(
      System.out);
    private static final CountDownLatch COMPLETION_LATCH = new CountDownLatch(1);
    private static final LDIFEntryWriter WRITER = new LDIFEntryWriter(System.out);
  private static String userName;
  private static String password;
  private static String baseDN;
@@ -213,21 +176,17 @@
  private static Connection connection = null;
  private static int resultCode = 0;
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: host, port, username, password, base
   *          DN, scope, filter, and zero or more attributes to be retrieved.
     *            The command line arguments: host, port, username, password,
     *            base DN, scope, filter, and zero or more attributes to be
     *            retrieved.
   */
  public static void main(final String[] args)
  {
    if (args.length < 7)
    {
      System.err
          .println("Usage: host port username password baseDN scope "
    public static void main(final String[] args) {
        if (args.length < 7) {
            System.err.println("Usage: host port username password baseDN scope "
              + "filter [attribute ...]");
      System.exit(1);
    }
@@ -240,78 +199,55 @@
    baseDN = args[4];
    final String scopeString = args[5];
    filter = args[6];
    if (args.length > 7)
    {
        if (args.length > 7) {
      attributes = Arrays.copyOfRange(args, 7, args.length);
    }
    else
    {
        } else {
      attributes = new String[0];
    }
    if (scopeString.equalsIgnoreCase("base"))
    {
        if (scopeString.equalsIgnoreCase("base")) {
      scope = SearchScope.BASE_OBJECT;
    }
    else if (scopeString.equalsIgnoreCase("one"))
    {
        } else if (scopeString.equalsIgnoreCase("one")) {
      scope = SearchScope.SINGLE_LEVEL;
    }
    else if (scopeString.equalsIgnoreCase("sub"))
    {
        } else if (scopeString.equalsIgnoreCase("sub")) {
      scope = SearchScope.WHOLE_SUBTREE;
    }
    else if (scopeString.equalsIgnoreCase("subordinates"))
    {
        } else if (scopeString.equalsIgnoreCase("subordinates")) {
      scope = SearchScope.SUBORDINATES;
    }
    else
    {
        } else {
      System.err.println("Unknown scope: " + scopeString);
      System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
      return;
    }
    // Initiate the asynchronous connect, bind, and search.
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(
        hostName, port);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(hostName, port);
    factory.getConnectionAsync(new ConnectResultHandlerImpl());
    // Await completion.
    try
    {
        try {
      COMPLETION_LATCH.await();
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    try
    {
        try {
      WRITER.flush();
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
      return;
    }
    if (connection != null)
    {
        if (connection != null) {
      connection.close();
    }
    System.exit(resultCode);
  }
  private SearchAsync()
  {
    private SearchAsync() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -79,13 +78,13 @@
        char[] password = c.readPassword("Password: ");
        // Search using mail address, and then bind with the DN and password.
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host,
                port);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
        Connection connection = null;
        try {
            connection = factory.getConnection();
            SearchResultEntry entry = connection.searchSingleEntry(baseDN,
                    SearchScope.WHOLE_SUBTREE, "(mail=" + mail + ")", "cn");
            SearchResultEntry entry =
                    connection.searchSingleEntry(baseDN, SearchScope.WHOLE_SUBTREE, "(mail=" + mail
                            + ")", "cn");
            DN bindDN = entry.getName();
            BindResult result = connection.bind(bindDN.toString(), password);
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.FileInputStream;
@@ -42,12 +39,45 @@
import javax.net.ssl.SSLContext;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldif.*;
import org.forgerock.opendj.ldap.CancelledResultException;
import org.forgerock.opendj.ldap.Connections;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.KeyManagers;
import org.forgerock.opendj.ldap.LDAPClientContext;
import org.forgerock.opendj.ldap.LDAPListener;
import org.forgerock.opendj.ldap.LDAPListenerOptions;
import org.forgerock.opendj.ldap.LinkedHashMapEntry;
import org.forgerock.opendj.ldap.Matcher;
import org.forgerock.opendj.ldap.Modification;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.RequestContext;
import org.forgerock.opendj.ldap.RequestHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.SSLContextBuilder;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.ServerConnection;
import org.forgerock.opendj.ldap.ServerConnectionFactory;
import org.forgerock.opendj.ldap.TrustManagers;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldif.LDIFEntryReader;
/**
 * An LDAP directory server which exposes data contained in an LDIF file. This
@@ -64,91 +94,65 @@
 *  &lt;listenAddress> &lt;listenPort> [&lt;ldifFile>]
 * </pre>
 */
public final class Server
{
  private static final class MemoryBackend implements
      RequestHandler<RequestContext>
  {
public final class Server {
    private static final class MemoryBackend implements RequestHandler<RequestContext> {
    private final ConcurrentSkipListMap<DN, Entry> entries;
    private final ReentrantReadWriteLock entryLock = new ReentrantReadWriteLock();
    private MemoryBackend(final ConcurrentSkipListMap<DN, Entry> entries)
    {
        private MemoryBackend(final ConcurrentSkipListMap<DN, Entry> entries) {
      this.entries = entries;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleAdd(final RequestContext requestContext,
        final AddRequest request,
        public void handleAdd(final RequestContext requestContext, final AddRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      // TODO: controls.
      entryLock.writeLock().lock();
      try
      {
            try {
        DN dn = request.getName();
        if (entries.containsKey(dn))
        {
                if (entries.containsKey(dn)) {
          resultHandler.handleErrorResult(ErrorResultException.newErrorResult(
              ResultCode.ENTRY_ALREADY_EXISTS, "The entry " + dn.toString()
                  + " already exists"));
        }
        DN parent = dn.parent();
        if (!entries.containsKey(parent))
        {
                if (!entries.containsKey(parent)) {
          resultHandler.handleErrorResult(ErrorResultException.newErrorResult(
              ResultCode.NO_SUCH_OBJECT,
              "The parent entry " + parent.toString() + " does not exist"));
        }
        else
        {
                            ResultCode.NO_SUCH_OBJECT, "The parent entry " + parent.toString()
                                    + " does not exist"));
                } else {
          entries.put(dn, request);
          resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS));
        }
      }
      finally
      {
            } finally {
        entryLock.writeLock().unlock();
      }
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleBind(final RequestContext requestContext,
        final int version, final BindRequest request,
        public void handleBind(final RequestContext requestContext, final int version,
                final BindRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super BindResult> resultHandler)
    {
      if (request.getAuthenticationType() != ((byte) 0x80))
      {
                final ResultHandler<? super BindResult> resultHandler) {
            if (request.getAuthenticationType() != ((byte) 0x80)) {
        // TODO: SASL authentication not implemented.
        resultHandler.handleErrorResult(newErrorResult(
            ResultCode.PROTOCOL_ERROR,
                resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
            "non-SIMPLE authentication not supported: "
                + request.getAuthenticationType()));
      }
      else
      {
            } else {
        // TODO: always succeed.
        resultHandler.handleResult(Responses.newBindResult(ResultCode.SUCCESS));
      }
    }
    /**
     * {@inheritDoc}
     */
@@ -156,48 +160,35 @@
    public void handleCompare(final RequestContext requestContext,
        final CompareRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super CompareResult> resultHandler)
    {
                final ResultHandler<? super CompareResult> resultHandler) {
      // TODO:
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleDelete(final RequestContext requestContext,
        final DeleteRequest request,
        public void handleDelete(final RequestContext requestContext, final DeleteRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      // TODO: controls.
      entryLock.writeLock().lock();
      try
      {
            try {
        // TODO: check for children.
        DN dn = request.getName();
        if (!entries.containsKey(dn))
        {
                if (!entries.containsKey(dn)) {
          resultHandler.handleErrorResult(ErrorResultException.newErrorResult(
              ResultCode.NO_SUCH_OBJECT, "The entry " + dn.toString()
                  + " does not exist"));
        }
        else
        {
                } else {
          entries.remove(dn);
          resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS));
        }
      }
      finally
      {
            } finally {
        entryLock.writeLock().unlock();
      }
    }
    /**
     * {@inheritDoc}
     */
@@ -205,61 +196,45 @@
    public <R extends ExtendedResult> void handleExtendedRequest(
        final RequestContext requestContext, final ExtendedRequest<R> request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super R> resultHandler)
    {
                final ResultHandler<? super R> resultHandler) {
      // TODO: not implemented.
      resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
          "Extended request operation not supported"));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleModify(final RequestContext requestContext,
        final ModifyRequest request,
        public void handleModify(final RequestContext requestContext, final ModifyRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      // TODO: controls.
      // TODO: read lock is not really enough since concurrent updates may
      // still occur to the same entry.
      entryLock.readLock().lock();
      try
      {
            try {
        DN dn = request.getName();
        Entry entry = entries.get(dn);
        if (entry == null)
        {
                if (entry == null) {
          resultHandler.handleErrorResult(ErrorResultException.newErrorResult(
              ResultCode.NO_SUCH_OBJECT, "The entry " + dn.toString()
                  + " does not exist"));
        }
        Entry newEntry = new LinkedHashMapEntry(entry);
        for (Modification mod : request.getModifications())
        {
                for (Modification mod : request.getModifications()) {
          ModificationType modType = mod.getModificationType();
          if (modType.equals(ModificationType.ADD))
          {
                    if (modType.equals(ModificationType.ADD)) {
            // TODO: Reject empty attribute and duplicate values.
            newEntry.addAttribute(mod.getAttribute(), null);
          }
          else if (modType.equals(ModificationType.DELETE))
          {
                    } else if (modType.equals(ModificationType.DELETE)) {
            // TODO: Reject missing values.
            newEntry.removeAttribute(mod.getAttribute(), null);
          }
          else if (modType.equals(ModificationType.REPLACE))
          {
                    } else if (modType.equals(ModificationType.REPLACE)) {
            newEntry.replaceAttribute(mod.getAttribute());
          }
          else
          {
            resultHandler.handleErrorResult(newErrorResult(
                ResultCode.PROTOCOL_ERROR,
                    } else {
                        resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
                "Modify request contains an unsupported modification type"));
            return;
          }
@@ -267,15 +242,11 @@
        entries.put(dn, newEntry);
        resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS));
      }
      finally
      {
            } finally {
        entryLock.readLock().unlock();
      }
    }
    /**
     * {@inheritDoc}
     */
@@ -283,32 +254,25 @@
    public void handleModifyDN(final RequestContext requestContext,
        final ModifyDNRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final ResultHandler<? super Result> resultHandler)
    {
                final ResultHandler<? super Result> resultHandler) {
      // TODO: not implemented.
      resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
          "ModifyDN request operation not supported"));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void handleSearch(final RequestContext requestContext,
        final SearchRequest request,
        public void handleSearch(final RequestContext requestContext, final SearchRequest request,
        final IntermediateResponseHandler intermediateResponseHandler,
        final SearchResultHandler resultHandler)
    {
                final SearchResultHandler resultHandler) {
      // TODO: controls, limits, etc.
      entryLock.readLock().lock();
      try
      {
            try {
        DN dn = request.getName();
        Entry baseEntry = entries.get(dn);
        if (baseEntry == null)
        {
                if (baseEntry == null) {
          resultHandler.handleErrorResult(ErrorResultException.newErrorResult(
              ResultCode.NO_SUCH_OBJECT, "The entry " + dn.toString()
                  + " does not exist"));
@@ -319,113 +283,82 @@
        Filter filter = request.getFilter();
        Matcher matcher = filter.matcher();
        if (scope.equals(SearchScope.BASE_OBJECT))
        {
          if (matcher.matches(baseEntry).toBoolean())
          {
                if (scope.equals(SearchScope.BASE_OBJECT)) {
                    if (matcher.matches(baseEntry).toBoolean()) {
            sendEntry(request, resultHandler, baseEntry);
          }
        }
        else if (scope.equals(SearchScope.SINGLE_LEVEL))
        {
                } else if (scope.equals(SearchScope.SINGLE_LEVEL)) {
          NavigableMap<DN, Entry> subtree = entries.tailMap(dn, false);
          for (Entry entry : subtree.values())
          {
                    for (Entry entry : subtree.values()) {
            // Check for cancellation.
            requestContext.checkIfCancelled(false);
            DN childDN = entry.getName();
            if (childDN.isChildOf(dn))
            {
              if (!matcher.matches(entry).toBoolean())
              {
                        if (childDN.isChildOf(dn)) {
                            if (!matcher.matches(entry).toBoolean()) {
                continue;
              }
              if (!sendEntry(request, resultHandler, entry))
              {
                            if (!sendEntry(request, resultHandler, entry)) {
                // Caller has asked to stop sending results.
                break;
              }
            }
            else if (!childDN.isSubordinateOrEqualTo(dn))
            {
                        } else if (!childDN.isSubordinateOrEqualTo(dn)) {
              // The remaining entries will be out of scope.
              break;
            }
          }
        }
        else if (scope.equals(SearchScope.WHOLE_SUBTREE))
        {
                } else if (scope.equals(SearchScope.WHOLE_SUBTREE)) {
          NavigableMap<DN, Entry> subtree = entries.tailMap(dn);
          for (Entry entry : subtree.values())
          {
                    for (Entry entry : subtree.values()) {
            // Check for cancellation.
            requestContext.checkIfCancelled(false);
            DN childDN = entry.getName();
            if (childDN.isSubordinateOrEqualTo(dn))
            {
              if (!matcher.matches(entry).toBoolean())
              {
                        if (childDN.isSubordinateOrEqualTo(dn)) {
                            if (!matcher.matches(entry).toBoolean()) {
                continue;
              }
              if (!sendEntry(request, resultHandler, entry))
              {
                            if (!sendEntry(request, resultHandler, entry)) {
                // Caller has asked to stop sending results.
                break;
              }
            }
            else
            {
                        } else {
              // The remaining entries will be out of scope.
              break;
            }
          }
        }
        else
        {
          resultHandler.handleErrorResult(newErrorResult(
              ResultCode.PROTOCOL_ERROR,
                } else {
                    resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR,
              "Search request contains an unsupported search scope"));
          return;
        }
        resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS));
      }
      catch (CancelledResultException e)
      {
            } catch (CancelledResultException e) {
        resultHandler.handleErrorResult(e);
      }
      finally
      {
            } finally {
        entryLock.readLock().unlock();
      }
    }
    private boolean sendEntry(SearchRequest request,
        SearchResultHandler resultHandler, Entry entry)
    {
        private boolean sendEntry(SearchRequest request, SearchResultHandler resultHandler,
                Entry entry) {
      // TODO: check filter, strip attributes.
      return resultHandler.handleEntry(Responses.newSearchResultEntry(entry));
    }
  }
  /**
   * Main method.
   *
   * @param args
   *          The command line arguments: listen address, listen port, ldifFile
     *            The command line arguments: listen address, listen port,
     *            ldifFile
   */
  public static void main(final String[] args)
  {
    if (args.length != 3 && args.length != 6)
    {
    public static void main(final String[] args) {
        if (args.length != 3 && args.length != 6) {
      System.err.println("Usage: listenAddress listenPort ldifFile "
          + "[keyStoreFile keyStorePassword certNickname]");
      System.exit(1);
@@ -440,8 +373,7 @@
    final String certNickname = (args.length == 6) ? args[5] : null;
    // Create the memory backend.
    final ConcurrentSkipListMap<DN, Entry> entries =
        readEntriesFromLDIF(ldifFileName);
        final ConcurrentSkipListMap<DN, Entry> entries = readEntriesFromLDIF(ldifFileName);
    final MemoryBackend backend = new MemoryBackend(entries);
    // Create a server connection adapter.
@@ -450,62 +382,46 @@
    // Create listener.
    LDAPListener listener = null;
    try
    {
      final LDAPListenerOptions options = new LDAPListenerOptions()
          .setBacklog(4096);
        try {
            final LDAPListenerOptions options = new LDAPListenerOptions().setBacklog(4096);
      if (keyStoreFileName != null)
      {
        // Configure SSL/TLS and enable it when connections are accepted.
        final SSLContext sslContext = new SSLContextBuilder()
            .setKeyManager(
            if (keyStoreFileName != null) {
                // Configure SSL/TLS and enable it when connections are
                // accepted.
                final SSLContext sslContext =
                        new SSLContextBuilder().setKeyManager(
                KeyManagers.useSingleCertificate(certNickname, KeyManagers
                    .useKeyStoreFile(keyStoreFileName,
                        keyStorePassword.toCharArray(), null)))
            .setTrustManager(TrustManagers.trustAll()).getSSLContext();
                                        .useKeyStoreFile(keyStoreFileName, keyStorePassword
                                                .toCharArray(), null))).setTrustManager(
                                TrustManagers.trustAll()).getSSLContext();
        ServerConnectionFactory<LDAPClientContext, Integer> sslWrapper =
            new ServerConnectionFactory<LDAPClientContext, Integer>()
        {
                        new ServerConnectionFactory<LDAPClientContext, Integer>() {
          public ServerConnection<Integer> handleAccept(
              LDAPClientContext clientContext) throws ErrorResultException
          {
                                    LDAPClientContext clientContext) throws ErrorResultException {
            clientContext.enableTLS(sslContext, null, null, false, false);
            return connectionHandler.handleAccept(clientContext);
          }
        };
        listener = new LDAPListener(localAddress, localPort, sslWrapper,
            options);
      }
      else
      {
                listener = new LDAPListener(localAddress, localPort, sslWrapper, options);
            } else {
        // No SSL.
        listener = new LDAPListener(localAddress, localPort, connectionHandler,
            options);
                listener = new LDAPListener(localAddress, localPort, connectionHandler, options);
      }
      System.out.println("Press any key to stop the server...");
      System.in.read();
    }
    catch (final Exception e)
    {
      System.out
          .println("Error listening on " + localAddress + ":" + localPort);
        } catch (final Exception e) {
            System.out.println("Error listening on " + localAddress + ":" + localPort);
      e.printStackTrace();
    }
    finally
    {
      if (listener != null)
      {
        } finally {
            if (listener != null) {
        listener.close();
      }
    }
  }
  /**
   * Reads the entries from the named LDIF file.
   *
@@ -513,18 +429,13 @@
   *          The name of the LDIF file.
   * @return The entries.
   */
  private static ConcurrentSkipListMap<DN, Entry> readEntriesFromLDIF(
      final String ldifFileName)
  {
    private static ConcurrentSkipListMap<DN, Entry> readEntriesFromLDIF(final String ldifFileName) {
    final ConcurrentSkipListMap<DN, Entry> entries;
    // Read the LDIF.
    InputStream ldif;
    try
    {
        try {
      ldif = new FileInputStream(ldifFileName);
    }
    catch (final FileNotFoundException e)
    {
        } catch (final FileNotFoundException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
      return null; // Satisfy compiler.
@@ -532,28 +443,19 @@
    entries = new ConcurrentSkipListMap<DN, Entry>();
    final LDIFEntryReader reader = new LDIFEntryReader(ldif);
    try
    {
      while (reader.hasNext())
      {
        try {
            while (reader.hasNext()) {
        Entry entry = reader.readEntry();
        entries.put(entry.getName(), entry);
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
      return null; // Satisfy compiler.
    }
    finally
    {
      try
      {
        } finally {
            try {
        reader.close();
      }
      catch (final IOException ignored)
      {
            } catch (final IOException ignored) {
        // Ignore.
      }
    }
@@ -561,30 +463,23 @@
    // Quickly sanity check that every entry (except root entries) have a
    // parent.
    boolean isValid = true;
    for (DN dn : entries.keySet())
    {
      if (dn.size() > 1)
      {
        for (DN dn : entries.keySet()) {
            if (dn.size() > 1) {
        DN parent = dn.parent();
        if (!entries.containsKey(parent))
        {
          System.err.println("The entry \"" + dn.toString()
              + "\" does not have a parent");
                if (!entries.containsKey(parent)) {
                    System.err
                            .println("The entry \"" + dn.toString() + "\" does not have a parent");
          isValid = false;
        }
      }
    }
    if (!isValid)
    {
        if (!isValid) {
      System.exit(1);
    }
    return entries;
  }
  private Server()
  {
    private Server() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package org.forgerock.opendj.examples;
import java.security.GeneralSecurityException;
import javax.net.ssl.SSLContext;
@@ -41,8 +38,6 @@
import org.forgerock.opendj.ldap.SSLContextBuilder;
import org.forgerock.opendj.ldap.TrustManagers;
/**
 * An example client application which performs simple authentication to a
 * directory server. This example takes the following command line parameters:
@@ -54,149 +49,120 @@
 * <li>use-starttls - (Optional) connect with StartTLS</li>
 * <li>use-ssl - (Optional) connect over SSL</li>
 * </ul>
 * The host, port, bind-dn, and bind-password are required. The use-starttls
 * and use-ssl parameters are optional and mutually exclusive.
 * The host, port, bind-dn, and bind-password are required. The use-starttls and
 * use-ssl parameters are optional and mutually exclusive.
 */
public final class SimpleAuth
{
public final class SimpleAuth {
  /**
   * Authenticate to the directory either over LDAP, over LDAPS, or using
   * StartTLS.
   *
   * @param args The command line arguments
     * @param args
     *            The command line arguments
   */
  public static void main(final String[] args)
  {
    public static void main(final String[] args) {
    parseArgs(args);
    // Connect and bind to the server, then close the connection.
    if (useStartTLS) connectStartTLS();
    else if (useSSL) connectSSL();
    else connect();
        if (useStartTLS) {
            connectStartTLS();
        } else if (useSSL) {
            connectSSL();
        } else {
            connect();
  }
    }
  /**
   * Authenticate over LDAP.
   */
  private static void connect()
  {
    final LDAPConnectionFactory factory = new LDAPConnectionFactory(
      host, port);
    private static void connect() {
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
    Connection connection = null;
    try
    {
        try {
      connection = factory.getConnection();
      connection.bind(bindDN, bindPassword.toCharArray());
      System.out.println("Authenticated as " + bindDN + ".");
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    finally
    {
      if (connection != null) connection.close();
        } finally {
            if (connection != null) {
                connection.close();
    }
  }
    }
  /**
   * For StartTLS and SSL the connection factory needs SSL context options.
   * In the general case, a trust manager in the SSL context serves to check
   * server certificates, and a key manager handles client keys when the server
   * checks certificates from our client.
     * For StartTLS and SSL the connection factory needs SSL context options. In
     * the general case, a trust manager in the SSL context serves to check
     * server certificates, and a key manager handles client keys when the
     * server checks certificates from our client.
   *
   * OpenDJ directory server lets you install by default with a self-signed
   * certificate that is not in the system trust store. To simplify this
   * implementation trusts all server certificates.
   */
  private static LDAPOptions getTrustAllOptions()
    throws GeneralSecurityException
  {
    private static LDAPOptions getTrustAllOptions() throws GeneralSecurityException {
    LDAPOptions lo = new LDAPOptions();
    SSLContext sslContext = new SSLContextBuilder()
      .setTrustManager(TrustManagers.trustAll()).getSSLContext();
        SSLContext sslContext =
                new SSLContextBuilder().setTrustManager(TrustManagers.trustAll()).getSSLContext();
    lo.setSSLContext(sslContext);
    lo.setUseStartTLS(useStartTLS);
    return lo;
  }
  /**
   * Perform authentication over a secure connection, trusting all server
   * certificates.
   */
  private static void trustAllConnect()
  {
    private static void trustAllConnect() {
    Connection connection = null;
    try
    {
        try {
      final LDAPConnectionFactory factory =
          new LDAPConnectionFactory(host, port, getTrustAllOptions());
      connection = factory.getConnection();
      connection.bind(bindDN, bindPassword.toCharArray());
      System.out.println("Authenticated as " + bindDN + ".");
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      System.err.println(e.getMessage());
      System.exit(e.getResult().getResultCode().intValue());
      return;
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
      return;
    }
    catch (final GeneralSecurityException e)
    {
        } catch (final GeneralSecurityException e) {
      System.err.println(e.getMessage());
      System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
    }
    finally
    {
      if (connection != null)
        } finally {
            if (connection != null) {
        connection.close();
    }
  }
    }
  /**
   * Authenticate using StartTLS.
   */
  private static void connectStartTLS()
  {
    private static void connectStartTLS() {
    trustAllConnect();
  }
  /**
   * Authenticate over LDAPS.
   */
  private static void connectSSL()
  {
    private static void connectSSL() {
    trustAllConnect();
  }
  private static String host;
  private static int port;
  private static String bindDN;
@@ -204,61 +170,47 @@
  private static boolean useStartTLS = false;
  private static boolean useSSL = false;
  /**
   * Parse command line arguments.
   * @param args host port bind-dn bind-password [ use-starttls | use-ssl ]
     *
     * @param args
     *            host port bind-dn bind-password [ use-starttls | use-ssl ]
   */
  private static void parseArgs(String[] args)
  {
    if (args.length < 4 || args.length > 5) giveUp();
    private static void parseArgs(String[] args) {
        if (args.length < 4 || args.length > 5) {
            giveUp();
        }
    host = args[0];
    port = Integer.parseInt(args[1]);
    bindDN = args[2];
    bindPassword = args[3];
    if (args.length == 5)
    {
      if (args[4].toLowerCase().equals("use-starttls"))
      {
        if (args.length == 5) {
            if (args[4].toLowerCase().equals("use-starttls")) {
        useStartTLS = true;
        useSSL = false;
      }
      else if (args[4].toLowerCase().equals("use-ssl"))
      {
            } else if (args[4].toLowerCase().equals("use-ssl")) {
        useStartTLS = false;
        useSSL = true;
            } else {
                giveUp();
      }
      else giveUp();
    }
  }
  private static void giveUp()
  {
    private static void giveUp() {
    printUsage();
    System.exit(1);
  }
  private static void printUsage()
  {
    System.err.println(
      "Usage: host port bind-dn bind-password [ use-starttls | use-ssl ]");
    System.err.println(
      "\thost, port, bind-dn, and bind-password arguments are required.");
    System.err.println(
      "\tuse-starttls and use-ssl are optional and mutually exclusive.");
    private static void printUsage() {
        System.err.println("Usage: host port bind-dn bind-password [ use-starttls | use-ssl ]");
        System.err.println("\thost, port, bind-dn, and bind-password arguments are required.");
        System.err.println("\tuse-starttls and use-ssl are optional and mutually exclusive.");
  }
  private SimpleAuth()
  {
    private SimpleAuth() {
    // Not used.
  }
}
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/package-info.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -30,3 +29,4 @@
 * OpenDJ LDAP SDK.
 */
package org.forgerock.opendj.examples;
opendj3/opendj-ldap-sdk/pom.xml
@@ -7,17 +7,16 @@
  ! (the "License").  You may not use this file except in compliance
  ! with the License.
  !
  ! You can obtain a copy of the license at
  ! trunk/opendj3/legal-notices/CDDLv1_0.txt
  ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
  ! or http://forgerock.org/license/CDDLv1.0.html.
  ! See the License for the specific language governing permissions
  ! and limitations under the License.
  !
  ! When distributing Covered Code, include this CDDL HEADER in each
  ! file and include the License file at
  ! trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
  ! add the following below this CDDL HEADER, with the fields enclosed
  ! by brackets "[]" replaced with your own identifying information:
  ! file and include the License file at legal-notices/CDDLv1_0.txt.
  ! If applicable, add the following below this CDDL HEADER, with the
  ! fields enclosed by brackets "[]" replaced with your own identifying
  ! information:
  !      Portions Copyright [yyyy] [name of copyright owner]
  !
  ! CDDL HEADER END
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferReader.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,9 +27,10 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.*;
import static com.forgerock.opendj.ldap.LDAPConstants.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
import static com.forgerock.opendj.ldap.LDAPConstants.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE;
import static com.forgerock.opendj.ldap.LDAPConstants.ELEMENT_READ_STATE_NEED_TYPE;
import static com.forgerock.opendj.ldap.LDAPConstants.ELEMENT_READ_STATE_NEED_VALUE_BYTES;
import static org.forgerock.opendj.ldap.CoreMessages.*;
import java.io.IOException;
@@ -49,15 +49,11 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * Grizzly ASN1 reader implementation.
 */
final class ASN1BufferReader extends AbstractASN1Reader implements ASN1Reader
{
  private final class ChildSequenceLimiter implements SequenceLimiter
  {
final class ASN1BufferReader extends AbstractASN1Reader implements ASN1Reader {
    private final class ChildSequenceLimiter implements SequenceLimiter {
    private SequenceLimiter parent;
    private ChildSequenceLimiter child;
@@ -66,12 +62,8 @@
    private int bytesRead;
    public void checkLimit(final int readSize) throws IOException
    {
      if ((readLimit > 0) && (bytesRead + readSize > readLimit))
      {
        public void checkLimit(final int readSize) throws IOException {
            if ((readLimit > 0) && (bytesRead + readSize > readLimit)) {
        final LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get();
        throw DecodeException.fatalError(message);
      }
@@ -81,41 +73,27 @@
      bytesRead += readSize;
    }
    public SequenceLimiter endSequence() throws IOException
    {
        public SequenceLimiter endSequence() throws IOException {
      parent.checkLimit(remaining());
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINE) && remaining() > 0)
      {
        StaticUtils.DEBUG_LOG
            .fine(String.format(
                "Ignoring %d unused trailing bytes in ASN.1 SEQUENCE",
                remaining()));
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINE) && remaining() > 0) {
                StaticUtils.DEBUG_LOG.fine(String.format(
                        "Ignoring %d unused trailing bytes in ASN.1 SEQUENCE", remaining()));
      }
      for (int i = 0; i < remaining(); i++)
      {
            for (int i = 0; i < remaining(); i++) {
        buffer.get();
      }
      return parent;
    }
    public int remaining()
    {
        public int remaining() {
      return readLimit - bytesRead;
    }
    public ChildSequenceLimiter startSequence(final int readLimit)
    {
      if (child == null)
      {
        public ChildSequenceLimiter startSequence(final int readLimit) {
            if (child == null) {
        child = new ChildSequenceLimiter();
        child.parent = this;
      }
@@ -127,45 +105,27 @@
    }
  }
  private final class RootSequenceLimiter implements SequenceLimiter
  {
    private final class RootSequenceLimiter implements SequenceLimiter {
    private ChildSequenceLimiter child;
    public void checkLimit(final int readSize) throws IOException
    {
      if (buffer.remaining() < readSize)
      {
        public void checkLimit(final int readSize) throws IOException {
            if (buffer.remaining() < readSize) {
        final LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get();
        throw DecodeException.fatalError(message);
      }
    }
    public ChildSequenceLimiter endSequence() throws DecodeException
    {
      final LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED
          .get();
        public ChildSequenceLimiter endSequence() throws DecodeException {
            final LocalizableMessage message = ERR_ASN1_SEQUENCE_READ_NOT_STARTED.get();
      throw new IllegalStateException(message.toString());
    }
    public int remaining()
    {
        public int remaining() {
      return buffer.remaining();
    }
    public ChildSequenceLimiter startSequence(final int readLimit)
    {
      if (child == null)
      {
        public ChildSequenceLimiter startSequence(final int readLimit) {
            if (child == null) {
        child = new ChildSequenceLimiter();
        child.parent = this;
      }
@@ -177,27 +137,16 @@
    }
  }
  private interface SequenceLimiter
  {
    private interface SequenceLimiter {
    public void checkLimit(int readSize) throws IOException;
    public SequenceLimiter endSequence() throws IOException;
    public int remaining();
    public SequenceLimiter startSequence(int readLimit);
  }
  private static final int MAX_STRING_BUFFER_SIZE = 1024;
  private int state = ELEMENT_READ_STATE_NEED_TYPE;
@@ -216,53 +165,43 @@
  private final byte[] stringBuffer;
  /**
   * Creates a new ASN1 reader whose source is the provided input stream and
   * having a user defined maximum BER element size.
   *
   * @param maxElementSize
   *          The maximum BER element size, or <code>0</code> to indicate that
   *          there is no limit.
     *            The maximum BER element size, or <code>0</code> to indicate
     *            that there is no limit.
   * @param memoryManager
   *          The memory manager to use for buffering.
   */
  ASN1BufferReader(final int maxElementSize,
      final MemoryManager<?> memoryManager)
  {
    ASN1BufferReader(final int maxElementSize, final MemoryManager<?> memoryManager) {
    this.readLimiter = new RootSequenceLimiter();
    this.stringBuffer = new byte[MAX_STRING_BUFFER_SIZE];
    this.maxElementSize = maxElementSize;
    this.buffer = BuffersBuffer.create(memoryManager);
  }
  /**
   * Closes this ASN.1 reader and the underlying stream.
   *
   * @throws IOException
   *           if an I/O error occurs
   */
  public void close() throws IOException
  {
    public void close() throws IOException {
    buffer.dispose();
  }
  /**
   * Determines if a complete ASN.1 element is ready to be read from the stream
   * reader.
     * Determines if a complete ASN.1 element is ready to be read from the
     * stream reader.
   *
   * @return <code>true</code> if another complete element is available or
   *         <code>false</code> otherwise.
   * @throws IOException
   *           If an error occurs while trying to decode an ASN1 element.
   */
  public boolean elementAvailable() throws IOException
  {
    public boolean elementAvailable() throws IOException {
    return !((state == ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(true))
        && !((state == ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE)
            && !needFirstLengthByteState(true))
@@ -272,8 +211,6 @@
  }
  /**
   * Determines if the input stream contains at least one ASN.1 element to be
   * read.
@@ -283,22 +220,17 @@
   * @throws IOException
   *           If an error occurs while trying to decode an ASN1 element.
   */
  public boolean hasNextElement() throws IOException
  {
    public boolean hasNextElement() throws IOException {
    return (state != ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true);
  }
  /**
   * {@inheritDoc}
   */
  public int peekLength() throws IOException
  {
    public int peekLength() throws IOException {
    peekType();
    switch (state)
    {
        switch (state) {
    case ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE:
      needFirstLengthByteState(false);
      break;
@@ -310,63 +242,49 @@
    return peekLength;
  }
  /**
   * {@inheritDoc}
   */
  public byte peekType() throws IOException
  {
    if (state == ELEMENT_READ_STATE_NEED_TYPE)
    {
    public byte peekType() throws IOException {
        if (state == ELEMENT_READ_STATE_NEED_TYPE) {
      needTypeState(false);
    }
    return peekType;
  }
  /**
   * {@inheritDoc}
   */
  public boolean readBoolean() throws IOException
  {
    public boolean readBoolean() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if (peekLength != 1)
    {
      final LocalizableMessage message = ERR_ASN1_BOOLEAN_INVALID_LENGTH
          .get(peekLength);
        if (peekLength != 1) {
            final LocalizableMessage message = ERR_ASN1_BOOLEAN_INVALID_LENGTH.get(peekLength);
      throw DecodeException.fatalError(message);
    }
    readLimiter.checkLimit(peekLength);
    final byte readByte = buffer.get();
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "READ ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)", peekType,
          peekLength, String.valueOf(readByte != 0x00)));
                    "READ ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)", peekType, peekLength,
                    String.valueOf(readByte != 0x00)));
    }
    state = ELEMENT_READ_STATE_NEED_TYPE;
    return readByte != 0x00;
  }
  /**
   * {@inheritDoc}
   */
  public void readEndSequence() throws IOException
  {
    public void readEndSequence() throws IOException {
    readLimiter = readLimiter.endSequence();
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format("READ ASN.1 END SEQUENCE"));
    }
@@ -374,32 +292,24 @@
    state = ELEMENT_READ_STATE_NEED_TYPE;
  }
  /**
   * {@inheritDoc}
   */
  public void readEndSet() throws IOException
  {
    public void readEndSet() throws IOException {
    // From an implementation point of view, a set is equivalent to a
    // sequence.
    readEndSequence();
  }
  /**
   * {@inheritDoc}
   */
  public int readEnumerated() throws IOException
  {
    public int readEnumerated() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if ((peekLength < 1) || (peekLength > 4))
    {
      final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH
          .get(peekLength);
        if ((peekLength < 1) || (peekLength > 4)) {
            final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
      throw DecodeException.fatalError(message);
    }
@@ -408,32 +318,24 @@
    return (int) readInteger();
  }
  /**
   * {@inheritDoc}
   */
  public long readInteger() throws IOException
  {
    public long readInteger() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if ((peekLength < 1) || (peekLength > 8))
    {
      final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH
          .get(peekLength);
        if ((peekLength < 1) || (peekLength > 8)) {
            final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength);
      throw DecodeException.fatalError(message);
    }
    readLimiter.checkLimit(peekLength);
    if (peekLength > 4)
    {
        if (peekLength > 4) {
      long longValue = 0;
      for (int i = 0; i < peekLength; i++)
      {
            for (int i = 0; i < peekLength; i++) {
        final int readByte = buffer.get();
        if ((i == 0) && (((byte) readByte) < 0))
        {
                if ((i == 0) && (((byte) readByte) < 0)) {
          longValue = 0xFFFFFFFFFFFFFFFFL;
        }
        longValue = (longValue << 8) | (readByte & 0xFF);
@@ -441,25 +343,20 @@
      state = ELEMENT_READ_STATE_NEED_TYPE;
      return longValue;
    }
    else
    {
        } else {
      int intValue = 0;
      for (int i = 0; i < peekLength; i++)
      {
            for (int i = 0; i < peekLength; i++) {
        final int readByte = buffer.get();
        if ((i == 0) && (((byte) readByte) < 0))
        {
                if ((i == 0) && (((byte) readByte) < 0)) {
          intValue = 0xFFFFFFFF;
        }
        intValue = (intValue << 8) | (readByte & 0xFF);
      }
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "READ ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", peekType,
            peekLength, intValue));
                        "READ ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", peekType, peekLength,
                        intValue));
      }
      state = ELEMENT_READ_STATE_NEED_TYPE;
@@ -467,45 +364,35 @@
    }
  }
  /**
   * {@inheritDoc}
   */
  public void readNull() throws IOException
  {
    public void readNull() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    // Make sure that the decoded length is exactly zero byte.
    if (peekLength != 0)
    {
      final LocalizableMessage message = ERR_ASN1_NULL_INVALID_LENGTH
          .get(peekLength);
        if (peekLength != 0) {
            final LocalizableMessage message = ERR_ASN1_NULL_INVALID_LENGTH.get(peekLength);
      throw DecodeException.fatalError(message);
    }
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "READ ASN.1 NULL(type=0x%x, length=%d)", peekType, peekLength));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format("READ ASN.1 NULL(type=0x%x, length=%d)",
                    peekType, peekLength));
    }
    state = ELEMENT_READ_STATE_NEED_TYPE;
  }
  /**
   * {@inheritDoc}
   */
  public ByteString readOctetString() throws IOException
  {
    public ByteString readOctetString() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if (peekLength == 0)
    {
        if (peekLength == 0) {
      state = ELEMENT_READ_STATE_NEED_TYPE;
      return ByteString.empty();
    }
@@ -515,30 +402,23 @@
    final byte[] value = new byte[peekLength];
    buffer.get(value);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG
          .finest(String.format("READ ASN.1 OCTETSTRING(type=0x%x, length=%d)",
              peekType, peekLength));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format(
                    "READ ASN.1 OCTETSTRING(type=0x%x, length=%d)", peekType, peekLength));
    }
    state = ELEMENT_READ_STATE_NEED_TYPE;
    return ByteString.wrap(value);
  }
  /**
   * {@inheritDoc}
   */
  public ByteStringBuilder readOctetString(final ByteStringBuilder builder)
      throws IOException
  {
    public ByteStringBuilder readOctetString(final ByteStringBuilder builder) throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if (peekLength == 0)
    {
        if (peekLength == 0) {
      state = ELEMENT_READ_STATE_NEED_TYPE;
      return builder;
    }
@@ -546,45 +426,35 @@
    readLimiter.checkLimit(peekLength);
    // Copy the value and construct the element to return.
    // TODO: Is there a more efficient way to do this?
    for (int i = 0; i < peekLength; i++)
    {
        for (int i = 0; i < peekLength; i++) {
      builder.append(buffer.get());
    }
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG
          .finest(String.format("READ ASN.1 OCTETSTRING(type=0x%x, length=%d)",
              peekType, peekLength));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format(
                    "READ ASN.1 OCTETSTRING(type=0x%x, length=%d)", peekType, peekLength));
    }
    state = ELEMENT_READ_STATE_NEED_TYPE;
    return builder;
  }
  /**
   * {@inheritDoc}
   */
  public String readOctetStringAsString() throws IOException
  {
    public String readOctetStringAsString() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    if (peekLength == 0)
    {
        if (peekLength == 0) {
      state = ELEMENT_READ_STATE_NEED_TYPE;
      return "";
    }
    byte[] readBuffer;
    if (peekLength <= stringBuffer.length)
    {
        if (peekLength <= stringBuffer.length) {
      readBuffer = stringBuffer;
    }
    else
    {
        } else {
      readBuffer = new byte[peekLength];
    }
@@ -594,14 +464,10 @@
    state = ELEMENT_READ_STATE_NEED_TYPE;
    String str;
    try
    {
        try {
      str = new String(readBuffer, 0, peekLength, "UTF-8");
    }
    catch (final Exception e)
    {
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.WARNING))
      {
        } catch (final Exception e) {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.WARNING)) {
        StaticUtils.DEBUG_LOG
            .warning("Unable to decode ASN.1 OCTETSTRING bytes as UTF-8 string: "
                + e.toString());
@@ -610,86 +476,65 @@
      str = new String(stringBuffer, 0, peekLength);
    }
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "READ ASN.1 OCTETSTRING(type=0x%x, length=%d, value=%s)", peekType,
          peekLength, str));
                    "READ ASN.1 OCTETSTRING(type=0x%x, length=%d, value=%s)", peekType, peekLength,
                    str));
    }
    return str;
  }
  /**
   * {@inheritDoc}
   */
  public void readStartSequence() throws IOException
  {
    public void readStartSequence() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    readLimiter = readLimiter.startSequence(peekLength);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "READ ASN.1 START SEQUENCE(type=0x%x, length=%d)", peekType,
          peekLength));
                    "READ ASN.1 START SEQUENCE(type=0x%x, length=%d)", peekType, peekLength));
    }
    // Reset the state
    state = ELEMENT_READ_STATE_NEED_TYPE;
  }
  /**
   * {@inheritDoc}
   */
  public void readStartSet() throws IOException
  {
    public void readStartSet() throws IOException {
    // From an implementation point of view, a set is equivalent to a
    // sequence.
    readStartSequence();
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Reader skipElement() throws IOException
  {
    public ASN1Reader skipElement() throws IOException {
    // Read the header if haven't done so already
    peekLength();
    readLimiter.checkLimit(peekLength);
    for (int i = 0; i < peekLength; i++)
    {
        for (int i = 0; i < peekLength; i++) {
      buffer.get();
    }
    state = ELEMENT_READ_STATE_NEED_TYPE;
    return this;
  }
  void appendBytesRead(final Buffer buffer)
  {
    void appendBytesRead(final Buffer buffer) {
    this.buffer.append(buffer);
  }
  void disposeBytesRead()
  {
    void disposeBytesRead() {
    this.buffer.shrink();
  }
  /**
   * Internal helper method reading the additional ASN.1 length bytes and
   * transition to the next state if successful.
@@ -700,18 +545,14 @@
   * @throws IOException
   *           If an error occurs while reading from the stream.
   */
  private boolean needAdditionalLengthBytesState(final boolean ensureRead)
      throws IOException
  {
    if (ensureRead && (readLimiter.remaining() < lengthBytesNeeded))
    {
    private boolean needAdditionalLengthBytesState(final boolean ensureRead) throws IOException {
        if (ensureRead && (readLimiter.remaining() < lengthBytesNeeded)) {
      return false;
    }
    byte readByte;
    readLimiter.checkLimit(lengthBytesNeeded);
    while (lengthBytesNeeded > 0)
    {
        while (lengthBytesNeeded > 0) {
      readByte = buffer.get();
      peekLength = (peekLength << 8) | (readByte & 0xFF);
      lengthBytesNeeded--;
@@ -719,9 +560,9 @@
    // Make sure that the element is not larger than the maximum allowed
    // message size.
    if ((maxElementSize > 0) && (peekLength > maxElementSize))
    {
      final LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED
        if ((maxElementSize > 0) && (peekLength > maxElementSize)) {
            final LocalizableMessage m =
                    ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED
          .get(peekLength, maxElementSize);
      throw DecodeException.fatalError(m);
    }
@@ -729,11 +570,9 @@
    return true;
  }
  /**
   * Internal helper method reading the first length bytes and transition to the
   * next state if successful.
     * Internal helper method reading the first length bytes and transition to
     * the next state if successful.
   *
   * @param ensureRead
   *          <code>true</code> to check for availability first.
@@ -741,37 +580,30 @@
   * @throws IOException
   *           If an error occurs while trying to decode an ASN1 element.
   */
  private boolean needFirstLengthByteState(final boolean ensureRead)
      throws IOException
  {
    if (ensureRead && (readLimiter.remaining() <= 0))
    {
    private boolean needFirstLengthByteState(final boolean ensureRead) throws IOException {
        if (ensureRead && (readLimiter.remaining() <= 0)) {
      return false;
    }
    readLimiter.checkLimit(1);
    byte readByte = buffer.get();
    peekLength = (readByte & 0x7F);
    if (peekLength != readByte)
    {
        if (peekLength != readByte) {
      lengthBytesNeeded = peekLength;
      if (lengthBytesNeeded > 4)
      {
        final LocalizableMessage message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES
            .get(lengthBytesNeeded);
            if (lengthBytesNeeded > 4) {
                final LocalizableMessage message =
                        ERR_ASN1_INVALID_NUM_LENGTH_BYTES.get(lengthBytesNeeded);
        throw DecodeException.fatalError(message);
      }
      peekLength = 0x00;
      if (ensureRead && (readLimiter.remaining() < lengthBytesNeeded))
      {
            if (ensureRead && (readLimiter.remaining() < lengthBytesNeeded)) {
        state = ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES;
        return false;
      }
      readLimiter.checkLimit(lengthBytesNeeded);
      while (lengthBytesNeeded > 0)
      {
            while (lengthBytesNeeded > 0) {
        readByte = buffer.get();
        peekLength = (peekLength << 8) | (readByte & 0xFF);
        lengthBytesNeeded--;
@@ -780,9 +612,9 @@
    // Make sure that the element is not larger than the maximum allowed
    // message size.
    if ((maxElementSize > 0) && (peekLength > maxElementSize))
    {
      final LocalizableMessage m = ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED
        if ((maxElementSize > 0) && (peekLength > maxElementSize)) {
            final LocalizableMessage m =
                    ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED
          .get(peekLength, maxElementSize);
      throw DecodeException.fatalError(m);
    }
@@ -790,8 +622,6 @@
    return true;
  }
  /**
   * Internal helper method reading the ASN.1 type byte and transition to the
   * next state if successful.
@@ -802,11 +632,9 @@
   * @throws IOException
   *           If an error occurs while trying to decode an ASN1 element.
   */
  private boolean needTypeState(final boolean ensureRead) throws IOException
  {
    private boolean needTypeState(final boolean ensureRead) throws IOException {
    // Read just the type.
    if (ensureRead && (readLimiter.remaining() <= 0))
    {
        if (ensureRead && (readLimiter.remaining() <= 0)) {
      return false;
    }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
 */
package com.forgerock.opendj.ldap;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_FALSE;
import static org.forgerock.opendj.asn1.ASN1Constants.BOOLEAN_VALUE_TRUE;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED;
@@ -49,45 +46,31 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * Grizzly ASN1 writer implementation.
 */
final class ASN1BufferWriter extends AbstractASN1Writer implements ASN1Writer,
    Cacheable
{
  private class ChildSequenceBuffer implements SequenceBuffer
  {
final class ASN1BufferWriter extends AbstractASN1Writer implements ASN1Writer, Cacheable {
    private class ChildSequenceBuffer implements SequenceBuffer {
    private SequenceBuffer parent;
    private ChildSequenceBuffer child;
    private final ByteStringBuilder buffer = new ByteStringBuilder(
        BUFFER_INIT_SIZE);
        private final ByteStringBuilder buffer = new ByteStringBuilder(BUFFER_INIT_SIZE);
    public SequenceBuffer endSequence() throws IOException
    {
        public SequenceBuffer endSequence() throws IOException {
      writeLength(parent, buffer.length());
      parent.writeByteArray(buffer.getBackingArray(), 0, buffer.length());
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 END SEQUENCE(length=%d)", buffer.length()));
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
                StaticUtils.DEBUG_LOG.finest(String.format("WRITE ASN.1 END SEQUENCE(length=%d)",
                        buffer.length()));
      }
      return parent;
    }
    public SequenceBuffer startSequence(final byte type) throws IOException
    {
      if (child == null)
      {
        public SequenceBuffer startSequence(final byte type) throws IOException {
            if (child == null) {
        child = new ChildSequenceBuffer();
        child.parent = this;
      }
@@ -98,46 +81,29 @@
      return child;
    }
    public void writeByte(final byte b) throws IOException
    {
        public void writeByte(final byte b) throws IOException {
      buffer.append(b);
    }
    public void writeByteArray(final byte[] bs, final int offset,
        final int length) throws IOException
    {
        public void writeByteArray(final byte[] bs, final int offset, final int length)
                throws IOException {
      buffer.append(bs, offset, length);
    }
  }
  private static final class RecyclableBuffer extends ByteBufferWrapper
  {
    private static final class RecyclableBuffer extends ByteBufferWrapper {
    private volatile boolean usable = true;
    private RecyclableBuffer()
    {
        private RecyclableBuffer() {
      visible = ByteBuffer.allocate(BUFFER_INIT_SIZE);
      allowBufferDispose = true;
    }
    @Override
    public void dispose()
    {
        public void dispose() {
      usable = true;
    }
    /**
     * Ensures that the specified number of additional bytes will fit in the
     * buffer and resizes it if necessary.
@@ -145,40 +111,27 @@
     * @param size
     *          The number of additional bytes.
     */
    public void ensureAdditionalCapacity(final int size)
    {
        public void ensureAdditionalCapacity(final int size) {
      final int newCount = visible.position() + size;
      if (newCount > visible.capacity())
      {
        final ByteBuffer newByteBuffer = ByteBuffer.allocate(Math.max(visible
            .capacity() << 1, newCount));
            if (newCount > visible.capacity()) {
                final ByteBuffer newByteBuffer =
                        ByteBuffer.allocate(Math.max(visible.capacity() << 1, newCount));
        visible.flip();
        visible = newByteBuffer.put(visible);
      }
    }
  }
  private class RootSequenceBuffer implements SequenceBuffer
  {
    private class RootSequenceBuffer implements SequenceBuffer {
    private ChildSequenceBuffer child;
    public SequenceBuffer endSequence() throws IOException
    {
      final LocalizableMessage message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED
          .get();
        public SequenceBuffer endSequence() throws IOException {
            final LocalizableMessage message = ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED.get();
      throw new IllegalStateException(message.toString());
    }
    public SequenceBuffer startSequence(final byte type) throws IOException
    {
      if (child == null)
      {
        public SequenceBuffer startSequence(final byte type) throws IOException {
            if (child == null) {
        child = new ChildSequenceBuffer();
        child.parent = this;
      }
@@ -190,62 +143,39 @@
      return child;
    }
    public void writeByte(final byte b) throws IOException
    {
        public void writeByte(final byte b) throws IOException {
      outBuffer.ensureAdditionalCapacity(1);
      outBuffer.put(b);
    }
    public void writeByteArray(final byte[] bs, final int offset,
        final int length) throws IOException
    {
        public void writeByteArray(final byte[] bs, final int offset, final int length)
                throws IOException {
      outBuffer.ensureAdditionalCapacity(length);
      outBuffer.put(bs, offset, length);
    }
  }
  private interface SequenceBuffer
  {
    private interface SequenceBuffer {
    public SequenceBuffer endSequence() throws IOException;
    public SequenceBuffer startSequence(byte type) throws IOException;
    public void writeByte(byte b) throws IOException;
    public void writeByteArray(byte[] bs, int offset, int length)
        throws IOException;
        public void writeByteArray(byte[] bs, int offset, int length) throws IOException;
  }
  private static final int BUFFER_INIT_SIZE = 1024;
  private final static ThreadCache.CachedTypeIndex<ASN1BufferWriter> WRITER_INDEX = ThreadCache
      .obtainIndex(ASN1BufferWriter.class, 1);
  static ASN1BufferWriter getWriter()
  {
    static ASN1BufferWriter getWriter() {
    ASN1BufferWriter asn1Writer = ThreadCache.takeFromCache(WRITER_INDEX);
    if (asn1Writer == null)
    {
        if (asn1Writer == null) {
      asn1Writer = new ASN1BufferWriter();
    }
    if (!asn1Writer.outBuffer.usable)
    {
        if (!asn1Writer.outBuffer.usable) {
      // If the output buffer is unusable, create a new one.
      asn1Writer.outBuffer = new RecyclableBuffer();
    }
@@ -253,26 +183,19 @@
    return asn1Writer;
  }
  private SequenceBuffer sequenceBuffer;
  private RecyclableBuffer outBuffer;
  private final RootSequenceBuffer rootBuffer;
  /**
   * Creates a new ASN.1 writer that writes to a StreamWriter.
   */
  private ASN1BufferWriter()
  {
    private ASN1BufferWriter() {
    this.sequenceBuffer = this.rootBuffer = new RootSequenceBuffer();
    this.outBuffer = new RecyclableBuffer();
  }
  /**
   * Closes this ASN.1 writer and the underlying outputstream. Any unfinished
   * sequences will be ended.
@@ -280,235 +203,168 @@
   * @throws IOException
   *           if an error occurs while closing the stream.
   */
  public void close() throws IOException
  {
    public void close() throws IOException {
    outBuffer = null;
  }
  /**
   * Flushes the stream.
   *
   * @throws IOException
   *           If an I/O error occurs
   */
  public void flush() throws IOException
  {
    public void flush() throws IOException {
    // Do nothing
  }
  public void recycle()
  {
    public void recycle() {
    sequenceBuffer = rootBuffer;
    outBuffer.clear();
    ThreadCache.putToCache(WRITER_INDEX, this);
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeBoolean(final byte type, final boolean booleanValue)
      throws IOException
  {
    public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException {
    sequenceBuffer.writeByte(type);
    writeLength(sequenceBuffer, 1);
    sequenceBuffer.writeByte(booleanValue ? BOOLEAN_VALUE_TRUE
        : BOOLEAN_VALUE_FALSE);
        sequenceBuffer.writeByte(booleanValue ? BOOLEAN_VALUE_TRUE : BOOLEAN_VALUE_FALSE);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "WRITE ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)", type, 1,
          String.valueOf(booleanValue)));
                    "WRITE ASN.1 BOOLEAN(type=0x%x, length=%d, value=%s)", type, 1, String
                            .valueOf(booleanValue)));
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeEndSequence() throws IOException
  {
    public ASN1Writer writeEndSequence() throws IOException {
    sequenceBuffer = sequenceBuffer.endSequence();
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeEndSet() throws IOException
  {
    public ASN1Writer writeEndSet() throws IOException {
    return writeEndSequence();
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeEnumerated(final byte type, final int intValue)
      throws IOException
  {
    public ASN1Writer writeEnumerated(final byte type, final int intValue) throws IOException {
    return writeInteger(type, intValue);
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeInteger(final byte type, final int intValue)
      throws IOException
  {
    public ASN1Writer writeInteger(final byte type, final int intValue) throws IOException {
    sequenceBuffer.writeByte(type);
    if (((intValue < 0) && ((intValue & 0xFFFFFF80) == 0xFFFFFF80))
        || ((intValue & 0x0000007F) == intValue))
    {
                || ((intValue & 0x0000007F) == intValue)) {
      writeLength(sequenceBuffer, 1);
      sequenceBuffer.writeByte((byte) (intValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 1,
            intValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 1, intValue));
      }
    }
    else if (((intValue < 0) && ((intValue & 0xFFFF8000) == 0xFFFF8000))
        || ((intValue & 0x00007FFF) == intValue))
    {
        } else if (((intValue < 0) && ((intValue & 0xFFFF8000) == 0xFFFF8000))
                || ((intValue & 0x00007FFF) == intValue)) {
      writeLength(sequenceBuffer, 2);
      sequenceBuffer.writeByte((byte) ((intValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (intValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 2,
            intValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 2, intValue));
      }
    }
    else if (((intValue < 0) && ((intValue & 0xFF800000) == 0xFF800000))
        || ((intValue & 0x007FFFFF) == intValue))
    {
        } else if (((intValue < 0) && ((intValue & 0xFF800000) == 0xFF800000))
                || ((intValue & 0x007FFFFF) == intValue)) {
      writeLength(sequenceBuffer, 3);
      sequenceBuffer.writeByte((byte) ((intValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((intValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (intValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 3,
            intValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 3, intValue));
      }
    }
    else
    {
        } else {
      writeLength(sequenceBuffer, 4);
      sequenceBuffer.writeByte((byte) ((intValue >> 24) & 0xFF));
      sequenceBuffer.writeByte((byte) ((intValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((intValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (intValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 4,
            intValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 4, intValue));
      }
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeInteger(final byte type, final long longValue)
      throws IOException
  {
    public ASN1Writer writeInteger(final byte type, final long longValue) throws IOException {
    sequenceBuffer.writeByte(type);
    if (((longValue < 0) && ((longValue & 0xFFFFFFFFFFFFFF80L) == 0xFFFFFFFFFFFFFF80L))
        || ((longValue & 0x000000000000007FL) == longValue))
    {
                || ((longValue & 0x000000000000007FL) == longValue)) {
      writeLength(sequenceBuffer, 1);
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 1,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 1, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFFFFFFFFFFFF8000L) == 0xFFFFFFFFFFFF8000L))
        || ((longValue & 0x0000000000007FFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFFFFFFFFFFFF8000L) == 0xFFFFFFFFFFFF8000L))
                || ((longValue & 0x0000000000007FFFL) == longValue)) {
      writeLength(sequenceBuffer, 2);
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 2,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 2, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFFFFFFFFFF800000L) == 0xFFFFFFFFFF800000L))
        || ((longValue & 0x00000000007FFFFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFFFFFFFFFF800000L) == 0xFFFFFFFFFF800000L))
                || ((longValue & 0x00000000007FFFFFL) == longValue)) {
      writeLength(sequenceBuffer, 3);
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 3,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 3, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFFFFFFFF80000000L) == 0xFFFFFFFF80000000L))
        || ((longValue & 0x000000007FFFFFFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFFFFFFFF80000000L) == 0xFFFFFFFF80000000L))
                || ((longValue & 0x000000007FFFFFFFL) == longValue)) {
      writeLength(sequenceBuffer, 4);
      sequenceBuffer.writeByte((byte) ((longValue >> 24) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 4,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 4, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFFFFFF8000000000L) == 0xFFFFFF8000000000L))
        || ((longValue & 0x0000007FFFFFFFFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFFFFFF8000000000L) == 0xFFFFFF8000000000L))
                || ((longValue & 0x0000007FFFFFFFFFL) == longValue)) {
      writeLength(sequenceBuffer, 5);
      sequenceBuffer.writeByte((byte) ((longValue >> 32) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 24) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 5,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 5, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFFFF800000000000L) == 0xFFFF800000000000L))
        || ((longValue & 0x00007FFFFFFFFFFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFFFF800000000000L) == 0xFFFF800000000000L))
                || ((longValue & 0x00007FFFFFFFFFFFL) == longValue)) {
      writeLength(sequenceBuffer, 6);
      sequenceBuffer.writeByte((byte) ((longValue >> 40) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 32) & 0xFF));
@@ -516,16 +372,12 @@
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 6,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 6, longValue));
      }
    }
    else if (((longValue < 0) && ((longValue & 0xFF80000000000000L) == 0xFF80000000000000L))
        || ((longValue & 0x007FFFFFFFFFFFFFL) == longValue))
    {
        } else if (((longValue < 0) && ((longValue & 0xFF80000000000000L) == 0xFF80000000000000L))
                || ((longValue & 0x007FFFFFFFFFFFFFL) == longValue)) {
      writeLength(sequenceBuffer, 7);
      sequenceBuffer.writeByte((byte) ((longValue >> 48) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 40) & 0xFF));
@@ -534,15 +386,11 @@
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 7,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 7, longValue));
      }
    }
    else
    {
        } else {
      writeLength(sequenceBuffer, 8);
      sequenceBuffer.writeByte((byte) ((longValue >> 56) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 48) & 0xFF));
@@ -552,91 +400,70 @@
      sequenceBuffer.writeByte((byte) ((longValue >> 16) & 0xFF));
      sequenceBuffer.writeByte((byte) ((longValue >> 8) & 0xFF));
      sequenceBuffer.writeByte((byte) (longValue & 0xFF));
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
        StaticUtils.DEBUG_LOG.finest(String.format(
            "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 8,
            longValue));
                        "WRITE ASN.1 INTEGER(type=0x%x, length=%d, value=%d)", type, 8, longValue));
      }
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeNull(final byte type) throws IOException
  {
    public ASN1Writer writeNull(final byte type) throws IOException {
    sequenceBuffer.writeByte(type);
    writeLength(sequenceBuffer, 0);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "WRITE ASN.1 NULL(type=0x%x, length=%d)", type, 0));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format("WRITE ASN.1 NULL(type=0x%x, length=%d)",
                    type, 0));
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeOctetString(final byte type, final byte[] value,
      final int offset, final int length) throws IOException
  {
    public ASN1Writer writeOctetString(final byte type, final byte[] value, final int offset,
            final int length) throws IOException {
    sequenceBuffer.writeByte(type);
    writeLength(sequenceBuffer, length);
    sequenceBuffer.writeByteArray(value, offset, length);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d)", type, length));
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeOctetString(final byte type, final ByteSequence value)
      throws IOException
  {
            throws IOException {
    sequenceBuffer.writeByte(type);
    writeLength(sequenceBuffer, value.length());
    // TODO: Is there a more efficient way to do this?
    for (int i = 0; i < value.length(); i++)
    {
        for (int i = 0; i < value.length(); i++) {
      sequenceBuffer.writeByte(value.byteAt(i));
    }
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG.finest(String
          .format("WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d)", type, value
              .length()));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format(
                    "WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d)", type, value.length()));
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeOctetString(final byte type, final String value)
      throws IOException
  {
    public ASN1Writer writeOctetString(final byte type, final String value) throws IOException {
    sequenceBuffer.writeByte(type);
    if (value == null)
    {
        if (value == null) {
      writeLength(sequenceBuffer, 0);
      return this;
    }
@@ -645,8 +472,7 @@
    writeLength(sequenceBuffer, bytes.length);
    sequenceBuffer.writeByteArray(bytes, 0, bytes.length);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "WRITE ASN.1 OCTETSTRING(type=0x%x, length=%d, " + "value=%s)", type,
          bytes.length, value));
@@ -654,46 +480,34 @@
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeStartSequence(final byte type) throws IOException
  {
    public ASN1Writer writeStartSequence(final byte type) throws IOException {
    // Get a child sequence buffer
    sequenceBuffer = sequenceBuffer.startSequence(type);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST))
    {
      StaticUtils.DEBUG_LOG.finest(String.format(
          "WRITE ASN.1 START SEQUENCE(type=0x%x)", type));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINEST)) {
            StaticUtils.DEBUG_LOG.finest(String.format("WRITE ASN.1 START SEQUENCE(type=0x%x)",
                    type));
    }
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public ASN1Writer writeStartSet(final byte type) throws IOException
  {
    public ASN1Writer writeStartSet(final byte type) throws IOException {
    // From an implementation point of view, a set is equivalent to a
    // sequence.
    return writeStartSequence(type);
  }
  Buffer getBuffer()
  {
    Buffer getBuffer() {
    outBuffer.usable = false;
    return outBuffer.flip();
  }
  /**
   * Writes the provided value for use as the length of an ASN.1 element.
   *
@@ -704,33 +518,22 @@
   * @throws IOException
   *           if an error occurs while writing.
   */
  private void writeLength(final SequenceBuffer buffer, final int length)
      throws IOException
  {
    if (length < 128)
    {
    private void writeLength(final SequenceBuffer buffer, final int length) throws IOException {
        if (length < 128) {
      buffer.writeByte((byte) length);
    }
    else if ((length & 0x000000FF) == length)
    {
        } else if ((length & 0x000000FF) == length) {
      buffer.writeByte((byte) 0x81);
      buffer.writeByte((byte) (length & 0xFF));
    }
    else if ((length & 0x0000FFFF) == length)
    {
        } else if ((length & 0x0000FFFF) == length) {
      buffer.writeByte((byte) 0x82);
      buffer.writeByte((byte) ((length >> 8) & 0xFF));
      buffer.writeByte((byte) (length & 0xFF));
    }
    else if ((length & 0x00FFFFFF) == length)
    {
        } else if ((length & 0x00FFFFFF) == length) {
      buffer.writeByte((byte) 0x83);
      buffer.writeByte((byte) ((length >> 16) & 0xFF));
      buffer.writeByte((byte) ((length >> 8) & 0xFF));
      buffer.writeByte((byte) (length & 0xFF));
    }
    else
    {
        } else {
      buffer.writeByte((byte) 0x84);
      buffer.writeByte((byte) ((length >> 24) & 0xFF));
      buffer.writeByte((byte) ((length >> 16) & 0xFF));
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,26 +27,25 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Result;
import com.forgerock.opendj.util.AsynchronousFutureResult;
/**
 * Abstract future result implementation.
 *
 * @param <S>
 *          The type of result returned by this future.
 */
abstract class AbstractLDAPFutureResultImpl<S extends Result> extends
    AsynchronousFutureResult<S> implements IntermediateResponseHandler
{
abstract class AbstractLDAPFutureResultImpl<S extends Result> extends AsynchronousFutureResult<S>
        implements IntermediateResponseHandler {
  private final Connection connection;
  private final int requestID;
@@ -56,13 +54,9 @@
  private volatile long timestamp;
  AbstractLDAPFutureResultImpl(final int requestID,
      final ResultHandler<? super S> resultHandler,
    AbstractLDAPFutureResultImpl(final int requestID, final ResultHandler<? super S> resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(resultHandler);
    this.requestID = requestID;
    this.connection = connection;
@@ -70,34 +64,24 @@
    this.timestamp = System.currentTimeMillis();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final int getRequestID()
  {
    public final int getRequestID() {
    return requestID;
  }
  @Override
  public final boolean handleIntermediateResponse(
      final IntermediateResponse response)
  {
    public final boolean handleIntermediateResponse(final IntermediateResponse response) {
    // FIXME: there's a potential race condition here - the future could
    // get cancelled between the isDone() call and the handler
    // invocation. We'd need to add support for intermediate handlers in
    // the synchronizer.
    if (!isDone())
    {
        if (!isDone()) {
      updateTimestamp();
      if (intermediateResponseHandler != null)
      {
        if (!intermediateResponseHandler.handleIntermediateResponse(response))
        {
            if (intermediateResponseHandler != null) {
                if (!intermediateResponseHandler.handleIntermediateResponse(response)) {
          intermediateResponseHandler = null;
        }
      }
@@ -105,24 +89,17 @@
    return true;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  protected final ErrorResultException handleCancelRequest(
      final boolean mayInterruptIfRunning)
  {
    protected final ErrorResultException handleCancelRequest(final boolean mayInterruptIfRunning) {
    connection.abandonAsync(Requests.newAbandonRequest(requestID));
    return null;
  }
  @Override
  protected void toString(final StringBuilder sb)
  {
    protected void toString(final StringBuilder sb) {
    sb.append(" requestID = ");
    sb.append(requestID);
    sb.append(" timestamp = ");
@@ -130,45 +107,28 @@
    super.toString(sb);
  }
  final void adaptErrorResult(final Result result)
  {
    final S errorResult = newErrorResult(result.getResultCode(),
        result.getDiagnosticMessage(), result.getCause());
    final void adaptErrorResult(final Result result) {
        final S errorResult =
                newErrorResult(result.getResultCode(), result.getDiagnosticMessage(), result
                        .getCause());
    setResultOrError(errorResult);
  }
  final long getTimestamp()
  {
    final long getTimestamp() {
    return timestamp;
  }
    abstract S newErrorResult(ResultCode resultCode, String diagnosticMessage, Throwable cause);
  abstract S newErrorResult(ResultCode resultCode, String diagnosticMessage,
      Throwable cause);
  final void setResultOrError(final S result)
  {
    if (result.getResultCode().isExceptional())
    {
    final void setResultOrError(final S result) {
        if (result.getResultCode().isExceptional()) {
      handleErrorResult(ErrorResultException.newErrorResult(result));
    }
    else
    {
        } else {
      handleResult(result);
    }
  }
  final void updateTimestamp()
  {
    final void updateTimestamp() {
    timestamp = System.currentTimeMillis();
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPMessageHandler.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,15 +26,26 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
/**
 * Abstract LDAP message handler.
@@ -43,194 +53,114 @@
 * @param <P>
 *          A user provided handler parameter.
 */
abstract class AbstractLDAPMessageHandler<P> implements LDAPMessageHandler<P>
{
  public void abandonRequest(final P param, final int messageID,
      final AbandonRequest request) throws UnexpectedRequestException,
      IOException
  {
abstract class AbstractLDAPMessageHandler<P> implements LDAPMessageHandler<P> {
    public void abandonRequest(final P param, final int messageID, final AbandonRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void addRequest(final P param, final int messageID,
      final AddRequest request) throws UnexpectedRequestException, IOException
  {
    public void addRequest(final P param, final int messageID, final AddRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void addResult(final P param, final int messageID, final Result result)
      throws UnexpectedResponseException, IOException
  {
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void bindRequest(final P param, final int messageID,
      final int version, final GenericBindRequest request)
      throws UnexpectedRequestException, IOException
  {
    public void bindRequest(final P param, final int messageID, final int version,
            final GenericBindRequest request) throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void bindResult(final P param, final int messageID,
      final BindResult result) throws UnexpectedResponseException, IOException
  {
    public void bindResult(final P param, final int messageID, final BindResult result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void compareRequest(final P param, final int messageID,
      final CompareRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void compareRequest(final P param, final int messageID, final CompareRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void compareResult(final P param, final int messageID,
      final CompareResult result) throws UnexpectedResponseException,
      IOException
  {
    public void compareResult(final P param, final int messageID, final CompareResult result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void deleteRequest(final P param, final int messageID,
      final DeleteRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void deleteRequest(final P param, final int messageID, final DeleteRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void deleteResult(final P param, final int messageID,
      final Result result) throws UnexpectedResponseException, IOException
  {
    public void deleteResult(final P param, final int messageID, final Result result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public <R extends ExtendedResult> void extendedRequest(final P param,
      final int messageID, final ExtendedRequest<R> request)
      throws UnexpectedRequestException, IOException
  {
    public <R extends ExtendedResult> void extendedRequest(final P param, final int messageID,
            final ExtendedRequest<R> request) throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void extendedResult(final P param, final int messageID,
      final ExtendedResult result) throws UnexpectedResponseException,
      IOException
  {
    public void extendedResult(final P param, final int messageID, final ExtendedResult result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void intermediateResponse(final P param, final int messageID,
      final IntermediateResponse response) throws UnexpectedResponseException,
      IOException
  {
            final IntermediateResponse response) throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, response);
  }
  public void modifyDNRequest(final P param, final int messageID,
      final ModifyDNRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void modifyDNRequest(final P param, final int messageID, final ModifyDNRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void modifyDNResult(final P param, final int messageID,
      final Result result) throws UnexpectedResponseException, IOException
  {
    public void modifyDNResult(final P param, final int messageID, final Result result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void modifyRequest(final P param, final int messageID,
      final ModifyRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void modifyRequest(final P param, final int messageID, final ModifyRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void modifyResult(final P param, final int messageID,
      final Result result) throws UnexpectedResponseException, IOException
  {
    public void modifyResult(final P param, final int messageID, final Result result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void searchRequest(final P param, final int messageID,
      final SearchRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void searchRequest(final P param, final int messageID, final SearchRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void searchResult(final P param, final int messageID,
      final Result result) throws UnexpectedResponseException, IOException
  {
    public void searchResult(final P param, final int messageID, final Result result)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, result);
  }
  public void searchResultEntry(final P param, final int messageID,
      final SearchResultEntry entry) throws UnexpectedResponseException,
      IOException
  {
    public void searchResultEntry(final P param, final int messageID, final SearchResultEntry entry)
            throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, entry);
  }
  public void searchResultReference(final P param, final int messageID,
      final SearchResultReference reference)
      throws UnexpectedResponseException, IOException
  {
            final SearchResultReference reference) throws UnexpectedResponseException, IOException {
    throw new UnexpectedResponseException(messageID, reference);
  }
  public void unbindRequest(final P param, final int messageID,
      final UnbindRequest request) throws UnexpectedRequestException,
      IOException
  {
    public void unbindRequest(final P param, final int messageID, final UnbindRequest request)
            throws UnexpectedRequestException, IOException {
    throw new UnexpectedRequestException(messageID, request);
  }
  public void unrecognizedMessage(final P param, final int messageID,
      final byte messageTag, final ByteString messageBytes)
      throws UnsupportedMessageException, IOException
  {
    public void unrecognizedMessage(final P param, final int messageID, final byte messageTag,
            final ByteString messageBytes) throws UnsupportedMessageException, IOException {
    throw new UnsupportedMessageException(messageID, messageTag, messageBytes);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ConnectionSecurityLayerFilter.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.ConnectionSecurityLayer;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.glassfish.grizzly.AbstractTransformer;
@@ -40,141 +37,92 @@
import org.glassfish.grizzly.memory.Buffers;
import org.glassfish.grizzly.memory.MemoryManager;
/**
 * Connection security layer filter adapter.
 */
final class ConnectionSecurityLayerFilter extends
    AbstractCodecFilter<Buffer, Buffer>
{
final class ConnectionSecurityLayerFilter extends AbstractCodecFilter<Buffer, Buffer> {
  /**
   * <tt>Transformer</tt>, which decodes SASL encrypted data, contained in the
   * input Buffer, to the output Buffer.
   */
  private static final class Decoder extends
      AbstractTransformer<Buffer, Buffer>
  {
    private static final class Decoder extends AbstractTransformer<Buffer, Buffer> {
    private static final int BUFFER_SIZE = 4096;
    private final byte[] buffer = new byte[BUFFER_SIZE];
    private final ConnectionSecurityLayer layer;
    private final MemoryManager<?> memoryManager;
    public Decoder(final ConnectionSecurityLayer layer,
        final MemoryManager<?> memoryManager)
    {
        public Decoder(final ConnectionSecurityLayer layer, final MemoryManager<?> memoryManager) {
      this.layer = layer;
      this.memoryManager = memoryManager;
    }
    public String getName()
    {
        public String getName() {
      return this.getClass().getName();
    }
    public boolean hasInputRemaining(final AttributeStorage storage,
        final Buffer input)
    {
        public boolean hasInputRemaining(final AttributeStorage storage, final Buffer input) {
      return input != null && input.hasRemaining();
    }
    @Override
    public TransformationResult<Buffer, Buffer> transformImpl(
        final AttributeStorage storage, final Buffer input)
    {
        public TransformationResult<Buffer, Buffer> transformImpl(final AttributeStorage storage,
                final Buffer input) {
      final int len = Math.min(buffer.length, input.remaining());
      input.get(buffer, 0, len);
      try
      {
        final Buffer output = Buffers.wrap(memoryManager,
            layer.unwrap(buffer, 0, len));
            try {
                final Buffer output = Buffers.wrap(memoryManager, layer.unwrap(buffer, 0, len));
        return TransformationResult.createCompletedResult(output, input);
      }
      catch (final ErrorResultException e)
      {
        return TransformationResult.createErrorResult(e.getResult()
            .getResultCode().intValue(), e.getMessage());
            } catch (final ErrorResultException e) {
                return TransformationResult.createErrorResult(e.getResult().getResultCode()
                        .intValue(), e.getMessage());
      }
    }
  }
  /**
   * <tt>Transformer</tt>, which encodes SASL encrypted data, contained in the
   * input Buffer, to the output Buffer.
   */
  private static final class Encoder extends
      AbstractTransformer<Buffer, Buffer>
  {
    private static final class Encoder extends AbstractTransformer<Buffer, Buffer> {
    private static final int BUFFER_SIZE = 4096;
    private final byte[] buffer = new byte[BUFFER_SIZE];
    private final ConnectionSecurityLayer layer;
    private final MemoryManager<?> memoryManager;
    private Encoder(final ConnectionSecurityLayer layer,
        final MemoryManager<?> memoryManager)
    {
        private Encoder(final ConnectionSecurityLayer layer, final MemoryManager<?> memoryManager) {
      this.layer = layer;
      this.memoryManager = memoryManager;
    }
    public String getName()
    {
        public String getName() {
      return this.getClass().getName();
    }
    public boolean hasInputRemaining(final AttributeStorage storage,
        final Buffer input)
    {
        public boolean hasInputRemaining(final AttributeStorage storage, final Buffer input) {
      return input != null && input.hasRemaining();
    }
    @Override
    public TransformationResult<Buffer, Buffer> transformImpl(
        final AttributeStorage storage, final Buffer input)
    {
        public TransformationResult<Buffer, Buffer> transformImpl(final AttributeStorage storage,
                final Buffer input) {
      final int len = Math.min(buffer.length, input.remaining());
      input.get(buffer, 0, len);
      try
      {
        final Buffer output = Buffers.wrap(memoryManager,
            layer.wrap(buffer, 0, len));
            try {
                final Buffer output = Buffers.wrap(memoryManager, layer.wrap(buffer, 0, len));
        return TransformationResult.createCompletedResult(output, input);
      }
      catch (final ErrorResultException e)
      {
        return TransformationResult.createErrorResult(e.getResult()
            .getResultCode().intValue(), e.getMessage());
            } catch (final ErrorResultException e) {
                return TransformationResult.createErrorResult(e.getResult().getResultCode()
                        .intValue(), e.getMessage());
      }
    }
  }
  ConnectionSecurityLayerFilter(final ConnectionSecurityLayer layer,
      final MemoryManager<?> memoryManager)
  {
            final MemoryManager<?> memoryManager) {
    super(new Decoder(layer, memoryManager), new Encoder(layer, memoryManager));
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransport.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
@@ -37,19 +34,14 @@
import org.glassfish.grizzly.strategies.SameThreadIOStrategy;
import org.glassfish.grizzly.strategies.WorkerThreadIOStrategy;
/**
 * The default {@link TCPNIOTransport} which all {@code LDAPConnectionFactory}s
 * and {@code LDAPListener}s will use unless otherwise specified in their
 * options.
 */
final class DefaultTCPNIOTransport
{
final class DefaultTCPNIOTransport {
  private static TCPNIOTransport defaultTransport = null;
  /**
   * Returns the default {@link TCPNIOTransport} which all
   * {@code LDAPConnectionFactory}s and {@code LDAPListener}s will use unless
@@ -57,36 +49,29 @@
   *
   * @return The default {@link TCPNIOTransport}.
   */
  static synchronized TCPNIOTransport getInstance()
  {
    if (defaultTransport == null)
    {
      final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder
          .newInstance();
    static synchronized TCPNIOTransport getInstance() {
        if (defaultTransport == null) {
            final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
      // Determine which threading strategy to use, and total number of threads.
      final String useWorkerThreadsStr = System
          .getProperty("org.forgerock.opendj.transport.useWorkerThreads");
            // Determine which threading strategy to use, and total number of
            // threads.
            final String useWorkerThreadsStr =
                    System.getProperty("org.forgerock.opendj.transport.useWorkerThreads");
      final boolean useWorkerThreadStrategy;
      if (useWorkerThreadsStr != null)
      {
        useWorkerThreadStrategy = Boolean
            .parseBoolean(useWorkerThreadsStr);
      }
      else
      {
        // The most best performing strategy to use is the SameThreadIOStrategy,
        // however it can only be used in cases where result listeners will not
            if (useWorkerThreadsStr != null) {
                useWorkerThreadStrategy = Boolean.parseBoolean(useWorkerThreadsStr);
            } else {
                // The most best performing strategy to use is the
                // SameThreadIOStrategy,
                // however it can only be used in cases where result listeners
                // will not
        // block.
        useWorkerThreadStrategy = true;
      }
      if (useWorkerThreadStrategy)
      {
            if (useWorkerThreadStrategy) {
        builder.setIOStrategy(WorkerThreadIOStrategy.getInstance());
      }
      else
      {
            } else {
        builder.setIOStrategy(SameThreadIOStrategy.getInstance());
      }
@@ -94,86 +79,70 @@
      final int cpus = Runtime.getRuntime().availableProcessors();
      // Calculate the number of selector threads.
      final String selectorsStr = System
          .getProperty("org.forgerock.opendj.transport.selectors");
            final String selectorsStr =
                    System.getProperty("org.forgerock.opendj.transport.selectors");
      final int selectorThreadCount;
      if (selectorsStr != null)
      {
            if (selectorsStr != null) {
        selectorThreadCount = Integer.parseInt(selectorsStr);
      }
      else
      {
        selectorThreadCount = useWorkerThreadStrategy ? Math.max(2,
            cpus / 4) : Math.max(5, (cpus / 2) - 1);
            } else {
                selectorThreadCount =
                        useWorkerThreadStrategy ? Math.max(2, cpus / 4) : Math.max(5,
                                (cpus / 2) - 1);
      }
      builder.getSelectorThreadPoolConfig()
          .setCorePoolSize(selectorThreadCount)
          .setMaxPoolSize(selectorThreadCount)
          .setPoolName("OpenDJ LDAP SDK Grizzly selector thread");
            builder.getSelectorThreadPoolConfig().setCorePoolSize(selectorThreadCount)
                    .setMaxPoolSize(selectorThreadCount).setPoolName(
                            "OpenDJ LDAP SDK Grizzly selector thread");
      // Calculate the number of worker threads.
      if (builder.getWorkerThreadPoolConfig() != null)
      {
        final String workersStr = System
            .getProperty("org.forgerock.opendj.transport.workers");
            if (builder.getWorkerThreadPoolConfig() != null) {
                final String workersStr =
                        System.getProperty("org.forgerock.opendj.transport.workers");
        final int workerThreadCount;
        if (workersStr != null)
        {
                if (workersStr != null) {
          workerThreadCount = Integer.parseInt(workersStr);
        }
        else
        {
          workerThreadCount = useWorkerThreadStrategy ? Math.max(5,
              (cpus * 2)) : 0;
                } else {
                    workerThreadCount = useWorkerThreadStrategy ? Math.max(5, (cpus * 2)) : 0;
        }
        builder.getWorkerThreadPoolConfig()
            .setCorePoolSize(workerThreadCount)
            .setMaxPoolSize(workerThreadCount)
            .setPoolName("OpenDJ LDAP SDK Grizzly worker thread");
                builder.getWorkerThreadPoolConfig().setCorePoolSize(workerThreadCount)
                        .setMaxPoolSize(workerThreadCount).setPoolName(
                                "OpenDJ LDAP SDK Grizzly worker thread");
      }
      // Parse IO related options.
      final String lingerStr = System
          .getProperty("org.forgerock.opendj.transport.linger");
      if (lingerStr != null)
      {
            final String lingerStr = System.getProperty("org.forgerock.opendj.transport.linger");
            if (lingerStr != null) {
        // Disabled by default.
        builder.setLinger(Integer.parseInt(lingerStr));
      }
      final String tcpNoDelayStr = System
          .getProperty("org.forgerock.opendj.transport.tcpNoDelay");
      if (tcpNoDelayStr != null)
      {
            final String tcpNoDelayStr =
                    System.getProperty("org.forgerock.opendj.transport.tcpNoDelay");
            if (tcpNoDelayStr != null) {
        // Enabled by default.
        builder.setTcpNoDelay(Boolean.parseBoolean(tcpNoDelayStr));
      }
      final String reuseAddressStr = System
          .getProperty("org.forgerock.opendj.transport.reuseAddress");
      if (reuseAddressStr != null)
      {
            final String reuseAddressStr =
                    System.getProperty("org.forgerock.opendj.transport.reuseAddress");
            if (reuseAddressStr != null) {
        // Enabled by default.
        builder
            .setReuseAddress(Boolean.parseBoolean(reuseAddressStr));
                builder.setReuseAddress(Boolean.parseBoolean(reuseAddressStr));
      }
      defaultTransport = builder.build();
      // FIXME: raise bug in Grizzly. We should not need to do this, but failure
            // FIXME: raise bug in Grizzly. We should not need to do this, but
            // failure
      // to do so causes many deadlocks.
      defaultTransport.setSelectorRunnersCount(selectorThreadCount);
      try
      {
            try {
        defaultTransport.start();
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        throw new RuntimeException(e);
      }
    }
@@ -181,10 +150,7 @@
    return defaultTransport;
  }
  private DefaultTCPNIOTransport()
  {
    private DefaultTCPNIOTransport() {
    // Prevent instantiation.
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/InternalConnection.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,50 +27,58 @@
package com.forgerock.opendj.ldap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.AbstractAsynchronousConnection;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionEventListener;
import org.forgerock.opendj.ldap.FutureResult;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.ServerConnection;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import com.forgerock.opendj.util.CompletedFutureResult;
import com.forgerock.opendj.util.Validator;
/**
 * This class defines a pseudo-connection object that can be used for performing
 * internal operations directly against a {@code ServerConnection}
 * implementation.
 */
public final class InternalConnection extends AbstractAsynchronousConnection
{
public final class InternalConnection extends AbstractAsynchronousConnection {
  private static final class InternalBindFutureResultImpl extends
      AbstractLDAPFutureResultImpl<BindResult>
  {
            AbstractLDAPFutureResultImpl<BindResult> {
    private final BindRequest bindRequest;
    InternalBindFutureResultImpl(final int messageID,
        final BindRequest bindRequest,
        InternalBindFutureResultImpl(final int messageID, final BindRequest bindRequest,
        final ResultHandler<? super BindResult> resultHandler,
        final IntermediateResponseHandler intermediateResponseHandler,
        final Connection connection)
    {
                final Connection connection) {
      super(messageID, resultHandler, intermediateResponseHandler, connection);
      this.bindRequest = bindRequest;
    }
    @Override
    public String toString()
    {
        public String toString() {
      final StringBuilder sb = new StringBuilder();
      sb.append("InternalBindFutureResultImpl(");
      sb.append("bindRequest = ");
@@ -81,147 +88,120 @@
      return sb.toString();
    }
    /**
     * {@inheritDoc}
     */
    @Override
    BindResult newErrorResult(final ResultCode resultCode,
        final String diagnosticMessage, final Throwable cause)
    {
      return Responses.newBindResult(resultCode)
          .setDiagnosticMessage(diagnosticMessage).setCause(cause);
        BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
                final Throwable cause) {
            return Responses.newBindResult(resultCode).setDiagnosticMessage(diagnosticMessage)
                    .setCause(cause);
    }
  }
  private final ServerConnection<Integer> serverConnection;
  private final List<ConnectionEventListener> listeners =
    new CopyOnWriteArrayList<ConnectionEventListener>();
  private final AtomicInteger messageID = new AtomicInteger();
  /**
   * Sets the server connection associated with this internal connection.
   *
   * @param serverConnection
   *          The server connection.
   */
  public InternalConnection(final ServerConnection<Integer> serverConnection)
  {
    public InternalConnection(final ServerConnection<Integer> serverConnection) {
    this.serverConnection = serverConnection;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Void> abandonAsync(final AbandonRequest request)
  {
    public FutureResult<Void> abandonAsync(final AbandonRequest request) {
    final int i = messageID.getAndIncrement();
    serverConnection.handleAbandon(i, request);
    return new CompletedFutureResult<Void>((Void) null, i);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Result> addAsync(final AddRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(i, request,
        resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(i, request, resultHandler, intermediateResponseHandler,
                        this);
    serverConnection.handleAdd(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void addConnectionEventListener(final ConnectionEventListener listener)
  {
    public void addConnectionEventListener(final ConnectionEventListener listener) {
    Validator.ensureNotNull(listener);
    listeners.add(listener);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<BindResult> bindAsync(final BindRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super BindResult> resultHandler)
  {
            final ResultHandler<? super BindResult> resultHandler) {
    final int i = messageID.getAndIncrement();
    final InternalBindFutureResultImpl future = new InternalBindFutureResultImpl(
        i, request, resultHandler, intermediateResponseHandler, this);
        final InternalBindFutureResultImpl future =
                new InternalBindFutureResultImpl(i, request, resultHandler,
                        intermediateResponseHandler, this);
    serverConnection.handleBind(i, 3, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void close(final UnbindRequest request, final String reason)
  {
    public void close(final UnbindRequest request, final String reason) {
    final int i = messageID.getAndIncrement();
    serverConnection.handleConnectionClosed(i, request);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<CompareResult> compareAsync(final CompareRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super CompareResult> resultHandler)
  {
            final ResultHandler<? super CompareResult> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPCompareFutureResultImpl future = new LDAPCompareFutureResultImpl(
        i, request, resultHandler, intermediateResponseHandler, this);
        final LDAPCompareFutureResultImpl future =
                new LDAPCompareFutureResultImpl(i, request, resultHandler,
                        intermediateResponseHandler, this);
    serverConnection.handleCompare(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Result> deleteAsync(final DeleteRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(i, request,
        resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(i, request, resultHandler, intermediateResponseHandler,
                        this);
    serverConnection.handleDelete(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
@@ -229,110 +209,91 @@
  public <R extends ExtendedResult> FutureResult<R> extendedRequestAsync(
      final ExtendedRequest<R> request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super R> resultHandler)
  {
            final ResultHandler<? super R> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPExtendedFutureResultImpl<R> future = new LDAPExtendedFutureResultImpl<R>(
        i, request, resultHandler, intermediateResponseHandler, this);
        final LDAPExtendedFutureResultImpl<R> future =
                new LDAPExtendedFutureResultImpl<R>(i, request, resultHandler,
                        intermediateResponseHandler, this);
    serverConnection.handleExtendedRequest(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isClosed()
  {
    public boolean isClosed() {
    // FIXME: this should be true after close has been called.
    return false;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isValid()
  {
    public boolean isValid() {
    // FIXME: this should be false if this connection is disconnected.
    return true;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Result> modifyAsync(final ModifyRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(i, request,
        resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(i, request, resultHandler, intermediateResponseHandler,
                        this);
    serverConnection.handleModify(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Result> modifyDNAsync(final ModifyDNRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(i, request,
        resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(i, request, resultHandler, intermediateResponseHandler,
                        this);
    serverConnection.handleModifyDN(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void removeConnectionEventListener(
      final ConnectionEventListener listener)
  {
    public void removeConnectionEventListener(final ConnectionEventListener listener) {
    Validator.ensureNotNull(listener);
    listeners.remove(listener);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Result> searchAsync(final SearchRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final SearchResultHandler resultHandler)
  {
            final SearchResultHandler resultHandler) {
    final int i = messageID.getAndIncrement();
    final LDAPSearchFutureResultImpl future = new LDAPSearchFutureResultImpl(i,
        request, resultHandler, intermediateResponseHandler, this);
        final LDAPSearchFutureResultImpl future =
                new LDAPSearchFutureResultImpl(i, request, resultHandler,
                        intermediateResponseHandler, this);
    serverConnection.handleSearch(i, request, future, future);
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public String toString()
  {
    public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("InternalConnection(");
    builder.append(String.valueOf(serverConnection));
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPBindFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
@@ -38,29 +35,20 @@
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.Responses;
/**
 * Bind result future implementation.
 */
final class LDAPBindFutureResultImpl extends
    AbstractLDAPFutureResultImpl<BindResult>
{
final class LDAPBindFutureResultImpl extends AbstractLDAPFutureResultImpl<BindResult> {
  private final BindClient bindClient;
  LDAPBindFutureResultImpl(final int requestID, final BindClient bindClient,
      final ResultHandler<? super BindResult> resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(requestID, resultHandler, intermediateResponseHandler, connection);
    this.bindClient = bindClient;
  }
  /**
   * {@inheritDoc}
   */
@@ -69,11 +57,8 @@
    return false;
  }
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("LDAPBindFutureResultImpl(");
    sb.append("bindClient = ");
@@ -83,23 +68,17 @@
    return sb.toString();
  }
  BindClient getBindClient()
  {
    BindClient getBindClient() {
    return bindClient;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  BindResult newErrorResult(final ResultCode resultCode,
      final String diagnosticMessage, final Throwable cause)
  {
    return Responses.newBindResult(resultCode).setDiagnosticMessage(
        diagnosticMessage).setCause(cause);
    BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
            final Throwable cause) {
        return Responses.newBindResult(resultCode).setDiagnosticMessage(diagnosticMessage)
                .setCause(cause);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPClientFilter.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.OID_NOTICE_OF_DISCONNECTION;
import java.io.EOFException;
@@ -41,8 +38,21 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindClient;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import org.glassfish.grizzly.Buffer;
import org.glassfish.grizzly.Connection;
import org.glassfish.grizzly.EmptyCompletionHandler;
@@ -52,14 +62,11 @@
import org.glassfish.grizzly.filterchain.FilterChainContext;
import org.glassfish.grizzly.filterchain.NextAction;
/**
 * Grizzly filter implementation for decoding LDAP responses and handling client
 * side logic for SSL and SASL operations over LDAP.
 */
final class LDAPClientFilter extends BaseFilter
{
final class LDAPClientFilter extends BaseFilter {
  private static final Attribute<LDAPConnection> LDAP_CONNECTION_ATTR =
    Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("LDAPClientConnection");
  private static final Attribute<ASN1BufferReader> LDAP_ASN1_READER_ATTR =
@@ -68,28 +75,22 @@
  private final int maxASN1ElementSize;
  private final LDAPReader ldapReader;
  private static final AbstractLDAPMessageHandler<FilterChainContext>
    CLIENT_RESPONSE_HANDLER = new AbstractLDAPMessageHandler<FilterChainContext>()
  {
    private static final AbstractLDAPMessageHandler<FilterChainContext> CLIENT_RESPONSE_HANDLER =
            new AbstractLDAPMessageHandler<FilterChainContext>() {
    @Override
    public void addResult(final FilterChainContext ctx, final int messageID,
        final Result result) throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final Result result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPFutureResultImpl) {
            final LDAPFutureResultImpl future =
                (LDAPFutureResultImpl) pendingRequest;
            if (future.getRequest() instanceof AddRequest)
            {
                                if (future.getRequest() instanceof AddRequest) {
              future.setResultOrError(result);
              return;
            }
@@ -99,80 +100,69 @@
      }
    }
    @Override
    public void bindResult(final FilterChainContext ctx, final int messageID,
        final BindResult result) throws UnexpectedResponseException,
        IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final BindResult result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPBindFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPBindFutureResultImpl) {
            final LDAPBindFutureResultImpl future =
                ((LDAPBindFutureResultImpl) pendingRequest);
            final BindClient bindClient = future.getBindClient();
            try
            {
              if (!bindClient.evaluateResult(result))
              {
                // The server is expecting a multi stage bind response.
                                try {
                                    if (!bindClient.evaluateResult(result)) {
                                        // The server is expecting a multi stage
                                        // bind response.
                final int msgID =
                    ldapConnection.continuePendingBindRequest(future);
                final ASN1BufferWriter asn1Writer =
                    ASN1BufferWriter.getWriter();
                try
                {
                  final GenericBindRequest nextRequest = bindClient
                      .nextBindRequest();
                                        try {
                                            final GenericBindRequest nextRequest =
                                                    bindClient.nextBindRequest();
                  new LDAPWriter().bindRequest(asn1Writer, msgID, 3,
                      nextRequest);
                  ctx.write(asn1Writer.getBuffer(), null);
                }
                finally
                {
                                        } finally {
                  asn1Writer.recycle();
                }
                return;
              }
            }
            catch (final ErrorResultException e)
            {
                                } catch (final ErrorResultException e) {
              future.adaptErrorResult(e.getResult());
              return;
            }
            catch (final IOException e)
            {
              // FIXME: I18N need to have a better error message.
                                } catch (final IOException e) {
                                    // FIXME: I18N need to have a better error
                                    // message.
              // FIXME: Is this the best result code?
              final Result errorResult = Responses.newResult(
                  ResultCode.CLIENT_SIDE_LOCAL_ERROR).setDiagnosticMessage(
                                    final Result errorResult =
                                            Responses
                                                    .newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
                                                    .setDiagnosticMessage(
                  "An error occurred during multi-stage authentication")
                  .setCause(e);
              future.adaptErrorResult(errorResult);
              return;
            }
            if (result.getResultCode() == ResultCode.SUCCESS)
            {
              final ConnectionSecurityLayer l = bindClient
                  .getConnectionSecurityLayer();
              if (l != null)
              {
                // The connection needs to be secured by the SASL
                                if (result.getResultCode() == ResultCode.SUCCESS) {
                                    final ConnectionSecurityLayer l =
                                            bindClient.getConnectionSecurityLayer();
                                    if (l != null) {
                                        // The connection needs to be secured by
                                        // the SASL
                // mechanism.
                ldapConnection.installFilter(new ConnectionSecurityLayerFilter(l, ctx
                    .getConnection().getTransport().getMemoryManager()));
                                        ldapConnection
                                                .installFilter(new ConnectionSecurityLayerFilter(l,
                                                        ctx.getConnection().getTransport()
                                                                .getMemoryManager()));
              }
            }
@@ -185,24 +175,17 @@
      }
    }
    @Override
    public void compareResult(final FilterChainContext ctx,
        final int messageID, final CompareResult result)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                public void compareResult(final FilterChainContext ctx, final int messageID,
                        final CompareResult result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPCompareFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPCompareFutureResultImpl) {
            final LDAPCompareFutureResultImpl future =
                (LDAPCompareFutureResultImpl) pendingRequest;
            future.setResultOrError(result);
@@ -213,27 +196,20 @@
      }
    }
    @Override
    public void deleteResult(final FilterChainContext ctx, final int messageID,
        final Result result) throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final Result result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPFutureResultImpl) {
            final LDAPFutureResultImpl future =
                (LDAPFutureResultImpl) pendingRequest;
            if (future.getRequest() instanceof DeleteRequest)
            {
                                if (future.getRequest() instanceof DeleteRequest) {
              future.setResultOrError(result);
              return;
            }
@@ -243,109 +219,85 @@
      }
    }
    @Override
    public void extendedResult(final FilterChainContext ctx,
        final int messageID, final ExtendedResult result)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        if (messageID == 0)
        {
                public void extendedResult(final FilterChainContext ctx, final int messageID,
                        final ExtendedResult result) throws UnexpectedResponseException,
                        IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        if (messageID == 0) {
          if ((result.getOID() != null)
              && result.getOID().equals(OID_NOTICE_OF_DISCONNECTION))
          {
                                    && result.getOID().equals(OID_NOTICE_OF_DISCONNECTION)) {
            final Result errorResult = Responses
                .newResult(result.getResultCode()).setDiagnosticMessage(
                    result.getDiagnosticMessage());
                                final Result errorResult =
                                        Responses
                                                .newResult(result.getResultCode())
                                                .setDiagnosticMessage(result.getDiagnosticMessage());
            ldapConnection.close(null, true, errorResult);
            return;
          }
          else
          {
                            } else {
            // Unsolicited notification received.
            ldapConnection.handleUnsolicitedNotification(result);
          }
        }
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if(pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPExtendedFutureResultImpl<?>)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPExtendedFutureResultImpl<?>) {
            final LDAPExtendedFutureResultImpl<?> extendedFuture =
              ((LDAPExtendedFutureResultImpl<?>) pendingRequest);
            try
            {
                                try {
              handleExtendedResult0(ldapConnection, extendedFuture, result);
            }
            catch (final DecodeException de)
            {
              // FIXME: should the connection be closed as well?
              final Result errorResult = Responses.newResult(
                  ResultCode.CLIENT_SIDE_DECODING_ERROR).setDiagnosticMessage(
                  de.getLocalizedMessage()).setCause(de);
                                } catch (final DecodeException de) {
                                    // FIXME: should the connection be closed as
                                    // well?
                                    final Result errorResult =
                                            Responses.newResult(
                                                    ResultCode.CLIENT_SIDE_DECODING_ERROR)
                                                    .setDiagnosticMessage(de.getLocalizedMessage())
                                                    .setCause(de);
              extendedFuture.adaptErrorResult(errorResult);
            }
          }
          else
          {
                            } else {
            throw new UnexpectedResponseException(messageID, result);
          }
        }
      }
    }
    @Override
    public void intermediateResponse(final FilterChainContext ctx,
        final int messageID, final IntermediateResponse response)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .getPendingRequest(messageID);
                public void intermediateResponse(final FilterChainContext ctx, final int messageID,
                        final IntermediateResponse response) throws UnexpectedResponseException,
                        IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.getPendingRequest(messageID);
        if (pendingRequest != null)
        {
                        if (pendingRequest != null) {
          pendingRequest.handleIntermediateResponse(response);
        }
      }
    }
    @Override
    public void modifyDNResult(final FilterChainContext ctx,
        final int messageID, final Result result)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                public void modifyDNResult(final FilterChainContext ctx, final int messageID,
                        final Result result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPFutureResultImpl) {
            final LDAPFutureResultImpl future =
                (LDAPFutureResultImpl) pendingRequest;
            if (future.getRequest() instanceof ModifyDNRequest)
            {
                                if (future.getRequest() instanceof ModifyDNRequest) {
              future.setResultOrError(result);
              return;
            }
@@ -355,27 +307,20 @@
      }
    }
    @Override
    public void modifyResult(final FilterChainContext ctx, final int messageID,
        final Result result) throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final Result result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPFutureResultImpl) {
            final LDAPFutureResultImpl future =
                (LDAPFutureResultImpl) pendingRequest;
            if (future.getRequest() instanceof ModifyRequest)
            {
                                if (future.getRequest() instanceof ModifyRequest) {
              future.setResultOrError(result);
              return;
            }
@@ -385,141 +330,106 @@
      }
    }
    @Override
    public void searchResult(final FilterChainContext ctx, final int messageID,
        final Result result) throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .removePendingRequest(messageID);
                        final Result result) throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.removePendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPSearchFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPSearchFutureResultImpl) {
            ((LDAPSearchFutureResultImpl) pendingRequest)
                .setResultOrError(result);
          }
          else
          {
                            } else {
            throw new UnexpectedResponseException(messageID, result);
          }
        }
      }
    }
    @Override
    public void searchResultEntry(final FilterChainContext ctx,
        final int messageID, final SearchResultEntry entry)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .getPendingRequest(messageID);
                public void searchResultEntry(final FilterChainContext ctx, final int messageID,
                        final SearchResultEntry entry) throws UnexpectedResponseException,
                        IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.getPendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPSearchFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPSearchFutureResultImpl) {
            ((LDAPSearchFutureResultImpl) pendingRequest).handleEntry(entry);
          }
          else
          {
                            } else {
            throw new UnexpectedResponseException(messageID, entry);
          }
        }
      }
    }
    @Override
    public void searchResultReference(final FilterChainContext ctx,
        final int messageID, final SearchResultReference reference)
        throws UnexpectedResponseException, IOException
    {
      final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if(ldapConnection != null)
      {
        final AbstractLDAPFutureResultImpl<?> pendingRequest = ldapConnection
            .getPendingRequest(messageID);
                        throws UnexpectedResponseException, IOException {
                    final LDAPConnection ldapConnection =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (ldapConnection != null) {
                        final AbstractLDAPFutureResultImpl<?> pendingRequest =
                                ldapConnection.getPendingRequest(messageID);
        if (pendingRequest != null)
        {
          if (pendingRequest instanceof LDAPSearchFutureResultImpl)
          {
                        if (pendingRequest != null) {
                            if (pendingRequest instanceof LDAPSearchFutureResultImpl) {
            ((LDAPSearchFutureResultImpl) pendingRequest)
                .handleReference(reference);
          }
          else
          {
                            } else {
            throw new UnexpectedResponseException(messageID, reference);
          }
        }
      }
    }
    // Needed in order to expose type information.
    private <R extends ExtendedResult> void handleExtendedResult0(
        final LDAPConnection conn,
        final LDAPExtendedFutureResultImpl<R> future,
        final ExtendedResult result) throws DecodeException
    {
      final R decodedResponse = future.decodeResult(result, conn
          .getLDAPOptions().getDecodeOptions());
                        final LDAPConnection conn, final LDAPExtendedFutureResultImpl<R> future,
                        final ExtendedResult result) throws DecodeException {
                    final R decodedResponse =
                            future.decodeResult(result, conn.getLDAPOptions().getDecodeOptions());
      if (future.getRequest() instanceof StartTLSExtendedRequest)
      {
        if (result.getResultCode() == ResultCode.SUCCESS)
        {
          try
          {
            final StartTLSExtendedRequest request = (StartTLSExtendedRequest) future
                .getRequest();
            conn.startTLS(request.getSSLContext(),
                request.getEnabledProtocols(), request.getEnabledCipherSuites(),
                new EmptyCompletionHandler<SSLEngine>()
                {
                    if (future.getRequest() instanceof StartTLSExtendedRequest) {
                        if (result.getResultCode() == ResultCode.SUCCESS) {
                            try {
                                final StartTLSExtendedRequest request =
                                        (StartTLSExtendedRequest) future.getRequest();
                                conn.startTLS(request.getSSLContext(), request
                                        .getEnabledProtocols(), request.getEnabledCipherSuites(),
                                        new EmptyCompletionHandler<SSLEngine>() {
                  @Override
                  public void completed(final SSLEngine result)
                  {
                                            public void completed(final SSLEngine result) {
                    conn.setBindOrStartTLSInProgress(false);
                    future.setResultOrError(decodedResponse);
                  }
                  @Override
                  public void failed(final Throwable throwable)
                  {
                    final Result errorResult = Responses.newResult(
                        ResultCode.CLIENT_SIDE_LOCAL_ERROR).setCause(throwable)
                        .setDiagnosticMessage("SSL handshake failed");
                                            public void failed(final Throwable throwable) {
                                                final Result errorResult =
                                                        Responses.newResult(
                                                                ResultCode.CLIENT_SIDE_LOCAL_ERROR)
                                                                .setCause(throwable)
                                                                .setDiagnosticMessage(
                                                                        "SSL handshake failed");
                    conn.setBindOrStartTLSInProgress(false);
                    conn.close(null, false, errorResult);
                    future.adaptErrorResult(errorResult);
                  }
                });
            return;
          }
          catch (final IOException e)
          {
            final Result errorResult = Responses.newResult(
                ResultCode.CLIENT_SIDE_LOCAL_ERROR).setCause(e)
                .setDiagnosticMessage(e.getMessage());
                            } catch (final IOException e) {
                                final Result errorResult =
                                        Responses.newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
                                                .setCause(e).setDiagnosticMessage(e.getMessage());
            future.adaptErrorResult(errorResult);
            conn.close(null, false, errorResult);
            return;
@@ -531,23 +441,15 @@
    }
  };
  LDAPClientFilter(final LDAPReader ldapReader, final int maxASN1ElementSize)
  {
    LDAPClientFilter(final LDAPReader ldapReader, final int maxASN1ElementSize) {
    this.ldapReader = ldapReader;
    this.maxASN1ElementSize = maxASN1ElementSize;
  }
  @Override
  public void exceptionOccurred(final FilterChainContext ctx,
      final Throwable error)
  {
    public void exceptionOccurred(final FilterChainContext ctx, final Throwable error) {
    final Connection<?> connection = ctx.getConnection();
    if (!connection.isOpen())
    {
        if (!connection.isOpen()) {
      // Grizzly doens't not deregister the read interest from the
      // selector so closing the connection results in an
      // EOFException.
@@ -557,87 +459,60 @@
    final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(connection);
    Result errorResult;
    if (error instanceof EOFException)
    {
        if (error instanceof EOFException) {
      // FIXME: Is this the best result code?
      errorResult = Responses.newResult(ResultCode.CLIENT_SIDE_SERVER_DOWN)
          .setCause(error);
    }
    else
    {
            errorResult = Responses.newResult(ResultCode.CLIENT_SIDE_SERVER_DOWN).setCause(error);
        } else {
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      errorResult = Responses.newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
          .setCause(error);
            errorResult = Responses.newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR).setCause(error);
    }
    ldapConnection.close(null, false, errorResult);
  }
  @Override
  public NextAction handleClose(final FilterChainContext ctx)
      throws IOException
  {
    public NextAction handleClose(final FilterChainContext ctx) throws IOException {
    final Connection<?> connection = ctx.getConnection();
    final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR
        .remove(connection);
    if (ldapConnection != null)
    {
        final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.remove(connection);
        if (ldapConnection != null) {
      TimeoutChecker.INSTANCE.removeConnection(ldapConnection);
      final Result errorResult = Responses
          .newResult(ResultCode.CLIENT_SIDE_SERVER_DOWN);
            final Result errorResult = Responses.newResult(ResultCode.CLIENT_SIDE_SERVER_DOWN);
      ldapConnection.close(null, false, errorResult);
    }
    return ctx.getInvokeAction();
  }
  @Override
  public NextAction handleRead(final FilterChainContext ctx) throws IOException
  {
    public NextAction handleRead(final FilterChainContext ctx) throws IOException {
    final Buffer buffer = (Buffer) ctx.getMessage();
    ASN1BufferReader asn1Reader = LDAP_ASN1_READER_ATTR
        .get(ctx.getConnection());
    if (asn1Reader == null)
    {
      asn1Reader = new ASN1BufferReader(maxASN1ElementSize, ctx.getConnection()
          .getTransport().getMemoryManager());
        ASN1BufferReader asn1Reader = LDAP_ASN1_READER_ATTR.get(ctx.getConnection());
        if (asn1Reader == null) {
            asn1Reader =
                    new ASN1BufferReader(maxASN1ElementSize, ctx.getConnection().getTransport()
                            .getMemoryManager());
      LDAP_ASN1_READER_ATTR.set(ctx.getConnection(), asn1Reader);
    }
    asn1Reader.appendBytesRead(buffer);
    try
    {
      while (asn1Reader.elementAvailable())
      {
        try {
            while (asn1Reader.elementAvailable()) {
        ldapReader.decode(asn1Reader, CLIENT_RESPONSE_HANDLER, ctx);
      }
    }
    catch(IOException ioe)
    {
      final LDAPConnection ldapConnection =
          LDAP_CONNECTION_ATTR.get(ctx.getConnection());
        } catch (IOException ioe) {
            final LDAPConnection ldapConnection = LDAP_CONNECTION_ATTR.get(ctx.getConnection());
      final Result errorResult =
          Responses.newResult(ResultCode.CLIENT_SIDE_DECODING_ERROR)
              .setCause(ioe).setDiagnosticMessage(ioe.getMessage());
                    Responses.newResult(ResultCode.CLIENT_SIDE_DECODING_ERROR).setCause(ioe)
                            .setDiagnosticMessage(ioe.getMessage());
      ldapConnection.close(null, false, errorResult);
      throw ioe;
    }
    finally
    {
        } finally {
      asn1Reader.disposeBytesRead();
    }
    return ctx.getStopAction();
  }
  void registerConnection(final Connection<?> connection,
      final LDAPConnection ldapConnection)
  {
    void registerConnection(final Connection<?> connection, final LDAPConnection ldapConnection) {
    TimeoutChecker.INSTANCE.addConnection(ldapConnection);
    LDAP_CONNECTION_ATTR.set(connection, ldapConnection);
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPCompareFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
@@ -38,33 +35,22 @@
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.Responses;
/**
 * Compare result future implementation.
 */
final class LDAPCompareFutureResultImpl extends
    AbstractLDAPFutureResultImpl<CompareResult>
{
final class LDAPCompareFutureResultImpl extends AbstractLDAPFutureResultImpl<CompareResult> {
  private final CompareRequest request;
  LDAPCompareFutureResultImpl(final int requestID,
      final CompareRequest request,
    LDAPCompareFutureResultImpl(final int requestID, final CompareRequest request,
      final ResultHandler<? super CompareResult> resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(requestID, resultHandler, intermediateResponseHandler, connection);
    this.request = request;
  }
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("LDAPCompareFutureResultImpl(");
    sb.append("request = ");
@@ -74,23 +60,17 @@
    return sb.toString();
  }
  CompareRequest getRequest()
  {
    CompareRequest getRequest() {
    return request;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  CompareResult newErrorResult(final ResultCode resultCode,
      final String diagnosticMessage, final Throwable cause)
  {
    return Responses.newCompareResult(resultCode).setDiagnosticMessage(
        diagnosticMessage).setCause(cause);
    CompareResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
            final Throwable cause) {
        return Responses.newCompareResult(resultCode).setDiagnosticMessage(diagnosticMessage)
                .setCause(cause);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnection.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.IOException;
@@ -44,9 +41,35 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.AbstractAsynchronousConnection;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionEventListener;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.FutureResult;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.LDAPOptions;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindClient;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.glassfish.grizzly.CompletionHandler;
import org.glassfish.grizzly.filterchain.Filter;
import org.glassfish.grizzly.filterchain.FilterChain;
@@ -58,32 +81,25 @@
import com.forgerock.opendj.util.StaticUtils;
import com.forgerock.opendj.util.Validator;
/**
 * LDAP connection implementation.
 * <p>
 * TODO: handle illegal state exceptions.
 */
final class LDAPConnection extends AbstractAsynchronousConnection implements
    Connection
{
final class LDAPConnection extends AbstractAsynchronousConnection implements Connection {
  private final org.glassfish.grizzly.Connection<?> connection;
  private Result connectionInvalidReason;
  private boolean isClosed = false;
  private final List<ConnectionEventListener> listeners =
      new CopyOnWriteArrayList<ConnectionEventListener>();
  private final AtomicInteger nextMsgID = new AtomicInteger(1);
  private final AtomicBoolean bindOrStartTLSInProgress = new AtomicBoolean(
      false);
    private final AtomicBoolean bindOrStartTLSInProgress = new AtomicBoolean(false);
  private final ConcurrentHashMap<Integer, AbstractLDAPFutureResultImpl<?>> pendingRequests =
      new ConcurrentHashMap<Integer, AbstractLDAPFutureResultImpl<?>>();
  private final Object stateLock = new Object();
  private final LDAPWriter ldapWriter = new LDAPWriter();
  private final LDAPOptions options;
  /**
   * Creates a new LDAP connection.
   *
@@ -92,47 +108,40 @@
   * @param options
   *          The LDAP client options.
   */
  LDAPConnection(final org.glassfish.grizzly.Connection<?> connection,
      final LDAPOptions options)
  {
    LDAPConnection(final org.glassfish.grizzly.Connection<?> connection, final LDAPOptions options) {
    this.connection = connection;
    this.options = options;
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Void> abandonAsync(final AbandonRequest request)
  {
    public FutureResult<Void> abandonAsync(final AbandonRequest request) {
    final AbstractLDAPFutureResultImpl<?> pendingRequest;
    final int messageID = nextMsgID.getAndIncrement();
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        return new CompletedFutureResult<Void>(
            newErrorResult(connectionInvalidReason), messageID);
      }
      if (bindOrStartTLSInProgress.get())
      {
        final Result errorResult = Responses.newResult(
            ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
            "Bind or Start TLS operation in progress");
        return new CompletedFutureResult<Void>(newErrorResult(errorResult),
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
                return new CompletedFutureResult<Void>(newErrorResult(connectionInvalidReason),
            messageID);
      }
            if (bindOrStartTLSInProgress.get()) {
                final Result errorResult =
                        Responses.newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                                "Bind or Start TLS operation in progress");
                return new CompletedFutureResult<Void>(newErrorResult(errorResult), messageID);
            }
      // First remove the future associated with the request to be abandoned.
            // First remove the future associated with the request to be
            // abandoned.
      pendingRequest = pendingRequests.remove(request.getRequestID());
    }
    if (pendingRequest == null)
    {
      // There has never been a request with the specified message ID or the
      // response has already been received and handled. We can ignore this
        if (pendingRequest == null) {
            // There has never been a request with the specified message ID or
            // the
            // response has already been received and handled. We can ignore
            // this
      // abandon request.
      // Message ID will be -1 since no request was sent.
@@ -141,83 +150,64 @@
    pendingRequest.cancel(false);
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.abandonRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
        return new CompletedFutureResult<Void>((Void) null, messageID);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      return new CompletedFutureResult<Void>(newErrorResult(errorResult),
          messageID);
            return new CompletedFutureResult<Void>(newErrorResult(errorResult), messageID);
    }
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Result> addAsync(final AddRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(messageID,
        request, resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses
            .newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.addRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -225,108 +215,88 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public void addConnectionEventListener(final ConnectionEventListener listener)
  {
    public void addConnectionEventListener(final ConnectionEventListener listener) {
    Validator.ensureNotNull(listener);
    listeners.add(listener);
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<BindResult> bindAsync(final BindRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super BindResult> resultHandler)
  {
            final ResultHandler<? super BindResult> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    BindClient context;
    try
    {
      context = request
          .createBindClient(connection.getPeerAddress() instanceof InetSocketAddress ?
              ((InetSocketAddress) connection.getPeerAddress()).getHostName()
        try {
            context =
                    request.createBindClient(
                            connection.getPeerAddress() instanceof InetSocketAddress
                            ? ((InetSocketAddress) connection.getPeerAddress()).getHostName()
              : connection.getPeerAddress().toString());
    }
    catch (final Exception e)
    {
        } catch (final Exception e) {
      // FIXME: I18N need to have a better error message.
      // FIXME: Is this the best result code?
      final Result errorResult = Responses
          .newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR)
          .setDiagnosticMessage(
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_LOCAL_ERROR).setDiagnosticMessage(
              "An error occurred while creating a bind context").setCause(e);
      final ErrorResultException error = ErrorResultException
          .newErrorResult(errorResult);
      if (resultHandler != null)
      {
            final ErrorResultException error = ErrorResultException.newErrorResult(errorResult);
            if (resultHandler != null) {
        resultHandler.handleErrorResult(error);
      }
      return new CompletedFutureResult<BindResult>(error, messageID);
    }
    final LDAPBindFutureResultImpl future = new LDAPBindFutureResultImpl(
        messageID, context, resultHandler, intermediateResponseHandler, this);
        final LDAPBindFutureResultImpl future =
                new LDAPBindFutureResultImpl(messageID, context, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (!pendingRequests.isEmpty())
      {
        future.setResultOrError(Responses.newBindResult(
            ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
            if (!pendingRequests.isEmpty()) {
                future.setResultOrError(Responses.newBindResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage(
            "There are other operations pending on this connection"));
        return future;
      }
      if (!bindOrStartTLSInProgress.compareAndSet(false, true))
      {
        future.setResultOrError(Responses.newBindResult(
            ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
            "Bind or Start TLS operation in progress"));
            if (!bindOrStartTLSInProgress.compareAndSet(false, true)) {
                future.setResultOrError(Responses.newBindResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
        // Use the bind client to get the initial request instead of using the
            try {
                // Use the bind client to get the initial request instead of
                // using the
        // bind request passed to this method.
        final GenericBindRequest initialRequest = context.nextBindRequest();
        ldapWriter.bindRequest(asn1Writer, messageID, 3, initialRequest);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      bindOrStartTLSInProgress.set(false);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -334,76 +304,57 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public void close(final UnbindRequest request, final String reason)
  {
    public void close(final UnbindRequest request, final String reason) {
    // FIXME: I18N need to internationalize this message.
    Validator.ensureNotNull(request);
    close(
        request,
        false,
        Responses.newResult(ResultCode.CLIENT_SIDE_USER_CANCELLED)
        close(request, false, Responses.newResult(ResultCode.CLIENT_SIDE_USER_CANCELLED)
            .setDiagnosticMessage(
                "Connection closed by client"
                    + (reason != null ? ": " + reason : "")));
                        "Connection closed by client" + (reason != null ? ": " + reason : "")));
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<CompareResult> compareAsync(final CompareRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super CompareResult> resultHandler)
  {
            final ResultHandler<? super CompareResult> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPCompareFutureResultImpl future = new LDAPCompareFutureResultImpl(
        messageID, request, resultHandler, intermediateResponseHandler, this);
        final LDAPCompareFutureResultImpl future =
                new LDAPCompareFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses.newCompareResult(
            ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
            "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newCompareResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.compareRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -411,57 +362,45 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Result> deleteAsync(final DeleteRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(messageID,
        request, resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses
            .newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.deleteRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -469,57 +408,46 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public <R extends ExtendedResult> FutureResult<R> extendedRequestAsync(
      final ExtendedRequest<R> request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super R> resultHandler)
  {
            final ResultHandler<? super R> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPExtendedFutureResultImpl<R> future = new LDAPExtendedFutureResultImpl<R>(
        messageID, request, resultHandler, intermediateResponseHandler, this);
        final LDAPExtendedFutureResultImpl<R> future =
                new LDAPExtendedFutureResultImpl<R>(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (request.getOID().equals(StartTLSExtendedRequest.OID))
      {
        if (!pendingRequests.isEmpty())
        {
          future.setResultOrError(request.getResultDecoder()
              .newExtendedErrorResult(ResultCode.OPERATIONS_ERROR, "",
            if (request.getOID().equals(StartTLSExtendedRequest.OID)) {
                if (!pendingRequests.isEmpty()) {
                    future.setResultOrError(request.getResultDecoder().newExtendedErrorResult(
                            ResultCode.OPERATIONS_ERROR, "",
                  "There are pending operations on this connection"));
          return future;
        }
        if (isTLSEnabled())
        {
          future.setResultOrError(request.getResultDecoder()
              .newExtendedErrorResult(ResultCode.OPERATIONS_ERROR, "",
                if (isTLSEnabled()) {
                    future.setResultOrError(request.getResultDecoder().newExtendedErrorResult(
                            ResultCode.OPERATIONS_ERROR, "",
                  "This connection is already TLS enabled"));
          return future;
        }
        if (!bindOrStartTLSInProgress.compareAndSet(false, true))
        {
          future.setResultOrError(request.getResultDecoder()
              .newExtendedErrorResult(ResultCode.OPERATIONS_ERROR, "",
                if (!bindOrStartTLSInProgress.compareAndSet(false, true)) {
                    future.setResultOrError(request.getResultDecoder().newExtendedErrorResult(
                            ResultCode.OPERATIONS_ERROR, "",
                  "Bind or Start TLS operation in progress"));
          return future;
        }
      }
      else
      {
        if (bindOrStartTLSInProgress.get())
        {
          future.setResultOrError(request.getResultDecoder()
              .newExtendedErrorResult(ResultCode.OPERATIONS_ERROR, "",
            } else {
                if (bindOrStartTLSInProgress.get()) {
                    future.setResultOrError(request.getResultDecoder().newExtendedErrorResult(
                            ResultCode.OPERATIONS_ERROR, "",
                  "Bind or Start TLS operation in progress"));
          return future;
        }
@@ -527,28 +455,22 @@
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.extendedRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      bindOrStartTLSInProgress.set(false);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -556,83 +478,63 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isClosed()
  {
    synchronized (stateLock)
    {
    public boolean isClosed() {
        synchronized (stateLock) {
      return isClosed;
    }
  }
  /**
   * {@inheritDoc}
   */
  public boolean isValid()
  {
    synchronized (stateLock)
    {
    public boolean isValid() {
        synchronized (stateLock) {
      return connectionInvalidReason == null && !isClosed;
    }
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Result> modifyAsync(final ModifyRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(messageID,
        request, resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses
            .newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.modifyRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -640,57 +542,45 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Result> modifyDNAsync(final ModifyDNRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final ResultHandler<? super Result> resultHandler)
  {
            final ResultHandler<? super Result> resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPFutureResultImpl future = new LDAPFutureResultImpl(messageID,
        request, resultHandler, intermediateResponseHandler, this);
        final LDAPFutureResultImpl future =
                new LDAPFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses
            .newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.modifyDNRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -698,69 +588,53 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public void removeConnectionEventListener(
      final ConnectionEventListener listener)
  {
    public void removeConnectionEventListener(final ConnectionEventListener listener) {
    Validator.ensureNotNull(listener);
    listeners.remove(listener);
  }
  /**
   * {@inheritDoc}
   */
  public FutureResult<Result> searchAsync(final SearchRequest request,
      final IntermediateResponseHandler intermediateResponseHandler,
      final SearchResultHandler resultHandler)
  {
            final SearchResultHandler resultHandler) {
    final int messageID = nextMsgID.getAndIncrement();
    final LDAPSearchFutureResultImpl future = new LDAPSearchFutureResultImpl(
        messageID, request, resultHandler, intermediateResponseHandler, this);
        final LDAPSearchFutureResultImpl future =
                new LDAPSearchFutureResultImpl(messageID, request, resultHandler,
                        intermediateResponseHandler, this);
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        future.adaptErrorResult(connectionInvalidReason);
        return future;
      }
      if (bindOrStartTLSInProgress.get())
      {
        future.setResultOrError(Responses
            .newResult(ResultCode.OPERATIONS_ERROR).setDiagnosticMessage(
                "Bind or Start TLS operation in progress"));
            if (bindOrStartTLSInProgress.get()) {
                future.setResultOrError(Responses.newResult(ResultCode.OPERATIONS_ERROR)
                        .setDiagnosticMessage("Bind or Start TLS operation in progress"));
        return future;
      }
      pendingRequests.put(messageID, future);
    }
    try
    {
        try {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        ldapWriter.searchRequest(asn1Writer, messageID, request);
        connection.write(asn1Writer.getBuffer(), null);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      pendingRequests.remove(messageID);
      // FIXME: what other sort of IOExceptions can be thrown?
      // FIXME: Is this the best result code?
      final Result errorResult = Responses.newResult(
          ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
            final Result errorResult =
                    Responses.newResult(ResultCode.CLIENT_SIDE_ENCODING_ERROR).setCause(e);
      connectionErrorOccurred(errorResult);
      future.adaptErrorResult(errorResult);
    }
@@ -768,13 +642,10 @@
    return future;
  }
  /**
   * {@inheritDoc}
   */
  public String toString()
  {
    public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("LDAPConnection(");
    builder.append(connection.getLocalAddress());
@@ -784,16 +655,11 @@
    return builder.toString();
  }
  int continuePendingBindRequest(final LDAPBindFutureResultImpl future)
      throws ErrorResultException
  {
            throws ErrorResultException {
    final int newMsgID = nextMsgID.getAndIncrement();
    synchronized (stateLock)
    {
      if (connectionInvalidReason != null)
      {
        synchronized (stateLock) {
            if (connectionInvalidReason != null) {
        throw newErrorResult(connectionInvalidReason);
      }
      pendingRequests.put(newMsgID, future);
@@ -801,33 +667,21 @@
    return newMsgID;
  }
  long cancelExpiredRequests(final long currentTime)
  {
    long cancelExpiredRequests(final long currentTime) {
    final long timeout = options.getTimeout(TimeUnit.MILLISECONDS);
    long delay = timeout;
    if (timeout > 0)
    {
      for (int requestID : pendingRequests.keySet())
      {
        final AbstractLDAPFutureResultImpl<?> future = pendingRequests
            .get(requestID);
        if (future != null)
        {
        if (timeout > 0) {
            for (int requestID : pendingRequests.keySet()) {
                final AbstractLDAPFutureResultImpl<?> future = pendingRequests.get(requestID);
                if (future != null) {
          final long diff = (future.getTimestamp() + timeout) - currentTime;
          if (diff <= 0 && pendingRequests.remove(requestID) != null)
          {
            StaticUtils.DEBUG_LOG.fine("Cancelling expired future result: "
                + future);
            final Result result = Responses
                .newResult(ResultCode.CLIENT_SIDE_TIMEOUT);
                    if (diff <= 0 && pendingRequests.remove(requestID) != null) {
                        StaticUtils.DEBUG_LOG.fine("Cancelling expired future result: " + future);
                        final Result result = Responses.newResult(ResultCode.CLIENT_SIDE_TIMEOUT);
            future.adaptErrorResult(result);
            abandonAsync(Requests.newAbandonRequest(future.getRequestID()));
          }
          else
          {
                    } else {
            delay = Math.min(delay, diff);
          }
        }
@@ -836,157 +690,119 @@
    return delay;
  }
  void close(final UnbindRequest unbindRequest,
      final boolean isDisconnectNotification, final Result reason)
  {
    void close(final UnbindRequest unbindRequest, final boolean isDisconnectNotification,
            final Result reason) {
    boolean notifyClose = false;
    boolean notifyErrorOccurred = false;
    synchronized (stateLock)
    {
      if (isClosed)
      {
        synchronized (stateLock) {
            if (isClosed) {
        // Already closed.
        return;
      }
      if (connectionInvalidReason != null)
      {
            if (connectionInvalidReason != null) {
        // Already closed.
        isClosed = true;
        return;
      }
      if (unbindRequest != null)
      {
            if (unbindRequest != null) {
        // User closed.
        isClosed = true;
        notifyClose = true;
      }
      else
      {
            } else {
        notifyErrorOccurred = true;
      }
      // Mark the connection as invalid.
      if (!isDisconnectNotification)
      {
        // Connection termination was detected locally, so use the provided
            if (!isDisconnectNotification) {
                // Connection termination was detected locally, so use the
                // provided
        // reason for all subsequent requests.
        connectionInvalidReason = reason;
      }
      else
      {
        // Connection termination was triggered remotely. We don't want to
            } else {
                // Connection termination was triggered remotely. We don't want
                // to
        // blindly pass on the result code to requests since it could be
        // confused for a genuine response. For example, if the disconnect
        // contained the invalidCredentials result code then this could be
        // misinterpreted as a genuine authentication failure for subsequent
                // confused for a genuine response. For example, if the
                // disconnect
                // contained the invalidCredentials result code then this could
                // be
                // misinterpreted as a genuine authentication failure for
                // subsequent
        // bind requests.
        connectionInvalidReason = Responses.newResult(
            ResultCode.CLIENT_SIDE_SERVER_DOWN).setDiagnosticMessage(
            "Connection closed by server");
                connectionInvalidReason =
                        Responses.newResult(ResultCode.CLIENT_SIDE_SERVER_DOWN)
                                .setDiagnosticMessage("Connection closed by server");
      }
    }
    // First abort all outstanding requests.
    for (int requestID : pendingRequests.keySet())
    {
      final AbstractLDAPFutureResultImpl<?> future = pendingRequests
          .remove(requestID);
      if (future != null)
      {
        for (int requestID : pendingRequests.keySet()) {
            final AbstractLDAPFutureResultImpl<?> future = pendingRequests.remove(requestID);
            if (future != null) {
        future.adaptErrorResult(connectionInvalidReason);
      }
    }
    // Now try cleanly closing the connection if possible.
    // Only send unbind if specified.
    if (unbindRequest != null && !isDisconnectNotification)
    {
      try
      {
        if (unbindRequest != null && !isDisconnectNotification) {
            try {
        final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
        try
        {
          ldapWriter.unbindRequest(asn1Writer, nextMsgID.getAndIncrement(),
              unbindRequest);
                try {
                    ldapWriter
                            .unbindRequest(asn1Writer, nextMsgID.getAndIncrement(), unbindRequest);
          connection.write(asn1Writer.getBuffer(), null);
        }
        finally
        {
                } finally {
          asn1Writer.recycle();
        }
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        // Underlying channel prob blown up. Just ignore.
      }
    }
    try
    {
        try {
      connection.close();
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      // Ignore.
    }
    // Notify listeners.
    if (notifyClose)
    {
      for (final ConnectionEventListener listener : listeners)
      {
        if (notifyClose) {
            for (final ConnectionEventListener listener : listeners) {
        listener.handleConnectionClosed();
      }
    }
    if (notifyErrorOccurred)
    {
      for (final ConnectionEventListener listener : listeners)
      {
        if (notifyErrorOccurred) {
            for (final ConnectionEventListener listener : listeners) {
        // Use the reason provided in the disconnect notification.
        listener.handleConnectionError(isDisconnectNotification,
            newErrorResult(reason));
                listener.handleConnectionError(isDisconnectNotification, newErrorResult(reason));
      }
    }
  }
  LDAPOptions getLDAPOptions()
  {
    LDAPOptions getLDAPOptions() {
    return options;
  }
  AbstractLDAPFutureResultImpl<?> getPendingRequest(final Integer messageID)
  {
    AbstractLDAPFutureResultImpl<?> getPendingRequest(final Integer messageID) {
    return pendingRequests.get(messageID);
  }
  void handleUnsolicitedNotification(final ExtendedResult result)
  {
    if (isClosed())
    {
    void handleUnsolicitedNotification(final ExtendedResult result) {
        if (isClosed()) {
      // Don't notify after connection is closed.
      return;
    }
    for (final ConnectionEventListener listener : listeners)
    {
        for (final ConnectionEventListener listener : listeners) {
      listener.handleUnsolicitedNotification(result);
    }
  }
  /**
   * Installs a new Grizzly filter (e.g. SSL/SASL) beneath the top-level LDAP
   * filter.
@@ -994,21 +810,17 @@
   * @param filter
   *          The filter to be installed.
   */
  void installFilter(final Filter filter)
  {
    synchronized (stateLock)
    {
    void installFilter(final Filter filter) {
        synchronized (stateLock) {
      // Determine the index where the filter should be added.
      FilterChain oldFilterChain = (FilterChain) connection.getProcessor();
      int filterIndex = oldFilterChain.size() - 1;
      if (filter instanceof SSLFilter)
      {
        // Beneath any ConnectionSecurityLayerFilters if present, otherwise
            if (filter instanceof SSLFilter) {
                // Beneath any ConnectionSecurityLayerFilters if present,
                // otherwise
        // beneath the LDAP filter.
        for (int i = oldFilterChain.size() - 2; i >= 0; i--)
        {
          if (!(oldFilterChain.get(i) instanceof ConnectionSecurityLayerFilter))
          {
                for (int i = oldFilterChain.size() - 2; i >= 0; i--) {
                    if (!(oldFilterChain.get(i) instanceof ConnectionSecurityLayerFilter)) {
            filterIndex = i + 1;
            break;
          }
@@ -1016,32 +828,24 @@
      }
      // Create the new filter chain.
      FilterChain newFilterChain = FilterChainBuilder.stateless()
          .addAll(oldFilterChain)
          .add(filterIndex, filter)
            FilterChain newFilterChain =
                    FilterChainBuilder.stateless().addAll(oldFilterChain).add(filterIndex, filter)
          .build();
      connection.setProcessor(newFilterChain);
    }
  }
  /**
   * Indicates whether or not TLS is enabled on this connection.
   *
   * @return {@code true} if TLS is enabled on this connection, otherwise
   *         {@code false}.
   */
  boolean isTLSEnabled()
  {
    synchronized (stateLock)
    {
      final FilterChain currentFilterChain = (FilterChain) connection
          .getProcessor();
      for (Filter filter : currentFilterChain)
      {
        if (filter instanceof SSLFilter)
        {
    boolean isTLSEnabled() {
        synchronized (stateLock) {
            final FilterChain currentFilterChain = (FilterChain) connection.getProcessor();
            for (Filter filter : currentFilterChain) {
                if (filter instanceof SSLFilter) {
          return true;
        }
      }
@@ -1049,50 +853,35 @@
    }
  }
  AbstractLDAPFutureResultImpl<?> removePendingRequest(final Integer messageID)
  {
    AbstractLDAPFutureResultImpl<?> removePendingRequest(final Integer messageID) {
    return pendingRequests.remove(messageID);
  }
  void setBindOrStartTLSInProgress(final boolean state)
  {
    void setBindOrStartTLSInProgress(final boolean state) {
    bindOrStartTLSInProgress.set(state);
  }
  void startTLS(final SSLContext sslContext,
      final List<String> protocols, final List<String> cipherSuites,
      final CompletionHandler<SSLEngine> completionHandler) throws IOException
  {
    synchronized (stateLock)
    {
      if (isTLSEnabled())
      {
    void startTLS(final SSLContext sslContext, final List<String> protocols,
            final List<String> cipherSuites, final CompletionHandler<SSLEngine> completionHandler)
            throws IOException {
        synchronized (stateLock) {
            if (isTLSEnabled()) {
        throw new IllegalStateException("TLS already enabled");
      }
      SSLEngineConfigurator sslEngineConfigurator = new SSLEngineConfigurator(
          sslContext, true, false, false);
      sslEngineConfigurator.setEnabledProtocols(protocols.isEmpty() ? null
          : protocols.toArray(new String[protocols.size()]));
      sslEngineConfigurator
          .setEnabledCipherSuites(cipherSuites.isEmpty() ? null : cipherSuites
              .toArray(new String[cipherSuites.size()]));
            SSLEngineConfigurator sslEngineConfigurator =
                    new SSLEngineConfigurator(sslContext, true, false, false);
            sslEngineConfigurator.setEnabledProtocols(protocols.isEmpty() ? null : protocols
                    .toArray(new String[protocols.size()]));
            sslEngineConfigurator.setEnabledCipherSuites(cipherSuites.isEmpty() ? null
                    : cipherSuites.toArray(new String[cipherSuites.size()]));
      SSLFilter sslFilter = new SSLFilter(null, sslEngineConfigurator);
      installFilter(sslFilter);
      sslFilter.handshake(connection, completionHandler);
    }
  }
  private void connectionErrorOccurred(final Result reason)
  {
    private void connectionErrorOccurred(final Result reason) {
    close(null, false, reason);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.IOException;
@@ -38,7 +35,13 @@
import javax.net.ssl.SSLEngine;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.FutureResult;
import org.forgerock.opendj.ldap.LDAPOptions;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
@@ -54,119 +57,89 @@
import com.forgerock.opendj.util.FutureResultTransformer;
import com.forgerock.opendj.util.RecursiveFutureResult;
/**
 * LDAP connection factory implementation.
 */
public final class LDAPConnectionFactoryImpl implements ConnectionFactory
{
public final class LDAPConnectionFactoryImpl implements ConnectionFactory {
  @SuppressWarnings("rawtypes")
  private final class ConnectionCompletionHandler implements
      CompletionHandler<org.glassfish.grizzly.Connection>
  {
            CompletionHandler<org.glassfish.grizzly.Connection> {
    private final FutureResultTransformer<Result, Connection> startTLSFutureResult;
    private final RecursiveFutureResult<LDAPConnection, ExtendedResult> connectionFutureResult;
    private LDAPConnection connection;
    private ConnectionCompletionHandler(final ResultHandler<? super Connection> handler)
    {
      this.startTLSFutureResult = new FutureResultTransformer<Result, Connection>(
          handler)
      {
        private ConnectionCompletionHandler(final ResultHandler<? super Connection> handler) {
            this.startTLSFutureResult = new FutureResultTransformer<Result, Connection>(handler) {
        @Override
        protected ErrorResultException transformErrorResult(
            final ErrorResultException errorResult)
        {
                        final ErrorResultException errorResult) {
          // Ensure that the connection is closed.
          try
          {
            if (connection != null)
            {
                    try {
                        if (connection != null) {
              connection.close();
            }
          }
          catch (final Exception e)
          {
                    } catch (final Exception e) {
            // Ignore.
          }
          return errorResult;
        }
        @Override
        protected LDAPConnection transformResult(final Result result)
            throws ErrorResultException
        {
                        throws ErrorResultException {
          return connection;
        }
      };
      this.connectionFutureResult = new RecursiveFutureResult<LDAPConnection, ExtendedResult>(
          startTLSFutureResult)
      {
            this.connectionFutureResult =
                    new RecursiveFutureResult<LDAPConnection, ExtendedResult>(startTLSFutureResult) {
        @Override
        protected FutureResult<? extends ExtendedResult> chainResult(
            final LDAPConnection innerResult,
            final ResultHandler<? super ExtendedResult> handler)
            throws ErrorResultException
        {
                                throws ErrorResultException {
          connection = innerResult;
          if (options.getSSLContext() != null && options.useStartTLS())
          {
                            if (options.getSSLContext() != null && options.useStartTLS()) {
            // Chain StartTLS extended request.
            final StartTLSExtendedRequest startTLS = Requests
                .newStartTLSExtendedRequest(options.getSSLContext());
            startTLS.addEnabledCipherSuite(options.getEnabledCipherSuites()
                .toArray(new String[options.getEnabledCipherSuites().size()]));
                                final StartTLSExtendedRequest startTLS =
                                        Requests.newStartTLSExtendedRequest(options.getSSLContext());
                                startTLS.addEnabledCipherSuite(options
                                        .getEnabledCipherSuites()
                                        .toArray(
                                                new String[options.getEnabledCipherSuites().size()]));
            startTLS.addEnabledProtocol(options.getEnabledProtocols().toArray(
                new String[options.getEnabledProtocols().size()]));
            return connection.extendedRequestAsync(startTLS, null, handler);
          }
          else if (options.getSSLContext() != null)
          {
                            } else if (options.getSSLContext() != null) {
            // Install SSL/TLS layer.
            try
            {
              connection.startTLS(options.getSSLContext(),
                  options.getEnabledProtocols(),
                  options.getEnabledCipherSuites(),
                  new EmptyCompletionHandler<SSLEngine>()
                  {
                                try {
                                    connection.startTLS(options.getSSLContext(), options
                                            .getEnabledProtocols(), options
                                            .getEnabledCipherSuites(),
                                            new EmptyCompletionHandler<SSLEngine>() {
                    @Override
                    public void completed(final SSLEngine result)
                    {
                                                public void completed(final SSLEngine result) {
                      handler.handleResult(null);
                    }
                    @Override
                    public void failed(final Throwable throwable)
                    {
                                                public void failed(final Throwable throwable) {
                      handler.handleErrorResult(newErrorResult(
                          ResultCode.CLIENT_SIDE_CONNECT_ERROR,
                          throwable.getMessage(), throwable));
                    }
                  });
              return null;
                                } catch (final IOException ioe) {
                                    throw newErrorResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR, ioe
                                            .getMessage(), ioe);
            }
            catch (final IOException ioe)
            {
              throw newErrorResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR,
                  ioe.getMessage(), ioe);
            }
          }
          else
          {
                            } else {
            // Plain connection.
            handler.handleResult(null);
            return new CompletedFutureResult<ExtendedResult>(
@@ -179,63 +152,46 @@
      startTLSFutureResult.setFutureResult(connectionFutureResult);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void cancelled()
    {
        public void cancelled() {
      // Ignore this.
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void completed(final org.glassfish.grizzly.Connection connection)
    {
        public void completed(final org.glassfish.grizzly.Connection connection) {
      connectionFutureResult.handleResult(adaptConnection(connection));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void failed(final Throwable throwable)
    {
      connectionFutureResult
          .handleErrorResult(adaptConnectionException(throwable));
        public void failed(final Throwable throwable) {
            connectionFutureResult.handleErrorResult(adaptConnectionException(throwable));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void updated(final org.glassfish.grizzly.Connection connection)
    {
        public void updated(final org.glassfish.grizzly.Connection connection) {
      // Ignore this.
    }
  }
  private final SocketAddress socketAddress;
  private final TCPNIOTransport transport;
  private final FilterChain defaultFilterChain;
  private final LDAPClientFilter clientFilter;
  private final LDAPOptions options;
  /**
   * Creates a new LDAP connection factory implementation which can be used to
   * create connections to the Directory Server at the provided host and port
@@ -246,81 +202,58 @@
   * @param options
   *          The LDAP connection options to use when creating connections.
   */
  public LDAPConnectionFactoryImpl(final SocketAddress address,
      final LDAPOptions options)
  {
    if (options.getTCPNIOTransport() == null)
    {
    public LDAPConnectionFactoryImpl(final SocketAddress address, final LDAPOptions options) {
        if (options.getTCPNIOTransport() == null) {
      this.transport = DefaultTCPNIOTransport.getInstance();
    }
    else
    {
        } else {
      this.transport = options.getTCPNIOTransport();
    }
    this.socketAddress = address;
    this.options = new LDAPOptions(options);
    this.clientFilter = new LDAPClientFilter(new LDAPReader(
        this.options.getDecodeOptions()), 0);
    this.defaultFilterChain = FilterChainBuilder.stateless()
        .add(new TransportFilter())
        .add(clientFilter)
        .build();
        this.clientFilter =
                new LDAPClientFilter(new LDAPReader(this.options.getDecodeOptions()), 0);
        this.defaultFilterChain =
                FilterChainBuilder.stateless().add(new TransportFilter()).add(clientFilter).build();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public Connection getConnection() throws ErrorResultException,
      InterruptedException
  {
    public Connection getConnection() throws ErrorResultException, InterruptedException {
    return getConnectionAsync(null).get();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public FutureResult<Connection> getConnectionAsync(
      final ResultHandler<? super Connection> handler)
  {
            final ResultHandler<? super Connection> handler) {
    final ConnectionCompletionHandler ch = new ConnectionCompletionHandler(handler);
    try
    {
        try {
      ch.connectionFutureResult.setFutureResult(transport.connect(socketAddress, ch));
      return ch.startTLSFutureResult;
    }
    catch (final IOException e)
    {
        } catch (final IOException e) {
      final ErrorResultException result = adaptConnectionException(e);
      return new CompletedFutureResult<Connection>(result);
    }
  }
  /**
   * Returns the address of the Directory Server.
   *
   * @return The address of the Directory Server.
   */
  public SocketAddress getSocketAddress()
  {
    public SocketAddress getSocketAddress() {
    return socketAddress;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("LDAPConnectionFactory(");
    builder.append(getSocketAddress().toString());
@@ -328,32 +261,22 @@
    return builder.toString();
  }
  private LDAPConnection adaptConnection(
      final org.glassfish.grizzly.Connection<?> connection)
  {
    private LDAPConnection adaptConnection(final org.glassfish.grizzly.Connection<?> connection) {
    // Test shows that its much faster with non block writes but risk
    // running out of memory if the server is slow.
    connection.configureBlocking(true);
    connection.setProcessor(defaultFilterChain);
    final LDAPConnection ldapConnection = new LDAPConnection(connection,
        options);
        final LDAPConnection ldapConnection = new LDAPConnection(connection, options);
    clientFilter.registerConnection(connection, ldapConnection);
    return ldapConnection;
  }
  private ErrorResultException adaptConnectionException(Throwable t)
  {
    if (t instanceof ExecutionException)
    {
    private ErrorResultException adaptConnectionException(Throwable t) {
        if (t instanceof ExecutionException) {
      t = t.getCause();
    }
    return newErrorResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR, t.getMessage(),
        t);
        return newErrorResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR, t.getMessage(), t);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConstants.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,13 +25,10 @@
 */
package com.forgerock.opendj.ldap;
/**
 * This class defines a number of constants used in the LDAP protocol.
 */
public final class LDAPConstants
{
public final class LDAPConstants {
  /**
   * The protocol op type for bind requests.
@@ -152,14 +148,14 @@
  public static final byte TYPE_REFERRAL_SEQUENCE = (byte) 0xA3;
  /**
   * The BER type to use for the AuthenticationChoice element in a bind request
   * when simple authentication is to be used.
     * The BER type to use for the AuthenticationChoice element in a bind
     * request when simple authentication is to be used.
   */
  public static final byte TYPE_AUTHENTICATION_SIMPLE = (byte) 0x80;
  /**
   * The BER type to use for the AuthenticationChoice element in a bind request
   * when SASL authentication is to be used.
     * The BER type to use for the AuthenticationChoice element in a bind
     * request when SASL authentication is to be used.
   */
  public static final byte TYPE_AUTHENTICATION_SASL = (byte) 0xA3;
@@ -234,7 +230,8 @@
  public static final byte TYPE_SUBFINAL = (byte) 0x82;
  /**
   * The BER type to use for the matching rule OID in a matching rule assertion.
     * The BER type to use for the matching rule OID in a matching rule
     * assertion.
   */
  public static final byte TYPE_MATCHING_RULE_ID = (byte) 0x81;
@@ -323,10 +320,7 @@
   */
  public static final int ELEMENT_READ_STATE_NEED_VALUE_BYTES = 3;
  private LDAPConstants()
  {
    private LDAPConstants() {
    // Prevent instantiation.
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPExtendedFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,15 +27,16 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
/**
 * Extended result future implementation.
 *
@@ -44,27 +44,19 @@
 *          The type of result returned by this future.
 */
final class LDAPExtendedFutureResultImpl<R extends ExtendedResult> extends
    AbstractLDAPFutureResultImpl<R>
{
        AbstractLDAPFutureResultImpl<R> {
  private final ExtendedRequest<R> request;
  LDAPExtendedFutureResultImpl(final int requestID,
      final ExtendedRequest<R> request,
    LDAPExtendedFutureResultImpl(final int requestID, final ExtendedRequest<R> request,
      final ResultHandler<? super R> resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(requestID, resultHandler, intermediateResponseHandler, connection);
    this.request = request;
  }
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("LDAPExtendedFutureResultImpl(");
    sb.append("request = ");
@@ -74,8 +66,6 @@
    return sb.toString();
  }
  /**
   * {@inheritDoc}
   */
@@ -84,31 +74,20 @@
    return !request.getOID().equals(StartTLSExtendedRequest.OID);
  }
  R decodeResult(final ExtendedResult result, final DecodeOptions options)
      throws DecodeException
  {
    R decodeResult(final ExtendedResult result, final DecodeOptions options) throws DecodeException {
    return request.getResultDecoder().decodeExtendedResult(result, options);
  }
  ExtendedRequest<R> getRequest()
  {
    ExtendedRequest<R> getRequest() {
    return request;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  R newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
      final Throwable cause)
  {
    return request.getResultDecoder().newExtendedErrorResult(resultCode, "",
        diagnosticMessage);
            final Throwable cause) {
        return request.getResultDecoder().newExtendedErrorResult(resultCode, "", diagnosticMessage);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
@@ -38,31 +35,22 @@
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
/**
 * Result future implementation.
 */
final class LDAPFutureResultImpl extends AbstractLDAPFutureResultImpl<Result>
{
final class LDAPFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> {
  private final Request request;
  LDAPFutureResultImpl(final int requestID, final Request request,
      final ResultHandler<? super Result> resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(requestID, resultHandler, intermediateResponseHandler, connection);
    this.request = request;
  }
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("LDAPFutureResultImpl(");
    sb.append("request = ");
@@ -72,23 +60,17 @@
    return sb.toString();
  }
  Request getRequest()
  {
    Request getRequest() {
    return request;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  Result newErrorResult(final ResultCode resultCode,
      final String diagnosticMessage, final Throwable cause)
  {
    return Responses.newResult(resultCode)
        .setDiagnosticMessage(diagnosticMessage).setCause(cause);
    Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
            final Throwable cause) {
        return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause(
                cause);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPListenerImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import java.io.Closeable;
import java.io.IOException;
import java.net.SocketAddress;
@@ -47,20 +44,15 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * LDAP listener implementation.
 */
public final class LDAPListenerImpl implements Closeable
{
public final class LDAPListenerImpl implements Closeable {
  private final TCPNIOTransport transport;
  private final FilterChain defaultFilterChain;
  private final ServerConnectionFactory<LDAPClientContext, Integer> connectionFactory;
  private final TCPNIOServerConnection serverConnection;
  /**
   * Creates a new LDAP listener implementation which will listen for LDAP
   * client connections using the provided address and connection options.
@@ -68,8 +60,8 @@
   * @param address
   *          The address to listen on.
   * @param factory
   *          The server connection factory which will be used to create server
   *          connections.
     *            The server connection factory which will be used to create
     *            server connections.
   * @param options
   *          The LDAP listener options.
   * @throws IOException
@@ -78,77 +70,55 @@
   */
  public LDAPListenerImpl(final SocketAddress address,
      final ServerConnectionFactory<LDAPClientContext, Integer> factory,
      final LDAPListenerOptions options) throws IOException
  {
    if (options.getTCPNIOTransport() == null)
    {
            final LDAPListenerOptions options) throws IOException {
        if (options.getTCPNIOTransport() == null) {
      this.transport = DefaultTCPNIOTransport.getInstance();
    }
    else
    {
        } else {
      this.transport = options.getTCPNIOTransport();
    }
    this.connectionFactory = factory;
    final DecodeOptions decodeOptions = new DecodeOptions(options
        .getDecodeOptions());
    this.defaultFilterChain = FilterChainBuilder
        .stateless()
        .add(new TransportFilter())
        .add(new LDAPServerFilter(this, new LDAPReader(decodeOptions), 0))
        .build();
        final DecodeOptions decodeOptions = new DecodeOptions(options.getDecodeOptions());
        this.defaultFilterChain =
                FilterChainBuilder.stateless().add(new TransportFilter()).add(
                        new LDAPServerFilter(this, new LDAPReader(decodeOptions), 0)).build();
    this.serverConnection = transport.bind(address, options.getBacklog());
    this.serverConnection.setProcessor(defaultFilterChain);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void close()
  {
    try
    {
    public void close() {
        try {
      serverConnection.close().get();
    }
    catch (final InterruptedException e)
    {
        } catch (final InterruptedException e) {
      // Cannot handle here.
      Thread.currentThread().interrupt();
    }
    catch (final Exception e)
    {
        } catch (final Exception e) {
      // Ignore the exception.
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.WARNING))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.WARNING)) {
        StaticUtils.DEBUG_LOG.log(Level.WARNING,
            "Exception occurred while closing listener:" + e.getMessage(), e);
      }
    }
  }
  /**
   * Returns the address that this LDAP listener is listening on.
   *
   * @return The address that this LDAP listener is listening on.
   */
  public SocketAddress getSocketAddress()
  {
    public SocketAddress getSocketAddress() {
    return serverConnection.getLocalAddress();
  }
  /**
   * {@inheritDoc}
   */
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("LDAPListener(");
    builder.append(getSocketAddress().toString());
@@ -156,17 +126,11 @@
    return builder.toString();
  }
  ServerConnectionFactory<LDAPClientContext, Integer> getConnectionFactory()
  {
    ServerConnectionFactory<LDAPClientContext, Integer> getConnectionFactory() {
    return connectionFactory;
  }
  FilterChain getDefaultFilterChain()
  {
    FilterChain getDefaultFilterChain() {
    return defaultFilterChain;
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPMessageHandler.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,15 +26,26 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
/**
 * LDAP message handler interface.
@@ -43,117 +53,70 @@
 * @param <P>
 *          A user provided handler parameter.
 */
interface LDAPMessageHandler<P>
{
interface LDAPMessageHandler<P> {
  void abandonRequest(P param, int messageID, AbandonRequest request)
      throws UnexpectedRequestException, IOException;
  void addRequest(P param, int messageID, AddRequest request)
      throws UnexpectedRequestException, IOException;
  void addResult(P param, int messageID, Result result)
      throws UnexpectedResponseException, IOException;
  void bindRequest(P param, int messageID, int version,
      GenericBindRequest request) throws UnexpectedRequestException,
    void addRequest(P param, int messageID, AddRequest request) throws UnexpectedRequestException,
      IOException;
    void addResult(P param, int messageID, Result result) throws UnexpectedResponseException,
            IOException;
    void bindRequest(P param, int messageID, int version, GenericBindRequest request)
            throws UnexpectedRequestException, IOException;
  void bindResult(P param, int messageID, BindResult result)
      throws UnexpectedResponseException, IOException;
    void bindResult(P param, int messageID, BindResult result) throws UnexpectedResponseException,
            IOException;
  void compareRequest(P param, int messageID, CompareRequest request)
      throws UnexpectedRequestException, IOException;
  void compareResult(P param, int messageID, CompareResult result)
      throws UnexpectedResponseException, IOException;
  void deleteRequest(P param, int messageID, DeleteRequest request)
      throws UnexpectedRequestException, IOException;
  void deleteResult(P param, int messageID, Result result)
      throws UnexpectedResponseException, IOException;
  <R extends ExtendedResult> void extendedRequest(P param, int messageID,
      ExtendedRequest<R> request) throws UnexpectedRequestException,
    void deleteResult(P param, int messageID, Result result) throws UnexpectedResponseException,
      IOException;
    <R extends ExtendedResult> void extendedRequest(P param, int messageID,
            ExtendedRequest<R> request) throws UnexpectedRequestException, IOException;
  void extendedResult(P param, int messageID, ExtendedResult result)
      throws UnexpectedResponseException, IOException;
  void intermediateResponse(P param, int messageID,
      IntermediateResponse response) throws UnexpectedResponseException,
      IOException;
    void intermediateResponse(P param, int messageID, IntermediateResponse response)
            throws UnexpectedResponseException, IOException;
  void modifyDNRequest(P param, int messageID, ModifyDNRequest request)
      throws UnexpectedRequestException, IOException;
  void modifyDNResult(P param, int messageID, Result result)
      throws UnexpectedResponseException, IOException;
    void modifyDNResult(P param, int messageID, Result result) throws UnexpectedResponseException,
            IOException;
  void modifyRequest(P param, int messageID, ModifyRequest request)
      throws UnexpectedRequestException, IOException;
  void modifyResult(P param, int messageID, Result result)
      throws UnexpectedResponseException, IOException;
    void modifyResult(P param, int messageID, Result result) throws UnexpectedResponseException,
            IOException;
  void searchRequest(P param, int messageID, SearchRequest request)
      throws UnexpectedRequestException, IOException;
  void searchResult(P param, int messageID, Result result)
      throws UnexpectedResponseException, IOException;
    void searchResult(P param, int messageID, Result result) throws UnexpectedResponseException,
            IOException;
  void searchResultEntry(P param, int messageID, SearchResultEntry entry)
      throws UnexpectedResponseException, IOException;
  void searchResultReference(P param, int messageID,
      SearchResultReference reference) throws UnexpectedResponseException,
      IOException;
    void searchResultReference(P param, int messageID, SearchResultReference reference)
            throws UnexpectedResponseException, IOException;
  void unbindRequest(P param, int messageID, UnbindRequest request)
      throws UnexpectedRequestException, IOException;
  void unrecognizedMessage(P param, int messageID, byte messageTag,
      ByteString messageBytes) throws UnsupportedMessageException, IOException;
    void unrecognizedMessage(P param, int messageID, byte messageTag, ByteString messageBytes)
            throws UnsupportedMessageException, IOException;
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.*;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_BOOLEAN_TYPE;
import static org.forgerock.opendj.asn1.ASN1Constants.UNIVERSAL_OCTET_STRING_TYPE;
@@ -42,111 +39,111 @@
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.asn1.ASN1Reader;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.Attribute;
import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.Modification;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.controls.Control;
import org.forgerock.opendj.ldap.controls.GenericControl;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.GenericExtendedRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Request;
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.GenericExtendedResult;
import org.forgerock.opendj.ldap.responses.GenericIntermediateResponse;
import org.forgerock.opendj.ldap.responses.Response;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import org.forgerock.opendj.ldap.schema.Schema;
import com.forgerock.opendj.util.StaticUtils;
/**
 * Static methods for decoding LDAP messages.
 */
final class LDAPReader
{
  static SearchResultEntry decodeEntry(final ASN1Reader reader,
      final DecodeOptions options) throws IOException
  {
final class LDAPReader {
    static SearchResultEntry decodeEntry(final ASN1Reader reader, final DecodeOptions options)
            throws IOException {
    Entry entry;
    reader.readStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      DN dn;
      try
      {
            try {
        dn = DN.valueOf(dnString, schema);
      }
      catch (final LocalizedIllegalArgumentException e)
      {
            } catch (final LocalizedIllegalArgumentException e) {
        throw DecodeException.error(e.getMessageObject());
      }
      entry = options.getEntryFactory().newEntry(dn);
      reader.readStartSequence();
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          reader.readStartSequence();
          try
          {
                    try {
            final String ads = reader.readOctetStringAsString();
            AttributeDescription ad;
            try
            {
                        try {
              ad = AttributeDescription.valueOf(ads, schema);
            }
            catch (final LocalizedIllegalArgumentException e)
            {
                        } catch (final LocalizedIllegalArgumentException e) {
              throw DecodeException.error(e.getMessageObject());
            }
            final Attribute attribute = options.getAttributeFactory()
                .newAttribute(ad);
                        final Attribute attribute = options.getAttributeFactory().newAttribute(ad);
            reader.readStartSet();
            try
            {
              while (reader.hasNextElement())
              {
                        try {
                            while (reader.hasNextElement()) {
                attribute.add(reader.readOctetString());
              }
              entry.addAttribute(attribute);
            }
            finally
            {
                        } finally {
              reader.readEndSet();
            }
          }
          finally
          {
                    } finally {
            reader.readEndSequence();
          }
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Responses.newSearchResultEntry(entry);
  }
  private final DecodeOptions options;
  LDAPReader(final DecodeOptions options)
  {
    LDAPReader(final DecodeOptions options) {
    this.options = options;
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP message.
   *
@@ -162,23 +159,17 @@
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  <P> void decode(final ASN1Reader reader, final LDAPMessageHandler<P> handler,
      final P param) throws IOException
  {
    <P> void decode(final ASN1Reader reader, final LDAPMessageHandler<P> handler, final P param)
            throws IOException {
    reader.readStartSequence();
    try
    {
        try {
      final int messageID = (int) reader.readInteger();
      decodeProtocolOp(reader, messageID, handler, param);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 read as an LDAP abandon
   * request protocol op.
@@ -188,123 +179,95 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeAbandonRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeAbandonRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    final int msgToAbandon = (int) reader.readInteger(OP_TYPE_ABANDON_REQUEST);
    final AbandonRequest message = Requests.newAbandonRequest(msgToAbandon);
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP ABANDON REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP ABANDON REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.abandonRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP add request
   * protocol op.
     * Decodes the elements from the provided ASN.1 reader as an LDAP add
     * request protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeAddRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeAddRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Entry entry;
    reader.readStartSequence(OP_TYPE_ADD_REQUEST);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      final DN dn = decodeDN(dnString, schema);
      entry = options.getEntryFactory().newEntry(dn);
      reader.readStartSequence();
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          reader.readStartSequence();
          try
          {
                    try {
            final String ads = reader.readOctetStringAsString();
            final AttributeDescription ad = decodeAttributeDescription(ads,
                schema);
            final Attribute attribute = options.getAttributeFactory()
                .newAttribute(ad);
                        final AttributeDescription ad = decodeAttributeDescription(ads, schema);
                        final Attribute attribute = options.getAttributeFactory().newAttribute(ad);
            reader.readStartSet();
            try
            {
              while (reader.hasNextElement())
              {
                        try {
                            while (reader.hasNextElement()) {
                attribute.add(reader.readOctetString());
              }
              entry.addAttribute(attribute);
            }
            finally
            {
                        } finally {
              reader.readEndSet();
            }
          }
          finally
          {
                    } finally {
            reader.readEndSequence();
          }
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    final AddRequest message = Requests.newAddRequest(entry);
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP ADD REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP ADD REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.addRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an add response
   * protocol op.
@@ -314,64 +277,49 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeAddResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeAddResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Result message;
    reader.readStartSequence(OP_TYPE_ADD_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
            message =
                    Responses.newResult(resultCode).setMatchedDN(matchedDN).setDiagnosticMessage(
                            diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
      StaticUtils.DEBUG_LOG.finer(String
          .format("DECODE LDAP ADD RESULT(messageID=%d, result=%s)", messageID,
              message));
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
            StaticUtils.DEBUG_LOG.finer(String.format(
                    "DECODE LDAP ADD RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.addResult(p, messageID, message);
  }
  private AttributeDescription decodeAttributeDescription(
      final String attributeDescription, final Schema schema)
      throws DecodeException
  {
    try
    {
    private AttributeDescription decodeAttributeDescription(final String attributeDescription,
            final Schema schema) throws DecodeException {
        try {
      return AttributeDescription.valueOf(attributeDescription, schema);
    }
    catch (final LocalizedIllegalArgumentException e)
    {
        } catch (final LocalizedIllegalArgumentException e) {
      throw DecodeException.error(e.getMessageObject());
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 read as an LDAP bind request
   * protocol op.
@@ -381,47 +329,39 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeBindRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeBindRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    reader.readStartSequence(OP_TYPE_BIND_REQUEST);
    try
    {
        try {
      final int protocolVersion = (int) reader.readInteger();
      final String authName = reader.readOctetStringAsString();
      final byte authType = reader.peekType();
      final byte[] authBytes = reader.readOctetString(authType).toByteArray();
      final GenericBindRequest request = Requests.newGenericBindRequest(
          authName, authType, authBytes);
            final GenericBindRequest request =
                    Requests.newGenericBindRequest(authName, authType, authBytes);
      decodeControls(reader, request);
      if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
      {
            if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
        StaticUtils.DEBUG_LOG.finer(String.format(
            "DECODE LDAP BIND REQUEST(messageID=%d, auth=0x%x, request=%s)",
            messageID, request.getAuthenticationType(), request));
                        "DECODE LDAP BIND REQUEST(messageID=%d, auth=0x%x, request=%s)", messageID,
                        request.getAuthenticationType(), request));
      }
      handler.bindRequest(p, messageID, protocolVersion, request);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a bind response
   * protocol op.
@@ -431,54 +371,44 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeBindResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeBindResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    BindResult message;
    reader.readStartSequence(OP_TYPE_BIND_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newBindResult(resultCode).setMatchedDN(matchedDN)
            message =
                    Responses.newBindResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
      decodeResponseReferrals(reader, message);
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_SERVER_SASL_CREDENTIALS))
      {
            if (reader.hasNextElement() && (reader.peekType() == TYPE_SERVER_SASL_CREDENTIALS)) {
        message.setServerSASLCredentials(reader
            .readOctetString(TYPE_SERVER_SASL_CREDENTIALS));
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP BIND RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP BIND RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.bindResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP compare
   * request protocol op.
@@ -488,58 +418,46 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeCompareRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeCompareRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    CompareRequest message;
    reader.readStartSequence(OP_TYPE_COMPARE_REQUEST);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      final DN dn = decodeDN(dnString, schema);
      reader.readStartSequence();
      try
      {
            try {
        final String ads = reader.readOctetStringAsString();
        final AttributeDescription ad = decodeAttributeDescription(ads, schema);
        final ByteString assertionValue = reader.readOctetString();
        message = Requests.newCompareRequest(dn, ad, assertionValue);
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP COMPARE REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP COMPARE REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.compareRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a compare response
   * protocol op.
@@ -549,48 +467,40 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeCompareResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeCompareResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    CompareResult message;
    reader.readStartSequence(OP_TYPE_COMPARE_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newCompareResult(resultCode).setMatchedDN(matchedDN)
            message =
                    Responses.newCompareResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP COMPARE RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP COMPARE RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.compareResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP control.
   *
@@ -601,32 +511,23 @@
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private void decodeControl(final ASN1Reader reader, final Request request)
      throws IOException
  {
    private void decodeControl(final ASN1Reader reader, final Request request) throws IOException {
    String oid;
    boolean isCritical;
    ByteString value;
    reader.readStartSequence();
    try
    {
        try {
      oid = reader.readOctetStringAsString();
      isCritical = false;
      value = null;
      if (reader.hasNextElement()
          && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE))
      {
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE)) {
        isCritical = reader.readBoolean();
      }
      if (reader.hasNextElement()
          && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE))
      {
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE)) {
        value = reader.readOctetString();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
@@ -634,8 +535,6 @@
    request.addControl(c);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP control.
   *
@@ -646,32 +545,23 @@
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private void decodeControl(final ASN1Reader reader, final Response response)
      throws IOException
  {
    private void decodeControl(final ASN1Reader reader, final Response response) throws IOException {
    String oid;
    boolean isCritical;
    ByteString value;
    reader.readStartSequence();
    try
    {
        try {
      oid = reader.readOctetStringAsString();
      isCritical = false;
      value = null;
      if (reader.hasNextElement()
          && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE))
      {
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_BOOLEAN_TYPE)) {
        isCritical = reader.readBoolean();
      }
      if (reader.hasNextElement()
          && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE))
      {
            if (reader.hasNextElement() && (reader.peekType() == UNIVERSAL_OCTET_STRING_TYPE)) {
        value = reader.readOctetString();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
@@ -679,8 +569,6 @@
    response.addControl(c);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a set of controls.
   *
@@ -691,28 +579,19 @@
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private void decodeControls(final ASN1Reader reader, final Request request)
      throws IOException
  {
    if (reader.hasNextElement() && (reader.peekType() == TYPE_CONTROL_SEQUENCE))
    {
    private void decodeControls(final ASN1Reader reader, final Request request) throws IOException {
        if (reader.hasNextElement() && (reader.peekType() == TYPE_CONTROL_SEQUENCE)) {
      reader.readStartSequence(TYPE_CONTROL_SEQUENCE);
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          decodeControl(reader, request);
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a set of controls.
   *
@@ -724,27 +603,19 @@
   *           If an error occurred while reading bytes to decode.
   */
  private void decodeControls(final ASN1Reader reader, final Response response)
      throws IOException
  {
    if (reader.hasNextElement() && (reader.peekType() == TYPE_CONTROL_SEQUENCE))
    {
            throws IOException {
        if (reader.hasNextElement() && (reader.peekType() == TYPE_CONTROL_SEQUENCE)) {
      reader.readStartSequence(TYPE_CONTROL_SEQUENCE);
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          decodeControl(reader, response);
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP delete
   * request protocol op.
@@ -754,37 +625,30 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeDeleteRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    final String dnString = reader
        .readOctetStringAsString(OP_TYPE_DELETE_REQUEST);
    private <P> void decodeDeleteRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
        final String dnString = reader.readOctetStringAsString(OP_TYPE_DELETE_REQUEST);
    final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
    final DN dn = decodeDN(dnString, schema);
    final DeleteRequest message = Requests.newDeleteRequest(dn);
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP DELETE REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP DELETE REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.deleteRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a delete response
   * protocol op.
@@ -794,63 +658,48 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeDeleteResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeDeleteResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Result message;
    reader.readStartSequence(OP_TYPE_DELETE_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
            message =
                    Responses.newResult(resultCode).setMatchedDN(matchedDN).setDiagnosticMessage(
                            diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP DELETE RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP DELETE RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.deleteResult(p, messageID, message);
  }
  private DN decodeDN(final String dn, final Schema schema)
      throws DecodeException
  {
    try
    {
    private DN decodeDN(final String dn, final Schema schema) throws DecodeException {
        try {
      return DN.valueOf(dn, schema);
    }
    catch (final LocalizedIllegalArgumentException e)
    {
        } catch (final LocalizedIllegalArgumentException e) {
      throw DecodeException.error(e.getMessageObject());
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP extended
   * request protocol op.
@@ -860,118 +709,43 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeExtendedRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeExtendedRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    String oid;
    ByteString value;
    reader.readStartSequence(OP_TYPE_EXTENDED_REQUEST);
    try
    {
        try {
      oid = reader.readOctetStringAsString(TYPE_EXTENDED_REQUEST_OID);
      value = null;
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_EXTENDED_REQUEST_VALUE))
      {
            if (reader.hasNextElement() && (reader.peekType() == TYPE_EXTENDED_REQUEST_VALUE)) {
        value = reader.readOctetString(TYPE_EXTENDED_REQUEST_VALUE);
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    final GenericExtendedRequest message = Requests.newGenericExtendedRequest(
        oid, value);
        final GenericExtendedRequest message = Requests.newGenericExtendedRequest(oid, value);
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP EXTENDED REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP EXTENDED REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.extendedRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a extended response
   * protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeExtendedResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    GenericExtendedResult message;
    reader.readStartSequence(OP_TYPE_EXTENDED_RESPONSE);
    try
    {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newGenericExtendedResult(resultCode).setMatchedDN(
          matchedDN).setDiagnosticMessage(diagnosticMessage);
      decodeResponseReferrals(reader, message);
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_EXTENDED_RESPONSE_OID))
      {
        message.setOID(reader
            .readOctetStringAsString(TYPE_EXTENDED_RESPONSE_OID));
      }
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_EXTENDED_RESPONSE_VALUE))
      {
        message.setValue(reader.readOctetString(TYPE_EXTENDED_RESPONSE_VALUE));
      }
    }
    finally
    {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP EXTENDED RESULT(messageID=%d, result=%s)", messageID,
          message));
    }
    handler.extendedResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP intermediate
     * Decodes the elements from the provided ASN.1 reader as a extended
   * response protocol op.
   *
   * @param reader
@@ -979,80 +753,113 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeIntermediateResponse(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    GenericIntermediateResponse message;
    private <P> void decodeExtendedResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    reader.readStartSequence(OP_TYPE_INTERMEDIATE_RESPONSE);
    try
    {
      message = Responses.newGenericIntermediateResponse();
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_INTERMEDIATE_RESPONSE_OID))
      {
        message.setOID(reader
            .readOctetStringAsString(TYPE_INTERMEDIATE_RESPONSE_OID));
        GenericExtendedResult message;
        reader.readStartSequence(OP_TYPE_EXTENDED_RESPONSE);
        try {
            final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
            final String matchedDN = reader.readOctetStringAsString();
            final String diagnosticMessage = reader.readOctetStringAsString();
            message =
                    Responses.newGenericExtendedResult(resultCode).setMatchedDN(matchedDN)
                            .setDiagnosticMessage(diagnosticMessage);
            decodeResponseReferrals(reader, message);
            if (reader.hasNextElement() && (reader.peekType() == TYPE_EXTENDED_RESPONSE_OID)) {
                message.setOID(reader.readOctetStringAsString(TYPE_EXTENDED_RESPONSE_OID));
      }
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_INTERMEDIATE_RESPONSE_VALUE))
      {
        message.setValue(reader
            .readOctetString(TYPE_INTERMEDIATE_RESPONSE_VALUE));
            if (reader.hasNextElement() && (reader.peekType() == TYPE_EXTENDED_RESPONSE_VALUE)) {
                message.setValue(reader.readOctetString(TYPE_EXTENDED_RESPONSE_VALUE));
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP INTERMEDIATE RESPONSE(messageID=%d, response=%s)",
          messageID, message));
                    "DECODE LDAP EXTENDED RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.intermediateResponse(p, messageID, message);
        handler.extendedResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a modify DN request
   * protocol op.
     * Decodes the elements from the provided ASN.1 reader as an LDAP
     * intermediate response protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeModifyDNRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeIntermediateResponse(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
        GenericIntermediateResponse message;
        reader.readStartSequence(OP_TYPE_INTERMEDIATE_RESPONSE);
        try {
            message = Responses.newGenericIntermediateResponse();
            if (reader.hasNextElement() && (reader.peekType() == TYPE_INTERMEDIATE_RESPONSE_OID)) {
                message.setOID(reader.readOctetStringAsString(TYPE_INTERMEDIATE_RESPONSE_OID));
            }
            if (reader.hasNextElement() && (reader.peekType() == TYPE_INTERMEDIATE_RESPONSE_VALUE)) {
                message.setValue(reader.readOctetString(TYPE_INTERMEDIATE_RESPONSE_VALUE));
            }
        } finally {
            reader.readEndSequence();
        }
        decodeControls(reader, message);
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
            StaticUtils.DEBUG_LOG.finer(String.format(
                    "DECODE LDAP INTERMEDIATE RESPONSE(messageID=%d, response=%s)", messageID,
                    message));
        }
        handler.intermediateResponse(p, messageID, message);
    }
    /**
     * Decodes the elements from the provided ASN.1 reader as a modify DN
     * request protocol op.
     *
     * @param reader
     *            The ASN.1 reader.
     * @param messageID
     *            The decoded message ID for this message.
     * @param handler
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
     * @param p
     *            The parameter to pass into the <code>LDAPMessageHandler</code>
     * @throws IOException
     *             If an error occurred while reading bytes to decode.
     */
    private <P> void decodeModifyDNRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    ModifyDNRequest message;
    reader.readStartSequence(OP_TYPE_MODIFY_DN_REQUEST);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      final DN dn = decodeDN(dnString, schema);
@@ -1064,85 +871,69 @@
      message.setDeleteOldRDN(reader.readBoolean());
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_MODIFY_DN_NEW_SUPERIOR))
      {
        final String newSuperiorString = reader
            .readOctetStringAsString(TYPE_MODIFY_DN_NEW_SUPERIOR);
            if (reader.hasNextElement() && (reader.peekType() == TYPE_MODIFY_DN_NEW_SUPERIOR)) {
                final String newSuperiorString =
                        reader.readOctetStringAsString(TYPE_MODIFY_DN_NEW_SUPERIOR);
        final DN newSuperior = decodeDN(newSuperiorString, schema);
        message.setNewSuperior(newSuperior);
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP MODIFY DN REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP MODIFY DN REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.modifyDNRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a modify DN response
   * protocol op.
     * Decodes the elements from the provided ASN.1 reader as a modify DN
     * response protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeModifyDNResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeModifyDNResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Result message;
    reader.readStartSequence(OP_TYPE_MODIFY_DN_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
            message =
                    Responses.newResult(resultCode).setMatchedDN(matchedDN).setDiagnosticMessage(
                            diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP MODIFY DN RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP MODIFY DN RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.modifyDNResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP modify
   * request protocol op.
@@ -1152,102 +943,76 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeModifyRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeModifyRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    ModifyRequest message;
    reader.readStartSequence(OP_TYPE_MODIFY_REQUEST);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      final DN dn = decodeDN(dnString, schema);
      message = Requests.newModifyRequest(dn);
      reader.readStartSequence();
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          reader.readStartSequence();
          try
          {
                    try {
            final int typeIntValue = reader.readEnumerated();
            final ModificationType type = ModificationType
                .valueOf(typeIntValue);
            if (type == null)
            {
                        final ModificationType type = ModificationType.valueOf(typeIntValue);
                        if (type == null) {
              throw DecodeException
                  .error(ERR_LDAP_MODIFICATION_DECODE_INVALID_MOD_TYPE
                      .get(typeIntValue));
            }
            reader.readStartSequence();
            try
            {
                        try {
              final String ads = reader.readOctetStringAsString();
              final AttributeDescription ad = decodeAttributeDescription(ads,
                  schema);
              final Attribute attribute = options.getAttributeFactory()
                  .newAttribute(ad);
                            final AttributeDescription ad = decodeAttributeDescription(ads, schema);
                            final Attribute attribute =
                                    options.getAttributeFactory().newAttribute(ad);
              reader.readStartSet();
              try
              {
                while (reader.hasNextElement())
                {
                            try {
                                while (reader.hasNextElement()) {
                  attribute.add(reader.readOctetString());
                }
                message.addModification(new Modification(type, attribute));
              }
              finally
              {
                            } finally {
                reader.readEndSet();
              }
                        } finally {
                            reader.readEndSequence();
            }
            finally
            {
                    } finally {
              reader.readEndSequence();
            }
          }
          finally
          {
            } finally {
            reader.readEndSequence();
          }
        }
      }
      finally
      {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP MODIFY REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP MODIFY REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.modifyRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a modify response
   * protocol op.
@@ -1257,71 +1022,61 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeModifyResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeModifyResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Result message;
    reader.readStartSequence(OP_TYPE_MODIFY_RESPONSE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
            message =
                    Responses.newResult(resultCode).setMatchedDN(matchedDN).setDiagnosticMessage(
                            diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP MODIFY RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP MODIFY RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.modifyResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP protocol op.
     * Decodes the elements from the provided ASN.1 reader as an LDAP protocol
     * op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeProtocolOp(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeProtocolOp(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    final byte type = reader.peekType();
    switch (type)
    {
        switch (type) {
    case OP_TYPE_UNBIND_REQUEST: // 0x42
      decodeUnbindRequest(reader, messageID, handler, p);
      break;
@@ -1332,8 +1087,7 @@
    case 0x47: // 0x47
    case 0x48: // 0x48
    case 0x49: // 0x49
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_DELETE_REQUEST: // 0x4A
      decodeDeleteRequest(reader, messageID, handler, p);
@@ -1343,8 +1097,7 @@
    case 0x4D: // 0x4D
    case 0x4E: // 0x4E
    case 0x4F: // 0x4F
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_ABANDON_REQUEST: // 0x50
      decodeAbandonRequest(reader, messageID, handler, p);
@@ -1364,8 +1117,7 @@
    case 0x5D: // 0x5D
    case 0x5E: // 0x5E
    case 0x5F: // 0x5F
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_BIND_REQUEST: // 0x60
      decodeBindRequest(reader, messageID, handler, p);
@@ -1374,8 +1126,7 @@
      decodeBindResult(reader, messageID, handler, p);
      break;
    case 0x62: // 0x62
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_SEARCH_REQUEST: // 0x63
      decodeSearchRequest(reader, messageID, handler, p);
@@ -1399,8 +1150,7 @@
      decodeAddResult(reader, messageID, handler, p);
      break;
    case 0x6A: // 0x6A
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_DELETE_RESPONSE: // 0x6B
      decodeDeleteResult(reader, messageID, handler, p);
@@ -1420,8 +1170,7 @@
    case 0x70: // 0x70
    case 0x71: // 0x71
    case 0x72: // 0x72
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_SEARCH_RESULT_REFERENCE: // 0x73
      decodeSearchResultReference(reader, messageID, handler, p);
@@ -1429,8 +1178,7 @@
    case 0x74: // 0x74
    case 0x75: // 0x75
    case 0x76: // 0x76
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    case OP_TYPE_EXTENDED_REQUEST: // 0x77
      decodeExtendedRequest(reader, messageID, handler, p);
@@ -1442,54 +1190,34 @@
      decodeIntermediateResponse(reader, messageID, handler, p);
      break;
    default:
      handler.unrecognizedMessage(p, messageID, type, reader
          .readOctetString(type));
            handler.unrecognizedMessage(p, messageID, type, reader.readOctetString(type));
      break;
    }
  }
  private RDN decodeRDN(final String rdn, final Schema schema)
      throws DecodeException
  {
    try
    {
    private RDN decodeRDN(final String rdn, final Schema schema) throws DecodeException {
        try {
      return RDN.valueOf(rdn, schema);
    }
    catch (final LocalizedIllegalArgumentException e)
    {
        } catch (final LocalizedIllegalArgumentException e) {
      throw DecodeException.error(e.getMessageObject());
    }
  }
  private void decodeResponseReferrals(final ASN1Reader reader,
      final Result message) throws IOException
  {
    if (reader.hasNextElement()
        && (reader.peekType() == TYPE_REFERRAL_SEQUENCE))
    {
    private void decodeResponseReferrals(final ASN1Reader reader, final Result message)
            throws IOException {
        if (reader.hasNextElement() && (reader.peekType() == TYPE_REFERRAL_SEQUENCE)) {
      reader.readStartSequence(TYPE_REFERRAL_SEQUENCE);
      try
      {
            try {
        // Should have at least 1.
        do
        {
                do {
          message.addReferralURI((reader.readOctetStringAsString()));
        }
        while (reader.hasNextElement());
      }
      finally
      {
                } while (reader.hasNextElement());
            } finally {
        reader.readEndSequence();
      }
    }
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP search
   * request protocol op.
@@ -1499,43 +1227,35 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeSearchRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeSearchRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    SearchRequest message;
    reader.readStartSequence(OP_TYPE_SEARCH_REQUEST);
    try
    {
        try {
      final String baseDNString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(
          baseDNString);
            final Schema schema = options.getSchemaResolver().resolveSchema(baseDNString);
      final DN baseDN = decodeDN(baseDNString, schema);
      final int scopeIntValue = reader.readEnumerated();
      final SearchScope scope = SearchScope.valueOf(scopeIntValue);
      if (scope == null)
      {
        throw DecodeException
            .error(ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_SCOPE
            if (scope == null) {
                throw DecodeException.error(ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_SCOPE
                .get(scopeIntValue));
      }
      final int dereferencePolicyIntValue = reader.readEnumerated();
      final DereferenceAliasesPolicy dereferencePolicy = DereferenceAliasesPolicy
          .valueOf(dereferencePolicyIntValue);
      if (dereferencePolicy == null)
      {
        throw DecodeException
            .error(ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_DEREF
            final DereferenceAliasesPolicy dereferencePolicy =
                    DereferenceAliasesPolicy.valueOf(dereferencePolicyIntValue);
            if (dereferencePolicy == null) {
                throw DecodeException.error(ERR_LDAP_SEARCH_REQUEST_DECODE_INVALID_DEREF
                .get(dereferencePolicyIntValue));
      }
@@ -1546,101 +1266,80 @@
      message = Requests.newSearchRequest(baseDN, scope, filter);
      message.setDereferenceAliasesPolicy(dereferencePolicy);
      try
      {
            try {
        message.setTimeLimit(timeLimit);
        message.setSizeLimit(sizeLimit);
      }
      catch (final LocalizedIllegalArgumentException e)
      {
            } catch (final LocalizedIllegalArgumentException e) {
        throw DecodeException.error(e.getMessageObject());
      }
      message.setTypesOnly(typesOnly);
      reader.readStartSequence();
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          message.addAttribute(reader.readOctetStringAsString());
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP SEARCH REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP SEARCH REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.searchRequest(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a search result done
   * protocol op.
     * Decodes the elements from the provided ASN.1 reader as a search result
     * done protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeSearchResult(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeSearchResult(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Result message;
    reader.readStartSequence(OP_TYPE_SEARCH_RESULT_DONE);
    try
    {
        try {
      final ResultCode resultCode = ResultCode.valueOf(reader.readEnumerated());
      final String matchedDN = reader.readOctetStringAsString();
      final String diagnosticMessage = reader.readOctetStringAsString();
      message = Responses.newResult(resultCode).setMatchedDN(matchedDN)
          .setDiagnosticMessage(diagnosticMessage);
            message =
                    Responses.newResult(resultCode).setMatchedDN(matchedDN).setDiagnosticMessage(
                            diagnosticMessage);
      decodeResponseReferrals(reader, message);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP SEARCH RESULT(messageID=%d, result=%s)", messageID,
          message));
                    "DECODE LDAP SEARCH RESULT(messageID=%d, result=%s)", messageID, message));
    }
    handler.searchResult(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as an LDAP search
   * result entry protocol op.
@@ -1650,86 +1349,64 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeSearchResultEntry(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeSearchResultEntry(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    Entry entry;
    reader.readStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY);
    try
    {
        try {
      final String dnString = reader.readOctetStringAsString();
      final Schema schema = options.getSchemaResolver().resolveSchema(dnString);
      final DN dn = decodeDN(dnString, schema);
      entry = options.getEntryFactory().newEntry(dn);
      reader.readStartSequence();
      try
      {
        while (reader.hasNextElement())
        {
            try {
                while (reader.hasNextElement()) {
          reader.readStartSequence();
          try
          {
                    try {
            final String ads = reader.readOctetStringAsString();
            final AttributeDescription ad = decodeAttributeDescription(ads,
                schema);
            final Attribute attribute = options.getAttributeFactory()
                .newAttribute(ad);
                        final AttributeDescription ad = decodeAttributeDescription(ads, schema);
                        final Attribute attribute = options.getAttributeFactory().newAttribute(ad);
            reader.readStartSet();
            try
            {
              while (reader.hasNextElement())
              {
                        try {
                            while (reader.hasNextElement()) {
                attribute.add(reader.readOctetString());
              }
              entry.addAttribute(attribute);
            }
            finally
            {
                        } finally {
              reader.readEndSet();
            }
          }
          finally
          {
                    } finally {
            reader.readEndSequence();
          }
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    final SearchResultEntry message = Responses.newSearchResultEntry(entry);
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP SEARCH RESULT ENTRY(messageID=%d, entry=%s)", messageID,
          message));
                    "DECODE LDAP SEARCH RESULT ENTRY(messageID=%d, entry=%s)", messageID, message));
    }
    handler.searchResultEntry(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 reader as a search result
   * reference protocol op.
@@ -1739,79 +1416,65 @@
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeSearchResultReference(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeSearchResultReference(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    SearchResultReference message;
    reader.readStartSequence(OP_TYPE_SEARCH_RESULT_REFERENCE);
    try
    {
      message = Responses.newSearchResultReference(reader
          .readOctetStringAsString());
      while (reader.hasNextElement())
      {
        try {
            message = Responses.newSearchResultReference(reader.readOctetStringAsString());
            while (reader.hasNextElement()) {
        message.addURI(reader.readOctetStringAsString());
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP SEARCH RESULT REFERENCE(messageID=%d, reference=%s)",
          messageID, message));
                    "DECODE LDAP SEARCH RESULT REFERENCE(messageID=%d, reference=%s)", messageID,
                    message));
    }
    handler.searchResultReference(p, messageID, message);
  }
  /**
   * Decodes the elements from the provided ASN.1 read as an LDAP unbind request
   * protocol op.
     * Decodes the elements from the provided ASN.1 read as an LDAP unbind
     * request protocol op.
   *
   * @param reader
   *          The ASN.1 reader.
   * @param messageID
   *          The decoded message ID for this message.
   * @param handler
   *          The <code>LDAPMessageHandler</code> that will handle this decoded
   *          message.
     *            The <code>LDAPMessageHandler</code> that will handle this
     *            decoded message.
   * @param p
   *          The parameter to pass into the <code>LDAPMessageHandler</code>
   * @throws IOException
   *           If an error occurred while reading bytes to decode.
   */
  private <P> void decodeUnbindRequest(final ASN1Reader reader,
      final int messageID, final LDAPMessageHandler<P> handler, final P p)
      throws IOException
  {
    private <P> void decodeUnbindRequest(final ASN1Reader reader, final int messageID,
            final LDAPMessageHandler<P> handler, final P p) throws IOException {
    UnbindRequest message;
    reader.readNull(OP_TYPE_UNBIND_REQUEST);
    message = Requests.newUnbindRequest();
    decodeControls(reader, message);
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "DECODE LDAP UNBIND REQUEST(messageID=%d, request=%s)", messageID,
          message));
                    "DECODE LDAP UNBIND REQUEST(messageID=%d, request=%s)", messageID, message));
    }
    handler.unbindRequest(p, messageID, message);
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPSearchFutureResultImpl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.ResultCode;
@@ -40,46 +37,34 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
/**
 * Search result future implementation.
 */
final class LDAPSearchFutureResultImpl extends
    AbstractLDAPFutureResultImpl<Result> implements SearchResultHandler
{
final class LDAPSearchFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> implements
        SearchResultHandler {
  private SearchResultHandler searchResultHandler;
  private final SearchRequest request;
  LDAPSearchFutureResultImpl(final int requestID, final SearchRequest request,
      final SearchResultHandler resultHandler,
      final IntermediateResponseHandler intermediateResponseHandler,
      final Connection connection)
  {
            final Connection connection) {
    super(requestID, resultHandler, intermediateResponseHandler, connection);
    this.request = request;
    this.searchResultHandler = resultHandler;
  }
  public boolean handleEntry(final SearchResultEntry entry)
  {
    public boolean handleEntry(final SearchResultEntry entry) {
    // FIXME: there's a potential race condition here - the future could
    // get cancelled between the isDone() call and the handler
    // invocation. We'd need to add support for intermediate handlers in
    // the synchronizer.
    if (!isDone())
    {
        if (!isDone()) {
      updateTimestamp();
      if (searchResultHandler != null)
      {
        if (!searchResultHandler.handleEntry(entry))
        {
            if (searchResultHandler != null) {
                if (!searchResultHandler.handleEntry(entry)) {
          searchResultHandler = null;
        }
      }
@@ -87,21 +72,15 @@
    return true;
  }
  public boolean handleReference(final SearchResultReference reference)
  {
    public boolean handleReference(final SearchResultReference reference) {
    // FIXME: there's a potential race condition here - the future could
    // get cancelled between the isDone() call and the handler
    // invocation. We'd need to add support for intermediate handlers in
    // the synchronizer.
    if (!isDone())
    {
        if (!isDone()) {
      updateTimestamp();
      if (searchResultHandler != null)
      {
        if (!searchResultHandler.handleReference(reference))
        {
            if (searchResultHandler != null) {
                if (!searchResultHandler.handleReference(reference)) {
          searchResultHandler = null;
        }
      }
@@ -109,11 +88,8 @@
    return true;
  }
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("LDAPSearchFutureResultImpl(");
    sb.append("request = ");
@@ -123,23 +99,17 @@
    return sb.toString();
  }
  SearchRequest getRequest()
  {
    SearchRequest getRequest() {
    return request;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  Result newErrorResult(final ResultCode resultCode,
      final String diagnosticMessage, final Throwable cause)
  {
    return Responses.newResult(resultCode).setDiagnosticMessage(
        diagnosticMessage).setCause(cause);
    Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage,
            final Throwable cause) {
        return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause(
                cause);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.OID_NOTICE_OF_DISCONNECTION;
import java.io.IOException;
@@ -40,16 +37,45 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConnectionSecurityLayer;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.IntermediateResponseHandler;
import org.forgerock.opendj.ldap.LDAPClientContext;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.ServerConnection;
import org.forgerock.opendj.ldap.controls.Control;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.GenericExtendedResult;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import org.glassfish.grizzly.Buffer;
import org.glassfish.grizzly.Connection;
import org.glassfish.grizzly.Grizzly;
import org.glassfish.grizzly.attributes.Attribute;
import org.glassfish.grizzly.filterchain.*;
import org.glassfish.grizzly.filterchain.BaseFilter;
import org.glassfish.grizzly.filterchain.Filter;
import org.glassfish.grizzly.filterchain.FilterChain;
import org.glassfish.grizzly.filterchain.FilterChainBuilder;
import org.glassfish.grizzly.filterchain.FilterChainContext;
import org.glassfish.grizzly.filterchain.NextAction;
import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
import org.glassfish.grizzly.ssl.SSLFilter;
import org.glassfish.grizzly.ssl.SSLUtils;
@@ -57,220 +83,142 @@
import com.forgerock.opendj.util.StaticUtils;
import com.forgerock.opendj.util.Validator;
/**
 * Grizzly filter implementation for decoding LDAP requests and handling server
 * side logic for SSL and SASL operations over LDAP.
 */
final class LDAPServerFilter extends BaseFilter
{
final class LDAPServerFilter extends BaseFilter {
  private abstract class AbstractHandler<R extends Result> implements
      IntermediateResponseHandler, ResultHandler<R>
  {
            IntermediateResponseHandler, ResultHandler<R> {
    protected final int messageID;
    protected final Connection<?> connection;
    protected AbstractHandler(final int messageID,
        final Connection<?> connection)
    {
        protected AbstractHandler(final int messageID, final Connection<?> connection) {
      this.messageID = messageID;
      this.connection = connection;
    }
    @Override
    public final boolean handleIntermediateResponse(
        final IntermediateResponse response)
    {
        public final boolean handleIntermediateResponse(final IntermediateResponse response) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.intermediateResponse(asn1Writer, messageID, response);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
        return false;
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
      return true;
    }
  }
  private final class AddHandler extends AbstractHandler<Result>
  {
    private AddHandler(final int messageID, final Connection<?> connection)
    {
    private final class AddHandler extends AbstractHandler<Result> {
        private AddHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      handleResult(error.getResult());
    }
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.addResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class BindHandler extends AbstractHandler<BindResult>
  {
    private BindHandler(final int messageID, final Connection<?> connection)
    {
    private final class BindHandler extends AbstractHandler<BindResult> {
        private BindHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      final Result result = error.getResult();
      if (result instanceof BindResult)
      {
            if (result instanceof BindResult) {
        handleResult((BindResult) result);
      }
      else
      {
        final BindResult newResult = Responses.newBindResult(result
            .getResultCode());
            } else {
                final BindResult newResult = Responses.newBindResult(result.getResultCode());
        newResult.setDiagnosticMessage(result.getDiagnosticMessage());
        newResult.setMatchedDN(result.getMatchedDN());
        newResult.setCause(result.getCause());
        for (final Control control : result.getControls())
        {
                for (final Control control : result.getControls()) {
          newResult.addControl(control);
        }
        handleResult(newResult);
      }
    }
    @Override
    public void handleResult(final BindResult result)
    {
        public void handleResult(final BindResult result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.bindResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class ClientContextImpl implements LDAPClientContext
  {
    private final class ClientContextImpl implements LDAPClientContext {
    private final Connection<?> connection;
    private volatile boolean isClosed = false;
    private ServerConnection<Integer> serverConnection = null;
    private ClientContextImpl(final Connection<?> connection)
    {
        private ClientContextImpl(final Connection<?> connection) {
      this.connection = connection;
    }
    @Override
    public void disconnect()
    {
        public void disconnect() {
      LDAPServerFilter.notifyConnectionDisconnected(connection, null, null);
    }
    @Override
    public void disconnect(final ResultCode resultCode, final String message)
    {
        public void disconnect(final ResultCode resultCode, final String message) {
      Validator.ensureNotNull(resultCode);
      final GenericExtendedResult notification = Responses
          .newGenericExtendedResult(resultCode)
          .setOID(OID_NOTICE_OF_DISCONNECTION).setDiagnosticMessage(message);
            final GenericExtendedResult notification =
                    Responses.newGenericExtendedResult(resultCode).setOID(
                            OID_NOTICE_OF_DISCONNECTION).setDiagnosticMessage(message);
      sendUnsolicitedNotification(notification);
      LDAPServerFilter.notifyConnectionDisconnected(connection, resultCode,
          message);
            LDAPServerFilter.notifyConnectionDisconnected(connection, resultCode, message);
    }
    @Override
    public InetSocketAddress getLocalAddress()
    {
        public InetSocketAddress getLocalAddress() {
      return (InetSocketAddress) connection.getLocalAddress();
    }
    @Override
    public InetSocketAddress getPeerAddress()
    {
        public InetSocketAddress getPeerAddress() {
      return (InetSocketAddress) connection.getPeerAddress();
    }
    @Override
    public int getSecurityStrengthFactor()
    {
        public int getSecurityStrengthFactor() {
      int ssf = 0;
      final SSLEngine sslEngine = SSLUtils.getSSLEngine(connection);
      if (sslEngine != null)
      {
            if (sslEngine != null) {
        final String cipherString = sslEngine.getSession().getCipherSuite();
        for (final Map.Entry<String, Integer> mapEntry : CIPHER_KEY_SIZES
            .entrySet())
        {
          if (cipherString.indexOf(mapEntry.getKey()) >= 0)
          {
                for (final Map.Entry<String, Integer> mapEntry : CIPHER_KEY_SIZES.entrySet()) {
                    if (cipherString.indexOf(mapEntry.getKey()) >= 0) {
            ssf = mapEntry.getValue();
            break;
          }
@@ -280,63 +228,41 @@
      return ssf;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isClosed()
    {
        public boolean isClosed() {
      return isClosed;
    }
    @Override
    public void sendUnsolicitedNotification(final ExtendedResult notification)
    {
        public void sendUnsolicitedNotification(final ExtendedResult notification) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.extendedResult(asn1Writer, 0, notification);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        LDAPServerFilter.notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
    @Override
    public void enableConnectionSecurityLayer(
        final ConnectionSecurityLayer layer)
    {
      synchronized (this)
      {
        installFilter(new ConnectionSecurityLayerFilter(layer, connection
            .getTransport().getMemoryManager()));
        public void enableConnectionSecurityLayer(final ConnectionSecurityLayer layer) {
            synchronized (this) {
                installFilter(new ConnectionSecurityLayerFilter(layer, connection.getTransport()
                        .getMemoryManager()));
      }
    }
    @Override
    public void enableTLS(final SSLContext sslContext,
        final String[] protocols, final String[] suites,
        final boolean wantClientAuth, final boolean needClientAuth)
    {
        public void enableTLS(final SSLContext sslContext, final String[] protocols,
                final String[] suites, final boolean wantClientAuth, final boolean needClientAuth) {
      Validator.ensureNotNull(sslContext);
      synchronized (this)
      {
        if (isTLSEnabled())
        {
            synchronized (this) {
                if (isTLSEnabled()) {
          throw new IllegalStateException("TLS already enabled");
        }
@@ -350,13 +276,10 @@
      }
    }
    /**
     * {@inheritDoc}
     */
    public String toString()
    {
        public String toString() {
      StringBuilder builder = new StringBuilder();
      builder.append("LDAPClientContext(");
      builder.append(getLocalAddress());
@@ -366,50 +289,35 @@
      return builder.toString();
    }
    private void close()
    {
        private void close() {
      isClosed = true;
    }
    private ServerConnection<Integer> getServerConnection()
    {
        private ServerConnection<Integer> getServerConnection() {
      return serverConnection;
    }
    private void setServerConnection(
        final ServerConnection<Integer> serverConnection)
    {
        private void setServerConnection(final ServerConnection<Integer> serverConnection) {
      this.serverConnection = serverConnection;
    }
    /**
     * Installs a new Grizzly filter (e.g. SSL/SASL) beneath the top-level LDAP
     * filter.
         * Installs a new Grizzly filter (e.g. SSL/SASL) beneath the top-level
         * LDAP filter.
     *
     * @param filter
     *          The filter to be installed.
     */
    private void installFilter(final Filter filter)
    {
        private void installFilter(final Filter filter) {
      // Determine the index where the filter should be added.
      final FilterChain oldFilterChain = (FilterChain) connection.getProcessor();
      int filterIndex = oldFilterChain.size() - 1;
      if (filter instanceof SSLFilter)
      {
        // Beneath any ConnectionSecurityLayerFilters if present, otherwise
            if (filter instanceof SSLFilter) {
                // Beneath any ConnectionSecurityLayerFilters if present,
                // otherwise
        // beneath the LDAP filter.
        for (int i = oldFilterChain.size() - 2; i >= 0; i--)
        {
          if (!(oldFilterChain.get(i) instanceof ConnectionSecurityLayerFilter))
          {
                for (int i = oldFilterChain.size() - 2; i >= 0; i--) {
                    if (!(oldFilterChain.get(i) instanceof ConnectionSecurityLayerFilter)) {
            filterIndex = i + 1;
            break;
          }
@@ -417,29 +325,23 @@
      }
      // Create the new filter chain.
      final FilterChain newFilterChain = FilterChainBuilder.stateless()
          .addAll(oldFilterChain).add(filterIndex, filter).build();
            final FilterChain newFilterChain =
                    FilterChainBuilder.stateless().addAll(oldFilterChain).add(filterIndex, filter)
                            .build();
      connection.setProcessor(newFilterChain);
    }
    /**
     * Indicates whether or not TLS is enabled this provided connection.
     *
     * @return {@code true} if TLS is enabled on this connection, otherwise
     *         {@code false}.
     */
    private boolean isTLSEnabled()
    {
      synchronized (this)
      {
        final FilterChain currentFilterChain = (FilterChain) connection
            .getProcessor();
        for (Filter filter : currentFilterChain)
        {
          if (filter instanceof SSLFilter)
          {
        private boolean isTLSEnabled() {
            synchronized (this) {
                final FilterChain currentFilterChain = (FilterChain) connection.getProcessor();
                for (Filter filter : currentFilterChain) {
                    if (filter instanceof SSLFilter) {
            return true;
          }
        }
@@ -449,330 +351,211 @@
  }
  private final class CompareHandler extends AbstractHandler<CompareResult>
  {
    private CompareHandler(final int messageID, final Connection<?> connection)
    {
    private final class CompareHandler extends AbstractHandler<CompareResult> {
        private CompareHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      final Result result = error.getResult();
      if (result instanceof CompareResult)
      {
            if (result instanceof CompareResult) {
        handleResult((CompareResult) result);
      }
      else
      {
        final CompareResult newResult = Responses.newCompareResult(result
            .getResultCode());
            } else {
                final CompareResult newResult = Responses.newCompareResult(result.getResultCode());
        newResult.setDiagnosticMessage(result.getDiagnosticMessage());
        newResult.setMatchedDN(result.getMatchedDN());
        newResult.setCause(result.getCause());
        for (final Control control : result.getControls())
        {
                for (final Control control : result.getControls()) {
          newResult.addControl(control);
        }
        handleResult(newResult);
      }
    }
    @Override
    public void handleResult(final CompareResult result)
    {
        public void handleResult(final CompareResult result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.compareResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class DeleteHandler extends AbstractHandler<Result>
  {
    private DeleteHandler(final int messageID, final Connection<?> connection)
    {
    private final class DeleteHandler extends AbstractHandler<Result> {
        private DeleteHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      handleResult(error.getResult());
    }
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.deleteResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class ExtendedHandler<R extends ExtendedResult> extends
      AbstractHandler<R>
  {
    private ExtendedHandler(final int messageID, final Connection<?> connection)
    {
    private final class ExtendedHandler<R extends ExtendedResult> extends AbstractHandler<R> {
        private ExtendedHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      final Result result = error.getResult();
      if (result instanceof ExtendedResult)
      {
            if (result instanceof ExtendedResult) {
        handleResult((ExtendedResult) result);
      }
      else
      {
        final ExtendedResult newResult = Responses
            .newGenericExtendedResult(result.getResultCode());
            } else {
                final ExtendedResult newResult =
                        Responses.newGenericExtendedResult(result.getResultCode());
        newResult.setDiagnosticMessage(result.getDiagnosticMessage());
        newResult.setMatchedDN(result.getMatchedDN());
        newResult.setCause(result.getCause());
        for (final Control control : result.getControls())
        {
                for (final Control control : result.getControls()) {
          newResult.addControl(control);
        }
        handleResult(newResult);
      }
    }
    @Override
    public void handleResult(final ExtendedResult result)
    {
        public void handleResult(final ExtendedResult result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.extendedResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class ModifyDNHandler extends AbstractHandler<Result>
  {
    private ModifyDNHandler(final int messageID, final Connection<?> connection)
    {
    private final class ModifyDNHandler extends AbstractHandler<Result> {
        private ModifyDNHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      handleResult(error.getResult());
    }
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.modifyDNResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class ModifyHandler extends AbstractHandler<Result>
  {
    private ModifyHandler(final int messageID, final Connection<?> connection)
    {
    private final class ModifyHandler extends AbstractHandler<Result> {
        private ModifyHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      handleResult(error.getResult());
    }
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.modifyResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  private final class SearchHandler extends AbstractHandler<Result> implements
      SearchResultHandler
  {
    private SearchHandler(final int messageID, final Connection<?> connection)
    {
            SearchResultHandler {
        private SearchHandler(final int messageID, final Connection<?> connection) {
      super(messageID, connection);
    }
    @Override
    public boolean handleEntry(final SearchResultEntry entry)
    {
        public boolean handleEntry(final SearchResultEntry entry) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.searchResultEntry(asn1Writer, messageID, entry);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
        return false;
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
      return true;
    }
    @Override
    public void handleErrorResult(final ErrorResultException error)
    {
        public void handleErrorResult(final ErrorResultException error) {
      handleResult(error.getResult());
    }
    @Override
    public boolean handleReference(final SearchResultReference reference)
    {
        public boolean handleReference(final SearchResultReference reference) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.searchResultReference(asn1Writer, messageID, reference);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
        return false;
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
      return true;
    }
    @Override
    public void handleResult(final Result result)
    {
        public void handleResult(final Result result) {
      final ASN1BufferWriter asn1Writer = ASN1BufferWriter.getWriter();
      try
      {
            try {
        LDAP_WRITER.searchResult(asn1Writer, messageID, result);
        connection.write(asn1Writer.getBuffer(), null);
      }
      catch (final IOException ioe)
      {
            } catch (final IOException ioe) {
        notifyConnectionException(connection, ioe);
      }
      finally
      {
            } finally {
        asn1Writer.recycle();
      }
    }
  }
  // Map of cipher phrases to effective key size (bits). Taken from the
  // following RFCs: 5289, 4346, 3268,4132 and 4162.
  private static final Map<String, Integer> CIPHER_KEY_SIZES;
  static
  {
    static {
    CIPHER_KEY_SIZES = new LinkedHashMap<String, Integer>();
    CIPHER_KEY_SIZES.put("_WITH_AES_256_CBC_", 256);
    CIPHER_KEY_SIZES.put("_WITH_CAMELLIA_256_CBC_", 256);
@@ -798,303 +581,215 @@
  private static final Attribute<ASN1BufferReader> LDAP_ASN1_READER_ATTR =
    Grizzly.DEFAULT_ATTRIBUTE_BUILDER.createAttribute("LDAPASN1Reader");
  private static void notifyConnectionClosed(final Connection<?> connection,
      final int messageID, final UnbindRequest unbindRequest)
  {
    final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR
        .remove(connection);
    if (clientContext != null)
    {
    private static void notifyConnectionClosed(final Connection<?> connection, final int messageID,
            final UnbindRequest unbindRequest) {
        final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.remove(connection);
        if (clientContext != null) {
      // Close the connection context.
      clientContext.close();
      // Notify the server connection: it may be null if disconnect is invoked
            // Notify the server connection: it may be null if disconnect is
            // invoked
      // during accept.
      final ServerConnection<Integer> serverConnection = clientContext
          .getServerConnection();
      if (serverConnection != null)
      {
            final ServerConnection<Integer> serverConnection = clientContext.getServerConnection();
            if (serverConnection != null) {
        serverConnection.handleConnectionClosed(messageID, unbindRequest);
      }
      // If this close was a result of an unbind request then the connection
      // won't actually be closed yet. To avoid TIME_WAIT TCP state, let the
            // If this close was a result of an unbind request then the
            // connection
            // won't actually be closed yet. To avoid TIME_WAIT TCP state, let
            // the
      // client disconnect.
      if (unbindRequest != null)
      {
            if (unbindRequest != null) {
        return;
      }
      // Close the connection.
      try
      {
            try {
        connection.close();
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        StaticUtils.DEBUG_LOG.warning("Error closing connection: " + e);
      }
    }
  }
  private static void notifyConnectionDisconnected(
      final Connection<?> connection, final ResultCode resultCode,
      final String message)
  {
    final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR
        .remove(connection);
    if (clientContext != null)
    {
    private static void notifyConnectionDisconnected(final Connection<?> connection,
            final ResultCode resultCode, final String message) {
        final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.remove(connection);
        if (clientContext != null) {
      // Close the connection context.
      clientContext.close();
      // Notify the server connection: it may be null if disconnect is invoked
            // Notify the server connection: it may be null if disconnect is
            // invoked
      // during accept.
      final ServerConnection<Integer> serverConnection = clientContext
          .getServerConnection();
      if (serverConnection != null)
      {
            final ServerConnection<Integer> serverConnection = clientContext.getServerConnection();
            if (serverConnection != null) {
        serverConnection.handleConnectionDisconnected(resultCode, message);
      }
      // Close the connection.
      try
      {
            try {
        connection.close();
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        StaticUtils.DEBUG_LOG.warning("Error closing connection: " + e);
      }
    }
  }
  private static void notifyConnectionException(final Connection<?> connection,
      final Throwable error)
  {
    final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR
        .remove(connection);
    if (clientContext != null)
    {
            final Throwable error) {
        final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.remove(connection);
        if (clientContext != null) {
      // Close the connection context.
      clientContext.close();
      // Notify the server connection: it may be null if disconnect is invoked
            // Notify the server connection: it may be null if disconnect is
            // invoked
      // during accept.
      final ServerConnection<Integer> serverConnection = clientContext
          .getServerConnection();
      if (serverConnection != null)
      {
            final ServerConnection<Integer> serverConnection = clientContext.getServerConnection();
            if (serverConnection != null) {
        serverConnection.handleConnectionError(error);
      }
      // Close the connection.
      try
      {
            try {
        connection.close();
      }
      catch (final IOException e)
      {
            } catch (final IOException e) {
        StaticUtils.DEBUG_LOG.warning("Error closing connection: " + e);
      }
    }
  }
  private final AbstractLDAPMessageHandler<FilterChainContext> serverRequestHandler =
    new AbstractLDAPMessageHandler<FilterChainContext>()
  {
            new AbstractLDAPMessageHandler<FilterChainContext>() {
    @Override
    public void abandonRequest(final FilterChainContext ctx,
        final int messageID, final AbandonRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
                public void abandonRequest(final FilterChainContext ctx, final int messageID,
                        final AbandonRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
        conn.handleAbandon(messageID, request);
      }
    }
    @Override
    public void addRequest(final FilterChainContext ctx, final int messageID,
        final AddRequest request) throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final AddHandler handler = new AddHandler(messageID,
            ctx.getConnection());
                        final AddRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final AddHandler handler = new AddHandler(messageID, ctx.getConnection());
        conn.handleAdd(messageID, request, handler, handler);
      }
    }
    @Override
    public void bindRequest(final FilterChainContext ctx, final int messageID,
        final int version, final GenericBindRequest bindContext)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final BindHandler handler = new BindHandler(messageID,
            ctx.getConnection());
                        throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final BindHandler handler = new BindHandler(messageID, ctx.getConnection());
        conn.handleBind(messageID, version, bindContext, handler, handler);
      }
    }
    @Override
    public void compareRequest(final FilterChainContext ctx,
        final int messageID, final CompareRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final CompareHandler handler = new CompareHandler(messageID,
            ctx.getConnection());
                public void compareRequest(final FilterChainContext ctx, final int messageID,
                        final CompareRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final CompareHandler handler =
                                new CompareHandler(messageID, ctx.getConnection());
        conn.handleCompare(messageID, request, handler, handler);
      }
    }
    @Override
    public void deleteRequest(final FilterChainContext ctx,
        final int messageID, final DeleteRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final DeleteHandler handler = new DeleteHandler(messageID,
            ctx.getConnection());
                public void deleteRequest(final FilterChainContext ctx, final int messageID,
                        final DeleteRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final DeleteHandler handler =
                                new DeleteHandler(messageID, ctx.getConnection());
        conn.handleDelete(messageID, request, handler, handler);
      }
    }
    @Override
    public <R extends ExtendedResult> void extendedRequest(
        final FilterChainContext ctx, final int messageID,
        final ExtendedRequest<R> request) throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final ExtendedHandler<R> handler = new ExtendedHandler<R>(messageID,
            ctx.getConnection());
                        final ExtendedRequest<R> request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final ExtendedHandler<R> handler =
                                new ExtendedHandler<R>(messageID, ctx.getConnection());
        conn.handleExtendedRequest(messageID, request, handler, handler);
      }
    }
    @Override
    public void modifyDNRequest(final FilterChainContext ctx,
        final int messageID, final ModifyDNRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final ModifyDNHandler handler = new ModifyDNHandler(messageID,
            ctx.getConnection());
                public void modifyDNRequest(final FilterChainContext ctx, final int messageID,
                        final ModifyDNRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final ModifyDNHandler handler =
                                new ModifyDNHandler(messageID, ctx.getConnection());
        conn.handleModifyDN(messageID, request, handler, handler);
      }
    }
    @Override
    public void modifyRequest(final FilterChainContext ctx,
        final int messageID, final ModifyRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final ModifyHandler handler = new ModifyHandler(messageID,
            ctx.getConnection());
                public void modifyRequest(final FilterChainContext ctx, final int messageID,
                        final ModifyRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final ModifyHandler handler =
                                new ModifyHandler(messageID, ctx.getConnection());
        conn.handleModify(messageID, request, handler, handler);
      }
    }
    @Override
    public void searchRequest(final FilterChainContext ctx,
        final int messageID, final SearchRequest request)
        throws UnexpectedRequestException
    {
      final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(ctx
          .getConnection());
      if (clientContext != null)
      {
        final ServerConnection<Integer> conn = clientContext
            .getServerConnection();
        final SearchHandler handler = new SearchHandler(messageID,
            ctx.getConnection());
                public void searchRequest(final FilterChainContext ctx, final int messageID,
                        final SearchRequest request) throws UnexpectedRequestException {
                    final ClientContextImpl clientContext =
                            LDAP_CONNECTION_ATTR.get(ctx.getConnection());
                    if (clientContext != null) {
                        final ServerConnection<Integer> conn = clientContext.getServerConnection();
                        final SearchHandler handler =
                                new SearchHandler(messageID, ctx.getConnection());
        conn.handleSearch(messageID, request, handler, handler);
      }
    }
    @Override
    public void unbindRequest(final FilterChainContext ctx,
        final int messageID, final UnbindRequest request)
    {
                public void unbindRequest(final FilterChainContext ctx, final int messageID,
                        final UnbindRequest request) {
      notifyConnectionClosed(ctx.getConnection(), messageID, request);
    }
    @Override
    public void unrecognizedMessage(final FilterChainContext ctx,
        final int messageID, final byte messageTag,
        final ByteString messageBytes)
    {
      notifyConnectionException(ctx.getConnection(),
          new UnsupportedMessageException(messageID, messageTag, messageBytes));
                public void unrecognizedMessage(final FilterChainContext ctx, final int messageID,
                        final byte messageTag, final ByteString messageBytes) {
                    notifyConnectionException(ctx.getConnection(), new UnsupportedMessageException(
                            messageID, messageTag, messageBytes));
    }
  };
@@ -1104,84 +799,58 @@
  private final LDAPListenerImpl listener;
  LDAPServerFilter(final LDAPListenerImpl listener,
      final LDAPReader ldapReader, final int maxASN1ElementSize)
  {
    LDAPServerFilter(final LDAPListenerImpl listener, final LDAPReader ldapReader,
            final int maxASN1ElementSize) {
    this.listener = listener;
    this.ldapReader = ldapReader;
    this.maxASN1ElementSize = maxASN1ElementSize;
  }
  @Override
  public void exceptionOccurred(final FilterChainContext ctx,
      final Throwable error)
  {
    public void exceptionOccurred(final FilterChainContext ctx, final Throwable error) {
    notifyConnectionException(ctx.getConnection(), error);
  }
  @Override
  public NextAction handleAccept(final FilterChainContext ctx)
      throws IOException
  {
    public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
    final Connection<?> connection = ctx.getConnection();
    connection.configureBlocking(true);
    try
    {
        try {
      final ClientContextImpl clientContext = new ClientContextImpl(connection);
      final ServerConnection<Integer> serverConn = listener
          .getConnectionFactory().handleAccept(clientContext);
            final ServerConnection<Integer> serverConn =
                    listener.getConnectionFactory().handleAccept(clientContext);
      clientContext.setServerConnection(serverConn);
      LDAP_CONNECTION_ATTR.set(connection, clientContext);
    }
    catch (final ErrorResultException e)
    {
        } catch (final ErrorResultException e) {
      connection.close();
    }
    return ctx.getStopAction();
  }
  @Override
  public NextAction handleClose(final FilterChainContext ctx)
      throws IOException
  {
    public NextAction handleClose(final FilterChainContext ctx) throws IOException {
    notifyConnectionClosed(ctx.getConnection(), -1, null);
    return ctx.getStopAction();
  }
  @Override
  public NextAction handleRead(final FilterChainContext ctx) throws IOException
  {
    public NextAction handleRead(final FilterChainContext ctx) throws IOException {
    final Buffer buffer = (Buffer) ctx.getMessage();
    ASN1BufferReader asn1Reader = LDAP_ASN1_READER_ATTR
        .get(ctx.getConnection());
    if (asn1Reader == null)
    {
      asn1Reader = new ASN1BufferReader(maxASN1ElementSize, ctx.getConnection()
          .getTransport().getMemoryManager());
        ASN1BufferReader asn1Reader = LDAP_ASN1_READER_ATTR.get(ctx.getConnection());
        if (asn1Reader == null) {
            asn1Reader =
                    new ASN1BufferReader(maxASN1ElementSize, ctx.getConnection().getTransport()
                            .getMemoryManager());
      LDAP_ASN1_READER_ATTR.set(ctx.getConnection(), asn1Reader);
    }
    asn1Reader.appendBytesRead(buffer);
    try
    {
      while (asn1Reader.elementAvailable())
      {
        try {
            while (asn1Reader.elementAvailable()) {
        ldapReader.decode(asn1Reader, serverRequestHandler, ctx);
      }
    }
    finally
    {
        } finally {
      asn1Reader.disposeBytesRead();
    }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPUtils.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.*;
import java.io.IOException;
@@ -38,294 +35,213 @@
import org.forgerock.opendj.asn1.ASN1Reader;
import org.forgerock.opendj.asn1.ASN1Writer;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.FilterVisitor;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
/**
 * Common LDAP utility methods which may be used when implementing new controls
 * and extension.
 */
public final class LDAPUtils
{
public final class LDAPUtils {
  private static final FilterVisitor<IOException, ASN1Writer> ASN1_ENCODER =
    new FilterVisitor<IOException, ASN1Writer>()
  {
            new FilterVisitor<IOException, ASN1Writer>() {
    public IOException visitAndFilter(final ASN1Writer writer,
        final List<Filter> subFilters)
    {
      try
      {
                        final List<Filter> subFilters) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_AND);
        for (final Filter subFilter : subFilters)
        {
                        for (final Filter subFilter : subFilters) {
          final IOException e = subFilter.accept(this, writer);
          if (e != null)
          {
                            if (e != null) {
            return e;
          }
        }
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitApproxMatchFilter(final ASN1Writer writer,
        final String attributeDescription, final ByteString assertionValue)
    {
      try
      {
                        final String attributeDescription, final ByteString assertionValue) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_APPROXIMATE);
        writer.writeOctetString(attributeDescription);
        writer.writeOctetString(assertionValue);
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitEqualityMatchFilter(final ASN1Writer writer,
        final String attributeDescription, final ByteString assertionValue)
    {
      try
      {
                        final String attributeDescription, final ByteString assertionValue) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_EQUALITY);
        writer.writeOctetString(attributeDescription);
        writer.writeOctetString(assertionValue);
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitExtensibleMatchFilter(final ASN1Writer writer,
        final String matchingRule, final String attributeDescription,
        final ByteString assertionValue, final boolean dnAttributes)
    {
      try
      {
                        final ByteString assertionValue, final boolean dnAttributes) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_EXTENSIBLE_MATCH);
        if (matchingRule != null)
        {
                        if (matchingRule != null) {
          writer.writeOctetString(TYPE_MATCHING_RULE_ID, matchingRule);
        }
        if (attributeDescription != null)
        {
          writer
              .writeOctetString(TYPE_MATCHING_RULE_TYPE, attributeDescription);
                        if (attributeDescription != null) {
                            writer.writeOctetString(TYPE_MATCHING_RULE_TYPE, attributeDescription);
        }
        writer.writeOctetString(TYPE_MATCHING_RULE_VALUE, assertionValue);
        if (dnAttributes)
        {
                        if (dnAttributes) {
          writer.writeBoolean(TYPE_MATCHING_RULE_DN_ATTRIBUTES, true);
        }
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitGreaterOrEqualFilter(final ASN1Writer writer,
        final String attributeDescription, final ByteString assertionValue)
    {
      try
      {
                        final String attributeDescription, final ByteString assertionValue) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_GREATER_OR_EQUAL);
        writer.writeOctetString(attributeDescription);
        writer.writeOctetString(assertionValue);
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitLessOrEqualFilter(final ASN1Writer writer,
        final String attributeDescription, final ByteString assertionValue)
    {
      try
      {
                        final String attributeDescription, final ByteString assertionValue) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_LESS_OR_EQUAL);
        writer.writeOctetString(attributeDescription);
        writer.writeOctetString(assertionValue);
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitNotFilter(final ASN1Writer writer,
        final Filter subFilter)
    {
      try
      {
                public IOException visitNotFilter(final ASN1Writer writer, final Filter subFilter) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_NOT);
        final IOException e = subFilter.accept(this, writer);
        if (e != null)
        {
                        if (e != null) {
          return e;
        }
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitOrFilter(final ASN1Writer writer,
        final List<Filter> subFilters)
    {
      try
      {
                        final List<Filter> subFilters) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_OR);
        for (final Filter subFilter : subFilters)
        {
                        for (final Filter subFilter : subFilters) {
          final IOException e = subFilter.accept(this, writer);
          if (e != null)
          {
                            if (e != null) {
            return e;
          }
        }
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitPresentFilter(final ASN1Writer writer,
        final String attributeDescription)
    {
      try
      {
                        final String attributeDescription) {
                    try {
        writer.writeOctetString(TYPE_FILTER_PRESENCE, attributeDescription);
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitSubstringsFilter(final ASN1Writer writer,
        final String attributeDescription, final ByteString initialSubstring,
        final List<ByteString> anySubstrings, final ByteString finalSubstring)
    {
      try
      {
                        final List<ByteString> anySubstrings, final ByteString finalSubstring) {
                    try {
        writer.writeStartSequence(TYPE_FILTER_SUBSTRING);
        writer.writeOctetString(attributeDescription);
        writer.writeStartSequence();
        if (initialSubstring != null)
        {
                        if (initialSubstring != null) {
          writer.writeOctetString(TYPE_SUBINITIAL, initialSubstring);
        }
        for (final ByteSequence anySubstring : anySubstrings)
        {
                        for (final ByteSequence anySubstring : anySubstrings) {
          writer.writeOctetString(TYPE_SUBANY, anySubstring);
        }
        if (finalSubstring != null)
        {
                        if (finalSubstring != null) {
          writer.writeOctetString(TYPE_SUBFINAL, finalSubstring);
        }
        writer.writeEndSequence();
        writer.writeEndSequence();
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
    public IOException visitUnrecognizedFilter(final ASN1Writer writer,
        final byte filterTag, final ByteString filterBytes)
    {
      try
      {
                        final byte filterTag, final ByteString filterBytes) {
                    try {
        writer.writeOctetString(filterTag, filterBytes);
        return null;
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        return e;
      }
    }
  };
  /**
   * Reads the next ASN.1 element from the provided {@code ASN1Reader} as a
   * {@code Filter}.
   *
   * @param reader
   *          The {@code ASN1Reader} from which the ASN.1 encoded {@code Filter}
   *          should be read.
     *            The {@code ASN1Reader} from which the ASN.1 encoded
     *            {@code Filter} should be read.
   * @return The decoded {@code Filter}.
   * @throws IOException
   *           If an error occurs while reading from {@code reader}.
   */
  public static Filter decodeFilter(final ASN1Reader reader) throws IOException
  {
    public static Filter decodeFilter(final ASN1Reader reader) throws IOException {
    final byte type = reader.peekType();
    switch (type)
    {
        switch (type) {
    case TYPE_FILTER_AND:
      return decodeAndFilter(reader);
@@ -361,65 +277,54 @@
    }
  }
  /**
   * Reads the next ASN.1 element from the provided {@code ASN1Reader} as a
   * {@code SearchResultEntry}.
   *
   * @param reader
   *          The {@code ASN1Reader} from which the ASN.1 encoded {@code
   *          SearchResultEntry} should be read.
     *            The {@code ASN1Reader} from which the ASN.1 encoded
     *            {@code SearchResultEntry} should be read.
   * @param options
   *          The decode options to use when decoding the entry.
   * @return The decoded {@code SearchResultEntry}.
   * @throws IOException
   *           If an error occurs while reading from {@code reader}.
   */
  public static SearchResultEntry decodeSearchResultEntry(
      final ASN1Reader reader, final DecodeOptions options) throws IOException
  {
    public static SearchResultEntry decodeSearchResultEntry(final ASN1Reader reader,
            final DecodeOptions options) throws IOException {
    return LDAPReader.decodeEntry(reader, options);
  }
  /**
   * Writes the ASN.1 encoding of the provided {@code Filter} to the provided
   * {@code ASN1Writer}.
   *
   * @param writer
   *          The {@code ASN1Writer} to which the ASN.1 encoding of the provided
   *          {@code Filter} should be written.
     *            The {@code ASN1Writer} to which the ASN.1 encoding of the
     *            provided {@code Filter} should be written.
   * @param filter
   *          The filter to be encoded.
   * @return The updated {@code ASN1Writer}.
   * @throws IOException
   *           If an error occurs while writing to {@code writer}.
   */
  public static ASN1Writer encodeFilter(final ASN1Writer writer,
      final Filter filter) throws IOException
  {
    public static ASN1Writer encodeFilter(final ASN1Writer writer, final Filter filter)
            throws IOException {
    final IOException e = filter.accept(ASN1_ENCODER, writer);
    if (e != null)
    {
        if (e != null) {
      throw e;
    }
    else
    {
        } else {
      return writer;
    }
  }
  /**
   * Writes the ASN.1 encoding of the provided {@code SearchResultEntry} to the
   * provided {@code ASN1Writer}.
     * Writes the ASN.1 encoding of the provided {@code SearchResultEntry} to
     * the provided {@code ASN1Writer}.
   *
   * @param writer
   *          The {@code ASN1Writer} to which the ASN.1 encoding of the provided
   *          {@code SearchResultEntry} should be written.
     *            The {@code ASN1Writer} to which the ASN.1 encoding of the
     *            provided {@code SearchResultEntry} should be written.
   * @param entry
   *          The Search Result Entry to be encoded.
   * @return The updated {@code ASN1Writer}.
@@ -427,301 +332,211 @@
   *           If an error occurs while writing to {@code writer}.
   */
  public static ASN1Writer encodeSearchResultEntry(final ASN1Writer writer,
      final SearchResultEntry entry) throws IOException
  {
            final SearchResultEntry entry) throws IOException {
    // FIXME: this should include Controls.
    LDAPWriter.encodeEntry(writer, entry);
    return writer;
  }
  // Decodes an and filter.
  private static Filter decodeAndFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeAndFilter(final ASN1Reader reader) throws IOException {
    Filter filter;
    reader.readStartSequence(TYPE_FILTER_AND);
    try
    {
      if (reader.hasNextElement())
      {
        try {
            if (reader.hasNextElement()) {
        final List<Filter> subFilters = new LinkedList<Filter>();
        do
        {
                do {
          subFilters.add(decodeFilter(reader));
        }
        while (reader.hasNextElement());
                } while (reader.hasNextElement());
        filter = Filter.newAndFilter(subFilters);
      }
      else
      {
            } else {
        // No sub-filters - this is an RFC 4526 absolute true filter.
        filter = Filter.getAbsoluteTrueFilter();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return filter;
  }
  // Decodes an approximate match filter.
  private static Filter decodeApproxMatchFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeApproxMatchFilter(final ASN1Reader reader) throws IOException {
    String attributeDescription;
    ByteString assertionValue;
    reader.readStartSequence(TYPE_FILTER_APPROXIMATE);
    try
    {
        try {
      attributeDescription = reader.readOctetStringAsString();
      assertionValue = reader.readOctetString();
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newApproxMatchFilter(attributeDescription, assertionValue);
  }
  // Decodes an equality match filter.
  private static Filter decodeEqualityMatchFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeEqualityMatchFilter(final ASN1Reader reader) throws IOException {
    String attributeDescription;
    ByteString assertionValue;
    reader.readStartSequence(TYPE_FILTER_EQUALITY);
    try
    {
        try {
      attributeDescription = reader.readOctetStringAsString();
      assertionValue = reader.readOctetString();
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newEqualityMatchFilter(attributeDescription, assertionValue);
  }
  // Decodes an extensible match filter.
  private static Filter decodeExtensibleMatchFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeExtensibleMatchFilter(final ASN1Reader reader) throws IOException {
    String matchingRule;
    String attributeDescription;
    boolean dnAttributes;
    ByteString assertionValue;
    reader.readStartSequence(TYPE_FILTER_EXTENSIBLE_MATCH);
    try
    {
        try {
      matchingRule = null;
      if (reader.peekType() == TYPE_MATCHING_RULE_ID)
      {
            if (reader.peekType() == TYPE_MATCHING_RULE_ID) {
        matchingRule = reader.readOctetStringAsString(TYPE_MATCHING_RULE_ID);
      }
      attributeDescription = null;
      if (reader.peekType() == TYPE_MATCHING_RULE_TYPE)
      {
        attributeDescription = reader
            .readOctetStringAsString(TYPE_MATCHING_RULE_TYPE);
            if (reader.peekType() == TYPE_MATCHING_RULE_TYPE) {
                attributeDescription = reader.readOctetStringAsString(TYPE_MATCHING_RULE_TYPE);
      }
      dnAttributes = false;
      if (reader.hasNextElement()
          && (reader.peekType() == TYPE_MATCHING_RULE_DN_ATTRIBUTES))
      {
            if (reader.hasNextElement() && (reader.peekType() == TYPE_MATCHING_RULE_DN_ATTRIBUTES)) {
        dnAttributes = reader.readBoolean();
      }
      assertionValue = reader.readOctetString(TYPE_MATCHING_RULE_VALUE);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newExtensibleMatchFilter(matchingRule, attributeDescription,
        assertionValue, dnAttributes);
        return Filter.newExtensibleMatchFilter(matchingRule, attributeDescription, assertionValue,
                dnAttributes);
  }
  // Decodes a greater than or equal filter.
  private static Filter decodeGreaterOrEqualMatchFilter(final ASN1Reader reader)
      throws IOException
  {
            throws IOException {
    String attributeDescription;
    ByteString assertionValue;
    reader.readStartSequence(TYPE_FILTER_GREATER_OR_EQUAL);
    try
    {
        try {
      attributeDescription = reader.readOctetStringAsString();
      assertionValue = reader.readOctetString();
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newGreaterOrEqualFilter(attributeDescription, assertionValue);
  }
  // Decodes a less than or equal filter.
  private static Filter decodeLessOrEqualMatchFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeLessOrEqualMatchFilter(final ASN1Reader reader) throws IOException {
    String attributeDescription;
    ByteString assertionValue;
    reader.readStartSequence(TYPE_FILTER_LESS_OR_EQUAL);
    try
    {
        try {
      attributeDescription = reader.readOctetStringAsString();
      assertionValue = reader.readOctetString();
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newLessOrEqualFilter(attributeDescription, assertionValue);
  }
  // Decodes a not filter.
  private static Filter decodeNotFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeNotFilter(final ASN1Reader reader) throws IOException {
    Filter subFilter;
    reader.readStartSequence(TYPE_FILTER_NOT);
    try
    {
        try {
      subFilter = decodeFilter(reader);
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return Filter.newNotFilter(subFilter);
  }
  // Decodes an or filter.
  private static Filter decodeOrFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeOrFilter(final ASN1Reader reader) throws IOException {
    Filter filter;
    reader.readStartSequence(TYPE_FILTER_OR);
    try
    {
      if (reader.hasNextElement())
      {
        try {
            if (reader.hasNextElement()) {
        final List<Filter> subFilters = new LinkedList<Filter>();
        do
        {
                do {
          subFilters.add(decodeFilter(reader));
        }
        while (reader.hasNextElement());
                } while (reader.hasNextElement());
        filter = Filter.newOrFilter(subFilters);
      }
      else
      {
            } else {
        // No sub-filters - this is an RFC 4526 absolute false filter.
        filter = Filter.getAbsoluteFalseFilter();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    return filter;
  }
  // Decodes a sub-strings filter.
  private static Filter decodeSubstringsFilter(final ASN1Reader reader)
      throws IOException
  {
    private static Filter decodeSubstringsFilter(final ASN1Reader reader) throws IOException {
    ByteString initialSubstring = null;
    List<ByteString> anySubstrings = null;
    ByteString finalSubstring = null;
    String attributeDescription;
    reader.readStartSequence(TYPE_FILTER_SUBSTRING);
    try
    {
        try {
      attributeDescription = reader.readOctetStringAsString();
      reader.readStartSequence();
      try
      {
            try {
        // FIXME: There should be at least one element in this substring
        // filter sequence.
        if (reader.peekType() == TYPE_SUBINITIAL)
        {
                if (reader.peekType() == TYPE_SUBINITIAL) {
          initialSubstring = reader.readOctetString(TYPE_SUBINITIAL);
        }
        if (reader.hasNextElement() && (reader.peekType() == TYPE_SUBANY))
        {
                if (reader.hasNextElement() && (reader.peekType() == TYPE_SUBANY)) {
          anySubstrings = new LinkedList<ByteString>();
          do
          {
                    do {
            anySubstrings.add(reader.readOctetString(TYPE_SUBANY));
                    } while (reader.hasNextElement() && (reader.peekType() == TYPE_SUBANY));
          }
          while (reader.hasNextElement() && (reader.peekType() == TYPE_SUBANY));
        }
        if (reader.hasNextElement() && (reader.peekType() == TYPE_SUBFINAL))
        {
                if (reader.hasNextElement() && (reader.peekType() == TYPE_SUBFINAL)) {
          finalSubstring = reader.readOctetString(TYPE_SUBFINAL);
        }
      }
      finally
      {
            } finally {
        reader.readEndSequence();
      }
    }
    finally
    {
        } finally {
      reader.readEndSequence();
    }
    if (anySubstrings == null)
    {
        if (anySubstrings == null) {
      anySubstrings = Collections.emptyList();
    }
    return Filter.newSubstringsFilter(attributeDescription, initialSubstring,
        anySubstrings, finalSubstring);
        return Filter.newSubstringsFilter(attributeDescription, initialSubstring, anySubstrings,
                finalSubstring);
  }
  /**
   * Prevent instantiation.
   */
  private LDAPUtils()
  {
    private LDAPUtils() {
    // Nothing to do.
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPWriter.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap;
import static com.forgerock.opendj.ldap.LDAPConstants.*;
import java.io.IOException;
@@ -42,62 +39,65 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.Modification;
import org.forgerock.opendj.ldap.controls.Control;
import org.forgerock.opendj.ldap.requests.*;
import org.forgerock.opendj.ldap.responses.*;
import org.forgerock.opendj.ldap.requests.AbandonRequest;
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
import org.forgerock.opendj.ldap.requests.DeleteRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
import org.forgerock.opendj.ldap.requests.GenericBindRequest;
import org.forgerock.opendj.ldap.requests.ModifyDNRequest;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
import org.forgerock.opendj.ldap.requests.Request;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.requests.UnbindRequest;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.CompareResult;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.IntermediateResponse;
import org.forgerock.opendj.ldap.responses.Response;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import com.forgerock.opendj.util.StaticUtils;
/**
 * Static methods for encoding LDAP messages.
 */
final class LDAPWriter implements LDAPMessageHandler<ASN1Writer>
{
  public static void encodeControl(final ASN1Writer writer,
      final Control control) throws IOException
  {
final class LDAPWriter implements LDAPMessageHandler<ASN1Writer> {
    public static void encodeControl(final ASN1Writer writer, final Control control)
            throws IOException {
    writer.writeStartSequence();
    writer.writeOctetString(control.getOID());
    if (control.isCritical())
    {
        if (control.isCritical()) {
      writer.writeBoolean(control.isCritical());
    }
    if (control.getValue() != null)
    {
        if (control.getValue() != null) {
      writer.writeOctetString(control.getValue());
    }
    writer.writeEndSequence();
  }
  public static void encodeEntry(final ASN1Writer writer,
      final SearchResultEntry searchResultEntry) throws IOException
  {
            final SearchResultEntry searchResultEntry) throws IOException {
    writer.writeStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY);
    writer.writeOctetString(searchResultEntry.getName().toString());
    writer.writeStartSequence();
    for (final Attribute attr : searchResultEntry.getAllAttributes())
    {
        for (final Attribute attr : searchResultEntry.getAllAttributes()) {
      encodeAttribute(writer, attr);
    }
    writer.writeEndSequence();
    writer.writeEndSequence();
  }
  private static void encodeAttribute(final ASN1Writer writer,
      final Attribute attribute) throws IOException
  {
    private static void encodeAttribute(final ASN1Writer writer, final Attribute attribute)
            throws IOException {
    writer.writeStartSequence();
    writer.writeOctetString(attribute.getAttributeDescriptionAsString());
    writer.writeStartSet();
    for (final ByteString value : attribute)
    {
        for (final ByteString value : attribute) {
      writer.writeOctetString(value);
    }
    writer.writeEndSequence();
@@ -105,28 +105,20 @@
    writer.writeEndSequence();
  }
  private static void encodeChange(final ASN1Writer writer,
      final Modification change) throws IOException
  {
    private static void encodeChange(final ASN1Writer writer, final Modification change)
            throws IOException {
    writer.writeStartSequence();
    writer.writeEnumerated(change.getModificationType().intValue());
    encodeAttribute(writer, change.getAttribute());
    writer.writeEndSequence();
  }
  private static void encodeMessageFooter(final ASN1Writer writer,
      final Request request) throws IOException
  {
    private static void encodeMessageFooter(final ASN1Writer writer, final Request request)
            throws IOException {
    final List<Control> controls = request.getControls();
    if (!controls.isEmpty())
    {
        if (!controls.isEmpty()) {
      writer.writeStartSequence(TYPE_CONTROL_SEQUENCE);
      for (final Control control : controls)
      {
            for (final Control control : controls) {
        encodeControl(writer, control);
      }
      writer.writeEndSequence();
@@ -135,17 +127,12 @@
    writer.writeEndSequence();
  }
  private static void encodeMessageFooter(final ASN1Writer writer,
      final Response response) throws IOException
  {
    private static void encodeMessageFooter(final ASN1Writer writer, final Response response)
            throws IOException {
    final List<Control> controls = response.getControls();
    if (!controls.isEmpty())
    {
        if (!controls.isEmpty()) {
      writer.writeStartSequence(TYPE_CONTROL_SEQUENCE);
      for (final Control control : controls)
      {
            for (final Control control : controls) {
        encodeControl(writer, control);
      }
      writer.writeEndSequence();
@@ -154,71 +141,49 @@
    writer.writeEndSequence();
  }
  private static void encodeMessageHeader(final ASN1Writer writer,
      final int messageID) throws IOException
  {
    private static void encodeMessageHeader(final ASN1Writer writer, final int messageID)
            throws IOException {
    writer.writeStartSequence();
    writer.writeInteger(messageID);
  }
  private static void encodeResultFooter(final ASN1Writer writer)
      throws IOException
  {
    private static void encodeResultFooter(final ASN1Writer writer) throws IOException {
    writer.writeEndSequence();
  }
  private static void encodeResultHeader(final ASN1Writer writer,
      final byte typeTag, final Result rawMessage) throws IOException
  {
    private static void encodeResultHeader(final ASN1Writer writer, final byte typeTag,
            final Result rawMessage) throws IOException {
    writer.writeStartSequence(typeTag);
    writer.writeEnumerated(rawMessage.getResultCode().intValue());
    writer.writeOctetString(rawMessage.getMatchedDN());
    writer.writeOctetString(rawMessage.getDiagnosticMessage());
    final List<String> referralURIs = rawMessage.getReferralURIs();
    if (!referralURIs.isEmpty())
    {
        if (!referralURIs.isEmpty()) {
      writer.writeStartSequence(TYPE_REFERRAL_SEQUENCE);
      for (final String s : referralURIs)
      {
            for (final String s : referralURIs) {
        writer.writeOctetString(s);
      }
      writer.writeEndSequence();
    }
  }
  public void abandonRequest(final ASN1Writer writer, final int messageID,
      final AbandonRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final AbandonRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP ABANDON REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP ABANDON REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeInteger(OP_TYPE_ABANDON_REQUEST, request.getRequestID());
    encodeMessageFooter(writer, request);
  }
  public void addRequest(final ASN1Writer writer, final int messageID,
      final AddRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void addRequest(final ASN1Writer writer, final int messageID, final AddRequest request)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP ADD REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP ADD REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_ADD_REQUEST);
@@ -226,8 +191,7 @@
    // Write the attributes
    writer.writeStartSequence();
    for (final Attribute attr : request.getAllAttributes())
    {
        for (final Attribute attr : request.getAllAttributes()) {
      encodeAttribute(writer, attr);
    }
    writer.writeEndSequence();
@@ -236,17 +200,11 @@
    encodeMessageFooter(writer, request);
  }
  public void addResult(final ASN1Writer writer, final int messageID,
      final Result result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
      StaticUtils.DEBUG_LOG
          .finer(String.format(
              "ENCODE LDAP ADD RESULT(messageID=%d, result=%s)", messageID,
              result));
    public void addResult(final ASN1Writer writer, final int messageID, final Result result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
            StaticUtils.DEBUG_LOG.finer(String.format(
                    "ENCODE LDAP ADD RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_ADD_RESPONSE, result);
@@ -254,64 +212,47 @@
    encodeMessageFooter(writer, result);
  }
  public void bindRequest(final ASN1Writer writer, final int messageID,
      final int version, final GenericBindRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void bindRequest(final ASN1Writer writer, final int messageID, final int version,
            final GenericBindRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP BIND REQUEST(messageID=%d, auth=0x%x, request=%s)",
          messageID, request.getAuthenticationType(), request));
                    "ENCODE LDAP BIND REQUEST(messageID=%d, auth=0x%x, request=%s)", messageID,
                    request.getAuthenticationType(), request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_BIND_REQUEST);
    writer.writeInteger(version);
    writer.writeOctetString(request.getName());
    writer.writeOctetString(request.getAuthenticationType(), request
        .getAuthenticationValue());
        writer.writeOctetString(request.getAuthenticationType(), request.getAuthenticationValue());
    writer.writeEndSequence();
    encodeMessageFooter(writer, request);
  }
  public void bindResult(final ASN1Writer writer, final int messageID,
      final BindResult result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
      StaticUtils.DEBUG_LOG.finer(String
          .format("ENCODE LDAP BIND RESULT(messageID=%d, result=%s)",
              messageID, result));
    public void bindResult(final ASN1Writer writer, final int messageID, final BindResult result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
            StaticUtils.DEBUG_LOG.finer(String.format(
                    "ENCODE LDAP BIND RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_BIND_RESPONSE, result);
    final ByteString saslCredentials = result.getServerSASLCredentials();
    if (saslCredentials != null && saslCredentials.length() > 0)
    {
      writer.writeOctetString(TYPE_SERVER_SASL_CREDENTIALS, result
          .getServerSASLCredentials());
        if (saslCredentials != null && saslCredentials.length() > 0) {
            writer.writeOctetString(TYPE_SERVER_SASL_CREDENTIALS, result.getServerSASLCredentials());
    }
    encodeResultFooter(writer);
    encodeMessageFooter(writer, result);
  }
  public void compareRequest(final ASN1Writer writer, final int messageID,
      final CompareRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final CompareRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP COMPARE REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP COMPARE REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_COMPARE_REQUEST);
@@ -326,16 +267,11 @@
    encodeMessageFooter(writer, request);
  }
  public void compareResult(final ASN1Writer writer, final int messageID,
      final CompareResult result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final CompareResult result) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP COMPARE RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP COMPARE RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_COMPARE_RESPONSE, result);
@@ -343,33 +279,22 @@
    encodeMessageFooter(writer, result);
  }
  public void deleteRequest(final ASN1Writer writer, final int messageID,
      final DeleteRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final DeleteRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP DELETE REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP DELETE REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeOctetString(OP_TYPE_DELETE_REQUEST, request.getName()
        .toString());
        writer.writeOctetString(OP_TYPE_DELETE_REQUEST, request.getName().toString());
    encodeMessageFooter(writer, request);
  }
  public void deleteResult(final ASN1Writer writer, final int messageID,
      final Result result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void deleteResult(final ASN1Writer writer, final int messageID, final Result result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP DELETE RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP DELETE RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_DELETE_RESPONSE, result);
@@ -377,25 +302,18 @@
    encodeMessageFooter(writer, result);
  }
  public <R extends ExtendedResult> void extendedRequest(
      final ASN1Writer writer, final int messageID,
      final ExtendedRequest<R> request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public <R extends ExtendedResult> void extendedRequest(final ASN1Writer writer,
            final int messageID, final ExtendedRequest<R> request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP EXTENDED REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP EXTENDED REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_EXTENDED_REQUEST);
    writer.writeOctetString(TYPE_EXTENDED_REQUEST_OID, request.getOID());
    final ByteString requestValue = request.getValue();
    if (requestValue != null)
    {
        if (requestValue != null) {
      writer.writeOctetString(TYPE_EXTENDED_REQUEST_VALUE, requestValue);
    }
@@ -403,16 +321,11 @@
    encodeMessageFooter(writer, request);
  }
  public void extendedResult(final ASN1Writer writer, final int messageID,
      final ExtendedResult result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final ExtendedResult result) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP EXTENDED RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP EXTENDED RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_EXTENDED_RESPONSE, result);
@@ -420,13 +333,11 @@
    final String responseName = result.getOID();
    final ByteString responseValue = result.getValue();
    if (responseName != null)
    {
        if (responseName != null) {
      writer.writeOctetString(TYPE_EXTENDED_RESPONSE_OID, responseName);
    }
    if (responseValue != null)
    {
        if (responseValue != null) {
      writer.writeOctetString(TYPE_EXTENDED_RESPONSE_VALUE, responseValue);
    }
@@ -434,17 +345,12 @@
    encodeMessageFooter(writer, result);
  }
  public void intermediateResponse(final ASN1Writer writer,
      final int messageID, final IntermediateResponse response)
      throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void intermediateResponse(final ASN1Writer writer, final int messageID,
            final IntermediateResponse response) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP INTERMEDIATE RESPONSE(messageID=%d, response=%s)",
          messageID, response));
                    "ENCODE LDAP INTERMEDIATE RESPONSE(messageID=%d, response=%s)", messageID,
                    response));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_INTERMEDIATE_RESPONSE);
@@ -452,32 +358,23 @@
    final String responseName = response.getOID();
    final ByteString responseValue = response.getValue();
    if (responseName != null)
    {
      writer
          .writeOctetString(TYPE_INTERMEDIATE_RESPONSE_OID, response.getOID());
        if (responseName != null) {
            writer.writeOctetString(TYPE_INTERMEDIATE_RESPONSE_OID, response.getOID());
    }
    if (responseValue != null)
    {
      writer.writeOctetString(TYPE_INTERMEDIATE_RESPONSE_VALUE, response
          .getValue());
        if (responseValue != null) {
            writer.writeOctetString(TYPE_INTERMEDIATE_RESPONSE_VALUE, response.getValue());
    }
    writer.writeEndSequence();
    encodeMessageFooter(writer, response);
  }
  public void modifyDNRequest(final ASN1Writer writer, final int messageID,
      final ModifyDNRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final ModifyDNRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP MODIFY DN REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP MODIFY DN REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_MODIFY_DN_REQUEST);
@@ -486,26 +383,19 @@
    writer.writeBoolean(request.isDeleteOldRDN());
    final DN newSuperior = request.getNewSuperior();
    if (newSuperior != null)
    {
      writer.writeOctetString(TYPE_MODIFY_DN_NEW_SUPERIOR, newSuperior
          .toString());
        if (newSuperior != null) {
            writer.writeOctetString(TYPE_MODIFY_DN_NEW_SUPERIOR, newSuperior.toString());
    }
    writer.writeEndSequence();
    encodeMessageFooter(writer, request);
  }
  public void modifyDNResult(final ASN1Writer writer, final int messageID,
      final Result result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void modifyDNResult(final ASN1Writer writer, final int messageID, final Result result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP MODIFY DN RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP MODIFY DN RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_MODIFY_DN_RESPONSE, result);
@@ -513,24 +403,18 @@
    encodeMessageFooter(writer, result);
  }
  public void modifyRequest(final ASN1Writer writer, final int messageID,
      final ModifyRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final ModifyRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP MODIFY REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP MODIFY REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_MODIFY_REQUEST);
    writer.writeOctetString(request.getName().toString());
    writer.writeStartSequence();
    for (final Modification change : request.getModifications())
    {
        for (final Modification change : request.getModifications()) {
      encodeChange(writer, change);
    }
    writer.writeEndSequence();
@@ -539,16 +423,11 @@
    encodeMessageFooter(writer, request);
  }
  public void modifyResult(final ASN1Writer writer, final int messageID,
      final Result result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void modifyResult(final ASN1Writer writer, final int messageID, final Result result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP MODIFY RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP MODIFY RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_MODIFY_RESPONSE, result);
@@ -556,16 +435,11 @@
    encodeMessageFooter(writer, result);
  }
  public void searchRequest(final ASN1Writer writer, final int messageID,
      final SearchRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final SearchRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP SEARCH REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP SEARCH REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_SEARCH_REQUEST);
@@ -578,8 +452,7 @@
    LDAPUtils.encodeFilter(writer, request.getFilter());
    writer.writeStartSequence();
    for (final String attribute : request.getAttributes())
    {
        for (final String attribute : request.getAttributes()) {
      writer.writeOctetString(attribute);
    }
    writer.writeEndSequence();
@@ -588,16 +461,11 @@
    encodeMessageFooter(writer, request);
  }
  public void searchResult(final ASN1Writer writer, final int messageID,
      final Result result) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void searchResult(final ASN1Writer writer, final int messageID, final Result result)
            throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP SEARCH RESULT(messageID=%d, result=%s)", messageID,
          result));
                    "ENCODE LDAP SEARCH RESULT(messageID=%d, result=%s)", messageID, result));
    }
    encodeMessageHeader(writer, messageID);
    encodeResultHeader(writer, OP_TYPE_SEARCH_RESULT_DONE, result);
@@ -605,71 +473,51 @@
    encodeMessageFooter(writer, result);
  }
  public void searchResultEntry(final ASN1Writer writer, final int messageID,
      final SearchResultEntry entry) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final SearchResultEntry entry) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP SEARCH RESULT ENTRY(messageID=%d, entry=%s)", messageID,
          entry));
                    "ENCODE LDAP SEARCH RESULT ENTRY(messageID=%d, entry=%s)", messageID, entry));
    }
    encodeMessageHeader(writer, messageID);
    encodeEntry(writer, entry);
    encodeMessageFooter(writer, entry);
  }
  public void searchResultReference(final ASN1Writer writer,
      final int messageID, final SearchResultReference reference)
      throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
    public void searchResultReference(final ASN1Writer writer, final int messageID,
            final SearchResultReference reference) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP SEARCH RESULT REFERENCE(messageID=%d, reference=%s)",
          messageID, reference));
                    "ENCODE LDAP SEARCH RESULT REFERENCE(messageID=%d, reference=%s)", messageID,
                    reference));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeStartSequence(OP_TYPE_SEARCH_RESULT_REFERENCE);
    for (final String url : reference.getURIs())
    {
        for (final String url : reference.getURIs()) {
      writer.writeOctetString(url);
    }
    writer.writeEndSequence();
    encodeMessageFooter(writer, reference);
  }
  public void unbindRequest(final ASN1Writer writer, final int messageID,
      final UnbindRequest request) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final UnbindRequest request) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP UNBIND REQUEST(messageID=%d, request=%s)", messageID,
          request));
                    "ENCODE LDAP UNBIND REQUEST(messageID=%d, request=%s)", messageID, request));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeNull(OP_TYPE_UNBIND_REQUEST);
    encodeMessageFooter(writer, request);
  }
  public void unrecognizedMessage(final ASN1Writer writer, final int messageID,
      final byte messageTag, final ByteString messageBytes) throws IOException
  {
    if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER))
    {
            final byte messageTag, final ByteString messageBytes) throws IOException {
        if (StaticUtils.DEBUG_LOG.isLoggable(Level.FINER)) {
      StaticUtils.DEBUG_LOG.finer(String.format(
          "ENCODE LDAP UNKNOWN MESSAGE(messageID=%d, messageTag=%s, "
              + "messageBytes=%s)", messageID, StaticUtils
              .byteToHex(messageTag), messageBytes.toString()));
                            + "messageBytes=%s)", messageID, StaticUtils.byteToHex(messageTag),
                    messageBytes.toString()));
    }
    encodeMessageHeader(writer, messageID);
    writer.writeOctetString(messageTag, messageBytes);
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/TimeoutChecker.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package com.forgerock.opendj.ldap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -37,83 +34,59 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * Checks connection for pending requests that have timed out.
 */
final class TimeoutChecker
{
final class TimeoutChecker {
  static final TimeoutChecker INSTANCE = new TimeoutChecker();
  private final LinkedTransferQueue<LDAPConnection> connections;
  private transient final ReentrantLock lock;
  private transient final Condition available;
  private TimeoutChecker()
  {
    private TimeoutChecker() {
    this.connections = new LinkedTransferQueue<LDAPConnection>();
    this.lock = new ReentrantLock();
    this.available = lock.newCondition();
    final Thread checkerThread = new Thread("Timeout Checker")
    {
        final Thread checkerThread = new Thread("Timeout Checker") {
      @Override
      public void run()
      {
            public void run() {
        StaticUtils.DEBUG_LOG.fine("Timeout Checker Starting");
        final ReentrantLock lock = TimeoutChecker.this.lock;
        lock.lock();
        try
        {
          while (true)
          {
                try {
                    while (true) {
            final long currentTime = System.currentTimeMillis();
            long delay = 0;
            for (final LDAPConnection connection : connections)
            {
                        for (final LDAPConnection connection : connections) {
              StaticUtils.DEBUG_LOG.finer("Checking connection " + connection
                  + " delay = " + delay);
              final long newDelay = connection
                  .cancelExpiredRequests(currentTime);
              if (newDelay > 0)
              {
                if (delay > 0)
                {
                            final long newDelay = connection.cancelExpiredRequests(currentTime);
                            if (newDelay > 0) {
                                if (delay > 0) {
                  delay = Math.min(newDelay, delay);
                }
                else
                {
                                } else {
                  delay = newDelay;
                }
              }
            }
            try
            {
              if (delay <= 0)
              {
                        try {
                            if (delay <= 0) {
                StaticUtils.DEBUG_LOG.finer("There are no connections with "
                    + "timeout specified. Sleeping");
                available.await();
              }
              else
              {
                            } else {
                StaticUtils.DEBUG_LOG.finer("Sleeping for " + delay + "ms");
                available.await(delay, TimeUnit.MILLISECONDS);
              }
            }
            catch (final InterruptedException e)
            {
                        } catch (final InterruptedException e) {
              // Just go around again.
            }
          }
        }
        finally
        {
                } finally {
          lock.unlock();
        }
      }
@@ -123,35 +96,23 @@
    checkerThread.start();
  }
  void addConnection(final LDAPConnection connection)
  {
    void addConnection(final LDAPConnection connection) {
    final ReentrantLock lock = this.lock;
    lock.lock();
    try
    {
        try {
      connections.add(connection);
      available.signalAll();
    }
    finally
    {
        } finally {
      lock.unlock();
    }
  }
  void removeConnection(final LDAPConnection connection)
  {
    void removeConnection(final LDAPConnection connection) {
    final ReentrantLock lock = this.lock;
    lock.lock();
    try
    {
        try {
      connections.remove(connection);
    }
    finally
    {
        } finally {
      lock.unlock();
    }
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedRequestException.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,45 +26,31 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.requests.Request;
/**
 * Thrown when an expected LDAP request is received.
 */
@SuppressWarnings("serial")
final class UnexpectedRequestException extends IOException
{
final class UnexpectedRequestException extends IOException {
  private final int messageID;
  private final Request request;
  public UnexpectedRequestException(final int messageID, final Request request)
  {
    super(LocalizableMessage.raw("Unexpected LDAP request: id=%d, message=%s",
        messageID, request).toString());
    public UnexpectedRequestException(final int messageID, final Request request) {
        super(LocalizableMessage.raw("Unexpected LDAP request: id=%d, message=%s", messageID,
                request).toString());
    this.messageID = messageID;
    this.request = request;
  }
  public int getMessageID()
  {
    public int getMessageID() {
    return messageID;
  }
  public Request getRequest()
  {
    public Request getRequest() {
    return request;
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedResponseException.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,46 +26,31 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.responses.Response;
/**
 * Thrown when an unexpected LDAP response is received.
 */
@SuppressWarnings("serial")
final class UnexpectedResponseException extends IOException
{
final class UnexpectedResponseException extends IOException {
  private final int messageID;
  private final Response response;
  public UnexpectedResponseException(final int messageID,
      final Response response)
  {
    super(LocalizableMessage.raw("Unexpected LDAP response: id=%d, message=%s",
        messageID, response).toString());
    public UnexpectedResponseException(final int messageID, final Response response) {
        super(LocalizableMessage.raw("Unexpected LDAP response: id=%d, message=%s", messageID,
                response).toString());
    this.messageID = messageID;
    this.response = response;
  }
  public int getMessageID()
  {
    public int getMessageID() {
    return messageID;
  }
  public Response getResponse()
  {
    public Response getResponse() {
    return response;
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnsupportedMessageException.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,56 +26,37 @@
package com.forgerock.opendj.ldap;
import java.io.IOException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
/**
 * Thrown when an unsupported LDAP message is received.
 */
@SuppressWarnings("serial")
final class UnsupportedMessageException extends IOException
{
final class UnsupportedMessageException extends IOException {
  private final int id;
  private final byte tag;
  private final ByteString content;
  public UnsupportedMessageException(final int id, final byte tag,
      final ByteString content)
  {
    super(LocalizableMessage
        .raw("Unsupported LDAP message: id=%d, tag=%d, content=%s", id, tag,
            content).toString());
    public UnsupportedMessageException(final int id, final byte tag, final ByteString content) {
        super(LocalizableMessage.raw("Unsupported LDAP message: id=%d, tag=%d, content=%s", id,
                tag, content).toString());
    this.id = id;
    this.tag = tag;
    this.content = content;
  }
  public ByteString getContent()
  {
    public ByteString getContent() {
    return content;
  }
  public int getID()
  {
    public int getID() {
    return id;
  }
  public byte getTag()
  {
    public byte getTag() {
    return tag;
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,8 +25,6 @@
 */
package com.forgerock.opendj.ldap.controls;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ACCTUSABLEREQ_CONTROL_BAD_OID;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE;
@@ -40,16 +37,13 @@
import com.forgerock.opendj.util.Validator;
/**
 * The Sun-defined account usability request control. The OID for this control
 * is 1.3.6.1.4.1.42.2.27.9.5.8, and it does not have a value.
 *
 * @see AccountUsabilityResponseControl
 */
public final class AccountUsabilityRequestControl implements Control
{
public final class AccountUsabilityRequestControl implements Control {
  /**
   * The OID for the account usability request control.
   */
@@ -67,118 +61,88 @@
   * control.
   */
  public static final ControlDecoder<AccountUsabilityRequestControl> DECODER =
    new ControlDecoder<AccountUsabilityRequestControl>()
  {
            new ControlDecoder<AccountUsabilityRequestControl>() {
    public AccountUsabilityRequestControl decodeControl(final Control control,
        final DecodeOptions options) throws DecodeException
    {
                        final DecodeOptions options) throws DecodeException {
      Validator.ensureNotNull(control);
      if (control instanceof AccountUsabilityRequestControl)
      {
                    if (control instanceof AccountUsabilityRequestControl) {
        return (AccountUsabilityRequestControl) control;
      }
      if (!control.getOID().equals(OID))
      {
        final LocalizableMessage message = ERR_ACCTUSABLEREQ_CONTROL_BAD_OID
            .get(control.getOID(), OID);
                    if (!control.getOID().equals(OID)) {
                        final LocalizableMessage message =
                                ERR_ACCTUSABLEREQ_CONTROL_BAD_OID.get(control.getOID(), OID);
        throw DecodeException.error(message);
      }
      if (control.hasValue())
      {
        final LocalizableMessage message = ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE
            .get();
                    if (control.hasValue()) {
                        final LocalizableMessage message =
                                ERR_ACCTUSABLEREQ_CONTROL_HAS_VALUE.get();
        throw DecodeException.error(message);
      }
      return control.isCritical() ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
    }
    public String getOID()
    {
                public String getOID() {
      return OID;
    }
  };
  /**
   * Creates a new account usability request control having the provided
   * criticality.
   *
   * @param isCritical
   *          {@code true} if it is unacceptable to perform the operation
   *          without applying the semantics of this control, or {@code false}
   *          if it can be ignored.
     *            without applying the semantics of this control, or
     *            {@code false} if it can be ignored.
   * @return The new control.
   */
  public static AccountUsabilityRequestControl newControl(
      final boolean isCritical)
  {
    public static AccountUsabilityRequestControl newControl(final boolean isCritical) {
    return isCritical ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
  }
  // Prevent direct instantiation.
  private AccountUsabilityRequestControl(final boolean isCritical)
  {
    private AccountUsabilityRequestControl(final boolean isCritical) {
    this.isCritical = isCritical;
  }
  /**
   * {@inheritDoc}
   */
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * {@inheritDoc}
   */
  public ByteString getValue()
  {
    public ByteString getValue() {
    return null;
  }
  /**
   * {@inheritDoc}
   */
  public boolean hasValue()
  {
    public boolean hasValue() {
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isCritical()
  {
    public boolean isCritical() {
    return isCritical;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("AccountUsableRequestControl(oid=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/AccountUsabilityResponseControl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,8 +25,6 @@
 */
package com.forgerock.opendj.ldap.controls;
import static com.forgerock.opendj.util.StaticUtils.byteToHex;
import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_ACCTUSABLERES_CONTROL_BAD_OID;
@@ -51,8 +48,6 @@
import com.forgerock.opendj.util.StaticUtils;
import com.forgerock.opendj.util.Validator;
/**
 * The Sun-defined account usability response control. The OID for this control
 * is 1.3.6.1.4.1.42.2.27.9.5.8, and it has a value encoded according to the
@@ -73,8 +68,7 @@
 *
 * @see AccountUsabilityRequestControl
 */
public final class AccountUsabilityResponseControl implements Control
{
public final class AccountUsabilityResponseControl implements Control {
  /**
   * The OID for the account usability response control.
   */
@@ -85,43 +79,35 @@
   * control.
   */
  public static final ControlDecoder<AccountUsabilityResponseControl> DECODER =
    new ControlDecoder<AccountUsabilityResponseControl>()
  {
            new ControlDecoder<AccountUsabilityResponseControl>() {
    public AccountUsabilityResponseControl decodeControl(final Control control,
        final DecodeOptions options) throws DecodeException
    {
                        final DecodeOptions options) throws DecodeException {
      Validator.ensureNotNull(control);
      if (control instanceof AccountUsabilityResponseControl)
      {
                    if (control instanceof AccountUsabilityResponseControl) {
        return (AccountUsabilityResponseControl) control;
      }
      if (!control.getOID().equals(OID))
      {
        final LocalizableMessage message = ERR_ACCTUSABLERES_CONTROL_BAD_OID
            .get(control.getOID(), OID);
                    if (!control.getOID().equals(OID)) {
                        final LocalizableMessage message =
                                ERR_ACCTUSABLERES_CONTROL_BAD_OID.get(control.getOID(), OID);
        throw DecodeException.error(message);
      }
      if (!control.hasValue())
      {
                    if (!control.hasValue()) {
        // The response control must always have a value.
        final LocalizableMessage message = ERR_ACCTUSABLERES_NO_CONTROL_VALUE
            .get();
                        final LocalizableMessage message = ERR_ACCTUSABLERES_NO_CONTROL_VALUE.get();
        throw DecodeException.error(message);
      }
      try
      {
                    try {
        final ASN1Reader reader = ASN1.getReader(control.getValue());
        switch (reader.peekType())
        {
                        switch (reader.peekType()) {
        case TYPE_SECONDS_BEFORE_EXPIRATION:
          final int secondsBeforeExpiration = (int) reader.readInteger();
          return new AccountUsabilityResponseControl(control.isCritical(),
              true, false, false, false, -1, false, 0, secondsBeforeExpiration);
                            return new AccountUsabilityResponseControl(control.isCritical(), true,
                                    false, false, false, -1, false, 0, secondsBeforeExpiration);
        case TYPE_MORE_INFO:
          boolean isInactive = false;
          boolean isReset = false;
@@ -131,56 +117,47 @@
          int secondsBeforeUnlock = 0;
          reader.readStartSequence();
          if (reader.hasNextElement() && (reader.peekType() == TYPE_INACTIVE))
          {
                            if (reader.hasNextElement() && (reader.peekType() == TYPE_INACTIVE)) {
            isInactive = reader.readBoolean();
          }
          if (reader.hasNextElement() && (reader.peekType() == TYPE_RESET))
          {
                            if (reader.hasNextElement() && (reader.peekType() == TYPE_RESET)) {
            isReset = reader.readBoolean();
          }
          if (reader.hasNextElement() && (reader.peekType() == TYPE_EXPIRED))
          {
                            if (reader.hasNextElement() && (reader.peekType() == TYPE_EXPIRED)) {
            isExpired = reader.readBoolean();
          }
          if (reader.hasNextElement()
              && (reader.peekType() == TYPE_REMAINING_GRACE_LOGINS))
          {
                                    && (reader.peekType() == TYPE_REMAINING_GRACE_LOGINS)) {
            remainingGraceLogins = (int) reader.readInteger();
          }
          if (reader.hasNextElement()
              && (reader.peekType() == TYPE_SECONDS_BEFORE_UNLOCK))
          {
                                    && (reader.peekType() == TYPE_SECONDS_BEFORE_UNLOCK)) {
            isLocked = true;
            secondsBeforeUnlock = (int) reader.readInteger();
          }
          reader.readEndSequence();
          return new AccountUsabilityResponseControl(control.isCritical(),
              false, isInactive, isReset, isExpired, remainingGraceLogins,
              isLocked, secondsBeforeUnlock, -1);
                            return new AccountUsabilityResponseControl(control.isCritical(), false,
                                    isInactive, isReset, isExpired, remainingGraceLogins, isLocked,
                                    secondsBeforeUnlock, -1);
        default:
          final LocalizableMessage message = ERR_ACCTUSABLERES_UNKNOWN_VALUE_ELEMENT_TYPE
                            final LocalizableMessage message =
                                    ERR_ACCTUSABLERES_UNKNOWN_VALUE_ELEMENT_TYPE
              .get(byteToHex(reader.peekType()));
          throw DecodeException.error(message);
        }
      }
      catch (final IOException e)
      {
                    } catch (final IOException e) {
        StaticUtils.DEBUG_LOG.throwing(
            "AccountUsabilityResponseControl.decodeControl", "decode", e);
        final LocalizableMessage message = ERR_ACCTUSABLERES_DECODE_ERROR
            .get(getExceptionMessage(e));
                        final LocalizableMessage message =
                                ERR_ACCTUSABLERES_DECODE_ERROR.get(getExceptionMessage(e));
        throw DecodeException.error(message);
      }
    }
    public String getOID()
    {
                public String getOID() {
      return OID;
    }
  };
@@ -227,16 +204,14 @@
   */
  private static final byte TYPE_SECONDS_BEFORE_UNLOCK = (byte) 0x84;
  /**
   * Creates a new account usability response control that may be used to
   * indicate that the account is not available and provide information about
   * the underlying reason.
   *
   * @param isInactive
   *          Indicates whether the user's account has been inactivated by an
   *          administrator.
     *            Indicates whether the user's account has been inactivated by
     *            an administrator.
   * @param isReset
   *          Indicates whether the user's password has been reset by an
   *          administrator.
@@ -254,38 +229,29 @@
   *          automatically unlocked and must be reset by an administrator.
   * @return The new control.
   */
  public static AccountUsabilityResponseControl newControl(
      final boolean isInactive, final boolean isReset, final boolean isExpired,
      final int remainingGraceLogins, final boolean isLocked,
      final int secondsBeforeUnlock)
  {
    return new AccountUsabilityResponseControl(false, false, isInactive,
        isReset, isExpired, remainingGraceLogins, isLocked,
        secondsBeforeUnlock, -1);
    public static AccountUsabilityResponseControl newControl(final boolean isInactive,
            final boolean isReset, final boolean isExpired, final int remainingGraceLogins,
            final boolean isLocked, final int secondsBeforeUnlock) {
        return new AccountUsabilityResponseControl(false, false, isInactive, isReset, isExpired,
                remainingGraceLogins, isLocked, secondsBeforeUnlock, -1);
  }
  /**
   * Creates a new account usability response control that may be used to
   * indicate that the account is available and provide the number of seconds
   * until expiration.
   *
   * @param secondsBeforeExpiration
   *          The length of time in seconds until the user's password expires,
   *          or {@code -1} if the user's password will not expire or the
   *          expiration time is unknown.
     *            The length of time in seconds until the user's password
     *            expires, or {@code -1} if the user's password will not expire
     *            or the expiration time is unknown.
   * @return The new control.
   */
  public static AccountUsabilityResponseControl newControl(
      final int secondsBeforeExpiration)
  {
    return new AccountUsabilityResponseControl(false, true, false, false,
        false, -1, false, 0, secondsBeforeExpiration);
    public static AccountUsabilityResponseControl newControl(final int secondsBeforeExpiration) {
        return new AccountUsabilityResponseControl(false, true, false, false, false, -1, false, 0,
                secondsBeforeExpiration);
  }
  // Indicates whether the user's account is usable.
  private final boolean isUsable;
@@ -315,15 +281,11 @@
  private final boolean isCritical;
  // Prevent direct instantiation.
  private AccountUsabilityResponseControl(final boolean isCritical,
      final boolean isUsable, final boolean isInactive, final boolean isReset,
      final boolean isExpired, final int remainingGraceLogins,
      final boolean isLocked, final int secondsBeforeUnlock,
      final int secondsBeforeExpiration)
  {
    private AccountUsabilityResponseControl(final boolean isCritical, final boolean isUsable,
            final boolean isInactive, final boolean isReset, final boolean isExpired,
            final int remainingGraceLogins, final boolean isLocked, final int secondsBeforeUnlock,
            final int secondsBeforeExpiration) {
    this.isCritical = isCritical;
    this.isUsable = isUsable;
    this.isInactive = isInactive;
@@ -335,32 +297,24 @@
    this.secondsBeforeExpiration = secondsBeforeExpiration;
  }
  /**
   * {@inheritDoc}
   */
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * Returns the number of remaining grace logins for the user. This value is
   * unreliable if the user's password has not expired.
   *
   * @return The number of remaining grace logins for the user, or {@code -1} if
   *         the grace logins feature is not enabled for the user.
     * @return The number of remaining grace logins for the user, or {@code -1}
     *         if the grace logins feature is not enabled for the user.
   */
  public int getRemainingGraceLogins()
  {
    public int getRemainingGraceLogins() {
    return remainingGraceLogins;
  }
  /**
   * Returns the length of time in seconds before the user's password expires.
   * This value is unreliable if the account is not available.
@@ -369,178 +323,134 @@
   *         or {@code -1} if it is unknown or password expiration is not
   *         enabled for the user.
   */
  public int getSecondsBeforeExpiration()
  {
    public int getSecondsBeforeExpiration() {
    return secondsBeforeExpiration;
  }
  /**
   * Returns the length of time in seconds before the user's account is
   * automatically unlocked. This value is unreliable is the user's account is
   * not locked.
   *
   * @return The length of time in seconds before the user's account is
   *         automatically unlocked, or {@code -1} if it requires administrative
   *         action to unlock the account.
     *         automatically unlocked, or {@code -1} if it requires
     *         administrative action to unlock the account.
   */
  public int getSecondsBeforeUnlock()
  {
    public int getSecondsBeforeUnlock() {
    return secondsBeforeUnlock;
  }
  /**
   * {@inheritDoc}
   */
  public ByteString getValue()
  {
    public ByteString getValue() {
    final ByteStringBuilder buffer = new ByteStringBuilder();
    final ASN1Writer writer = ASN1.getWriter(buffer);
    try
    {
      if (secondsBeforeExpiration < 0)
      {
        writer.writeInteger(TYPE_SECONDS_BEFORE_EXPIRATION,
            secondsBeforeExpiration);
      }
      else
      {
        try {
            if (secondsBeforeExpiration < 0) {
                writer.writeInteger(TYPE_SECONDS_BEFORE_EXPIRATION, secondsBeforeExpiration);
            } else {
        writer.writeStartSequence(TYPE_MORE_INFO);
        if (isInactive)
        {
                if (isInactive) {
          writer.writeBoolean(TYPE_INACTIVE, true);
        }
        if (isReset)
        {
                if (isReset) {
          writer.writeBoolean(TYPE_RESET, true);
        }
        if (isExpired)
        {
                if (isExpired) {
          writer.writeBoolean(TYPE_EXPIRED, true);
          if (remainingGraceLogins >= 0)
          {
            writer.writeInteger(TYPE_REMAINING_GRACE_LOGINS,
                remainingGraceLogins);
                    if (remainingGraceLogins >= 0) {
                        writer.writeInteger(TYPE_REMAINING_GRACE_LOGINS, remainingGraceLogins);
          }
        }
        if (isLocked)
        {
                if (isLocked) {
          writer.writeInteger(TYPE_SECONDS_BEFORE_UNLOCK, secondsBeforeUnlock);
        }
        writer.writeEndSequence();
      }
      return buffer.toByteString();
    }
    catch (final IOException ioe)
    {
        } catch (final IOException ioe) {
      // This should never happen unless there is a bug somewhere.
      throw new RuntimeException(ioe);
    }
  }
  /**
   * {@inheritDoc}
   */
  public boolean hasValue()
  {
    public boolean hasValue() {
    return true;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isCritical()
  {
    public boolean isCritical() {
    return isCritical;
  }
  /**
   * Returns {@code true} if the user's password has expired.
   *
   * @return <CODE>true</CODE> if the user's password has expired, or
   *         <CODE>false</CODE> if not.
   */
  public boolean isExpired()
  {
    public boolean isExpired() {
    return isExpired;
  }
  /**
   * Returns {@code true} if the user's account has been inactivated by an
   * administrator.
   *
   * @return <CODE>true</CODE> if the user's account has been inactivated by an
   *         administrator, or <CODE>false</CODE> if not.
     * @return <CODE>true</CODE> if the user's account has been inactivated by
     *         an administrator, or <CODE>false</CODE> if not.
   */
  public boolean isInactive()
  {
    public boolean isInactive() {
    return isInactive;
  }
  /**
   * Returns {@code true} if the user's account is locked for some reason.
   *
   * @return <CODE>true</CODE> if the user's account is locked, or
   *         <CODE>false</CODE> if it is not.
   */
  public boolean isLocked()
  {
    public boolean isLocked() {
    return isLocked;
  }
  /**
   * Returns {@code true} if the user's password has been administratively reset
   * and the user must change that password before any other operations will be
   * allowed.
     * Returns {@code true} if the user's password has been administratively
     * reset and the user must change that password before any other operations
     * will be allowed.
   *
   * @return <CODE>true</CODE> if the user's password has been administratively
   *         reset, or <CODE>false</CODE> if not.
     * @return <CODE>true</CODE> if the user's password has been
     *         administratively reset, or <CODE>false</CODE> if not.
   */
  public boolean isReset()
  {
    public boolean isReset() {
    return isReset;
  }
  /**
   * Returns {@code true} if the associated user account is available for use.
   *
   * @return <CODE>true</CODE> if the associated user account is available, or
   *         <CODE>false</CODE> if not.
   */
  public boolean isUsable()
  {
    public boolean isUsable() {
    return isUsable;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("AccountUsableResponseControl(oid=");
    builder.append(getOID());
@@ -548,13 +458,10 @@
    builder.append(isCritical());
    builder.append(", isUsable=");
    builder.append(isUsable);
    if (isUsable)
    {
        if (isUsable) {
      builder.append(",secondsBeforeExpiration=");
      builder.append(secondsBeforeExpiration);
    }
    else
    {
        } else {
      builder.append(",isInactive=");
      builder.append(isInactive);
      builder.append(",isReset=");
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/RealAttributesOnlyRequestControl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,8 +25,6 @@
 */
package com.forgerock.opendj.ldap.controls;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_REAL_ATTRS_ONLY_CONTROL_BAD_OID;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_REAL_ATTRS_ONLY_INVALID_CONTROL_VALUE;
@@ -40,14 +37,11 @@
import com.forgerock.opendj.util.Validator;
/**
 * The Sun-defined real attributes only request control. The OID for this
 * control is 2.16.840.1.113730.3.4.17, and it does not have a value.
 */
public final class RealAttributesOnlyRequestControl implements Control
{
public final class RealAttributesOnlyRequestControl implements Control {
  /**
   * The OID for the real attributes only request control.
   */
@@ -64,122 +58,89 @@
   * control.
   */
  public static final ControlDecoder<RealAttributesOnlyRequestControl> DECODER =
    new ControlDecoder<RealAttributesOnlyRequestControl>()
  {
            new ControlDecoder<RealAttributesOnlyRequestControl>() {
    public RealAttributesOnlyRequestControl decodeControl(
        final Control control, final DecodeOptions options)
        throws DecodeException
    {
                public RealAttributesOnlyRequestControl decodeControl(final Control control,
                        final DecodeOptions options) throws DecodeException {
      Validator.ensureNotNull(control);
      if (control instanceof RealAttributesOnlyRequestControl)
      {
                    if (control instanceof RealAttributesOnlyRequestControl) {
        return (RealAttributesOnlyRequestControl) control;
      }
      if (!control.getOID().equals(OID))
      {
        final LocalizableMessage message = ERR_REAL_ATTRS_ONLY_CONTROL_BAD_OID
            .get(control.getOID(), OID);
                    if (!control.getOID().equals(OID)) {
                        final LocalizableMessage message =
                                ERR_REAL_ATTRS_ONLY_CONTROL_BAD_OID.get(control.getOID(), OID);
        throw DecodeException.error(message);
      }
      if (control.hasValue())
      {
        final LocalizableMessage message = ERR_REAL_ATTRS_ONLY_INVALID_CONTROL_VALUE
            .get();
                    if (control.hasValue()) {
                        final LocalizableMessage message =
                                ERR_REAL_ATTRS_ONLY_INVALID_CONTROL_VALUE.get();
        throw DecodeException.error(message);
      }
      return control.isCritical() ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
    }
    public String getOID()
    {
                public String getOID() {
      return OID;
    }
  };
  /**
   * Creates a new real attributes only request control having the provided
   * criticality.
   *
   * @param isCritical
   *          {@code true} if it is unacceptable to perform the operation
   *          without applying the semantics of this control, or {@code false}
   *          if it can be ignored.
     *            without applying the semantics of this control, or
     *            {@code false} if it can be ignored.
   * @return The new control.
   */
  public static RealAttributesOnlyRequestControl newControl(
      final boolean isCritical)
  {
    public static RealAttributesOnlyRequestControl newControl(final boolean isCritical) {
    return isCritical ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
  }
  private final boolean isCritical;
  private RealAttributesOnlyRequestControl(final boolean isCritical)
  {
    private RealAttributesOnlyRequestControl(final boolean isCritical) {
    this.isCritical = isCritical;
  }
  /**
   * {@inheritDoc}
   */
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * {@inheritDoc}
   */
  public ByteString getValue()
  {
    public ByteString getValue() {
    return null;
  }
  /**
   * {@inheritDoc}
   */
  public boolean hasValue()
  {
    public boolean hasValue() {
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isCritical()
  {
    public boolean isCritical() {
    return isCritical;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("RealAttributesOnlyRequestControl(oid=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/VirtualAttributesOnlyRequestControl.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -26,8 +25,6 @@
 */
package com.forgerock.opendj.ldap.controls;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_VIRTUAL_ATTRS_ONLY_CONTROL_BAD_OID;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_VIRTUAL_ATTRS_ONLY_INVALID_CONTROL_VALUE;
@@ -40,14 +37,11 @@
import com.forgerock.opendj.util.Validator;
/**
 * The Sun-defined virtual attributes only request control. The OID for this
 * control is 2.16.840.1.113730.3.4.19, and it does not have a value.
 */
public final class VirtualAttributesOnlyRequestControl implements Control
{
public final class VirtualAttributesOnlyRequestControl implements Control {
  /**
   * The OID for the virtual attributes only request control.
   */
@@ -63,123 +57,90 @@
   * A decoder which can be used for decoding the virtual attributes only
   * request control.
   */
  public static final ControlDecoder<VirtualAttributesOnlyRequestControl>
    DECODER = new ControlDecoder<VirtualAttributesOnlyRequestControl>()
  {
    public static final ControlDecoder<VirtualAttributesOnlyRequestControl> DECODER =
            new ControlDecoder<VirtualAttributesOnlyRequestControl>() {
    public VirtualAttributesOnlyRequestControl decodeControl(
        final Control control, final DecodeOptions options)
        throws DecodeException
    {
                public VirtualAttributesOnlyRequestControl decodeControl(final Control control,
                        final DecodeOptions options) throws DecodeException {
      Validator.ensureNotNull(control);
      if (control instanceof VirtualAttributesOnlyRequestControl)
      {
                    if (control instanceof VirtualAttributesOnlyRequestControl) {
        return (VirtualAttributesOnlyRequestControl) control;
      }
      if (!control.getOID().equals(OID))
      {
        final LocalizableMessage message = ERR_VIRTUAL_ATTRS_ONLY_CONTROL_BAD_OID
            .get(control.getOID(), OID);
                    if (!control.getOID().equals(OID)) {
                        final LocalizableMessage message =
                                ERR_VIRTUAL_ATTRS_ONLY_CONTROL_BAD_OID.get(control.getOID(), OID);
        throw DecodeException.error(message);
      }
      if (control.hasValue())
      {
        final LocalizableMessage message = ERR_VIRTUAL_ATTRS_ONLY_INVALID_CONTROL_VALUE
            .get();
                    if (control.hasValue()) {
                        final LocalizableMessage message =
                                ERR_VIRTUAL_ATTRS_ONLY_INVALID_CONTROL_VALUE.get();
        throw DecodeException.error(message);
      }
      return control.isCritical() ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
    }
    public String getOID()
    {
                public String getOID() {
      return OID;
    }
  };
  /**
   * Creates a new virtual attributes only request control having the provided
   * criticality.
   *
   * @param isCritical
   *          {@code true} if it is unacceptable to perform the operation
   *          without applying the semantics of this control, or {@code false}
   *          if it can be ignored.
     *            without applying the semantics of this control, or
     *            {@code false} if it can be ignored.
   * @return The new control.
   */
  public static VirtualAttributesOnlyRequestControl newControl(
      final boolean isCritical)
  {
    public static VirtualAttributesOnlyRequestControl newControl(final boolean isCritical) {
    return isCritical ? CRITICAL_INSTANCE : NONCRITICAL_INSTANCE;
  }
  private final boolean isCritical;
  private VirtualAttributesOnlyRequestControl(final boolean isCritical)
  {
    private VirtualAttributesOnlyRequestControl(final boolean isCritical) {
    this.isCritical = isCritical;
  }
  /**
   * {@inheritDoc}
   */
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * {@inheritDoc}
   */
  public ByteString getValue()
  {
    public ByteString getValue() {
    return null;
  }
  /**
   * {@inheritDoc}
   */
  public boolean hasValue()
  {
    public boolean hasValue() {
    return false;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isCritical()
  {
    public boolean isCritical() {
    return isCritical;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("VirtualAttributesOnlyRequestControl(oid=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/controls/package-info.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -30,5 +29,3 @@
 */
package com.forgerock.opendj.ldap.controls;
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetConnectionIDExtendedRequest.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package com.forgerock.opendj.ldap.extensions;
import java.io.IOException;
import org.forgerock.i18n.LocalizableMessage;
@@ -46,31 +43,23 @@
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.ExtendedResultDecoder;
/**
 * Get connection ID extended request. This operation can be used to retrieve
 * the client connection ID.
 *
 * @see GetConnectionIDExtendedResult
 */
public final class GetConnectionIDExtendedRequest
    extends
    AbstractExtendedRequest<GetConnectionIDExtendedRequest, GetConnectionIDExtendedResult>
{
  private static final class RequestDecoder
      implements
      ExtendedRequestDecoder<GetConnectionIDExtendedRequest, GetConnectionIDExtendedResult>
  {
public final class GetConnectionIDExtendedRequest extends
        AbstractExtendedRequest<GetConnectionIDExtendedRequest, GetConnectionIDExtendedResult> {
    private static final class RequestDecoder implements
            ExtendedRequestDecoder<GetConnectionIDExtendedRequest, GetConnectionIDExtendedResult> {
    public GetConnectionIDExtendedRequest decodeExtendedRequest(
        final ExtendedRequest<?> request, final DecodeOptions options)
        throws DecodeException
    {
                throws DecodeException {
      // TODO: Check the OID and that the value is not present.
      final GetConnectionIDExtendedRequest newRequest = new GetConnectionIDExtendedRequest();
      for (final Control control : request.getControls())
      {
            for (final Control control : request.getControls()) {
        newRequest.addControl(control);
      }
      return newRequest;
@@ -78,70 +67,50 @@
    }
  }
  private static final class ResultDecoder extends
      AbstractExtendedResultDecoder<GetConnectionIDExtendedResult>
  {
            AbstractExtendedResultDecoder<GetConnectionIDExtendedResult> {
    /**
     * {@inheritDoc}
     */
    public GetConnectionIDExtendedResult newExtendedErrorResult(
        final ResultCode resultCode, final String matchedDN,
        final String diagnosticMessage)
    {
      if (!resultCode.isExceptional())
      {
        public GetConnectionIDExtendedResult newExtendedErrorResult(final ResultCode resultCode,
                final String matchedDN, final String diagnosticMessage) {
            if (!resultCode.isExceptional()) {
        // A successful response must contain a response name and
        // value.
        throw new IllegalArgumentException(
            "No response name and value for result code "
                throw new IllegalArgumentException("No response name and value for result code "
                + resultCode.intValue());
      }
      return GetConnectionIDExtendedResult.newResult(resultCode, -1)
          .setMatchedDN(matchedDN).setDiagnosticMessage(diagnosticMessage);
            return GetConnectionIDExtendedResult.newResult(resultCode, -1).setMatchedDN(matchedDN)
                    .setDiagnosticMessage(diagnosticMessage);
    }
    public GetConnectionIDExtendedResult decodeExtendedResult(
        final ExtendedResult result, final DecodeOptions options)
        throws DecodeException
    {
      if (result instanceof GetConnectionIDExtendedResult)
      {
        public GetConnectionIDExtendedResult decodeExtendedResult(final ExtendedResult result,
                final DecodeOptions options) throws DecodeException {
            if (result instanceof GetConnectionIDExtendedResult) {
        return (GetConnectionIDExtendedResult) result;
      }
      else
      {
            } else {
        final ResultCode resultCode = result.getResultCode();
        final ByteString responseValue = result.getValue();
        if (!resultCode.isExceptional()
            && ((responseValue == null) || (responseValue.length() <= 0)))
        {
          throw DecodeException.error(LocalizableMessage
              .raw("Empty response value"));
                        && ((responseValue == null) || (responseValue.length() <= 0))) {
                    throw DecodeException.error(LocalizableMessage.raw("Empty response value"));
        }
        try
        {
                try {
          final ASN1Reader reader = ASN1.getReader(responseValue);
          final int connectionID = (int) reader.readInteger();
          final GetConnectionIDExtendedResult newResult = GetConnectionIDExtendedResult
              .newResult(resultCode, connectionID).setMatchedDN(
                  result.getMatchedDN()).setDiagnosticMessage(
                    final GetConnectionIDExtendedResult newResult =
                            GetConnectionIDExtendedResult.newResult(resultCode, connectionID)
                                    .setMatchedDN(result.getMatchedDN()).setDiagnosticMessage(
                  result.getDiagnosticMessage());
          for (final Control control : result.getControls())
          {
                    for (final Control control : result.getControls()) {
            newResult.addControl(control);
          }
          return newResult;
        }
        catch (final IOException e)
        {
                } catch (final IOException e) {
          throw DecodeException.error(LocalizableMessage
              .raw("Error decoding response value"), e);
        }
@@ -149,8 +118,6 @@
    }
  }
  /**
   * The OID for the extended operation that can be used to get the client
   * connection ID. It will be both the request and response OID.
@@ -162,86 +129,65 @@
    new GetConnectionIDExtendedRequest();
  /**
   * A decoder which can be used to decode get connection ID extended operation
   * requests.
     * A decoder which can be used to decode get connection ID extended
     * operation requests.
   */
  public static final RequestDecoder REQUEST_DECODER = new RequestDecoder();
  // No need to expose this.
  private static final ResultDecoder RESULT_DECODER = new ResultDecoder();
  /**
   * Creates a new get connection ID extended request.
   *
   * @return The new get connection ID extended request.
   */
  public static GetConnectionIDExtendedRequest newRequest()
  {
    public static GetConnectionIDExtendedRequest newRequest() {
    return INSTANCE;
  }
  // Prevent instantiation.
  private GetConnectionIDExtendedRequest()
  {
    private GetConnectionIDExtendedRequest() {
    // Nothing to do.
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ExtendedResultDecoder<GetConnectionIDExtendedResult> getResultDecoder()
  {
    public ExtendedResultDecoder<GetConnectionIDExtendedResult> getResultDecoder() {
    return RESULT_DECODER;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ByteString getValue()
  {
    public ByteString getValue() {
    return null;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasValue()
  {
    public boolean hasValue() {
    return false;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("GetConnectionIDExtendedRequest(requestName=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetConnectionIDExtendedResult.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap.extensions;
import java.io.IOException;
import org.forgerock.opendj.asn1.ASN1;
@@ -41,15 +38,13 @@
import com.forgerock.opendj.util.Validator;
/**
 * Get connection ID extended result.
 *
 * @see GetConnectionIDExtendedRequest
 */
public final class GetConnectionIDExtendedResult extends
    AbstractExtendedResult<GetConnectionIDExtendedResult>
{
        AbstractExtendedResult<GetConnectionIDExtendedResult> {
  /**
   * Creates a new get connection ID extended result.
   *
@@ -61,66 +56,47 @@
   * @throws NullPointerException
   *           If {@code resultCode} was {@code null}.
   */
  public static GetConnectionIDExtendedResult newResult(
      final ResultCode resultCode, final int connectionID)
  {
    public static GetConnectionIDExtendedResult newResult(final ResultCode resultCode,
            final int connectionID) {
    Validator.ensureNotNull(resultCode);
    return new GetConnectionIDExtendedResult(resultCode, connectionID);
  }
  private int connectionID;
  private GetConnectionIDExtendedResult(final ResultCode resultCode,
      final int connectionID)
  {
    private GetConnectionIDExtendedResult(final ResultCode resultCode, final int connectionID) {
    super(resultCode);
    this.connectionID = connectionID;
  }
  /**
   * Returns the client connection ID.
   *
   * @return The client connection ID.
   */
  public int getConnectionID()
  {
    public int getConnectionID() {
    return connectionID;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String getOID()
  {
    public String getOID() {
    return GetConnectionIDExtendedRequest.OID;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ByteString getValue()
  {
    public ByteString getValue() {
    final ByteStringBuilder buffer = new ByteStringBuilder(6);
    final ASN1Writer writer = ASN1.getWriter(buffer);
    try
    {
        try {
      writer.writeInteger(connectionID);
    }
    catch (final IOException ioe)
    {
        } catch (final IOException ioe) {
      // This should never happen unless there is a bug somewhere.
      throw new RuntimeException(ioe);
    }
@@ -128,19 +104,14 @@
    return buffer.toByteString();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasValue()
  {
    public boolean hasValue() {
    return true;
  }
  /**
   * Sets the client connection ID.
   *
@@ -148,20 +119,16 @@
   *          The client connection ID.
   * @return This get connection ID result.
   */
  public GetConnectionIDExtendedResult setConnectionID(final int connectionID)
  {
    public GetConnectionIDExtendedResult setConnectionID(final int connectionID) {
    this.connectionID = connectionID;
    return this;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("GetConnectionIDExtendedResponse(resultCode=");
    builder.append(getResultCode());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/GetSymmetricKeyExtendedRequest.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package com.forgerock.opendj.ldap.extensions;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_GET_SYMMETRIC_KEY_ASN1_DECODE_EXCEPTION;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_GET_SYMMETRIC_KEY_NO_VALUE;
@@ -38,7 +35,11 @@
import org.forgerock.opendj.asn1.ASN1;
import org.forgerock.opendj.asn1.ASN1Reader;
import org.forgerock.opendj.asn1.ASN1Writer;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.controls.Control;
import org.forgerock.opendj.ldap.requests.AbstractExtendedRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
@@ -50,25 +51,19 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * Get symmetric key extended request.
 */
public final class GetSymmetricKeyExtendedRequest extends
    AbstractExtendedRequest<GetSymmetricKeyExtendedRequest, ExtendedResult>
{
        AbstractExtendedRequest<GetSymmetricKeyExtendedRequest, ExtendedResult> {
  private static final class RequestDecoder implements
      ExtendedRequestDecoder<GetSymmetricKeyExtendedRequest, ExtendedResult>
  {
            ExtendedRequestDecoder<GetSymmetricKeyExtendedRequest, ExtendedResult> {
    public GetSymmetricKeyExtendedRequest decodeExtendedRequest(
        final ExtendedRequest<?> request, final DecodeOptions options)
        throws DecodeException
    {
                throws DecodeException {
      final ByteString requestValue = request.getValue();
      if (requestValue == null)
      {
            if (requestValue == null) {
        // The request must always have a value.
        final LocalizableMessage message = ERR_GET_SYMMETRIC_KEY_NO_VALUE.get();
        throw DecodeException.error(message);
@@ -77,69 +72,51 @@
      String requestSymmetricKey = null;
      String instanceKeyID = null;
      try
      {
            try {
        final ASN1Reader reader = ASN1.getReader(requestValue);
        reader.readStartSequence();
        if (reader.hasNextElement()
            && (reader.peekType() == TYPE_SYMMETRIC_KEY_ELEMENT))
        {
                if (reader.hasNextElement() && (reader.peekType() == TYPE_SYMMETRIC_KEY_ELEMENT)) {
          requestSymmetricKey = reader.readOctetStringAsString();
        }
        if (reader.hasNextElement()
            && (reader.peekType() == TYPE_INSTANCE_KEY_ID_ELEMENT))
        {
                if (reader.hasNextElement() && (reader.peekType() == TYPE_INSTANCE_KEY_ID_ELEMENT)) {
          instanceKeyID = reader.readOctetStringAsString();
        }
        reader.readEndSequence();
        final GetSymmetricKeyExtendedRequest newRequest = new GetSymmetricKeyExtendedRequest()
            .setRequestSymmetricKey(requestSymmetricKey).setInstanceKeyID(
                instanceKeyID);
                final GetSymmetricKeyExtendedRequest newRequest =
                        new GetSymmetricKeyExtendedRequest().setRequestSymmetricKey(
                                requestSymmetricKey).setInstanceKeyID(instanceKeyID);
        for (final Control control : request.getControls())
        {
                for (final Control control : request.getControls()) {
          newRequest.addControl(control);
        }
        return newRequest;
      }
      catch (final IOException ae)
      {
        StaticUtils.DEBUG_LOG.throwing("GetSymmetricKeyRequest.Operation",
            "decodeRequest", ae);
            } catch (final IOException ae) {
                StaticUtils.DEBUG_LOG.throwing("GetSymmetricKeyRequest.Operation", "decodeRequest",
                        ae);
        final LocalizableMessage message = ERR_GET_SYMMETRIC_KEY_ASN1_DECODE_EXCEPTION
            .get(ae.getMessage());
                final LocalizableMessage message =
                        ERR_GET_SYMMETRIC_KEY_ASN1_DECODE_EXCEPTION.get(ae.getMessage());
        throw DecodeException.error(message, ae);
      }
    }
  }
  private static final class ResultDecoder extends
      AbstractExtendedResultDecoder<ExtendedResult>
  {
    private static final class ResultDecoder extends AbstractExtendedResultDecoder<ExtendedResult> {
    public ExtendedResult newExtendedErrorResult(final ResultCode resultCode,
        final String matchedDN, final String diagnosticMessage)
    {
      return Responses.newGenericExtendedResult(resultCode).setMatchedDN(
          matchedDN).setDiagnosticMessage(diagnosticMessage);
                final String matchedDN, final String diagnosticMessage) {
            return Responses.newGenericExtendedResult(resultCode).setMatchedDN(matchedDN)
                    .setDiagnosticMessage(diagnosticMessage);
    }
    public ExtendedResult decodeExtendedResult(final ExtendedResult result,
        final DecodeOptions options) throws DecodeException
    {
                final DecodeOptions options) throws DecodeException {
      return result;
    }
  }
  /**
   * The request OID for the get symmetric key extended operation.
   */
@@ -151,118 +128,90 @@
  private static final byte TYPE_SYMMETRIC_KEY_ELEMENT = (byte) 0x80;
  /**
   * The BER type value for the instance key ID element of the operation value.
     * The BER type value for the instance key ID element of the operation
     * value.
   */
  private static final byte TYPE_INSTANCE_KEY_ID_ELEMENT = (byte) 0x81;
  /**
   * A decoder which can be used to decode get symmetric key extended operation
   * requests.
     * A decoder which can be used to decode get symmetric key extended
     * operation requests.
   */
  public static final RequestDecoder REQUEST_DECODER = new RequestDecoder();
  // No need to expose this.
  private static final ResultDecoder RESULT_DECODER = new ResultDecoder();
  /**
   * Creates a new get symmetric key extended request.
   *
   * @return The new get symmetric key extended request.
   */
  public static GetSymmetricKeyExtendedRequest newRequest()
  {
    public static GetSymmetricKeyExtendedRequest newRequest() {
    return new GetSymmetricKeyExtendedRequest();
  }
  private String requestSymmetricKey = null;
  private String instanceKeyID = null;
  // Instantiation via factory.
  private GetSymmetricKeyExtendedRequest()
  {
    private GetSymmetricKeyExtendedRequest() {
  }
  /**
   * Returns the instance key ID.
   *
   * @return The instance key ID.
   */
  public String getInstanceKeyID()
  {
    public String getInstanceKeyID() {
    return instanceKeyID;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * Returns the request symmetric key.
   *
   * @return The request symmetric key.
   */
  public String getRequestSymmetricKey()
  {
    public String getRequestSymmetricKey() {
    return requestSymmetricKey;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ExtendedResultDecoder<ExtendedResult> getResultDecoder()
  {
    public ExtendedResultDecoder<ExtendedResult> getResultDecoder() {
    return RESULT_DECODER;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ByteString getValue()
  {
    public ByteString getValue() {
    final ByteStringBuilder buffer = new ByteStringBuilder();
    final ASN1Writer writer = ASN1.getWriter(buffer);
    try
    {
        try {
      writer.writeStartSequence();
      if (requestSymmetricKey != null)
      {
        writer
            .writeOctetString(TYPE_SYMMETRIC_KEY_ELEMENT, requestSymmetricKey);
            if (requestSymmetricKey != null) {
                writer.writeOctetString(TYPE_SYMMETRIC_KEY_ELEMENT, requestSymmetricKey);
      }
      if (instanceKeyID != null)
      {
            if (instanceKeyID != null) {
        writer.writeOctetString(TYPE_INSTANCE_KEY_ID_ELEMENT, instanceKeyID);
      }
      writer.writeEndSequence();
    }
    catch (final IOException ioe)
    {
        } catch (final IOException ioe) {
      // This should never happen unless there is a bug somewhere.
      throw new RuntimeException(ioe);
    }
@@ -270,19 +219,14 @@
    return buffer.toByteString();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasValue()
  {
    public boolean hasValue() {
    return true;
  }
  /**
   * Sets the instance key ID.
   *
@@ -290,15 +234,11 @@
   *          The instance key ID.
   * @return This get symmetric key request.
   */
  public GetSymmetricKeyExtendedRequest setInstanceKeyID(
      final String instanceKeyID)
  {
    public GetSymmetricKeyExtendedRequest setInstanceKeyID(final String instanceKeyID) {
    this.instanceKeyID = instanceKeyID;
    return this;
  }
  /**
   * Sets the request symmetric key.
   *
@@ -306,21 +246,16 @@
   *          The request symmetric key.
   * @return This get symmetric key request.
   */
  public GetSymmetricKeyExtendedRequest setRequestSymmetricKey(
      final String requestSymmetricKey)
  {
    public GetSymmetricKeyExtendedRequest setRequestSymmetricKey(final String requestSymmetricKey) {
    this.requestSymmetricKey = requestSymmetricKey;
    return this;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("GetSymmetricKeyExtendedRequest(requestName=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateExtendedRequest.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.ldap.extensions;
import static com.forgerock.opendj.util.StaticUtils.formatAsGeneralizedTime;
import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_PWPSTATE_EXTOP_DECODE_FAILURE;
@@ -46,7 +43,12 @@
import org.forgerock.opendj.asn1.ASN1;
import org.forgerock.opendj.asn1.ASN1Reader;
import org.forgerock.opendj.asn1.ASN1Writer;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.controls.Control;
import org.forgerock.opendj.ldap.requests.AbstractExtendedRequest;
import org.forgerock.opendj.ldap.requests.ExtendedRequest;
@@ -57,8 +59,6 @@
import com.forgerock.opendj.util.Validator;
/**
 * This class implements an LDAP extended operation that can be used to query
 * and update elements of the Directory Server password policy state for a given
@@ -127,183 +127,136 @@
public final class PasswordPolicyStateExtendedRequest
    extends
    AbstractExtendedRequest<PasswordPolicyStateExtendedRequest, PasswordPolicyStateExtendedResult>
    implements PasswordPolicyStateOperationContainer
{
  private static final class MultiValueOperation implements
      PasswordPolicyStateOperation
  {
        implements PasswordPolicyStateOperationContainer {
    private static final class MultiValueOperation implements PasswordPolicyStateOperation {
    private final PasswordPolicyStateOperationType property;
    private final List<ByteString> values;
    private MultiValueOperation(
        final PasswordPolicyStateOperationType property, final ByteString value)
    {
        private MultiValueOperation(final PasswordPolicyStateOperationType property,
                final ByteString value) {
      this.property = property;
      this.values = Collections.singletonList(value);
    }
    private MultiValueOperation(
        final PasswordPolicyStateOperationType property,
        final List<ByteString> values)
    {
        private MultiValueOperation(final PasswordPolicyStateOperationType property,
                final List<ByteString> values) {
      this.property = property;
      this.values = values;
    }
    public PasswordPolicyStateOperationType getOperationType()
    {
        public PasswordPolicyStateOperationType getOperationType() {
      return property;
    }
    public Iterable<ByteString> getValues()
    {
        public Iterable<ByteString> getValues() {
      return values;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String toString()
    {
        public String toString() {
      return property.toString() + ": " + values;
    }
  }
  private static final class RequestDecoder
      implements
      ExtendedRequestDecoder<PasswordPolicyStateExtendedRequest, PasswordPolicyStateExtendedResult>
  {
            ExtendedRequestDecoder<PasswordPolicyStateExtendedRequest, PasswordPolicyStateExtendedResult> {
    public PasswordPolicyStateExtendedRequest decodeExtendedRequest(
        final ExtendedRequest<?> request, final DecodeOptions options)
        throws DecodeException
    {
                throws DecodeException {
      final ByteString requestValue = request.getValue();
      if ((requestValue == null) || (requestValue.length() <= 0))
      {
            if ((requestValue == null) || (requestValue.length() <= 0)) {
        throw DecodeException.error(ERR_PWPSTATE_EXTOP_NO_REQUEST_VALUE.get());
      }
      try
      {
            try {
        final ASN1Reader reader = ASN1.getReader(requestValue);
        reader.readStartSequence();
        // Read the target user DN
        final PasswordPolicyStateExtendedRequest newRequest =
          new PasswordPolicyStateExtendedRequest(
              reader.readOctetStringAsString());
                        new PasswordPolicyStateExtendedRequest(reader.readOctetStringAsString());
        decodeOperations(reader, newRequest);
        reader.readEndSequence();
        for (final Control control : request.getControls())
        {
                for (final Control control : request.getControls()) {
          newRequest.addControl(control);
        }
        return newRequest;
      }
      catch (final IOException ioe)
      {
        final LocalizableMessage message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE
            .get(getExceptionMessage(ioe));
            } catch (final IOException ioe) {
                final LocalizableMessage message =
                        ERR_PWPSTATE_EXTOP_DECODE_FAILURE.get(getExceptionMessage(ioe));
        throw DecodeException.error(message, ioe);
      }
    }
  }
  private static final class ResultDecoder extends
      AbstractExtendedResultDecoder<PasswordPolicyStateExtendedResult>
  {
            AbstractExtendedResultDecoder<PasswordPolicyStateExtendedResult> {
    /**
     * {@inheritDoc}
     */
    public PasswordPolicyStateExtendedResult newExtendedErrorResult(
        final ResultCode resultCode, final String matchedDN,
        final String diagnosticMessage)
    {
      if (!resultCode.isExceptional())
      {
                final ResultCode resultCode, final String matchedDN, final String diagnosticMessage) {
            if (!resultCode.isExceptional()) {
        // A successful response must contain a response name and
        // value.
        throw new IllegalArgumentException(
            "No response name and value for result code "
                throw new IllegalArgumentException("No response name and value for result code "
                + resultCode.intValue());
      }
      return new PasswordPolicyStateExtendedResult(resultCode, (String) null)
          .setMatchedDN(matchedDN).setDiagnosticMessage(diagnosticMessage);
            return new PasswordPolicyStateExtendedResult(resultCode, (String) null).setMatchedDN(
                    matchedDN).setDiagnosticMessage(diagnosticMessage);
    }
    public PasswordPolicyStateExtendedResult decodeExtendedResult(
        final ExtendedResult result, final DecodeOptions options)
        throws DecodeException
    {
        public PasswordPolicyStateExtendedResult decodeExtendedResult(final ExtendedResult result,
                final DecodeOptions options) throws DecodeException {
      final ResultCode resultCode = result.getResultCode();
      final ByteString responseValue = result.getValue();
      if (!resultCode.isExceptional()
          && ((responseValue == null) || (responseValue.length() <= 0)))
      {
                    && ((responseValue == null) || (responseValue.length() <= 0))) {
        throw DecodeException.error(ERR_PWPSTATE_EXTOP_NO_REQUEST_VALUE.get());
      }
      try
      {
            try {
        final ASN1Reader reader = ASN1.getReader(responseValue);
        reader.readStartSequence();
        // Read the target user DN
        final PasswordPolicyStateExtendedResult newResult = new PasswordPolicyStateExtendedResult(
            resultCode, reader.readOctetStringAsString()).setMatchedDN(
            result.getMatchedDN()).setDiagnosticMessage(
            result.getDiagnosticMessage());
                final PasswordPolicyStateExtendedResult newResult =
                        new PasswordPolicyStateExtendedResult(resultCode, reader
                                .readOctetStringAsString()).setMatchedDN(result.getMatchedDN())
                                .setDiagnosticMessage(result.getDiagnosticMessage());
        decodeOperations(reader, newResult);
        reader.readEndSequence();
        for (final Control control : result.getControls())
        {
                for (final Control control : result.getControls()) {
          newResult.addControl(control);
        }
        return newResult;
      }
      catch (final IOException ioe)
      {
        final LocalizableMessage message = ERR_PWPSTATE_EXTOP_DECODE_FAILURE
            .get(getExceptionMessage(ioe));
            } catch (final IOException ioe) {
                final LocalizableMessage message =
                        ERR_PWPSTATE_EXTOP_DECODE_FAILURE.get(getExceptionMessage(ioe));
        throw DecodeException.error(message, ioe);
      }
    }
  }
  /**
   * The OID for the password policy state extended operation (both the request
   * and response types).
     * The OID for the password policy state extended operation (both the
     * request and response types).
   */
  public static final String OID = "1.3.6.1.4.1.26027.1.6.1";
@@ -318,13 +271,11 @@
  static final String ACCOUNT_EXPIRATION_TIME_NAME = "Account Expiration Time";
  static final String SECONDS_UNTIL_ACCOUNT_EXPIRATION_NAME =
    "Seconds Until Account Expiration";
    static final String SECONDS_UNTIL_ACCOUNT_EXPIRATION_NAME = "Seconds Until Account Expiration";
  static final String PASSWORD_CHANGED_TIME_NAME = "Password Changed Time";
  static final String PASSWORD_EXPIRATION_WARNED_TIME_NAME =
    "Password Expiration Warned Time";
    static final String PASSWORD_EXPIRATION_WARNED_TIME_NAME = "Password Expiration Warned Time";
  static final String SECONDS_UNTIL_PASSWORD_EXPIRATION_NAME =
    "Seconds Until Password Expiration";
@@ -332,8 +283,7 @@
  static final String SECONDS_UNTIL_PASSWORD_EXPIRATION_WARNING_NAME =
    "Seconds Until Password Expiration Warning";
  static final String AUTHENTICATION_FAILURE_TIMES_NAME =
    "Authentication Failure Times";
    static final String AUTHENTICATION_FAILURE_TIMES_NAME = "Authentication Failure Times";
  static final String SECONDS_UNTIL_AUTHENTICATION_FAILURE_UNLOCK_NAME =
    "Seconds Until Authentication Failure Unlock";
@@ -343,8 +293,7 @@
  static final String LAST_LOGIN_TIME_NAME = "Last Login Time";
  static final String SECONDS_UNTIL_IDLE_LOCKOUT_NAME =
    "Seconds Until Idle Lockout";
    static final String SECONDS_UNTIL_IDLE_LOCKOUT_NAME = "Seconds Until Idle Lockout";
  static final String PASSWORD_RESET_STATE_NAME = "Password Reset State";
@@ -353,8 +302,7 @@
  static final String GRACE_LOGIN_USE_TIMES_NAME = "Grace Login Use Times";
  static final String REMAINING_GRACE_LOGIN_COUNT_NAME =
    "Remaining Grace Login Count";
    static final String REMAINING_GRACE_LOGIN_COUNT_NAME = "Remaining Grace Login Count";
  static final String PASSWORD_CHANGED_BY_REQUIRED_TIME_NAME =
    "Password Changed By Required Time";
@@ -373,30 +321,22 @@
  // No need to expose this.
  private static final ResultDecoder RESULT_DECODER = new ResultDecoder();
  static ByteString encode(final String targetUser,
      final List<PasswordPolicyStateOperation> operations)
  {
            final List<PasswordPolicyStateOperation> operations) {
    final ByteStringBuilder buffer = new ByteStringBuilder(6);
    final ASN1Writer writer = ASN1.getWriter(buffer);
    try
    {
        try {
      writer.writeStartSequence();
      writer.writeOctetString(targetUser);
      if (!operations.isEmpty())
      {
            if (!operations.isEmpty()) {
        writer.writeStartSequence();
        for (final PasswordPolicyStateOperation operation : operations)
        {
                for (final PasswordPolicyStateOperation operation : operations) {
          writer.writeStartSequence();
          writer.writeEnumerated(operation.getOperationType().ordinal());
          if (operation.getValues() != null)
          {
                    if (operation.getValues() != null) {
            writer.writeStartSequence();
            for (final ByteString value : operation.getValues())
            {
                        for (final ByteString value : operation.getValues()) {
              writer.writeOctetString(value);
            }
            writer.writeEndSequence();
@@ -406,9 +346,7 @@
        writer.writeEndSequence();
      }
      writer.writeEndSequence();
    }
    catch (final IOException ioe)
    {
        } catch (final IOException ioe) {
      // This should never happen unless there is a bug somewhere.
      throw new RuntimeException(ioe);
    }
@@ -416,47 +354,35 @@
    return buffer.toByteString();
  }
  private static void decodeOperations(final ASN1Reader reader,
      final PasswordPolicyStateOperationContainer container)
      throws IOException, DecodeException
  {
            final PasswordPolicyStateOperationContainer container) throws IOException,
            DecodeException {
    // See if we have operations
    if (reader.hasNextElement())
    {
        if (reader.hasNextElement()) {
      reader.readStartSequence();
      int opType;
      PasswordPolicyStateOperationType type;
      while (reader.hasNextElement())
      {
            while (reader.hasNextElement()) {
        reader.readStartSequence();
        // Read the opType
        opType = reader.readEnumerated();
        try
        {
                try {
          type = PasswordPolicyStateOperationType.values()[opType];
        }
        catch (final IndexOutOfBoundsException iobe)
        {
          throw DecodeException.error(ERR_PWPSTATE_EXTOP_UNKNOWN_OP_TYPE
              .get(String.valueOf(opType)), iobe);
                } catch (final IndexOutOfBoundsException iobe) {
                    throw DecodeException.error(ERR_PWPSTATE_EXTOP_UNKNOWN_OP_TYPE.get(String
                            .valueOf(opType)), iobe);
        }
        // See if we have any values
        if (reader.hasNextElement())
        {
                if (reader.hasNextElement()) {
          reader.readStartSequence();
          final ArrayList<ByteString> values = new ArrayList<ByteString>();
          while (reader.hasNextElement())
          {
                    while (reader.hasNextElement()) {
            values.add(reader.readOctetString());
          }
          reader.readEndSequence();
          container.addOperation(new MultiValueOperation(type, values));
        }
        else
        {
                } else {
          container.addOperation(type);
        }
        reader.readEndSequence();
@@ -465,8 +391,6 @@
    }
  }
  /**
   * Creates a new password policy state extended request using the provided
   * user name.
@@ -474,14 +398,11 @@
   * @param targetUser
   *          The name of the user.
   */
  public PasswordPolicyStateExtendedRequest(final DN targetUser)
  {
    public PasswordPolicyStateExtendedRequest(final DN targetUser) {
    Validator.ensureNotNull(targetUser);
    this.targetUser = targetUser.toString();
  }
  /**
   * Creates a new password policy state extended request using the provided
   * user name.
@@ -489,529 +410,360 @@
   * @param targetUser
   *          The name of the user.
   */
  public PasswordPolicyStateExtendedRequest(final String targetUser)
  {
    public PasswordPolicyStateExtendedRequest(final String targetUser) {
    Validator.ensureNotNull(targetUser);
    this.targetUser = targetUser;
  }
  /**
   * Adds the provided authentication failure time to this request.
   *
   * @param date
   *          The authentication failure time.
   */
  public void addAuthenticationFailureTime(final Date date)
  {
    if (date == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.ADD_AUTHENTICATION_FAILURE_TIMES);
    }
    else
    {
    public void addAuthenticationFailureTime(final Date date) {
        if (date == null) {
            operations.add(PasswordPolicyStateOperationType.ADD_AUTHENTICATION_FAILURE_TIMES);
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.ADD_AUTHENTICATION_FAILURE_TIMES,
          ByteString.valueOf(formatAsGeneralizedTime(date))));
                    PasswordPolicyStateOperationType.ADD_AUTHENTICATION_FAILURE_TIMES, ByteString
                            .valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * Adds the provided grace login use time to this request.
   *
   * @param date
   *          The grace login use time.
   */
  public void addGraceLoginUseTime(final Date date)
  {
    if (date == null)
    {
    public void addGraceLoginUseTime(final Date date) {
        if (date == null) {
      operations.add(PasswordPolicyStateOperationType.ADD_GRACE_LOGIN_USE_TIME);
    }
    else
    {
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.ADD_GRACE_LOGIN_USE_TIME, ByteString
              .valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * {@inheritDoc}
   */
  public void addOperation(final PasswordPolicyStateOperation operation)
  {
    public void addOperation(final PasswordPolicyStateOperation operation) {
    operations.add(operation);
  }
  /**
   * Clears the account disabled state.
   */
  public void clearAccountDisabledState()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_DISABLED_STATE);
    public void clearAccountDisabledState() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_DISABLED_STATE);
  }
  /**
   * Clears the account expiration time.
   */
  public void clearAccountExpirationTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_EXPIRATION_TIME);
    public void clearAccountExpirationTime() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_EXPIRATION_TIME);
  }
  /**
   * Clears the authentication failure times.
   */
  public void clearAuthenticationFailureTimes()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_AUTHENTICATION_FAILURE_TIMES);
    public void clearAuthenticationFailureTimes() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_AUTHENTICATION_FAILURE_TIMES);
  }
  /**
   * Clears the grace login use times.
   */
  public void clearGraceLoginUseTimes()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_GRACE_LOGIN_USE_TIMES);
    public void clearGraceLoginUseTimes() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_GRACE_LOGIN_USE_TIMES);
  }
  /**
   * Clears the last login time.
   */
  public void clearLastLoginTime()
  {
    public void clearLastLoginTime() {
    operations.add(PasswordPolicyStateOperationType.CLEAR_LAST_LOGIN_TIME);
  }
  /**
   * Clears the password changed by required time.
   */
  public void clearPasswordChangedByRequiredTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_BY_REQUIRED_TIME);
    public void clearPasswordChangedByRequiredTime() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_BY_REQUIRED_TIME);
  }
  /**
   * Clears the password changed time.
   */
  public void clearPasswordChangedTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_TIME);
    public void clearPasswordChangedTime() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_TIME);
  }
  /**
   * Clears the password expiration warned time.
   */
  public void clearPasswordExpirationWarnedTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_EXPIRATION_WARNED_TIME);
    public void clearPasswordExpirationWarnedTime() {
        operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_EXPIRATION_WARNED_TIME);
  }
  /**
   * Clears the password history.
   */
  public void clearPasswordHistory()
  {
    public void clearPasswordHistory() {
    operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_HISTORY);
  }
  /**
   * Clears the password reset state.
   */
  public void clearPasswordResetState()
  {
    public void clearPasswordResetState() {
    operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_RESET_STATE);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String getOID()
  {
    public String getOID() {
    return OID;
  }
  /**
   * {@inheritDoc}
   */
  public Iterable<PasswordPolicyStateOperation> getOperations()
  {
    public Iterable<PasswordPolicyStateOperation> getOperations() {
    return operations;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ExtendedResultDecoder<PasswordPolicyStateExtendedResult> getResultDecoder()
  {
    public ExtendedResultDecoder<PasswordPolicyStateExtendedResult> getResultDecoder() {
    return RESULT_DECODER;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ByteString getValue()
  {
    public ByteString getValue() {
    return encode(targetUser, operations);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasValue()
  {
    public boolean hasValue() {
    return true;
  }
  /**
   * Returns the account disabled state.
   */
  public void requestAccountDisabledState()
  {
    public void requestAccountDisabledState() {
    operations.add(PasswordPolicyStateOperationType.GET_ACCOUNT_DISABLED_STATE);
  }
  /**
   * Returns the account expiration time.
   */
  public void requestAccountExpirationTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_ACCOUNT_EXPIRATION_TIME);
    public void requestAccountExpirationTime() {
        operations.add(PasswordPolicyStateOperationType.GET_ACCOUNT_EXPIRATION_TIME);
  }
  /**
   * Returns the authentication failure times.
   */
  public void requestAuthenticationFailureTimes()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_AUTHENTICATION_FAILURE_TIMES);
    public void requestAuthenticationFailureTimes() {
        operations.add(PasswordPolicyStateOperationType.GET_AUTHENTICATION_FAILURE_TIMES);
  }
  /**
   * Returns the grace login use times.
   */
  public void requestGraceLoginUseTimes()
  {
    public void requestGraceLoginUseTimes() {
    operations.add(PasswordPolicyStateOperationType.GET_GRACE_LOGIN_USE_TIMES);
  }
  /**
   * Returns the last login time.
   */
  public void requestLastLoginTime()
  {
    public void requestLastLoginTime() {
    operations.add(PasswordPolicyStateOperationType.GET_LAST_LOGIN_TIME);
  }
  /**
   * Returns the password changed by required time.
   */
  public void requestPasswordChangedByRequiredTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_PASSWORD_CHANGED_BY_REQUIRED_TIME);
    public void requestPasswordChangedByRequiredTime() {
        operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_CHANGED_BY_REQUIRED_TIME);
  }
  /**
   * Returns the password changed time.
   */
  public void requestPasswordChangedTime()
  {
    public void requestPasswordChangedTime() {
    operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_CHANGED_TIME);
  }
  /**
   * Returns the password expiration warned time.
   */
  public void requestPasswordExpirationWarnedTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_PASSWORD_EXPIRATION_WARNED_TIME);
    public void requestPasswordExpirationWarnedTime() {
        operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_EXPIRATION_WARNED_TIME);
  }
  /**
   * Returns the password history.
   */
  public void requestPasswordHistory()
  {
    public void requestPasswordHistory() {
    operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_HISTORY);
  }
  /**
   * Returns the password policy DN.
   */
  public void requestPasswordPolicyDN()
  {
    public void requestPasswordPolicyDN() {
    operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_POLICY_DN);
  }
  /**
   * Returns the password reset state.
   */
  public void requestPasswordResetState()
  {
    public void requestPasswordResetState() {
    operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_RESET_STATE);
  }
  /**
   * Returns the remaining authentication failure count.
   */
  public void requestRemainingAuthenticationFailureCount()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_REMAINING_AUTHENTICATION_FAILURE_COUNT);
    public void requestRemainingAuthenticationFailureCount() {
        operations.add(PasswordPolicyStateOperationType.GET_REMAINING_AUTHENTICATION_FAILURE_COUNT);
  }
  /**
   * Returns the remaining grace login count.
   */
  public void requestRemainingGraceLoginCount()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_REMAINING_GRACE_LOGIN_COUNT);
    public void requestRemainingGraceLoginCount() {
        operations.add(PasswordPolicyStateOperationType.GET_REMAINING_GRACE_LOGIN_COUNT);
  }
  /**
   * Returns the seconds until account expiration.
   */
  public void requestSecondsUntilAccountExpiration()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION);
    public void requestSecondsUntilAccountExpiration() {
        operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION);
  }
  /**
   * Returns the seconds until authentication failure unlock.
   */
  public void requestSecondsUntilAuthenticationFailureUnlock()
  {
    public void requestSecondsUntilAuthenticationFailureUnlock() {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_AUTHENTICATION_FAILURE_UNLOCK);
  }
  /**
   * Returns the seconds until idle lockout.
   */
  public void requestSecondsUntilIdleLockout()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_IDLE_LOCKOUT);
    public void requestSecondsUntilIdleLockout() {
        operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_IDLE_LOCKOUT);
  }
  /**
   * Returns the seconds until password expiration.
   */
  public void requestSecondsUntilPasswordExpiration()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_EXPIRATION);
    public void requestSecondsUntilPasswordExpiration() {
        operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_EXPIRATION);
  }
  /**
   * Returns the seconds until password expiration warning.
   */
  public void requestSecondsUntilPasswordExpirationWarning()
  {
    public void requestSecondsUntilPasswordExpirationWarning() {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_EXPIRATION_WARNING);
  }
  /**
   * Returns the seconds until password reset lockout.
   */
  public void requestSecondsUntilPasswordResetLockout()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_RESET_LOCKOUT);
    public void requestSecondsUntilPasswordResetLockout() {
        operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_RESET_LOCKOUT);
  }
  /**
   * Returns the seconds until required change time.
   */
  public void requestSecondsUntilRequiredChangeTime()
  {
    operations
        .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME);
    public void requestSecondsUntilRequiredChangeTime() {
        operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME);
  }
  /**
   * Sets the account disabled state.
   *
   * @param state
   *          The account disabled state.
   */
  public void setAccountDisabledState(final boolean state)
  {
    public void setAccountDisabledState(final boolean state) {
    operations.add(new MultiValueOperation(
        PasswordPolicyStateOperationType.SET_ACCOUNT_DISABLED_STATE, ByteString
            .valueOf(String.valueOf(state))));
  }
  /**
   * Sets the account expiration time.
   *
   * @param date
   *          The account expiration time.
   */
  public void setAccountExpirationTime(final Date date)
  {
    if (date == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.SET_ACCOUNT_EXPIRATION_TIME);
    }
    else
    {
    public void setAccountExpirationTime(final Date date) {
        if (date == null) {
            operations.add(PasswordPolicyStateOperationType.SET_ACCOUNT_EXPIRATION_TIME);
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.SET_ACCOUNT_EXPIRATION_TIME,
          ByteString.valueOf(formatAsGeneralizedTime(date))));
                    PasswordPolicyStateOperationType.SET_ACCOUNT_EXPIRATION_TIME, ByteString
                            .valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * Sets the authentication failure times.
   *
   * @param dates
   *          The authentication failure times.
   */
  public void setAuthenticationFailureTimes(final Date... dates)
  {
    if (dates == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.SET_AUTHENTICATION_FAILURE_TIMES);
    }
    else
    {
      final ArrayList<ByteString> times = new ArrayList<ByteString>(
          dates.length);
      for (final Date date : dates)
      {
    public void setAuthenticationFailureTimes(final Date... dates) {
        if (dates == null) {
            operations.add(PasswordPolicyStateOperationType.SET_AUTHENTICATION_FAILURE_TIMES);
        } else {
            final ArrayList<ByteString> times = new ArrayList<ByteString>(dates.length);
            for (final Date date : dates) {
        times.add(ByteString.valueOf(formatAsGeneralizedTime(date)));
      }
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.SET_AUTHENTICATION_FAILURE_TIMES,
          times));
                    PasswordPolicyStateOperationType.SET_AUTHENTICATION_FAILURE_TIMES, times));
    }
  }
  /**
   * Sets the grace login use times.
   *
   * @param dates
   *          The grace login use times.
   */
  public void setGraceLoginUseTimes(final Date... dates)
  {
    if (dates == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.SET_GRACE_LOGIN_USE_TIMES);
    }
    else
    {
      final ArrayList<ByteString> times = new ArrayList<ByteString>(
          dates.length);
      for (final Date date : dates)
      {
    public void setGraceLoginUseTimes(final Date... dates) {
        if (dates == null) {
            operations.add(PasswordPolicyStateOperationType.SET_GRACE_LOGIN_USE_TIMES);
        } else {
            final ArrayList<ByteString> times = new ArrayList<ByteString>(dates.length);
            for (final Date date : dates) {
        times.add(ByteString.valueOf(formatAsGeneralizedTime(date)));
      }
      operations.add(new MultiValueOperation(
@@ -1019,114 +771,85 @@
    }
  }
  /**
   * Sets the last login time.
   *
   * @param date
   *          The last login time.
   */
  public void setLastLoginTime(final Date date)
  {
    if (date == null)
    {
    public void setLastLoginTime(final Date date) {
        if (date == null) {
      operations.add(PasswordPolicyStateOperationType.SET_LAST_LOGIN_TIME);
    }
    else
    {
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.SET_LAST_LOGIN_TIME, ByteString
              .valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * Sets the password changed by required time.
   *
   * @param state
   *          The password changed by required time.
   */
  public void setPasswordChangedByRequiredTime(final boolean state)
  {
    public void setPasswordChangedByRequiredTime(final boolean state) {
    operations.add(new MultiValueOperation(
        PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_BY_REQUIRED_TIME,
        ByteString.valueOf(String.valueOf(state))));
                PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_BY_REQUIRED_TIME, ByteString
                        .valueOf(String.valueOf(state))));
  }
  /**
   * Sets the password changed time.
   *
   * @param date
   *          The password changed time.
   */
  public void setPasswordChangedTime(final Date date)
  {
    if (date == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_TIME);
    }
    else
    {
    public void setPasswordChangedTime(final Date date) {
        if (date == null) {
            operations.add(PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_TIME);
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_TIME,
          ByteString.valueOf(formatAsGeneralizedTime(date))));
                    PasswordPolicyStateOperationType.SET_PASSWORD_CHANGED_TIME, ByteString
                            .valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * Sets the password expiration warned time.
   *
   * @param date
   *          The password expiration warned time.
   */
  public void setPasswordExpirationWarnedTime(final Date date)
  {
    if (date == null)
    {
      operations
          .add(PasswordPolicyStateOperationType.SET_PASSWORD_EXPIRATION_WARNED_TIME);
    public void setPasswordExpirationWarnedTime(final Date date) {
        if (date == null) {
            operations.add(PasswordPolicyStateOperationType.SET_PASSWORD_EXPIRATION_WARNED_TIME);
    }
    else
    {
        } else {
      operations.add(new MultiValueOperation(
          PasswordPolicyStateOperationType.SET_PASSWORD_EXPIRATION_WARNED_TIME,
          ByteString.valueOf(formatAsGeneralizedTime(date))));
    }
  }
  /**
   * Sets the password reset state.
   *
   * @param state
   *          The password reset state.
   */
  public void setPasswordResetState(final boolean state)
  {
    public void setPasswordResetState(final boolean state) {
    operations.add(new MultiValueOperation(
        PasswordPolicyStateOperationType.SET_PASSWORD_RESET_STATE, ByteString
            .valueOf(String.valueOf(state))));
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("PasswordPolicyStateExtendedRequest(requestName=");
    builder.append(getOID());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateExtendedResult.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
package com.forgerock.opendj.ldap.extensions;
import java.util.ArrayList;
import java.util.List;
@@ -37,22 +34,17 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.responses.AbstractExtendedResult;
/**
 * The password policy state extended result.
 */
public final class PasswordPolicyStateExtendedResult extends
    AbstractExtendedResult<PasswordPolicyStateExtendedResult> implements
    PasswordPolicyStateOperationContainer
{
        PasswordPolicyStateOperationContainer {
  private final String targetUser;
  private final List<PasswordPolicyStateOperation> operations =
    new ArrayList<PasswordPolicyStateOperation>();
  /**
   * Creates a new password policy state extended result with the provided
   * result code and target user.
@@ -62,14 +54,10 @@
   * @param targetUser
   *          The user name.
   */
  public PasswordPolicyStateExtendedResult(final ResultCode resultCode,
      final DN targetUser)
  {
    public PasswordPolicyStateExtendedResult(final ResultCode resultCode, final DN targetUser) {
    this(resultCode, String.valueOf(targetUser));
  }
  /**
   * Creates a new password policy state extended result with the provided
   * result code and target user.
@@ -79,75 +67,55 @@
   * @param targetUser
   *          The user name.
   */
  public PasswordPolicyStateExtendedResult(final ResultCode resultCode,
      final String targetUser)
  {
    public PasswordPolicyStateExtendedResult(final ResultCode resultCode, final String targetUser) {
    super(resultCode);
    this.targetUser = targetUser;
  }
  /**
   * {@inheritDoc}
   */
  public void addOperation(final PasswordPolicyStateOperation operation)
  {
    public void addOperation(final PasswordPolicyStateOperation operation) {
    operations.add(operation);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String getOID()
  {
    public String getOID() {
    // No response name defined.
    return PasswordPolicyStateExtendedRequest.OID;
  }
  /**
   * {@inheritDoc}
   */
  public Iterable<PasswordPolicyStateOperation> getOperations()
  {
    public Iterable<PasswordPolicyStateOperation> getOperations() {
    return operations;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ByteString getValue()
  {
    public ByteString getValue() {
    return PasswordPolicyStateExtendedRequest.encode(targetUser, operations);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean hasValue()
  {
    public boolean hasValue() {
    return true;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("PasswordPolicyStateExtendedResponse(resultCode=");
    builder.append(getResultCode());
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperation.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,17 +26,12 @@
package com.forgerock.opendj.ldap.extensions;
import org.forgerock.opendj.ldap.ByteString;
/**
 * Password policy state operation.
 */
public interface PasswordPolicyStateOperation
{
public interface PasswordPolicyStateOperation {
  /**
   * Returns the type of operation.
   *
@@ -45,8 +39,6 @@
   */
  PasswordPolicyStateOperationType getOperationType();
  /**
   * Returns the operation values.
   *
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperationContainer.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,13 +26,10 @@
package com.forgerock.opendj.ldap.extensions;
/**
 * Password policy state operation container.
 */
interface PasswordPolicyStateOperationContainer
{
interface PasswordPolicyStateOperationContainer {
  /**
   * Adds an operation to this container.
   *
@@ -42,8 +38,6 @@
   */
  void addOperation(PasswordPolicyStateOperation operation);
  /**
   * Returns the operations in this container.
   *
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/PasswordPolicyStateOperationType.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,59 +26,46 @@
package com.forgerock.opendj.ldap.extensions;
import org.forgerock.opendj.ldap.ByteString;
/**
 * Password policy state operation type.
 */
public enum PasswordPolicyStateOperationType implements
    PasswordPolicyStateOperation
{
public enum PasswordPolicyStateOperationType implements PasswordPolicyStateOperation {
  /**
   * Get password policy DN operation.
   */
  GET_PASSWORD_POLICY_DN(
      PasswordPolicyStateExtendedRequest.PASSWORD_POLICY_DN_NAME),
    GET_PASSWORD_POLICY_DN(PasswordPolicyStateExtendedRequest.PASSWORD_POLICY_DN_NAME),
  /**
   * Get account disabled state operation.
   */
  GET_ACCOUNT_DISABLED_STATE(
      PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
    GET_ACCOUNT_DISABLED_STATE(PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
  /**
   * Set account disabled state operation.
   */
  SET_ACCOUNT_DISABLED_STATE(
      PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
    SET_ACCOUNT_DISABLED_STATE(PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
  /**
   * Clear account disabled state operation.
   */
  CLEAR_ACCOUNT_DISABLED_STATE(
      PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
    CLEAR_ACCOUNT_DISABLED_STATE(PasswordPolicyStateExtendedRequest.ACCOUNT_DISABLED_STATE_NAME),
  /**
   * Get account expiration time operation.
   */
  GET_ACCOUNT_EXPIRATION_TIME(
      PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
    GET_ACCOUNT_EXPIRATION_TIME(PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
  /**
   * Set account expiration time operation.
   */
  SET_ACCOUNT_EXPIRATION_TIME(
      PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
    SET_ACCOUNT_EXPIRATION_TIME(PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
  /**
   * Clear account expiration time operation.
   */
  CLEAR_ACCOUNT_EXPIRATION_TIME(
      PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
    CLEAR_ACCOUNT_EXPIRATION_TIME(PasswordPolicyStateExtendedRequest.ACCOUNT_EXPIRATION_TIME_NAME),
  /**
   * Get seconds until account expiration operation.
@@ -90,20 +76,17 @@
  /**
   * Get password changed time operation.
   */
  GET_PASSWORD_CHANGED_TIME(
      PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
    GET_PASSWORD_CHANGED_TIME(PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
  /**
   * Set password changed time operation.
   */
  SET_PASSWORD_CHANGED_TIME(
      PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
    SET_PASSWORD_CHANGED_TIME(PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
  /**
   * Clear password changed time operation.
   */
  CLEAR_PASSWORD_CHANGED_TIME(
      PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
    CLEAR_PASSWORD_CHANGED_TIME(PasswordPolicyStateExtendedRequest.PASSWORD_CHANGED_TIME_NAME),
  /**
   * Get password expiration warned time operation.
@@ -195,20 +178,17 @@
  /**
   * Get password reset state operation.
   */
  GET_PASSWORD_RESET_STATE(
      PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
    GET_PASSWORD_RESET_STATE(PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
  /**
   * Set password reset state operation.
   */
  SET_PASSWORD_RESET_STATE(
      PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
    SET_PASSWORD_RESET_STATE(PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
  /**
   * Clear password reset state operation.
   */
  CLEAR_PASSWORD_RESET_STATE(
      PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
    CLEAR_PASSWORD_RESET_STATE(PasswordPolicyStateExtendedRequest.PASSWORD_RESET_STATE_NAME),
  /**
   * Get seconds until password reset lockout operation.
@@ -219,26 +199,22 @@
  /**
   * Get grace login use times operation.
   */
  GET_GRACE_LOGIN_USE_TIMES(
      PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
    GET_GRACE_LOGIN_USE_TIMES(PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
  /**
   * Add grace login use times operation.
   */
  ADD_GRACE_LOGIN_USE_TIME(
      PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
    ADD_GRACE_LOGIN_USE_TIME(PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
  /**
   * Set grace login use times operation.
   */
  SET_GRACE_LOGIN_USE_TIMES(
      PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
    SET_GRACE_LOGIN_USE_TIMES(PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
  /**
   * Clear grace login use times operation.
   */
  CLEAR_GRACE_LOGIN_USE_TIMES(
      PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
    CLEAR_GRACE_LOGIN_USE_TIMES(PasswordPolicyStateExtendedRequest.GRACE_LOGIN_USE_TIMES_NAME),
  /**
   * Get remaining grace login count operation.
@@ -278,46 +254,33 @@
  /**
   * Clear password history operation.
   */
  CLEAR_PASSWORD_HISTORY(
      PasswordPolicyStateExtendedRequest.PASSWORD_HISTORY_NAME);
    CLEAR_PASSWORD_HISTORY(PasswordPolicyStateExtendedRequest.PASSWORD_HISTORY_NAME);
  private String propertyName;
  private PasswordPolicyStateOperationType(final String propertyName)
  {
    private PasswordPolicyStateOperationType(final String propertyName) {
    this.propertyName = propertyName;
  }
  /**
   * {@inheritDoc}
   */
  public PasswordPolicyStateOperationType getOperationType()
  {
    public PasswordPolicyStateOperationType getOperationType() {
    return this;
  }
  /**
   * {@inheritDoc}
   */
  public Iterable<ByteString> getValues()
  {
    public Iterable<ByteString> getValues() {
    return null;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    return propertyName;
  }
}
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/extensions/package-info.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -30,5 +29,3 @@
 */
package com.forgerock.opendj.ldap.extensions;
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/package-info.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -30,5 +29,3 @@
 */
package com.forgerock.opendj.ldap;
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ASCIICharProp.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -28,8 +27,6 @@
package com.forgerock.opendj.util;
/**
 * A {@code ASCIICharProp} provides fast access to ASCII character properties.
 * In particular, the ability to query whether or not a character is a letter, a
@@ -39,8 +36,7 @@
 * The methods in this class do not perform memory allocations nor calculations
 * and so can be used safely in high performance situations.
 */
public final class ASCIICharProp implements Comparable<ASCIICharProp>
{
public final class ASCIICharProp implements Comparable<ASCIICharProp> {
  private final char c;
  private final char upperCaseChar;
@@ -69,16 +65,12 @@
  private static final ASCIICharProp[] CHAR_PROPS = new ASCIICharProp[128];
  static
  {
    for (int i = 0; i < 128; i++)
    {
    static {
        for (int i = 0; i < 128; i++) {
      CHAR_PROPS[i] = new ASCIICharProp((char) i);
    }
  }
  /**
   * Returns the character properties for the provided ASCII character. If a
   * non-ASCII character is provided then this method returns {@code null}.
@@ -88,20 +80,14 @@
   * @return The character properties for the provided ASCII character, or
   *         {@code null} if {@code c} is greater than {@code \u007F} .
   */
  public static ASCIICharProp valueOf(final char c)
  {
    if (c < 128)
    {
    public static ASCIICharProp valueOf(final char c) {
        if (c < 128) {
      return CHAR_PROPS[c];
    }
    else
    {
        } else {
      return null;
    }
  }
  /**
   * Returns the character properties for the provided ASCII character. If a
   * non-ASCII character is provided then this method returns {@code null}.
@@ -109,30 +95,22 @@
   * @param c
   *          The ASCII character.
   * @return The character properties for the provided ASCII character, or
   *         {@code null} if {@code c} is less than zero or greater than {@code
   *         \u007F} .
     *         {@code null} if {@code c} is less than zero or greater than
     *         {@code \u007F} .
   */
  public static ASCIICharProp valueOf(final int c)
  {
    if (c >= 0 && c < 128)
    {
    public static ASCIICharProp valueOf(final int c) {
        if (c >= 0 && c < 128) {
      return CHAR_PROPS[c];
    }
    else
    {
        } else {
      return null;
    }
  }
  private ASCIICharProp(final char c)
  {
    private ASCIICharProp(final char c) {
    this.c = c;
    this.stringValue = new String(new char[] { c });
    if (c >= 'a' && c <= 'z')
    {
        if (c >= 'a' && c <= 'z') {
      this.upperCaseChar = (char) (c - 32);
      this.lowerCaseChar = c;
      this.isUpperCaseChar = false;
@@ -142,19 +120,14 @@
      this.isKeyChar = true;
      this.isCompatKeyChar = true;
      this.decimalValue = -1;
      if (c >= 'a' && c <= 'f')
      {
            if (c >= 'a' && c <= 'f') {
        this.isHexChar = true;
        this.hexValue = c - 87;
      }
      else
      {
            } else {
        this.isHexChar = false;
        this.hexValue = -1;
      }
    }
    else if (c >= 'A' && c <= 'Z')
    {
        } else if (c >= 'A' && c <= 'Z') {
      this.upperCaseChar = c;
      this.lowerCaseChar = (char) (c + 32);
      this.isUpperCaseChar = true;
@@ -164,19 +137,14 @@
      this.isKeyChar = true;
      this.isCompatKeyChar = true;
      this.decimalValue = -1;
      if (c >= 'A' && c <= 'F')
      {
            if (c >= 'A' && c <= 'F') {
        this.isHexChar = true;
        this.hexValue = c - 55;
      }
      else
      {
            } else {
        this.isHexChar = false;
        this.hexValue = -1;
      }
    }
    else if (c >= '0' && c <= '9')
    {
        } else if (c >= '0' && c <= '9') {
      this.upperCaseChar = c;
      this.lowerCaseChar = c;
      this.isUpperCaseChar = false;
@@ -188,9 +156,7 @@
      this.isHexChar = true;
      this.hexValue = c - 48;
      this.decimalValue = c - 48;
    }
    else
    {
        } else {
      this.upperCaseChar = c;
      this.lowerCaseChar = c;
      this.isUpperCaseChar = false;
@@ -205,30 +171,22 @@
    }
  }
  /**
   * Returns the char value associated with this {@code ASCIICharProp}.
   *
   * @return The char value associated with this {@code ASCIICharProp}.
   */
  public char charValue()
  {
    public char charValue() {
    return c;
  }
  /**
   * {@inheritDoc}
   */
  public int compareTo(final ASCIICharProp o)
  {
    public int compareTo(final ASCIICharProp o) {
    return c - o.c;
  }
  /**
   * Returns the decimal value associated with this {@code ASCIICharProp}, or
   * {@code -1} if the value is not a decimal digit.
@@ -236,77 +194,59 @@
   * @return The decimal value associated with this {@code ASCIICharProp}, or
   *         {@code -1} if the value is not a decimal digit.
   */
  public int decimalValue()
  {
    public int decimalValue() {
    return decimalValue;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean equals(final Object obj)
  {
    public boolean equals(final Object obj) {
    return this == obj;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public int hashCode()
  {
    public int hashCode() {
    return c;
  }
  /**
   * Returns the hexadecimal value associated with this {@code ASCIICharProp} ,
   * or {@code -1} if the value is not a hexadecimal digit.
     * Returns the hexadecimal value associated with this {@code ASCIICharProp}
     * , or {@code -1} if the value is not a hexadecimal digit.
   *
   * @return The hexadecimal value associated with this {@code ASCIICharProp} ,
   *         or {@code -1} if the value is not a hexadecimal digit.
     * @return The hexadecimal value associated with this {@code ASCIICharProp}
     *         , or {@code -1} if the value is not a hexadecimal digit.
   */
  public int hexValue()
  {
    public int hexValue() {
    return hexValue;
  }
  /**
   * Indicates whether or not the char value associated with this {@code
   * ASCIICharProp} is a decimal digit.
     * Indicates whether or not the char value associated with this
     * {@code ASCIICharProp} is a decimal digit.
   *
   * @return {@code true} if the char value associated with this {@code
   *         ASCIICharProp} is a decimal digit.
     * @return {@code true} if the char value associated with this
     *         {@code ASCIICharProp} is a decimal digit.
   */
  public boolean isDigit()
  {
    public boolean isDigit() {
    return isDigit;
  }
  /**
   * Indicates whether or not the char value associated with this {@code
   * ASCIICharProp} is a hexadecimal digit.
     * Indicates whether or not the char value associated with this
     * {@code ASCIICharProp} is a hexadecimal digit.
   *
   * @return {@code true} if the char value associated with this {@code
   *         ASCIICharProp} is a hexadecimal digit.
     * @return {@code true} if the char value associated with this
     *         {@code ASCIICharProp} is a hexadecimal digit.
   */
  public boolean isHexDigit()
  {
    public boolean isHexDigit() {
    return isHexChar;
  }
  /**
   * Indicates whether or not the char value associated with this
   * {@code ASCIICharProp} is a {@code keychar} as defined in RFC 4512. A
@@ -320,94 +260,75 @@
   * </pre>
   *
   * @param allowCompatChars
   *          {@code true} if certain illegal characters should be allowed for
   *          compatibility reasons.
     *            {@code true} if certain illegal characters should be allowed
     *            for compatibility reasons.
   * @return {@code true} if the char value associated with this
   *         {@code ASCIICharProp} is a {@code keychar}.
   */
  public boolean isKeyChar(final boolean allowCompatChars)
  {
    public boolean isKeyChar(final boolean allowCompatChars) {
    return allowCompatChars ? isCompatKeyChar : isKeyChar;
  }
  /**
   * Indicates whether or not the char value associated with this {@code
   * ASCIICharProp} is a letter.
     * Indicates whether or not the char value associated with this
     * {@code ASCIICharProp} is a letter.
   *
   * @return {@code true} if the char value associated with this {@code
   *         ASCIICharProp} is a letter.
     * @return {@code true} if the char value associated with this
     *         {@code ASCIICharProp} is a letter.
   */
  public boolean isLetter()
  {
    public boolean isLetter() {
    return isLetter;
  }
  /**
   * Indicates whether or not the char value associated with this {@code
   * ASCIICharProp} is a lower-case character.
     * Indicates whether or not the char value associated with this
     * {@code ASCIICharProp} is a lower-case character.
   *
   * @return {@code true} if the char value associated with this {@code
   *         ASCIICharProp} is a lower-case character.
     * @return {@code true} if the char value associated with this
     *         {@code ASCIICharProp} is a lower-case character.
   */
  public boolean isLowerCase()
  {
    public boolean isLowerCase() {
    return isLowerCaseChar;
  }
  /**
   * Indicates whether or not the char value associated with this {@code
   * ASCIICharProp} is an upper-case character.
     * Indicates whether or not the char value associated with this
     * {@code ASCIICharProp} is an upper-case character.
   *
   * @return {@code true} if the char value associated with this {@code
   *         ASCIICharProp} is an upper-case character.
     * @return {@code true} if the char value associated with this
     *         {@code ASCIICharProp} is an upper-case character.
   */
  public boolean isUpperCase()
  {
    public boolean isUpperCase() {
    return isUpperCaseChar;
  }
  /**
   * Returns the lower-case char value associated with this {@code
   * ASCIICharProp}.
     * Returns the lower-case char value associated with this
     * {@code ASCIICharProp}.
   *
   * @return The lower-case char value associated with this {@code
   *         ASCIICharProp}.
     * @return The lower-case char value associated with this
     *         {@code ASCIICharProp}.
   */
  public char toLowerCase()
  {
    public char toLowerCase() {
    return lowerCaseChar;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String toString()
  {
    public String toString() {
    return stringValue;
  }
  /**
   * Returns the upper-case char value associated with this {@code
   * ASCIICharProp}.
     * Returns the upper-case char value associated with this
     * {@code ASCIICharProp}.
   *
   * @return The upper-case char value associated with this {@code
   *         ASCIICharProp}.
     * @return The upper-case char value associated with this
     *         {@code ASCIICharProp}.
   */
  public char toUpperCase()
  {
    public char toUpperCase() {
    return upperCaseChar;
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,17 +26,17 @@
package com.forgerock.opendj.util;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import org.forgerock.opendj.ldap.*;
import org.forgerock.opendj.ldap.CancelledResultException;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.FutureResult;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ResultHandler;
/**
 * This class provides a skeletal implementation of the {@code FutureResult}
@@ -66,12 +65,9 @@
 * @param <M>
 *          The type of result returned by this completion future.
 */
public class AsynchronousFutureResult<M> implements FutureResult<M>,
    ResultHandler<M>
{
public class AsynchronousFutureResult<M> implements FutureResult<M>, ResultHandler<M> {
  @SuppressWarnings("serial")
  private final class Sync extends AbstractQueuedSynchronizer
  {
    private final class Sync extends AbstractQueuedSynchronizer {
    // State value representing the initial state before a result has
    // been received.
    private static final int WAITING = 0;
@@ -96,261 +92,183 @@
    private M result = null;
    /**
     * Allow all threads to acquire if future has completed.
     */
    @Override
    protected int tryAcquireShared(final int ignore)
    {
        protected int tryAcquireShared(final int ignore) {
      return innerIsDone() ? 1 : -1;
    }
    /**
     * Signal that the future has completed and threads waiting on get() can be
     * released.
         * Signal that the future has completed and threads waiting on get() can
         * be released.
     */
    @Override
    protected boolean tryReleaseShared(final int finalState)
    {
        protected boolean tryReleaseShared(final int finalState) {
      // Ensures that errorResult/result is published.
      setState(finalState);
      return true;
    }
    boolean innerCancel(final boolean mayInterruptIfRunning)
    {
      if (!isCancelable() || !setStatePending())
      {
        boolean innerCancel(final boolean mayInterruptIfRunning) {
            if (!isCancelable() || !setStatePending()) {
        return false;
      }
      // Perform implementation defined cancellation.
      ErrorResultException errorResult = handleCancelRequest(mayInterruptIfRunning);
      if (errorResult == null)
      {
            if (errorResult == null) {
        errorResult = newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED);
      }
      this.errorResult = errorResult;
      try
      {
            try {
        // Invoke error result completion handler.
        if (handler != null)
        {
                if (handler != null) {
          handler.handleErrorResult(errorResult);
        }
      }
      finally
      {
            } finally {
        releaseShared(CANCELLED); // Publishes errorResult.
      }
      return true;
    }
    M innerGet() throws ErrorResultException, InterruptedException
    {
        M innerGet() throws ErrorResultException, InterruptedException {
      acquireSharedInterruptibly(0);
      return get0();
    }
    M innerGet(final long nanosTimeout) throws ErrorResultException,
        TimeoutException, InterruptedException
    {
      if (!tryAcquireSharedNanos(0, nanosTimeout))
      {
        M innerGet(final long nanosTimeout) throws ErrorResultException, TimeoutException,
                InterruptedException {
            if (!tryAcquireSharedNanos(0, nanosTimeout)) {
        throw new TimeoutException();
      }
      else
      {
            } else {
        return get0();
      }
    }
    boolean innerIsCancelled()
    {
        boolean innerIsCancelled() {
      return getState() == CANCELLED;
    }
    boolean innerIsDone()
    {
        boolean innerIsDone() {
      return getState() > 1;
    }
    void innerSetErrorResult(final ErrorResultException errorResult)
    {
      if (setStatePending())
      {
        void innerSetErrorResult(final ErrorResultException errorResult) {
            if (setStatePending()) {
        this.errorResult = errorResult;
        try
        {
                try {
          // Invoke error result completion handler.
          if (handler != null)
          {
                    if (handler != null) {
            handler.handleErrorResult(errorResult);
          }
        }
        finally
        {
                } finally {
          releaseShared(FAIL); // Publishes errorResult.
        }
      }
    }
    void innerSetResult(final M result)
    {
      if (setStatePending())
      {
        void innerSetResult(final M result) {
            if (setStatePending()) {
        this.result = result;
        try
        {
                try {
          // Invoke result completion handler.
          if (handler != null)
          {
                    if (handler != null) {
            handler.handleResult(result);
          }
        }
        finally
        {
                } finally {
          releaseShared(SUCCESS); // Publishes result.
        }
      }
    }
    private M get0() throws ErrorResultException
    {
      if (errorResult != null)
      {
        private M get0() throws ErrorResultException {
            if (errorResult != null) {
        // State must be FAILED or CANCELLED.
        throw errorResult;
      }
      else
      {
            } else {
        // State must be SUCCESS.
        return result;
      }
    }
    private boolean setStatePending()
    {
      for (;;)
      {
        private boolean setStatePending() {
            for (;;) {
        final int s = getState();
        if (s != WAITING)
        {
                if (s != WAITING) {
          return false;
        }
        if (compareAndSetState(s, PENDING))
        {
                if (compareAndSetState(s, PENDING)) {
          return true;
        }
      }
    }
  }
  private final Sync sync = new Sync();
  private final ResultHandler<? super M> handler;
  private final int requestID;
  /**
   * Creates a new asynchronous future result with the provided result handler
   * and a request ID of -1.
   *
   * @param handler
   *          A result handler which will be forwarded the result or error when
   *          it arrives, may be {@code null}.
     *            A result handler which will be forwarded the result or error
     *            when it arrives, may be {@code null}.
   */
  public AsynchronousFutureResult(final ResultHandler<? super M> handler)
  {
    public AsynchronousFutureResult(final ResultHandler<? super M> handler) {
    this(handler, -1);
  }
  /**
   * Creates a new asynchronous future result with the provided result handler
   * and request ID.
   *
   * @param handler
   *          A result handler which will be forwarded the result or error when
   *          it arrives, may be {@code null}.
     *            A result handler which will be forwarded the result or error
     *            when it arrives, may be {@code null}.
   * @param requestID
   *          The request ID which will be returned by the default
   *          implementation of {@link #getRequestID}.
   */
  public AsynchronousFutureResult(final ResultHandler<? super M> handler,
      final int requestID)
  {
    public AsynchronousFutureResult(final ResultHandler<? super M> handler, final int requestID) {
    this.handler = handler;
    this.requestID = requestID;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final boolean cancel(final boolean mayInterruptIfRunning)
  {
    public final boolean cancel(final boolean mayInterruptIfRunning) {
    return sync.innerCancel(mayInterruptIfRunning);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final M get() throws ErrorResultException, InterruptedException
  {
    public final M get() throws ErrorResultException, InterruptedException {
    return sync.innerGet();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final M get(final long timeout, final TimeUnit unit)
      throws ErrorResultException, TimeoutException, InterruptedException
  {
    public final M get(final long timeout, final TimeUnit unit) throws ErrorResultException,
            TimeoutException, InterruptedException {
    return sync.innerGet(unit.toNanos(timeout));
  }
  /**
   * {@inheritDoc}
   * <p>
@@ -358,33 +276,28 @@
   * construction, or -1 if none was provided.
   */
  @Override
  public int getRequestID()
  {
    public int getRequestID() {
    return requestID;
  }
  /**
   * Sets the error result associated with this future. If ({@code isDone() ==
   * true}) then the error result will be ignored, otherwise the result handler
   * will be invoked if one was provided and, on return, any threads waiting on
   * {@link #get} will be released and the provided error result will be thrown.
     * true}) then the error result will be ignored, otherwise the result
     * handler will be invoked if one was provided and, on return, any threads
     * waiting on {@link #get} will be released and the provided error result
     * will be thrown.
   *
   * @param errorResult
   *          The error result.
   */
  @Override
  public final void handleErrorResult(final ErrorResultException errorResult)
  {
    public final void handleErrorResult(final ErrorResultException errorResult) {
    sync.innerSetErrorResult(errorResult);
  }
  /**
   * Sets the result associated with this future. If ({@code isDone() == true})
   * then the result will be ignored, otherwise the result handler will be
     * Sets the result associated with this future. If ({@code isDone() == true}
     * ) then the result will be ignored, otherwise the result handler will be
   * invoked if one was provided and, on return, any threads waiting on
   * {@link #get} will be released and the provided result will be returned.
   *
@@ -392,35 +305,26 @@
   *          The result.
   */
  @Override
  public final void handleResult(final M result)
  {
    public final void handleResult(final M result) {
    sync.innerSetResult(result);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final boolean isCancelled()
  {
    public final boolean isCancelled() {
    return sync.innerIsCancelled();
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public final boolean isDone()
  {
    public final boolean isDone() {
    return sync.innerIsDone();
  }
  /**
   * Invoked when {@link #cancel} is called and {@code isDone() == false} and
   * immediately before any threads waiting on {@link #get} are released.
@@ -442,29 +346,22 @@
   * @return The custom error result, or {@code null} if the default is
   *         acceptable.
   */
  protected ErrorResultException handleCancelRequest(
      final boolean mayInterruptIfRunning)
  {
    protected ErrorResultException handleCancelRequest(final boolean mayInterruptIfRunning) {
    // Do nothing by default.
    return null;
  }
  /**
   * Indicates whether this future result can be canceled.
   *
   * @return {@code true} if this future result is cancelable or {@code false}
   *         otherwise.
   */
  protected boolean isCancelable()
  {
    protected boolean isCancelable() {
    // Return true by default.
    return true;
  }
  /**
   * Appends a string representation of this future's state to the provided
   * builder.
@@ -472,8 +369,7 @@
   * @param sb
   *          The string builder.
   */
  protected void toString(final StringBuilder sb)
  {
    protected void toString(final StringBuilder sb) {
    sb.append(" state = ");
    sb.append(sync);
  }
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Base64.java
@@ -6,17 +6,16 @@
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opendj3/legal-notices/CDDLv1_0.txt.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
@@ -27,8 +26,6 @@
 */
package com.forgerock.opendj.util;
import static com.forgerock.opendj.util.Validator.ensureNotNull;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_BASE64_DECODE_INVALID_CHARACTER;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_BASE64_DECODE_INVALID_LENGTH;
@@ -39,24 +36,19 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
/**
 * This class provides methods for performing base64 encoding and decoding.
 * Base64 is a mechanism for encoding binary data in ASCII form by converting
 * sets of three bytes with eight significant bits each to sets of four bytes
 * with six significant bits each.
 */
public final class Base64
{
public final class Base64 {
  /**
   * The set of characters that may be used in base64-encoded values.
   */
  private static final char[] BASE64_ALPHABET = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/").toCharArray();
  /**
   * Decodes the provided base64 encoded data.
   *
@@ -64,34 +56,29 @@
   *          The base64 encoded data.
   * @return The decoded data.
   * @throws LocalizedIllegalArgumentException
   *           If a problem occurs while attempting to decode {@code base64}.
     *             If a problem occurs while attempting to decode {@code base64}
     *             .
   * @throws NullPointerException
   *           If {@code base64} was {@code null}.
   */
  public static ByteString decode(final String base64)
  {
    public static ByteString decode(final String base64) {
    ensureNotNull(base64);
    // The encoded value must have length that is a multiple of four
    // bytes.
    final int length = base64.length();
    if ((length % 4) != 0)
    {
      final LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH
          .get(base64);
        if ((length % 4) != 0) {
            final LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH.get(base64);
      throw new LocalizedIllegalArgumentException(message);
    }
    final ByteStringBuilder builder = new ByteStringBuilder(length);
    for (int i = 0; i < length; i += 4)
    {
        for (int i = 0; i < length; i += 4) {
      boolean append = true;
      int value = 0;
      for (int j = 0; j < 4; j++)
      {
        switch (base64.charAt(i + j))
        {
            for (int j = 0; j < 4; j++) {
                switch (base64.charAt(i + j)) {
        case 'A':
          value <<= 6;
          break;
@@ -286,8 +273,7 @@
          break;
        case '=':
          append = false;
          switch (j)
          {
                    switch (j) {
          case 2:
            builder.append((byte) ((value >>> 4) & 0xFF));
            break;
@@ -298,25 +284,21 @@
          }
          break;
        default:
          final LocalizableMessage message = ERR_BASE64_DECODE_INVALID_CHARACTER
              .get(base64, base64.charAt(i + j));
                    final LocalizableMessage message =
                            ERR_BASE64_DECODE_INVALID_CHARACTER.get(base64, base64.charAt(i + j));
          throw new LocalizedIllegalArgumentException(message);
        }
        if (!append)
        {
                if (!append) {
          break;
        }
      }
      if (append)
      {
            if (append) {
        builder.append((byte) ((value >>> 16) & 0xFF));
        builder.append((byte) ((value >>> 8) & 0xFF));
        builder.append((byte) (value & 0xFF));
      }
      else
      {
            } else {
        break;
      }
    }
@@ -324,8 +306,6 @@
    return builder.toByteString();
  }
  /**
   * Encodes the provided data as a base64 string.
   *
@@ -335,18 +315,17 @@
   * @throws NullPointerException
   *           If {@code bytes} was {@code null}.
   */
  public static String encode(final ByteSequence bytes)
  {
    public static String encode(final ByteSequence bytes) {
    ensureNotNull(bytes);
    final StringBuilder buffer = new StringBuilder(4 * bytes.length() / 3);
    int pos = 0;
    final int iterations = bytes.length() / 3;
    for (int i = 0; i < iterations; i++)
    {
      final int value = ((bytes.byteAt(pos++) & 0xFF) << 16)
          | ((bytes.byteAt(pos++) & 0xFF) << 8) | (bytes.byteAt(pos++) & 0xFF);
        for (int i = 0; i < iterations; i++) {
            final int value =
                    ((bytes.byteAt(pos++) & 0xFF) << 16) | ((bytes.byteAt(pos++) & 0xFF) << 8)
                            | (bytes.byteAt(pos++) & 0xFF);
      buffer.append(BASE64_ALPHABET[(value >>> 18) & 0x3F]);
      buffer.append(BASE64_ALPHABET[(value >>> 12) & 0x3F]);
@@ -354,16 +333,14 @@
      buffer.append(BASE64_ALPHABET[value & 0x3F]);
    }
    switch (bytes.length() % 3)
    {
        switch (bytes.length() % 3) {
    case 1:
      buffer.append(BASE64_ALPHABET[(bytes.byteAt(pos) >>> 2) & 0x3F]);
      buffer.append(BASE64_ALPHABET[(bytes.byteAt(pos) << 4) & 0x3F]);
      buffer.append("==");
      break;
    case 2:
      final int value = ((bytes.byteAt(pos++) & 0xFF) << 8)
          | (bytes.byteAt(pos) & 0xFF);
            final int value = ((bytes.byteAt(pos++) & 0xFF) << 8) | (bytes.byteAt(pos) & 0xFF);
      buffer.append(BASE64_ALPHABET[(value >>> 10) & 0x3F]);
      buffer.append(BASE64_ALPHABET[(value >>> 4) & 0x3F]);
      buffer.append(BASE64_ALPHABET[(value << 2) & 0x3F]);
@@ -374,13 +351,10 @@
    return buffer.toString();
  }
  /**
   * Prevent instance creation.
   */
  private Base64()
  {
    private Base64() {
    // No implementation required.
  }
}
Diff truncated after the above file
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ByteSequenceOutputStream.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Collections2.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/CompletedFutureResult.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Function.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Functions.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/FutureResultTransformer.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Iterables.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Iterators.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Predicate.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/RecursiveFutureResult.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/SizeLimitInputStream.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StringPrepProfile.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/SubstringReader.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Validator.java opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Constants.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1InputStreamReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Reader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/ASN1Writer.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Reader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/AbstractASN1Writer.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/asn1/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AVA.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAttribute.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractEntry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractFilterVisitor.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractMapEntry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Assertion.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AssertionFailureException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attribute.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AttributeDescription.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AttributeFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Attributes.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticationException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthorizationException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteSequence.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteSequenceReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteString.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/CancelRequestListener.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/CancelledResultException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConditionResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionEventListener.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionSecurityLayer.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConstraintViolationException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DN.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DecodeException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DecodeOptions.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/DereferenceAliasesPolicy.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entries.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Entry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/EntryFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/EntryNotFoundException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultIOException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FailoverLoadBalancingAlgorithm.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Filter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FilterVisitor.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FutureResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/IntermediateResponseHandler.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/KeyManagers.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPClientContext.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPListenerOptions.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPOptions.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPUrl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedAttribute.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LinkedHashMapEntry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancingAlgorithm.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Matcher.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Modification.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ModificationType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MultipleEntriesFoundException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RDN.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ReferralException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestContext.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandler.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandlerFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RequestHandlerFactoryAdapter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ResultCode.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ResultHandler.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RoundRobinLoadBalancingAlgorithm.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SSLContextBuilder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SchemaResolver.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchResultHandler.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchResultReferenceIOException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SearchScope.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ServerConnection.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ServerConnectionFactory.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/SortKey.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TimeoutResultException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TreeMapEntry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/TrustManagers.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AssertionRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AuthorizationIdentityRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/AuthorizationIdentityResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/Control.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ControlDecoder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/EntryChangeNotificationResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/GenericControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/GetEffectiveRightsRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ManageDsaITRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/MatchedValuesRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordExpiredResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordExpiringResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyErrorType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PasswordPolicyWarningType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PermissiveModifyRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PersistentSearchChangeType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PersistentSearchRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PostReadRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PostReadResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PreReadRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/PreReadResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ProxiedAuthV1RequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ProxiedAuthV2RequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ServerSideSortRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/ServerSideSortResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SimplePagedResultsControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SubentriesRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/SubtreeDeleteRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/VirtualListViewRequestControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/VirtualListViewResponseControl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/controls/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbandonRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbandonRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractSASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AbstractUnmodifiableSASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AddRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindClient.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindClientImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CancelExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CancelExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/CompareRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DeleteRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DeleteRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExtendedRequestDecoder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/GenericExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyDNRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyDNRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/ModifyRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PasswordModifyExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Request.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/Requests.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SASLBindClientImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SASLBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SearchRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SimpleBindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/SimpleBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/StartTLSExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/StartTLSExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnbindRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnbindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAbandonRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAddRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableAnonymousSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCRAMMD5SASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCancelExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableCompareRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableDeleteRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableDigestMD5SASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableExternalSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGSSAPISASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableGenericExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableModifyDNRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableModifyRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePasswordModifyExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiablePlainSASLBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableSearchRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableSimpleBindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableStartTLSExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableUnbindRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/UnmodifiableWhoAmIExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/WhoAmIExtendedRequest.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/WhoAmIExtendedRequestImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractExtendedResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractExtendedResultDecoder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractIntermediateResponse.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResponseImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableIntermediateResponseImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableResponseImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/AbstractUnmodifiableResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/BindResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/BindResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/CompareResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/CompareResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ExtendedResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ExtendedResultDecoder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponse.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/GenericIntermediateResponseImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/IntermediateResponse.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/PasswordModifyExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Response.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Responses.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/Result.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/ResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntry.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultEntryImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultReference.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/SearchResultReferenceImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableBindResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableCompareResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableGenericIntermediateResponseImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiablePasswordModifyExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultEntryImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableSearchResultReferenceImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/UnmodifiableWhoAmIExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/WhoAmIExtendedResult.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/WhoAmIExtendedResultImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/responses/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AttributeUsage.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordExactEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/AuthPasswordSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BinarySyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/BooleanSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreListSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificateListSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificatePairSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ConflictingSchemaElementException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchema.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CoreSchemaImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/CountryStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRule.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRuleSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DefaultSchema.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DeliveryMethodSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DistinguishedNameSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DoubleMetaphoneApproximateMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnhancedGuideSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnumOrderingMatchingRule.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EnumSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/EqualLengthApproximateMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/FacsimileNumberSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/FaxSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GenerateCoreSchema.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/GuideSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IA5StringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/IntegerSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/KeywordEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxDescriptionSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUse.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameAndOptionalUIDSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameForm.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NameFormSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/NumericStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OIDSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClass.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectClassType.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ObjectIdentifierFirstComponentEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OctetStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/OtherMailboxSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PostalAddressSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PresentationAddressSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/PrintableStringSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/ProtocolInformationSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/RegexSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaConstants.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaElement.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SubstringAssertionSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SupportedAlgorithmSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Syntax.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSubstringMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TeletexTerminalIdentifierSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelexNumberSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UTCTimeSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDOrderingMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UUIDSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UnknownSchemaElementException.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordExactEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/UserPasswordSyntaxImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/WordEqualityMatchingRuleImpl.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/package-info.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFStream.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/AbstractLDIFWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecord.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordVisitor.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordVisitorWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ChangeRecordWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/EntryReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/EntryWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIF.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFEntryReader.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFEntryWriter.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/RejectedChangeRecordListener.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/RejectedLDIFListener.java opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/package-info.java opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_de.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_es.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_fr.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_ja.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_ko.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_zh_CN.properties opendj3/opendj-ldap-sdk/src/main/resources/org/forgerock/opendj/ldap/core_zh_TW.properties opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferWriterTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransportTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/LDAPTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityRequestControlTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/controls/AccountUsabilityResponseControlTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/ASCIICharPropTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/Base64TestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/StaticUtilsTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/StringPrepProfileTestCase.java opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/util/UtilTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ByteSequenceReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1InputStreamReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1OutputStreamWriterTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1ReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/asn1/ASN1WriterTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnectionTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AttributeDescriptionTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteSequenceTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ByteStringTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/EntriesTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/EntryTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/FilterTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPUrlTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LinkedAttributeTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/RDNTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/SdkTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/TestCaseUtils.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/TypesTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/controls/ControlsTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AbandonRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AddRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/AnonymousSASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/BindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/CRAMMD5SASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/CompareRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/DeleteRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/DigestMD5SASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ExtendedRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ExternalSASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/GSSAPISASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/GenericBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ModifyDNRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/ModifyRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/PlainSASLBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/RequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/RequestsTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/SimpleBindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/requests/UnbindRequestTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/responses/ResponsesTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/AttributeTypeTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BitStringEqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/BooleanEqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactEqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5EqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactOrderingMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreEqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5EqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreOrderingMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/DITContentRuleSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/DistinguishedNameEqualityMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/EnumSyntaxTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/GeneralizedTimeSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/GuideSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/IA5StringSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/LDAPSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleUseSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/OtherMailboxSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/RegexSyntaxTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SubstitutionSyntaxTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/TelexSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/UTCTimeSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/schema/UUIDSyntaxTest.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFEntryWriterTestCase.java opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldif/LDIFTestCase.java opendj3/opendj-ldap-sync/pom.xml opendj3/opendj-ldap-sync/src/main/assembly/bat/ldapsync.bat opendj3/opendj-ldap-sync/src/main/assembly/descriptor.xml opendj3/opendj-ldap-sync/src/main/assembly/libbat/_client-script.bat opendj3/opendj-ldap-sync/src/main/assembly/libbat/_script-util.bat opendj3/opendj-ldap-sync/src/main/assembly/libbat/setcp.bat opendj3/opendj-ldap-sync/src/main/assembly/libbin/_client-script.sh opendj3/opendj-ldap-sync/src/main/assembly/libbin/_script-util.sh opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/Main.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/ChangeRecordContext.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Filter.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/FilterResult.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Matchers.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/Transforms.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/filters/package-info.java opendj3/opendj-ldap-sync/src/main/java/org/forgerock/opendj/sync/package-info.java opendj3/opendj-ldap-toolkit/pom.xml opendj3/opendj-ldap-toolkit/src/main/assembly/bat/authrate.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapcompare.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapmodify.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldappasswordmodify.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldapsearch.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifdiff.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifmodify.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/ldifsearch.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/modrate.bat opendj3/opendj-ldap-toolkit/src/main/assembly/bat/searchrate.bat opendj3/opendj-ldap-toolkit/src/main/assembly/descriptor.xml opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/_client-script.bat opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/_script-util.bat opendj3/opendj-ldap-toolkit/src/main/assembly/libbat/setcp.bat opendj3/opendj-ldap-toolkit/src/main/assembly/libbin/_client-script.sh opendj3/opendj-ldap-toolkit/src/main/assembly/libbin/_script-util.sh opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ApplicationKeyManager.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Argument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentException.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentGroup.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentParser.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/BooleanArgument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/CLIException.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConsoleApplication.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/DataSource.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/FileBasedArgument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/IntegerArgument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiChoiceArgument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiColumnPrinter.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PromptingTrustManager.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/StringArgument.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ToolConstants.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/package-info.java opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_de.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_es.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_fr.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ja.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_ko.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_CN.properties opendj3/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools_zh_TW.properties opendj3/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ToolsTestCase.java opendj3/opendj-rest2ldap/pom.xml opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/AttributeMapper.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/CompletionHandler.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Context.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/EntryContainer.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/LDAPResource.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReadRequest.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/RestRequest.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Validator.java opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/package-info.java opendj3/pom.xml opendj3/src/site/resources/Example.ldif