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