001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.ldap.client.api; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.exception.LdapException; 025 026 027/** 028 * A factory that creates {@link LdapConnection} objects using the provided 029 * {@link LdapConnectionConfig}. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public interface LdapConnectionFactory 034{ 035 /** 036 * Issues a bind request on the supplied connection using the name and 037 * credentials from the LdapConnectionConfg supplied to the constructor. 038 * Returns the connection supplied for chaining. 039 * 040 * @param connection 041 * The connection to bind with the configuration credentials. 042 * @return The connection supplied. 043 * @throws LdapException 044 * If the bind fails. 045 */ 046 LdapConnection bindConnection( LdapConnection connection ) throws LdapException; 047 048 049 /** 050 * Applies the following configuration settings from the 051 * LdapConnectionConfig to the supplied connection: 052 * <ul> 053 * <li>timeOut</li> 054 * <li>binaryAttributeDetector</li> 055 * </ul> 056 * This method is called by newLdapConnection, so there is no need to call 057 * this on a newly created connection. This should be used for pooling where 058 * the returned connection could have been modified by the borrower in order 059 * to ensure the next borrower gets a correctly configured connection. 060 * Returns the supplied connection for chaining. 061 * 062 * @param connection 063 * The connection to configure 064 * @return The supplied connection. 065 */ 066 LdapConnection configureConnection( LdapConnection connection ); 067 068 069 /** 070 * Returns the LdapApiService instance used by this factory. 071 * 072 * @return The LdapApiService instance used by this factory 073 */ 074 LdapApiService getLdapApiService(); 075 076 077 /** 078 * Returns a newly created, configured, and authenticated connection. This 079 * method should be used by a connection pool to manufacture the pooled 080 * instances. 081 * 082 * @return A newly created, configured, and authenticated LdapConnection. 083 * @throws LdapException If the new connection couldn't be established 084 */ 085 LdapConnection newLdapConnection() throws LdapException; 086 087 088 /** 089 * Returns a newly created connection, that has not been bound (bind) that 090 * otherwise respects LdapConnectionConfig supplied to the constructor. This 091 * is useful for authentication purposes where the consumer will use a bind 092 * operation. 093 * 094 * @return A newly created and configured LdapConnection. 095 */ 096 LdapConnection newUnboundLdapConnection(); 097}