View Javadoc
1   /*
2    * Copyright (C) 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.transport.http;
11  
12  import java.io.IOException;
13  import java.security.GeneralSecurityException;
14  
15  import org.eclipse.jgit.annotations.NonNull;
16  
17  /**
18   * A {@link HttpConnectionFactory} that supports client-side sessions that can
19   * maintain state and configure connections.
20   *
21   * @since 5.11
22   */
23  public interface HttpConnectionFactory2 extends HttpConnectionFactory {
24  
25  	/**
26  	 * Creates a new {@link GitSession} instance that can be used with
27  	 * connections created by this {@link HttpConnectionFactory} instance.
28  	 *
29  	 * @return a new {@link GitSession}
30  	 */
31  	@NonNull
32  	GitSession newSession();
33  
34  	/**
35  	 * A {@code GitSession} groups the multiple HTTP connections
36  	 * {@link org.eclipse.jgit.transport.TransportHttp TransportHttp} uses for
37  	 * the requests it makes during a git fetch or push. A {@code GitSession}
38  	 * can maintain client-side HTTPS state and can configure individual
39  	 * connections.
40  	 */
41  	interface GitSession {
42  
43  		/**
44  		 * Configure a just created {@link HttpConnection}.
45  		 *
46  		 * @param connection
47  		 *            to configure; created by the same
48  		 *            {@link HttpConnectionFactory} instance
49  		 * @param sslVerify
50  		 *            whether SSL is to be verified
51  		 * @return the configured {@connection}
52  		 * @throws IOException
53  		 *             if the connection cannot be configured
54  		 * @throws GeneralSecurityException
55  		 *             if the connection cannot be configured
56  		 */
57  		@NonNull
58  		HttpConnection configure(@NonNull HttpConnection connection,
59  				boolean sslVerify) throws IOException, GeneralSecurityException;
60  
61  		/**
62  		 * Closes the {@link GitSession}, releasing any internal state.
63  		 */
64  		void close();
65  	}
66  }