View Javadoc
1   /*
2    * Copyright (C) 2018, 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.internal.transport.sshd.auth;
11  
12  import java.net.InetSocketAddress;
13  
14  /**
15   * Abstract base class for {@link AuthenticationHandler}s encapsulating basic
16   * common things.
17   *
18   * @param <ParameterType>
19   *            defining the parameter type for the authentication
20   * @param <TokenType>
21   *            defining the token type for the authentication
22   */
23  public abstract class AbstractAuthenticationHandler<ParameterType, TokenType>
24  		implements AuthenticationHandler<ParameterType, TokenType> {
25  
26  	/** The {@link InetSocketAddress} or the proxy to connect to. */
27  	protected InetSocketAddress proxy;
28  
29  	/** The last set parameters. */
30  	protected ParameterType params;
31  
32  	/** A flag telling whether this authentication is done. */
33  	protected boolean done;
34  
35  	/**
36  	 * Creates a new {@link AbstractAuthenticationHandler} to authenticate with
37  	 * the given {@code proxy}.
38  	 *
39  	 * @param proxy
40  	 *            the {@link InetSocketAddress} of the proxy to connect to
41  	 */
42  	public AbstractAuthenticationHandler(InetSocketAddress proxy) {
43  		this.proxy = proxy;
44  	}
45  
46  	@Override
47  	public final void setParams(ParameterType input) {
48  		params = input;
49  	}
50  
51  	@Override
52  	public final boolean isDone() {
53  		return done;
54  	}
55  
56  }