package com.airlock.iam.authentication.infrastructure.resource;

import com.airlock.iam.airlock2fa.api.domain.model.Airlock2FADeviceId;
import com.airlock.iam.authentication.application.service.airlock2fa.Airlock2FAAuthentication;
import com.airlock.iam.authentication.application.service.airlock2fa.Airlock2FAAuthenticationDeviceSelection;
import com.airlock.iam.authentication.application.service.airlock2fa.Airlock2FAMobileOnlyAuthentication;
import com.airlock.iam.authentication.application.service.airlock2fa.Airlock2FAUserFactorAuthentication;
import com.airlock.iam.authentication.infrastructure.generated.transfer.response.Airlock2FADeviceDataCollectionDocument;
import com.airlock.iam.authentication.infrastructure.generated.transfer.response.Airlock2FAMobileOnlyChallengeDataResourceDocument;
import com.airlock.iam.authentication.infrastructure.generated.transfer.response.Airlock2FAOfflineQrCodeChallengeDataResourceDocument;
import com.airlock.iam.authentication.infrastructure.generated.transfer.response.Airlock2FAZeroTouchInformationDataResourceDocument;
import com.airlock.iam.authentication.infrastructure.transfer.request.Airlock2FAOfflineQrCodeCheckRequest;
import com.airlock.iam.authentication.infrastructure.transfer.response.Airlock2FADeviceData;
import com.airlock.iam.authentication.infrastructure.transfer.response.Airlock2FAMobileOnlyChallengeData;
import com.airlock.iam.authentication.infrastructure.transfer.response.Airlock2FAOfflineQrCodeChallengeData;
import com.airlock.iam.authentication.infrastructure.transfer.response.Airlock2FAZeroTouchInformationData;
import com.airlock.iam.factor.domain.model.airlock2fa.otp.Airlock2FAOtp;
import com.airlock.iam.factor.domain.model.airlock2fa.otp.Airlock2FAPasscode;
import com.airlock.iam.flow.api.domain.model.flow.FlowResult;
import com.airlock.iam.flow.api.infrastructure.mapper.FlowResultMapper;
import com.airlock.iam.flow.auth.api.infrastructure.generated.transfer.response.AuthenticationFlowResultDataResourceDocument;
import com.airlock.iam.flow.infrastructure.mapper.FlowResultToCollectionDocumentMapper;
import com.airlock.iam.flow.shared.domain.model.airlock2fa.Airlock2FADeviceListData;
import com.airlock.iam.flow.shared.infrastructure.transfer.request.Airlock2FAPasscodeCheckRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Response;
import ma.glasnost.orika.MapperFacade;

@Path("/airlock-2fa")
public class Airlock2FAAuthenticationFlowResource {
   private final FlowResultMapper mapper;
   private final MapperFacade mapperFacade;
   private final Provider<Airlock2FAAuthentication> authentication;
   private final Provider<Airlock2FAUserFactorAuthentication> userFactorAuthentication;
   private final Provider<Airlock2FAMobileOnlyAuthentication> mobileFactorAuthentication;
   private final Provider<Airlock2FAAuthenticationDeviceSelection> deviceSelection;

