AbstractAuthenticationHandler.java

  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. import java.net.InetSocketAddress;

  12. /**
  13.  * Abstract base class for {@link AuthenticationHandler}s encapsulating basic
  14.  * common things.
  15.  *
  16.  * @param <ParameterType>
  17.  *            defining the parameter type for the authentication
  18.  * @param <TokenType>
  19.  *            defining the token type for the authentication
  20.  */
  21. public abstract class AbstractAuthenticationHandler<ParameterType, TokenType>
  22.         implements AuthenticationHandler<ParameterType, TokenType> {

  23.     /** The {@link InetSocketAddress} or the proxy to connect to. */
  24.     protected InetSocketAddress proxy;

  25.     /** The last set parameters. */
  26.     protected ParameterType params;

  27.     /** A flag telling whether this authentication is done. */
  28.     protected boolean done;

  29.     /**
  30.      * Creates a new {@link AbstractAuthenticationHandler} to authenticate with
  31.      * the given {@code proxy}.
  32.      *
  33.      * @param proxy
  34.      *            the {@link InetSocketAddress} of the proxy to connect to
  35.      */
  36.     public AbstractAuthenticationHandler(InetSocketAddress proxy) {
  37.         this.proxy = proxy;
  38.     }

  39.     @Override
  40.     public final void setParams(ParameterType input) {
  41.         params = input;
  42.     }

  43.     @Override
  44.     public final boolean isDone() {
  45.         return done;
  46.     }

  47. }