001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009-2010 Sun Microsystems, Inc.
025 *      Portions copyright 2011-2015 ForgeRock AS.
026 */
027
028package org.forgerock.opendj.ldap.spi;
029
030import org.forgerock.opendj.ldap.IntermediateResponseHandler;
031import org.forgerock.opendj.ldap.LdapException;
032import org.forgerock.opendj.ldap.ResultCode;
033import org.forgerock.opendj.ldap.requests.BindClient;
034import org.forgerock.opendj.ldap.requests.BindRequest;
035import org.forgerock.opendj.ldap.responses.BindResult;
036import org.forgerock.opendj.ldap.responses.Responses;
037import org.forgerock.util.promise.PromiseImpl;
038
039/**
040 * Bind result promise implementation.
041 */
042public final class BindResultLdapPromiseImpl extends ResultLdapPromiseImpl<BindRequest, BindResult> {
043    private final BindClient bindClient;
044
045    BindResultLdapPromiseImpl(
046            final PromiseImpl<BindResult, LdapException> impl,
047            final int requestID,
048            final BindRequest request,
049            final BindClient bindClient,
050            final IntermediateResponseHandler intermediateResponseHandler) {
051        super(impl, requestID, request, intermediateResponseHandler);
052        this.bindClient = bindClient;
053    }
054
055    /**
056     * Returns the bind client.
057     *
058     * @return The bind client.
059     */
060    public BindClient getBindClient() {
061        return bindClient;
062    }
063
064    @Override
065    public boolean isBindOrStartTLS() {
066        return true;
067    }
068
069    @Override
070    BindResult newErrorResult(final ResultCode resultCode, final String diagnosticMessage, final Throwable cause) {
071        return Responses.newBindResult(resultCode).setDiagnosticMessage(diagnosticMessage).setCause(cause);
072    }
073}