GssApiWithMicAuthenticationReporter.java

  1. /*
  2.  * Copyright (C) 2022 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;

  11. import java.util.List;

  12. import org.apache.sshd.client.session.ClientSession;
  13. import org.apache.sshd.common.AttributeRepository.AttributeKey;

  14. /**
  15.  * Callback interface for recording authentication state in
  16.  * {@link GssApiWithMicAuthentication}.
  17.  */
  18. public interface GssApiWithMicAuthenticationReporter {

  19.     /**
  20.      * An {@link AttributeKey} for a {@link ClientSession} holding the
  21.      * {@link GssApiWithMicAuthenticationReporter}.
  22.      */
  23.     static final AttributeKey<GssApiWithMicAuthenticationReporter> GSS_AUTHENTICATION_REPORTER = new AttributeKey<>();

  24.     /**
  25.      * Called when a new authentication attempt is made.
  26.      *
  27.      * @param session
  28.      *            the {@link ClientSession}
  29.      * @param service
  30.      *            the name of the requesting SSH service name
  31.      * @param mechanism
  32.      *            the OID of the mechanism used
  33.      */
  34.     default void signalAuthenticationAttempt(ClientSession session,
  35.             String service, String mechanism) {
  36.         // nothing
  37.     }

  38.     /**
  39.      * Called when there are no more mechanisms to try.
  40.      *
  41.      * @param session
  42.      *            the {@link ClientSession}
  43.      * @param service
  44.      *            the name of the requesting SSH service name
  45.      */
  46.     default void signalAuthenticationExhausted(ClientSession session,
  47.             String service) {
  48.         // nothing
  49.     }

  50.     /**
  51.      * Called when authentication was succeessful.
  52.      *
  53.      * @param session
  54.      *            the {@link ClientSession}
  55.      * @param service
  56.      *            the name of the requesting SSH service name
  57.      * @param mechanism
  58.      *            the OID of the mechanism used
  59.      */
  60.     default void signalAuthenticationSuccess(ClientSession session,
  61.             String service, String mechanism) {
  62.         // nothing
  63.     }

  64.     /**
  65.      * Called when the authentication was not successful.
  66.      *
  67.      * @param session
  68.      *            the {@link ClientSession}
  69.      * @param service
  70.      *            the name of the requesting SSH service name
  71.      * @param mechanism
  72.      *            the OID of the mechanism used
  73.      * @param partial
  74.      *            {@code true} if authentication was partially successful,
  75.      *            meaning one continues with additional authentication methods
  76.      *            given by {@code serverMethods}
  77.      * @param serverMethods
  78.      *            the {@link List} of authentication methods that can continue
  79.      */
  80.     default void signalAuthenticationFailure(ClientSession session,
  81.             String service, String mechanism, boolean partial,
  82.             List<String> serverMethods) {
  83.         // nothing
  84.     }
  85. }