   @Inject
   public Airlock2FAAuthenticationFlowResource(
      FlowResultMapper mapper,
      MapperFacade mapperFacade,
      Provider<Airlock2FAAuthentication> authentication,
      Provider<Airlock2FAUserFactorAuthentication> userFactorAuthentication,
      Provider<Airlock2FAMobileOnlyAuthentication> mobileFactorAuthentication,
      Provider<Airlock2FAAuthenticationDeviceSelection> deviceSelection
   ) {
      this.mapper = mapper;
      this.mapperFacade = mapperFacade;
      this.authentication = authentication;
      this.userFactorAuthentication = userFactorAuthentication;
      this.mobileFactorAuthentication = mobileFactorAuthentication;
      this.deviceSelection = deviceSelection;
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Authentication successful or further steps required.",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "400",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>AIRLOCK_2FA_PASSCODE_WRONG</td>\n<td>Passcode could not be validated successfully. Retry with correct passcode.</td>\n</tr>\n</table>\n</div>\n<br>Possible next step: <tt>AIRLOCK_2FA_PASSCODE_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>).\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>AIRLOCK_2FA_PASSCODE_WRONG</td>\n<td>The passcode could not be validated successfully and no retries are allowed.</td>\n</tr>\n<tr>\n<td>AUTH_METHOD_INACTIVE</td>\n<td>The Airlock 2FA account is locked. No retries are allowed.</td>\n</tr>\n</table>\n</div>\n<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Operation(
      description = "Verifies the submitted Airlock 2FA passcode. The previously selected device has no impact on the passcode verification.\nNote that passcode checks are only possible if the step is in offline mode (using <tt>POST /public/authentication/airlock-2fa/offline/</tt>).\n<div class=\"iam-resource-return\">Whether the check was successful. If the attribute <tt>nextAuthStep</tt> is present in the response,\n further steps are required to successfully authenticate. If the attribute is missing, the user is\n successfully authenticated.</div>",
      tags = "Airlock 2FA",
      summary = "Verify passcode"
   )
   @POST
   @Path("/passcode/check")
   @Consumes("application/json")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response checkPasscode(@Parameter(description = "Contains the passcode.") @NotNull @Valid Airlock2FAPasscodeCheckRequest request) {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get())
         .checkPasscode(Airlock2FAPasscode.airlock2FAPasscode(request.getPasscode()));
      return this.mapper.toResponse(result);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "The QR code challenge has been issued.\n<br>Possible next step: <tt>AIRLOCK_2FA_QR_CODE_OTP_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>)\n",
               content = {
                     @Content(
                        mediaType = "application/vnd.api+json",
                        schema = @Schema(implementation = Airlock2FAOfflineQrCodeChallengeDataResourceDocument.class)
                     ),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = Airlock2FAOfflineQrCodeChallengeDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Deprecated
   @Operation(
      description = "> [!caution]\n> This endpoint is deprecated. The challenge is returned as <a href=\"#additionalAuthAttributes\">additional attribute</a> with the <tt>AIRLOCK_2FA_QR_CODE_OTP_REQUIRED</tt>\nor <tt>AIRLOCK_2FA_PASSCODE_OR_QR_CODE_OTP_REQUIRED</tt> next step codes.\n<p>Retrieves the challenge for an Offline QR Code Airlock 2FA authentication.</p>\n<div class=\"iam-resource-return\">The Offline QR Code challenge.</div>",
      tags = "Airlock 2FA",
      summary = "Get challenge"
   )
   @POST
   @Path("/offline-qr-code/challenge/retrieve")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response retrieveOfflineQrCodeChallenge() {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get()).retrieveOfflineQrCodeChallenge();
      return this.mapper.toResponseWithData(result, Airlock2FAOfflineQrCodeChallengeData.class);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Authentication successful or further steps required.",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "400",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>AIRLOCK_2FA_QR_CODE_OTP_WRONG</td>\n<td>OTP could not be validated successfully. Retry with correct OTP.</td>\n</tr>\n</table>\n</div>\n<br>Possible next step: <tt>AIRLOCK_2FA_QR_CODE_OTP_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>)\n<br>\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>AIRLOCK_2FA_QR_CODE_OTP_WRONG</td>\n<td>The OTP could not be validated successfully and no retries are allowed.</td>\n</tr>\n</table>\n</div>\n<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Operation(
      description = "Verifies the submitted Airlock 2FA Offline QR Code OTP (challenge response).\nNote that Offline QR Code checks are only possible if the step is in offline mode (using <tt>POST /public/authentication/airlock-2fa/offline/</tt>).\n<div class=\"iam-resource-return\">Whether the check was successful. If the attribute <tt>nextAuthStep</tt> is present in the response,\n further steps are required to successfully authenticate. If the attribute is missing, the user is\n successfully authenticated.</div>",
      tags = "Airlock 2FA",
      summary = "Verify Offline QR Code OTP"
   )
   @POST
   @Path("/offline-qr-code/otp/check")
   @Consumes("application/json")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response checkOfflineQrCodeOtp(
      @Parameter(description = "Contains the Offline QR Code OTP.") @NotNull @Valid Airlock2FAOfflineQrCodeCheckRequest request
   ) {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get())
         .checkOfflineQrCodeOtp(Airlock2FAOtp.airlock2FAOtp(request.getOtp()));
      return this.mapper.toResponse(result);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "The challenge has been successfully issued.\n<br>Possible next step: <tt>AIRLOCK_2FA_POLLING_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>)\n",
               content = {
                     @Content(
                        mediaType = "application/vnd.api+json",
                        schema = @Schema(implementation = Airlock2FAMobileOnlyChallengeDataResourceDocument.class)
                     ),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = Airlock2FAMobileOnlyChallengeDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Deprecated
   @Operation(
      description = "> [!caution]\n> This endpoint is deprecated. The mobile authentication URI is returned as <a href=\"#additionalAuthAttributes\">additional attribute</a> with the\n<tt><s>AIRLOCK_2FA_MOBILE_ONLY_CHALLENGE_RETRIEVAL_REQUIRED</s></tt> or <tt>AIRLOCK_2FA_POLLING_REQUIRED</tt> next step codes.\n<p>Retrieves the challenge for a mobile-only Airlock 2FA authentication.</p>\n<div class=\"iam-resource-return\">A challenge in the form of a URI.</div>",
      tags = "Airlock 2FA",
      summary = "Get mobile challenge"
   )
   @POST
   @Path("/mobile-only/challenge/retrieve")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response retrieveMobileOnlyChallenge() {
      FlowResult result = ((Airlock2FAMobileOnlyAuthentication)this.mobileFactorAuthentication.get()).retrieveChallenge();
      return this.mapper.toResponseWithData(result, Airlock2FAMobileOnlyChallengeData.class);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Authentication successful or further steps required.\n<br>Possible next steps: <tt>AIRLOCK_2FA_PASSCODE_REQUIRED</tt>, <tt>AIRLOCK_2FA_QR_CODE_OTP_REQUIRED</tt>, <tt>AIRLOCK_2FA_PASSCODE_OR_QR_CODE_OTP_REQUIRED</tt> (as documented <a\nhref=\"#nextAuthStepCodes\">here</a>)\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "The current authentication flow has been aborted. May happen if an unprocessed result from the\nonline session is available upon calling this endpoint.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Operation(
      description = "Switches to the Airlock 2FA offline mode.\nIn this mode, only passcode and QR code checks can be performed.\n<div class=\"iam-resource-return\">If the attribute <tt>nextAuthStep</tt> is present in the response,\n further steps are required to successfully authenticate. If the attribute is missing, the user is\n successfully authenticated.</div>",
      tags = "Airlock 2FA",
      summary = "Switch to offline"
   )
   @POST
   @Path("/offline")
   @Consumes("application/json")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response switchToOffline() {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get()).switchToOffline();
      return this.mapper.toResponse(result);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Authentication successful or further steps required, such as further polling.\n<br>Possible next steps: <tt>AIRLOCK_2FA_POLLING_REQUIRED</tt>, <tt>AIRLOCK_2FA_POLLING_OR_OFFLINE_REQUIRED</tt>, <tt>AIRLOCK_2FA_USERNAMELESS_POLLING_REQUIRED</tt>\n(as documented <a href=\"#nextAuthStepCodes\">here</a>).\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "Authentication failed.\n<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Operation(
      description = "Polls the Airlock 2FA authentication status.\n<p>This endpoint is used for authentication using the Airlock 2FA factors One-Touch and Online QR Code,\nor for mobile-only authentication.</p>\n<div class=\"iam-resource-return\">The status of the Airlock 2FA authentication.\n If the attribute <tt>nextAuthStep</tt> is present in the response, further steps are required to successfully\n authenticate. If the attribute is missing, the user is successfully authenticated.</div>",
      tags = "Airlock 2FA",
      summary = "Poll status"
   )
   @POST
   @Path("/status/poll")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response pollAuthenticationStatus(
      @Parameter(
   description = "Whether the final result should be returned (optional, default <tt>false</tt>). See <a href=\"#pollingEndpoints\">polling endpoints</a> for details."
) @QueryParam("queryOnly") boolean queryOnly
   ) {
      FlowResult result = ((Airlock2FAAuthentication)this.authentication.get()).pollAuthenticationStatus(queryOnly);
      return this.mapper.toResponse(result);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Device list retrieved, device selection required.\n<br>Possible next steps: <tt>AIRLOCK_2FA_DEVICE_CHOICE_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>).\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = Airlock2FADeviceDataCollectionDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = Airlock2FADeviceDataCollectionDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "Authentication failed.\n<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Deprecated
   @Operation(
      description = "> [!caution]\n> This endpoint is deprecated. The device choices are returned as <a href=\"#additionalAuthAttributes\">additional attribute</a>\nwith the <tt>AIRLOCK_2FA_DEVICE_CHOICE_REQUIRED</tt> next step code.\n<p>Retrieves Airlock 2FA devices that can be selected for authentication.</p>\n<div class=\"iam-resource-return\">The list of selectable Airlock 2FA devices.</div>",
      tags = "Airlock 2FA",
      summary = "List devices"
   )
   @POST
   @Path("/devices/retrieve")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response retrieveDeviceChoices() {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get()).listDevices();
      return FlowResultToCollectionDocumentMapper.flowResultDataToCollectionDocumentMapper(this.mapper, this.mapperFacade)
         .map(result, Airlock2FADeviceListData.class, Airlock2FADeviceData.class, obj -> obj.getId().getId());
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Device selection successful. Further steps required, such as polling.\n<br>Possible next steps: <tt>AIRLOCK_2FA_POLLING_REQUIRED</tt>, <tt>AIRLOCK_2FA_POLLING_OR_OFFLINE_REQUIRED</tt> (as documented <a href=\"#nextAuthStepCodes\">here</a>).\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class)),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = AuthenticationFlowResultDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "400",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>AIRLOCK_2FA_DEVICE_CHOICE_FAILED</td>\n<td>The device could not be selected.</td>\n</tr>\n</table>\n</div>\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            ),
            @ApiResponse(
               responseCode = "403",
               description = "Authentication failed.\n<br>The current authentication flow has been aborted.\n<br>Possible next step: none.\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Operation(
      description = "Selects the Airlock 2FA device that will be used for authentication.\n<div class=\"iam-resource-return\">If the selection was successful.</div>",
      tags = "Airlock 2FA",
      summary = "Select device"
   )
   @POST
   @Path("/devices/{deviceId}/select")
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   public Response selectDevice(@Parameter(description = "The ID of the device to be selected.") @PathParam("deviceId") String deviceId) {
      FlowResult result = ((Airlock2FAAuthenticationDeviceSelection)this.deviceSelection.get()).selectDevice(Airlock2FADeviceId.airlock2FADeviceId(deviceId));
      return this.mapper.toResponse(result);
   }

   @ApiResponses(
      {
            @ApiResponse(
               responseCode = "200",
               description = "Information whether One-Touch is enabled.",
               content = {
                     @Content(
                        mediaType = "application/vnd.api+json",
                        schema = @Schema(implementation = Airlock2FAZeroTouchInformationDataResourceDocument.class)
                     ),
                     @Content(mediaType = "application/json", schema = @Schema(implementation = Airlock2FAZeroTouchInformationDataResourceDocument.class))
               }
            ),
            @ApiResponse(
               responseCode = "400",
               description = "<div class=\"iam-error-code\"><table>\n<tr>\n<td>UNEXPECTED_CALL</td>\n<td>If One-Touch is not enabled.</td>\n</tr>\n</table>\n</div>\n",
               content = {
                     @Content(mediaType = "application/vnd.api+json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse")),
                     @Content(mediaType = "application/json", schema = @Schema(ref = "json-api.yaml#/components/schemas/ErrorDocumentResponse"))
               }
            )
      }
   )
   @Deprecated
   @Operation(
      description = "> [!caution]\n> This endpoint is deprecated. The login ID is returned as <a href=\"#additionalAuthAttributes\">additional attribute</a> with the <tt>AIRLOCK_2FA_POLLING_REQUIRED</tt>\nor <tt>AIRLOCK_2FA_POLLING_OR_OFFLINE_REQUIRED</tt> next step codes.\n<p>Retrieves information (including the login ID), if One-Touch (or previously Zero-Touch) is enabled.\nNote that this endpoint returns an error and aborts the flow if One-Touch is not enabled or the\nselected device does not have the capabilities required for One-Touch.</p>\n<div class=\"iam-resource-return\">Whether One-Touch is enabled, including the login ID.</div>",
      tags = "Airlock 2FA",
      summary = "Get Login-ID"
   )
   @POST
   @Produces({"application/vnd.api+json", "application/json;qs=0.9"})
   @Path("/zero-touch-info/retrieve")
   public Response retrieveZeroTouchInformation() {
      FlowResult result = ((Airlock2FAUserFactorAuthentication)this.userFactorAuthentication.get()).retrieveZeroTouchInformation();
      return this.mapper.toResponseWithData(result, Airlock2FAZeroTouchInformationData.class);
   }
}
