| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!-- |
| | | ! CDDL HEADER START |
| | | ! |
| | | ! The contents of this file are subject to the terms of the |
| | | ! Common Development and Distribution License, Version 1.0 only |
| | | ! (the "License"). You may not use this file except in compliance |
| | | ! with the License. |
| | | ! |
| | | ! 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 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 |
| | | ! |
| | | ! Copyright 2011-2012 ForgeRock AS |
| | | ! |
| | | --> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <artifactId>opendj-project</artifactId> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <version>2.7.0-SNAPSHOT</version> |
| | | </parent> |
| | | <artifactId>opendj-core</artifactId> |
| | | <name>OpenDJ LDAP SDK</name> |
| | | <description> |
| | | This module includes OpenDJ core APIs for implementing LDAP Directory |
| | | client and server applications. |
| | | </description> |
| | | <packaging>bundle</packaging> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>i18n-core</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock</groupId> |
| | | <artifactId>forgerock-build-tools</artifactId> |
| | | <version>${forgerockBuildToolsVersion}</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | <properties> |
| | | <opendj.osgi.import> |
| | | com.sun.security.auth*;resolution:=optional, |
| | | * |
| | | </opendj.osgi.import> |
| | | </properties> |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>i18n-maven-plugin</artifactId> |
| | | <executions> |
| | | <execution> |
| | | <phase>generate-sources</phase> |
| | | <goals> |
| | | <goal>generate-messages</goal> |
| | | </goals> |
| | | <configuration> |
| | | <messageFiles> |
| | | <messageFile>com/forgerock/opendj/ldap/core.properties</messageFile> |
| | | </messageFiles> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.felix</groupId> |
| | | <artifactId>maven-bundle-plugin</artifactId> |
| | | <extensions>true</extensions> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-source-plugin</artifactId> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-jar-plugin</artifactId> |
| | | <version>2.4</version> |
| | | <executions> |
| | | <execution> |
| | | <goals> |
| | | <goal>test-jar</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | <reporting> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-project-info-reports-plugin</artifactId> |
| | | <reportSets> |
| | | <reportSet> |
| | | <reports> |
| | | <report>mailing-list</report> |
| | | <report>issue-tracking</report> |
| | | <report>license</report> |
| | | <report>cim</report> |
| | | <report>distribution-management</report> |
| | | </reports> |
| | | </reportSet> |
| | | </reportSets> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-javadoc-plugin</artifactId> |
| | | <configuration> |
| | | <links> |
| | | <link>http://commons.forgerock.org/i18n-framework/i18n-core/apidocs</link> |
| | | </links> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </reporting> |
| | | </project> |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/InternalConnection.java |
| | |
| | | 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.ldap.spi.AbstractLDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPCompareFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPExtendedFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPSearchFutureResultImpl; |
| | | |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | import com.forgerock.opendj.util.Validator; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return Responses.newBindResult(resultCode).setDiagnosticMessage(diagnosticMessage) |
| | | .setCause(cause); |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPUtils.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.asn1.ASN1Reader; |
| | | import org.forgerock.opendj.asn1.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.Attribute; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | 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.Entry; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.FilterVisitor; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | /** |
| | | * Common LDAP utility methods which may be used when implementing new controls |
| | |
| | | */ |
| | | public static SearchResultEntry decodeSearchResultEntry(final ASN1Reader reader, |
| | | final DecodeOptions options) throws IOException { |
| | | return LDAPReader.decodeEntry(reader, options); |
| | | Entry entry; |
| | | |
| | | reader.readStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY); |
| | | try { |
| | | final String dnString = reader.readOctetStringAsString(); |
| | | final Schema schema = options.getSchemaResolver().resolveSchema(dnString); |
| | | DN dn; |
| | | try { |
| | | dn = DN.valueOf(dnString, schema); |
| | | } catch (final LocalizedIllegalArgumentException e) { |
| | | throw DecodeException.error(e.getMessageObject()); |
| | | } |
| | | |
| | | entry = options.getEntryFactory().newEntry(dn); |
| | | reader.readStartSequence(); |
| | | try { |
| | | while (reader.hasNextElement()) { |
| | | reader.readStartSequence(); |
| | | try { |
| | | final String ads = reader.readOctetStringAsString(); |
| | | AttributeDescription ad; |
| | | try { |
| | | ad = AttributeDescription.valueOf(ads, schema); |
| | | } catch (final LocalizedIllegalArgumentException e) { |
| | | throw DecodeException.error(e.getMessageObject()); |
| | | } |
| | | |
| | | final Attribute attribute = options.getAttributeFactory().newAttribute(ad); |
| | | |
| | | reader.readStartSet(); |
| | | try { |
| | | while (reader.hasNextElement()) { |
| | | attribute.add(reader.readOctetString()); |
| | | } |
| | | entry.addAttribute(attribute); |
| | | } finally { |
| | | reader.readEndSet(); |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | |
| | | return Responses.newSearchResultEntry(entry); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static ASN1Writer encodeSearchResultEntry(final ASN1Writer writer, |
| | | final SearchResultEntry entry) throws IOException { |
| | | // FIXME: this should include Controls. |
| | | LDAPWriter.encodeEntry(writer, entry); |
| | | writer.writeStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY); |
| | | writer.writeOctetString(entry.getName().toString()); |
| | | |
| | | writer.writeStartSequence(); |
| | | for (final Attribute attr : entry.getAllAttributes()) { |
| | | encodeAttribute(writer, attr); |
| | | } |
| | | writer.writeEndSequence(); |
| | | writer.writeEndSequence(); |
| | | return writer; |
| | | } |
| | | |
| | | 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) { |
| | | writer.writeOctetString(value); |
| | | } |
| | | writer.writeEndSequence(); |
| | | |
| | | writer.writeEndSequence(); |
| | | } |
| | | |
| | | // Decodes an and filter. |
| | | private static Filter decodeAndFilter(final ASN1Reader reader) throws IOException { |
| | | Filter filter; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/AsynchronousFutureResult.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.util; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | * @param <S> |
| | | * The type of result returned by this future. |
| | | */ |
| | | abstract class AbstractLDAPFutureResultImpl<S extends Result> |
| | | public abstract class AbstractLDAPFutureResultImpl<S extends Result> |
| | | extends AsynchronousFutureResult<S, ResultHandler<? super S>> |
| | | implements IntermediateResponseHandler { |
| | | private final Connection connection; |
| | |
| | | private IntermediateResponseHandler intermediateResponseHandler; |
| | | private volatile long timestamp; |
| | | |
| | | AbstractLDAPFutureResultImpl(final int requestID, |
| | | /** |
| | | * Creates a future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param resultHandler |
| | | * handler that consumes the result |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | protected AbstractLDAPFutureResultImpl(final int requestID, |
| | | final ResultHandler<? super S> resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | super.toString(sb); |
| | | } |
| | | |
| | | final void adaptErrorResult(final Result result) { |
| | | /** |
| | | * Sets the result associated to this future as an error result. |
| | | * |
| | | * @param result result of an operation |
| | | */ |
| | | public final void adaptErrorResult(final Result result) { |
| | | final S errorResult = |
| | | newErrorResult(result.getResultCode(), result.getDiagnosticMessage(), result |
| | | .getCause()); |
| | | setResultOrError(errorResult); |
| | | } |
| | | |
| | | final long getTimestamp() { |
| | | /** |
| | | * Returns the creation time of this future. |
| | | * |
| | | * @return the timestamp indicating creation time of this future |
| | | */ |
| | | public final long getTimestamp() { |
| | | return timestamp; |
| | | } |
| | | |
| | | abstract S newErrorResult(ResultCode resultCode, String diagnosticMessage, Throwable cause); |
| | | /** |
| | | * Create a new error result. |
| | | * |
| | | * @param resultCode |
| | | * operation result code |
| | | * @param diagnosticMessage |
| | | * message associated to the error |
| | | * @param cause |
| | | * cause of the error |
| | | * @return the error result |
| | | */ |
| | | protected abstract S newErrorResult(ResultCode resultCode, String diagnosticMessage, Throwable cause); |
| | | |
| | | final void setResultOrError(final S result) { |
| | | /** |
| | | * Sets the result associated to this future. |
| | | * |
| | | * @param result the result of operation |
| | | */ |
| | | public final void setResultOrError(final S result) { |
| | | if (result.getResultCode().isExceptional()) { |
| | | handleErrorResult(ErrorResultException.newErrorResult(result)); |
| | | } else { |
| | |
| | | * @return {@code true} if this request should be canceled once the timeout |
| | | * period expires. |
| | | */ |
| | | boolean checkForTimeout() { |
| | | public boolean checkForTimeout() { |
| | | return true; |
| | | } |
| | | } |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPBindFutureResultImpl.java |
| | |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | |
| | | /** |
| | | * Bind result future implementation. |
| | | */ |
| | | final class LDAPBindFutureResultImpl extends AbstractLDAPFutureResultImpl<BindResult> { |
| | | public final class LDAPBindFutureResultImpl extends AbstractLDAPFutureResultImpl<BindResult> { |
| | | private final BindClient bindClient; |
| | | |
| | | LDAPBindFutureResultImpl(final int requestID, final BindClient bindClient, |
| | | /** |
| | | * Creates an bind future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param bindClient |
| | | * client that binds to the server |
| | | * @param resultHandler |
| | | * handler that consumes result of bind |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | public LDAPBindFutureResultImpl(final int requestID, final BindClient bindClient, |
| | | final ResultHandler<? super BindResult> resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | BindClient getBindClient() { |
| | | /** |
| | | * Returns the client. |
| | | * |
| | | * @return the bind client |
| | | */ |
| | | public BindClient getBindClient() { |
| | | return bindClient; |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return Responses.newBindResult(resultCode).setDiagnosticMessage(diagnosticMessage) |
| | | .setCause(cause); |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPCompareFutureResultImpl.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | |
| | | /** |
| | | * Compare result future implementation. |
| | | */ |
| | | final class LDAPCompareFutureResultImpl extends AbstractLDAPFutureResultImpl<CompareResult> { |
| | | public final class LDAPCompareFutureResultImpl extends AbstractLDAPFutureResultImpl<CompareResult> { |
| | | private final CompareRequest request; |
| | | |
| | | LDAPCompareFutureResultImpl(final int requestID, final CompareRequest request, |
| | | /** |
| | | * Creates a compare future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param request |
| | | * compare request |
| | | * @param resultHandler |
| | | * handler that consumes compare result |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | public LDAPCompareFutureResultImpl(final int requestID, final CompareRequest request, |
| | | final ResultHandler<? super CompareResult> resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | CompareResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected CompareResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return Responses.newCompareResult(resultCode).setDiagnosticMessage(diagnosticMessage) |
| | | .setCause(cause); |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPExtendedFutureResultImpl.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | |
| | | * @param <R> |
| | | * The type of result returned by this future. |
| | | */ |
| | | final class LDAPExtendedFutureResultImpl<R extends ExtendedResult> extends |
| | | public final class LDAPExtendedFutureResultImpl<R extends ExtendedResult> extends |
| | | AbstractLDAPFutureResultImpl<R> { |
| | | private final ExtendedRequest<R> request; |
| | | |
| | | LDAPExtendedFutureResultImpl(final int requestID, final ExtendedRequest<R> request, |
| | | /** |
| | | * Creates an extended future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param request |
| | | * extended request |
| | | * @param resultHandler |
| | | * handler that consumes result |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | public LDAPExtendedFutureResultImpl(final int requestID, final ExtendedRequest<R> request, |
| | | final ResultHandler<? super R> resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | return !request.getOID().equals(StartTLSExtendedRequest.OID); |
| | | } |
| | | |
| | | R decodeResult(final ExtendedResult result, final DecodeOptions options) throws DecodeException { |
| | | /** |
| | | * Decode an extended result. |
| | | * |
| | | * @param result |
| | | * extended result to decode |
| | | * @param options |
| | | * decoding options |
| | | * @return the decoded extended result |
| | | * @throws DecodeException |
| | | * if a problem occurs during decoding |
| | | */ |
| | | public R decodeResult(final ExtendedResult result, final DecodeOptions options) throws DecodeException { |
| | | return request.getResultDecoder().decodeExtendedResult(result, options); |
| | | } |
| | | |
| | | ExtendedRequest<R> getRequest() { |
| | | /** |
| | | * Returns the extended request. |
| | | * |
| | | * @return the extended request |
| | | */ |
| | | public ExtendedRequest<R> getRequest() { |
| | | return request; |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | R newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected R newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return request.getResultDecoder().newExtendedErrorResult(resultCode, "", diagnosticMessage); |
| | | } |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPFutureResultImpl.java |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | |
| | | /** |
| | | * Result future implementation. |
| | | */ |
| | | final class LDAPFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> { |
| | | public final class LDAPFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> { |
| | | private final Request request; |
| | | |
| | | LDAPFutureResultImpl(final int requestID, final Request request, |
| | | /** |
| | | * Creates a future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param request |
| | | * the request sent to server |
| | | * @param resultHandler |
| | | * handler that consumes the result |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | public LDAPFutureResultImpl(final int requestID, final Request request, |
| | | final ResultHandler<? super Result> resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | Request getRequest() { |
| | | /** |
| | | * Returns the initial request. |
| | | * |
| | | * @return the request |
| | | */ |
| | | public Request getRequest() { |
| | | return request; |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause( |
| | | cause); |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPSearchFutureResultImpl.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | |
| | | /** |
| | | * Search result future implementation. |
| | | */ |
| | | final class LDAPSearchFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> implements |
| | | public final class LDAPSearchFutureResultImpl extends AbstractLDAPFutureResultImpl<Result> implements |
| | | SearchResultHandler { |
| | | private SearchResultHandler searchResultHandler; |
| | | private final SearchRequest request; |
| | | private final boolean isPersistentSearch; |
| | | |
| | | LDAPSearchFutureResultImpl(final int requestID, final SearchRequest request, |
| | | /** |
| | | * Creates a search future result. |
| | | * |
| | | * @param requestID |
| | | * identifier of the request |
| | | * @param request |
| | | * search request |
| | | * @param resultHandler |
| | | * handler that consumes search result |
| | | * @param intermediateResponseHandler |
| | | * handler that consumes intermediate responses from extended |
| | | * operations |
| | | * @param connection |
| | | * the connection to directory server |
| | | */ |
| | | public LDAPSearchFutureResultImpl(final int requestID, final SearchRequest request, |
| | | final SearchResultHandler resultHandler, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final Connection connection) { |
| | |
| | | this.isPersistentSearch = request.containsControl(PersistentSearchRequestControl.OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | 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 |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | 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 |
| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the search request. |
| | | * |
| | | * @return the search request |
| | | */ |
| | | SearchRequest getRequest() { |
| | | return request; |
| | | } |
| | | |
| | | @Override |
| | | Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | protected Result newErrorResult(final ResultCode resultCode, final String diagnosticMessage, |
| | | final Throwable cause) { |
| | | return Responses.newResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause( |
| | | cause); |
| | | } |
| | | |
| | | /** |
| | | * Persistent searches should not time out. |
| | | */ |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public |
| | | boolean checkForTimeout() { |
| | | // Persistent searches should not time out. |
| | | return !isPersistentSearch; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * 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 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 |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.*; |
| | | |
| | | import java.net.SocketAddress; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | 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.spi.LDAPConnectionFactoryImpl; |
| | | |
| | | import com.forgerock.opendj.util.AsynchronousFutureResult; |
| | | |
| | | /** |
| | | * Basic LDAP connection factory implementation to use for tests only. |
| | | */ |
| | | public final class BasicLDAPConnectionFactory implements LDAPConnectionFactoryImpl { |
| | | |
| | | private final LDAPOptions options; |
| | | private final SocketAddress socketAddress; |
| | | |
| | | /** |
| | | * Creates a new LDAP connection factory which does nothing. |
| | | * |
| | | * @param address |
| | | * The address of the Directory Server to connect to. |
| | | * @param options |
| | | * The LDAP connection options to use when creating connections. |
| | | */ |
| | | public BasicLDAPConnectionFactory(final SocketAddress address, final LDAPOptions options) { |
| | | this.socketAddress = address; |
| | | this.options = new LDAPOptions(options); |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | // nothing to do |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ErrorResultException { |
| | | try { |
| | | return getConnectionAsync(null).get(); |
| | | } catch (final InterruptedException e) { |
| | | throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public FutureResult<Connection> getConnectionAsync( |
| | | final ResultHandler<? super Connection> handler) { |
| | | final AsynchronousFutureResult<Connection, ResultHandler<? super Connection>> future = |
| | | new AsynchronousFutureResult<Connection, ResultHandler<? super Connection>>(handler); |
| | | future.handleResult(org.mockito.Mockito.mock(Connection.class)); |
| | | return future; |
| | | } |
| | | |
| | | /** |
| | | * Returns the address of the Directory Server. |
| | | * |
| | | * @return The address of the Directory Server. |
| | | */ |
| | | public SocketAddress getSocketAddress() { |
| | | return socketAddress; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append("LDAPConnectionFactory("); |
| | | builder.append(getSocketAddress().toString()); |
| | | builder.append(')'); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | LDAPOptions getLDAPOptions() { |
| | | return options; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * 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 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 |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.SocketAddress; |
| | | import org.forgerock.opendj.ldap.LDAPClientContext; |
| | | import org.forgerock.opendj.ldap.LDAPListenerOptions; |
| | | import org.forgerock.opendj.ldap.ServerConnectionFactory; |
| | | import org.forgerock.opendj.ldap.spi.LDAPListenerImpl; |
| | | |
| | | /** |
| | | * Basic LDAP listener implementation to use for tests only. |
| | | */ |
| | | public final class BasicLDAPListener implements LDAPListenerImpl { |
| | | private final ServerConnectionFactory<LDAPClientContext, Integer> connectionFactory; |
| | | private final SocketAddress socketAddress; |
| | | |
| | | /** |
| | | * Creates a new LDAP listener implementation which does nothing. |
| | | * |
| | | * @param address |
| | | * The address to listen on. |
| | | * @param factory |
| | | * The server connection factory can be used to create |
| | | * server connections. |
| | | * @param options |
| | | * The LDAP listener options. |
| | | * @throws IOException |
| | | * is never thrown with this do-nothing implementation |
| | | */ |
| | | public BasicLDAPListener(final SocketAddress address, |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> factory, |
| | | final LDAPListenerOptions options) throws IOException { |
| | | this.connectionFactory = factory; |
| | | this.socketAddress = address; |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | // nothing to do |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SocketAddress getSocketAddress() { |
| | | return socketAddress; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append("LDAPListener("); |
| | | builder.append(getSocketAddress().toString()); |
| | | builder.append(')'); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | ServerConnectionFactory<LDAPClientContext, Integer> getConnectionFactory() { |
| | | return connectionFactory; |
| | | } |
| | | } |
copy from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyTransportProvider.java
copy to opendj3/opendj-core/src/test/java/com/forgerock/opendj/ldap/BasicTransportProvider.java
| File was copied from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyTransportProvider.java |
| | |
| | | import org.forgerock.opendj.ldap.spi.TransportProvider; |
| | | |
| | | /** |
| | | * Provides an implementation of {@code LDAPListener} using Grizzly as |
| | | * transport. |
| | | * Provides an basic implementation of a transport provider doing nothing. |
| | | * This should be used for tests only. |
| | | * <p> |
| | | * To be used, this implementation must be declared in the |
| | | * provider-configuration file |
| | | * {@code META-INF/services/org.forgerock.opendj.ldap.spi.LDAPListenerProvider} |
| | | * {@code META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider} |
| | | * with this single line: |
| | | * |
| | | * <pre> |
| | | * com.forgerock.opendj.ldap.GrizzlyLDAPListenerProvider |
| | | * com.forgerock.opendj.ldap.BasicTransportProvider |
| | | * </pre>. |
| | | * <p> |
| | | * To require that this implementation is used, you must set the transport |
| | | * provider to {@code Grizzly} using |
| | | * {@code LDAPListenerOptions#setTransportProvider(String)} method. Otherwise |
| | | * there is no guarantee that this implementation will be used. |
| | | */ |
| | | public class GrizzlyTransportProvider implements TransportProvider { |
| | | public class BasicTransportProvider implements TransportProvider { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDAPConnectionFactoryImpl getLDAPConnectionFactory(SocketAddress address, LDAPOptions options) { |
| | | return new GrizzlyLDAPConnectionFactory(address, options); |
| | | return new BasicLDAPConnectionFactory(address, options); |
| | | //return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | ServerConnectionFactory<LDAPClientContext, Integer> factory, |
| | | LDAPListenerOptions options) |
| | | throws IOException { |
| | | return new GrizzlyLDAPListener(address, factory, options); |
| | | //return null; |
| | | return new BasicLDAPListener(address, factory, options); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return "Grizzly"; |
| | | return "Basic"; |
| | | } |
| | | |
| | | } |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnectionTestCase.java |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class AbstractAsynchronousConnectionTestCase extends SdkTestCase { |
| | | |
| | | private final class MockConnection extends AbstractAsynchronousConnection { |
| | | public final class MockConnection extends AbstractAsynchronousConnection { |
| | | private final ResultCode resultCode; |
| | | private final SearchResultEntry[] entries; |
| | | |
| | | private MockConnection(ResultCode resultCode, SearchResultEntry...entries) { |
| | | public MockConnection(ResultCode resultCode, SearchResultEntry...entries) { |
| | | this.resultCode = resultCode; |
| | | this.entries = entries; |
| | | } |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MockConnectionEventListener.java |
| | |
| | | * A connection event listener which records events and signals when it has been |
| | | * notified. |
| | | */ |
| | | final class MockConnectionEventListener implements ConnectionEventListener { |
| | | public final class MockConnectionEventListener implements ConnectionEventListener { |
| | | private final CountDownLatch closedLatch = new CountDownLatch(1); |
| | | private final CountDownLatch errorLatch = new CountDownLatch(1); |
| | | private final CountDownLatch notificationLatch = new CountDownLatch(1); |
| | |
| | | notificationLatch.countDown(); |
| | | } |
| | | |
| | | void awaitClose(long timeout, TimeUnit unit) { |
| | | public void awaitClose(long timeout, TimeUnit unit) { |
| | | await(closedLatch, timeout, unit); |
| | | } |
| | | |
| | | void awaitError(long timeout, TimeUnit unit) { |
| | | public void awaitError(long timeout, TimeUnit unit) { |
| | | await(errorLatch, timeout, unit); |
| | | } |
| | | |
| | | void awaitNotification(long timeout, TimeUnit unit) { |
| | | public void awaitNotification(long timeout, TimeUnit unit) { |
| | | await(notificationLatch, timeout, unit); |
| | | } |
| | | |
| | | Boolean isDisconnectNotification() { |
| | | public Boolean isDisconnectNotification() { |
| | | return isDisconnectNotification; |
| | | } |
| | | |
| | | ErrorResultException getError() { |
| | | public ErrorResultException getError() { |
| | | return error; |
| | | } |
| | | |
| | | ExtendedResult getNotification() { |
| | | public ExtendedResult getNotification() { |
| | | return notification; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | int getInvocationCount() { |
| | | public int getInvocationCount() { |
| | | return invocationCount.get(); |
| | | } |
| | | } |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/SdkTestCase.java |
| | |
| | | * |
| | | * @param exceptionClass expected exception |
| | | */ |
| | | void failWasExpected(Class<? extends Throwable> exceptionClass) { |
| | | protected void failWasExpected(Class<? extends Throwable> exceptionClass) { |
| | | fail("should throw an exception " + exceptionClass.getSimpleName()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param level logging level to use |
| | | */ |
| | | void setDefaultLogLevel(Level level) { |
| | | protected void setDefaultLogLevel(Level level) { |
| | | Logger.getLogger(StaticUtils.DEFAULT_LOG.getName()).setLevel(level); |
| | | } |
| | | |
copy from opendj3/opendj-ldap-sdk/src/main/resources/META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider
copy to opendj3/opendj-core/src/test/resources/META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider
| File was copied from opendj3/opendj-ldap-sdk/src/main/resources/META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider |
| | |
| | | # |
| | | # Copyright 2013 ForgeRock AS. |
| | | # |
| | | com.forgerock.opendj.ldap.GrizzlyTransportProvider |
| | | com.forgerock.opendj.ldap.BasicTransportProvider |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!-- |
| | | ! CDDL HEADER START |
| | | ! |
| | | ! The contents of this file are subject to the terms of the |
| | | ! Common Development and Distribution License, Version 1.0 only |
| | | ! (the "License"). You may not use this file except in compliance |
| | | ! with the License. |
| | | ! |
| | | ! 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 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 |
| | | ! |
| | | ! Copyright 2013 ForgeRock AS |
| | | ! |
| | | --> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <artifactId>opendj-project</artifactId> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <version>2.7.0-SNAPSHOT</version> |
| | | </parent> |
| | | <artifactId>opendj-grizzly</artifactId> |
| | | <name>Grizzly Provider for OpenDJ LDAP SDK</name> |
| | | <description> |
| | | This module includes a Grizzly-based implementation of transport provider for OpenDJ LDAP SDK. |
| | | </description> |
| | | <packaging>bundle</packaging> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-core</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-core</artifactId> |
| | | <type>test-jar</type> |
| | | <version>${project.version}</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>i18n-core</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.glassfish.grizzly</groupId> |
| | | <artifactId>grizzly-framework</artifactId> |
| | | <version>${grizzlyFrameworkVersion}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock</groupId> |
| | | <artifactId>forgerock-build-tools</artifactId> |
| | | <version>${forgerockBuildToolsVersion}</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | <properties> |
| | | <opendj.osgi.import> |
| | | com.sun.security.auth*;resolution:=optional, |
| | | * |
| | | </opendj.osgi.import> |
| | | </properties> |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.felix</groupId> |
| | | <artifactId>maven-bundle-plugin</artifactId> |
| | | <extensions>true</extensions> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-source-plugin</artifactId> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | <reporting> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-project-info-reports-plugin</artifactId> |
| | | <reportSets> |
| | | <reportSet> |
| | | <reports> |
| | | <report>mailing-list</report> |
| | | <report>issue-tracking</report> |
| | | <report>license</report> |
| | | <report>cim</report> |
| | | <report>distribution-management</report> |
| | | </reports> |
| | | </reportSet> |
| | | </reportSets> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-javadoc-plugin</artifactId> |
| | | <configuration> |
| | | <links> |
| | | <link>http://commons.forgerock.org/i18n-framework/i18n-core/apidocs</link> |
| | | </links> |
| | | </configuration> |
| | | </plugin> |
| | | </plugins> |
| | | </reporting> |
| | | </project> |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferReader.java |
| | |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | 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; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ASN1BufferWriter.java |
| | |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ASN1_SEQUENCE_WRITE_NOT_STARTED; |
| | | import static com.forgerock.opendj.util.StaticUtils.IO_LOG; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPMessageHandler.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/ConnectionSecurityLayerFilter.java |
| | |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import org.forgerock.opendj.ldap.ConnectionSecurityLayer; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransport.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.DEFAULT_LOG; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyLDAPConnection.java |
| | |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.DEFAULT_LOG; |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; |
| | | import static com.forgerock.opendj.util.StaticUtils.*; |
| | | |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.InetSocketAddress; |
| | |
| | | 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.SSLContextBuilder; |
| | | import org.forgerock.opendj.ldap.SearchResultHandler; |
| | | import org.forgerock.opendj.ldap.TrustManagers; |
| | | import org.forgerock.opendj.ldap.requests.AbandonRequest; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | |
| | | 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.ldap.spi.AbstractLDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPBindFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPCompareFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPExtendedFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPSearchFutureResultImpl; |
| | | import org.glassfish.grizzly.CompletionHandler; |
| | | import org.glassfish.grizzly.filterchain.Filter; |
| | | import org.glassfish.grizzly.filterchain.FilterChain; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyLDAPConnectionFactory.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static com.forgerock.opendj.ldap.TimeoutChecker.TIMEOUT_CHECKER; |
| | | |
| | | import static com.forgerock.opendj.grizzly.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static com.forgerock.opendj.grizzly.TimeoutChecker.TIMEOUT_CHECKER; |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.*; |
| | | |
| | | import java.io.IOException; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyLDAPListener.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static com.forgerock.opendj.grizzly.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static com.forgerock.opendj.util.StaticUtils.DEFAULT_LOG; |
| | | |
| | | import java.io.IOException; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/GrizzlyTransportProvider.java |
| | |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.SocketAddress; |
| | |
| | | import org.forgerock.opendj.ldap.spi.TransportProvider; |
| | | |
| | | /** |
| | | * Provides an implementation of {@code LDAPListener} using Grizzly as |
| | | * transport. |
| | | * Provides an implementation of a transport provider using Grizzly as |
| | | * transport. This provider is named "Grizzly". |
| | | * <p> |
| | | * To be used, this implementation must be declared in the |
| | | * provider-configuration file |
| | | * {@code META-INF/services/org.forgerock.opendj.ldap.spi.LDAPListenerProvider} |
| | | * {@code META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider} |
| | | * with this single line: |
| | | * |
| | | * <pre> |
| | | * com.forgerock.opendj.ldap.GrizzlyLDAPListenerProvider |
| | | * com.forgerock.opendj.ldap.GrizzlyTransportProvider |
| | | * </pre>. |
| | | * <p> |
| | | * To require that this implementation is used, you must set the transport |
| | | * provider to {@code Grizzly} using |
| | | * {@code LDAPListenerOptions#setTransportProvider(String)} method. Otherwise |
| | | * there is no guarantee that this implementation will be used. |
| | | * provider to "Grizzly" using {@code LDAPOptions#setTransportProvider()} |
| | | * method if requesting a {@code LDAPConnectionFactory} or |
| | | * {@code LDAPListenerOptions#setTransportProvider()} method if requesting a |
| | | * {@code LDAPListener}. Otherwise there is no guarantee that this |
| | | * implementation will be used. |
| | | */ |
| | | public class GrizzlyTransportProvider implements TransportProvider { |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPClientFilter.java |
| | |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.OID_NOTICE_OF_DISCONNECTION; |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.*; |
| | | |
| | | import java.io.EOFException; |
| | | import java.io.IOException; |
| | |
| | | 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.spi.AbstractLDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPBindFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPCompareFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPExtendedFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPFutureResultImpl; |
| | | import org.forgerock.opendj.ldap.spi.LDAPSearchFutureResultImpl; |
| | | import org.glassfish.grizzly.Buffer; |
| | | import org.glassfish.grizzly.Connection; |
| | | import org.glassfish.grizzly.EmptyCompletionHandler; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPMessageHandler.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPReader.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.*; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_LDAP_MODIFICATION_DECODE_INVALID_MOD_TYPE; |
| | |
| | | import static com.forgerock.opendj.util.StaticUtils.byteToHex; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.asn1.ASN1; |
| | | import org.forgerock.opendj.asn1.ASN1Reader; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.ldap.LDAPUtils; |
| | | |
| | | /** |
| | | * Static methods for decoding LDAP messages. |
| | | */ |
| | | final class LDAPReader { |
| | | static SearchResultEntry decodeEntry(final ASN1Reader reader, final DecodeOptions options) |
| | | throws IOException { |
| | | Entry entry; |
| | | |
| | | reader.readStartSequence(OP_TYPE_SEARCH_RESULT_ENTRY); |
| | | try { |
| | | final String dnString = reader.readOctetStringAsString(); |
| | | final Schema schema = options.getSchemaResolver().resolveSchema(dnString); |
| | | DN dn; |
| | | try { |
| | | dn = DN.valueOf(dnString, schema); |
| | | } catch (final LocalizedIllegalArgumentException e) { |
| | | throw DecodeException.error(e.getMessageObject()); |
| | | } |
| | | |
| | | entry = options.getEntryFactory().newEntry(dn); |
| | | reader.readStartSequence(); |
| | | try { |
| | | while (reader.hasNextElement()) { |
| | | reader.readStartSequence(); |
| | | try { |
| | | final String ads = reader.readOctetStringAsString(); |
| | | AttributeDescription ad; |
| | | try { |
| | | ad = AttributeDescription.valueOf(ads, schema); |
| | | } catch (final LocalizedIllegalArgumentException e) { |
| | | throw DecodeException.error(e.getMessageObject()); |
| | | } |
| | | |
| | | final Attribute attribute = options.getAttributeFactory().newAttribute(ad); |
| | | |
| | | reader.readStartSet(); |
| | | try { |
| | | while (reader.hasNextElement()) { |
| | | attribute.add(reader.readOctetString()); |
| | | } |
| | | entry.addAttribute(attribute); |
| | | } finally { |
| | | reader.readEndSet(); |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | } finally { |
| | | reader.readEndSequence(); |
| | | } |
| | | |
| | | return Responses.newSearchResultEntry(entry); |
| | | } |
| | | |
| | | private final DecodeOptions options; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java |
| | |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.OID_NOTICE_OF_DISCONNECTION; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPWriter.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.*; |
| | | import static com.forgerock.opendj.util.StaticUtils.IO_LOG; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.asn1.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.Attribute; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | |
| | | import com.forgerock.opendj.ldap.LDAPUtils; |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/TimeoutChecker.java |
| | |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.DEFAULT_LOG; |
| | | import static java.util.Collections.newSetFromMap; |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedRequestException.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnexpectedResponseException.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/UnsupportedMessageException.java |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * 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 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 |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | /** |
| | | * Classes implementing Grizzly transport provider. |
| | | */ |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| New file |
| | |
| | | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| | | <html> |
| | | <body> |
| | | The OpenDJ SDK for Java provides a high performance easy to use |
| | | library of classes and interfaces for accessing and implementing |
| | | LDAP Directory Services as defined in <a |
| | | href="http://tools.ietf.org/html/rfc4510">RFC 4510</a>. |
| | | <br> |
| | | For an introduction to LDAP, read the <em>OpenDJ SDK Developer's Guide</em> |
| | | chapter on <a |
| | | href="http://opendj.forgerock.org/doc/dev-guide/index.html#chap-understanding-ldap" |
| | | >Understanding LDAP</a>. Also see the chapter on <a |
| | | href="http://opendj.forgerock.org/doc/dev-guide/index.html#chap-best-practices" |
| | | >Best Practices For LDAP Application Developers</a>. |
| | | <br> |
| | | <h1>Getting Started</h1> |
| | | The following example shows how the OpenDJ SDK may be used to |
| | | connect to a directory server, authenticate, and then perform a |
| | | search. The search results are output as LDIF to the standard |
| | | output: |
| | | <br> |
| | | <table width="100%"> |
| | | <tbody> |
| | | <tr> |
| | | <td> |
| | | <pre> // Create an LDIF writer which will write the search results to stdout. |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(System.out); |
| | | Connection connection = null; |
| | | try |
| | | { |
| | | // Connect and bind to the server. |
| | | final LDAPConnectionFactory factory = new LDAPConnectionFactory("localhost", 1389); |
| | | |
| | | connection = factory.getConnection(); |
| | | connection.bind(userName, password); |
| | | |
| | | // Read the entries and output them as LDIF. |
| | | final ConnectionEntryReader reader = connection.search(baseDN, scope, filter, attributes); |
| | | while (reader.hasNext()) |
| | | { |
| | | if (reader.isEntry()) |
| | | { |
| | | // Got an entry. |
| | | final SearchResultEntry entry = reader.readEntry(); |
| | | writer.writeComment("Search result entry: " + entry.getName().toString()); |
| | | writer.writeEntry(entry); |
| | | } |
| | | else |
| | | { |
| | | // Got a continuation reference. |
| | | final SearchResultReference ref = reader.readReference(); |
| | | writer.writeComment("Search result reference: " + ref.getURIs().toString()); |
| | | } |
| | | } |
| | | writer.flush(); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | // Handle exceptions... |
| | | System.err.println(e.getMessage()); |
| | | } |
| | | finally |
| | | { |
| | | if (connection != null) |
| | | { |
| | | connection.close(); |
| | | } |
| | | }</pre> |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | <br><!-- It seems the .zip is not packaged with the SDK. --> |
| | | Additional examples can be found online at the <a |
| | | href="http://opendj.forgerock.org/opendj-ldap-sdk-examples/" |
| | | >OpenDJ LDAP SDK Examples</a> site. |
| | | <br> |
| | | <h1>Creating Connections</h1> |
| | | The following classes can be used to create and manage connections to |
| | | LDAP directory servers: |
| | | <ul> |
| | | <li>{@link org.forgerock.opendj.ldap.LDAPConnectionFactory}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.Connection}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.Connections}</li> |
| | | </ul> |
| | | <br> |
| | | <h1>Creating Requests</h1> |
| | | The following classes can be used to create LDAP requests: |
| | | <ul> |
| | | <li>{@link org.forgerock.opendj.ldap.requests.Requests}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.requests.Request}</li> |
| | | </ul> |
| | | <br> |
| | | <h1>Using Controls</h1> |
| | | Common LDAP control implementations can be found in |
| | | {@link org.forgerock.opendj.ldap.controls}. |
| | | <br> |
| | | <h1>Core Types</h1> |
| | | The following classes and interfaces represent core types: |
| | | <ul> |
| | | <li>{@link org.forgerock.opendj.ldap.AttributeDescription}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.Attribute}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.DN}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.Entry}</li> |
| | | <li>{@link org.forgerock.opendj.ldap.Filter}</li> |
| | | </ul> |
| | | <br> |
| | | @see <a href="http://tools.ietf.org/html/rfc4511">RFC 4511 - Lightweight |
| | | Directory Access Protocol (LDAP): The Protocol </a> |
| | | @see org.forgerock.opendj.ldap |
| | | </body> |
| | | </html> |
| File was renamed from opendj3/opendj-ldap-sdk/src/main/resources/META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider |
| | |
| | | # |
| | | # Copyright 2013 ForgeRock AS. |
| | | # |
| | | com.forgerock.opendj.ldap.GrizzlyTransportProvider |
| | | com.forgerock.opendj.grizzly.GrizzlyTransportProvider |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferReaderTestCase.java |
| | |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | import java.nio.ByteBuffer; |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/ASN1BufferWriterTestCase.java |
| | |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | | import java.nio.ByteBuffer; |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java |
| | |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static java.util.Arrays.*; |
| | | |
| | |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.ConnectionPool; |
| | | import org.forgerock.opendj.ldap.Connections; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.FailoverLoadBalancingAlgorithm; |
| | | import org.forgerock.opendj.ldap.FutureResult; |
| | | 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.LDAPOptions; |
| | | import org.forgerock.opendj.ldap.LDAPServer; |
| | | import org.forgerock.opendj.ldap.MockConnectionEventListener; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ResultHandler; |
| | | import org.forgerock.opendj.ldap.RoundRobinLoadBalancingAlgorithm; |
| | | import org.forgerock.opendj.ldap.SSLContextBuilder; |
| | | import org.forgerock.opendj.ldap.SdkTestCase; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.ServerConnection; |
| | | import org.forgerock.opendj.ldap.ServerConnectionFactory; |
| | | import org.forgerock.opendj.ldap.TestCaseUtils; |
| | | import org.forgerock.opendj.ldap.TrustManagers; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | | import org.forgerock.opendj.ldap.requests.DigestMD5SASLBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | |
| | | |
| | | // AuthenticatedConnectionFactory |
| | | factories[2][0] = |
| | | new AuthenticatedConnectionFactory(new LDAPConnectionFactory(getServerSocketAddress()), |
| | | Connections.newAuthenticatedConnectionFactory(new LDAPConnectionFactory(getServerSocketAddress()), |
| | | Requests.newSimpleBindRequest("", new char[0])); |
| | | |
| | | // AuthenticatedConnectionFactory with multi-stage SASL |
| | | factories[3][0] = |
| | | new AuthenticatedConnectionFactory(new LDAPConnectionFactory(getServerSocketAddress()), |
| | | Connections.newAuthenticatedConnectionFactory(new LDAPConnectionFactory(getServerSocketAddress()), |
| | | Requests.newCRAMMD5SASLBindRequest("id:user", "password".toCharArray())); |
| | | |
| | | // LDAPConnectionFactory with default options |
| | |
| | | // localhost.localdomain). |
| | | // FIXME: enable QOP once OPENDJ-514 is fixed. |
| | | factories[6][0] = |
| | | new AuthenticatedConnectionFactory(new LDAPConnectionFactory( |
| | | Connections.newAuthenticatedConnectionFactory(new LDAPConnectionFactory( |
| | | getServerSocketAddress(), options), Requests.newDigestMD5SASLBindRequest( |
| | | "id:user", "password".toCharArray()).setCipher( |
| | | DigestMD5SASLBindRequest.CIPHER_LOW)); |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransportTestCase.java |
| | |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static com.forgerock.opendj.ldap.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static org.forgerock.opendj.ldap.TestCaseUtils.findFreeSocketAddress; |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.forgerock.opendj.ldap.TestCaseUtils.*; |
| | | import static com.forgerock.opendj.grizzly.DefaultTCPNIOTransport.DEFAULT_TRANSPORT; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.net.Socket; |
| | | import java.net.SocketAddress; |
| | |
| | | import org.glassfish.grizzly.nio.transport.TCPNIOTransport; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import com.forgerock.opendj.ldap.LDAPTestCase; |
| | | import com.forgerock.opendj.util.ReferenceCountedObject; |
| | | |
| | | /** |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/GrizzlyLDAPConnectionTestCase.java |
| | |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static org.fest.assertions.Assertions.assertThat; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.mockito.Mockito.verify; |
| | | import static org.mockito.Mockito.verifyZeroInteractions; |
| | | import static org.fest.assertions.Assertions.*; |
| | | import static org.mockito.Mockito.*; |
| | | |
| | | import java.net.SocketAddress; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | import org.forgerock.opendj.ldap.LDAPOptions; |
| | | import org.forgerock.opendj.ldap.RequestHandler; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SdkTestCase; |
| | | import org.forgerock.opendj.ldap.SearchResultHandler; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.TestCaseUtils; |
| | |
| | | * Tests LDAP connection implementation class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class GrizzlyLDAPConnectionTestCase extends LDAPTestCase { |
| | | public class GrizzlyLDAPConnectionTestCase extends SdkTestCase { |
| | | |
| | | /** |
| | | * Tests that a normal request is subject to client side timeout checking. |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPConnectionFactoryTestCase.java |
| | |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static org.fest.assertions.Assertions.assertThat; |
| | | import static org.forgerock.opendj.ldap.TestCaseUtils.findFreeSocketAddress; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.fest.assertions.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.TestCaseUtils.*; |
| | | import static org.mockito.Mockito.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.concurrent.Semaphore; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.LDAPClientContext; |
| | | import org.forgerock.opendj.ldap.LDAPConnectionFactory; |
| | | import org.forgerock.opendj.ldap.LDAPListener; |
| | | import org.forgerock.opendj.ldap.LDAPOptions; |
| | | import org.forgerock.opendj.ldap.MockConnectionEventListener; |
| | | import org.forgerock.opendj.ldap.ProviderNotFoundException; |
| | | import org.forgerock.opendj.ldap.SdkTestCase; |
| | | import org.forgerock.opendj.ldap.ServerConnection; |
| | | import org.forgerock.opendj.ldap.ServerConnectionFactory; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java |
| | |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | package com.forgerock.opendj.grizzly; |
| | | |
| | | import static org.fest.assertions.Assertions.*; |
| | | import static org.fest.assertions.Fail.*; |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.logging.Level; |
| | | |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ConnectionException; |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.Connections; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | 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.ProviderNotFoundException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ResultHandler; |
| | | import org.forgerock.opendj.ldap.RoundRobinLoadBalancingAlgorithm; |
| | | import org.forgerock.opendj.ldap.SdkTestCase; |
| | | import org.forgerock.opendj.ldap.SearchResultHandler; |
| | | import org.forgerock.opendj.ldap.ServerConnection; |
| | | import org.forgerock.opendj.ldap.ServerConnectionFactory; |
| | | import org.forgerock.opendj.ldap.requests.AbandonRequest; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-shade-plugin</artifactId> |
| | | <configuration> |
| | | <createDependencyReducedPom>false</createDependencyReducedPom> |
| | | <createDependencyReducedPom>false</createDependencyReducedPom> |
| | | <artifactSet> |
| | | <excludes> |
| | | <!-- avoid duplicate classes, as opendj-ldap-sdk already contains them --> |
| | | <exclude>org.forgerock.opendj:opendj-core</exclude> |
| | | <exclude>org.forgerock.opendj:opendj-grizzly</exclude> |
| | | </excludes> |
| | | </artifactSet> |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | |
| | | This module includes OpenDJ core APIs for implementing LDAP Directory |
| | | client and server applications. |
| | | </description> |
| | | <packaging>bundle</packaging> |
| | | <packaging>jar</packaging> |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>i18n-core</artifactId> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-core</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.glassfish.grizzly</groupId> |
| | | <artifactId>grizzly-framework</artifactId> |
| | | <version>${grizzlyFrameworkVersion}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.slf4j</groupId> |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock</groupId> |
| | | <artifactId>forgerock-build-tools</artifactId> |
| | | <version>${forgerockBuildToolsVersion}</version> |
| | | <scope>test</scope> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-grizzly</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | <properties> |
| | |
| | | </properties> |
| | | <build> |
| | | <plugins> |
| | | <!-- Unpack opendj-core and opendj-grizzly to rebuild an unified jar with bundle --> |
| | | <plugin> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>i18n-maven-plugin</artifactId> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-dependency-plugin</artifactId> |
| | | <version>2.8</version> |
| | | <executions> |
| | | <execution> |
| | | <phase>generate-sources</phase> |
| | | <id>unpack-dependencies</id> |
| | | <phase>package</phase> |
| | | <goals> |
| | | <goal>generate-messages</goal> |
| | | <goal>unpack-dependencies</goal> |
| | | </goals> |
| | | <configuration> |
| | | <messageFiles> |
| | | <messageFile>com/forgerock/opendj/ldap/core.properties</messageFile> |
| | | </messageFiles> |
| | | <includeArtifactIds>opendj-grizzly, opendj-core</includeArtifactIds> |
| | | <includes>**/*.class,**\/services\/*</includes> |
| | | <excludes>**/*.properties</excludes> |
| | | <outputDirectory>${project.build.directory}/classes</outputDirectory> |
| | | <overWriteReleases>false</overWriteReleases> |
| | | <overWriteSnapshots>true</overWriteSnapshots> |
| | | <excludeTransitive>true</excludeTransitive> |
| | | </configuration> |
| | | </execution> |
| | | </executions> |
| | |
| | | <groupId>org.apache.felix</groupId> |
| | | <artifactId>maven-bundle-plugin</artifactId> |
| | | <extensions>true</extensions> |
| | | <executions> |
| | | <execution> |
| | | <phase>package</phase> |
| | | <goals> |
| | | <goal>bundle</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | <configuration> |
| | | <instructions> |
| | | <Include-Resource>META-INF/services=target/classes/META-INF/services</Include-Resource> |
| | | </instructions> |
| | | </configuration> |
| | | </plugin> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.forgerock.opendj</groupId> |
| | | <artifactId>opendj-ldap-sdk</artifactId> |
| | | <artifactId>opendj-core</artifactId> |
| | | <version>${project.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | |
| | | </site> |
| | | </distributionManagement> |
| | | <modules> |
| | | <module>opendj-core</module> |
| | | <module>opendj-grizzly</module> |
| | | <module>opendj-ldap-sdk</module> |
| | | <module>opendj-ldap-toolkit</module> |
| | | <module>opendj-ldap-sdk-examples</module> |