package com.airlock.iam.flow.shared.application.configuration.airlock2fa;

import com.airlock.iam.factor.application.configuration.airlock2fa.Airlock2FASettings;
import com.airlock.iam.flow.api.application.configuration.valueprovider.ValueMapProviderConfig;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.license.PluginLicenseRestriction;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(
   description = "<p>Provides Airlock 2FA authentication information regarding the Auth Token ID device, as well as cooldown information of the authentication device.</p><p>The provided Auth Token ID information concerns the device from the Auth Token ID and is available as soon as the user has used or activated an Airlock 2FA device as a second factor for authentication in this session. Currently, the following values are provided:</p><ul><li><b>a2fa-auth-token-device-id</b>: This key provides the device ID of the Airlock 2FA device.</li><li><b>a2fa-auth-token-device-type</b>: This key provides the device type of the Airlock 2FA device. It can have the following values: <ul><li><b>ios</b></li><li><b>android</b></li><li><b>hardware</b></li></ul></li><li><b>a2fa-auth-token-device-display-name</b>: This key provides the display name of the Airlock 2FA device.</li><li><b>a2fa-auth-token-device-enrollment-timestamp</b>: Timestamp (as date-time object) of the point in time when the Airlock 2FA device was enrolled. This value can be used by template-based providers to format the timestamp into a specific date format.</li></ul><p>The cooldown information concerns the device that was used for authentication and is available as soon as the user has successfully used an Airlock 2FA device for authentication in this session. Unlike the Auth Token ID, which is also updated after registering a new device, the values provided here only concern the device used for the actual authentication. Currently, the following values are provided:</p><ul><li><b>a2fa-cooldown-auth-device</b>: This key reports whether or not the Airlock 2FA device used during authentication is in cooldown. This key can have the following values: <ul><li><b>cooldown</b>: the device is in cooldown</li><li><b>active</b>: the device is fully active</li></ul></li><li><b>a2fa-cooldown-ends</b>: Timestamp (as date-time object) of the point in time when cooldown will end for the Airlock 2FA device that was used during authentication. If the Airlock 2FA device used for authentication is <b>active</b> (not in cooldown), this key is not supplied. This value can be used by template-based providers to format the timestamp into a specific date format.</li></ul><p>The following key is always provided and reports what type of devices the user has in the account:</p><ul><li><b>a2fa-cooldown-devices</b>: This key can have the following values: <ul><li><b>has_active</b>: at least one active Airlock 2FA device is available</li><li><b>all_cooldown</b>: only Airlock 2FA devices in cooldown are available</li><li><b>none</b>: no Airlock 2FA devices are available</li></ul></li></ul></p>",
   displayName = "Airlock 2FA Authentication Data Map"
)
@PluginLicenseRestriction(moduleAffiliation = "Airlock2FA")
public class Airlock2FAAuthenticationDataValueMapProviderConfig implements ValueMapProviderConfig {
   public static final String AIRLOCK_2FA_AUTH_TOKEN_DEVICE_ID = "a2fa-auth-token-device-id";
   public static final String AIRLOCK_2FA_AUTH_TOKEN_DEVICE_TYPE = "a2fa-auth-token-device-type";
   public static final String AIRLOCK_2FA_AUTH_TOKEN_DEVICE_DISPLAY_NAME = "a2fa-auth-token-device-display-name";
   public static final String AIRLOCK_2FA_AUTH_TOKEN_DEVICE_ENROLLMENT_TIMESTAMP = "a2fa-auth-token-device-enrollment-timestamp";
   public static final String AIRLOCK_2FA_COOLDOWN_AUTH_DEVICE = "a2fa-cooldown-auth-device";
   public static final String AIRLOCK_2FA_COOLDOWN_ENDS = "a2fa-cooldown-ends";
   public static final String AIRLOCK_2FA_COOLDOWN_DEVICES = "a2fa-cooldown-devices";
   @PluginProperty(
      displayName = "Airlock 2FA Settings",
      description = "Settings of Airlock 2FA. It is recommended to use the same settings everywhere. Otherwise, the values provided by this data map can seem inconsistent.",
      optional = false,
      globalPluginReference = "globalAirlock2FASettings"
   )
   private Airlock2FASettings airlock2faSettings;

   public Airlock2FASettings getAirlock2faSettings() {
      return this.airlock2faSettings;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static Airlock2FAAuthenticationDataValueMapProviderConfig.Airlock2FAAuthenticationDataValueMapProviderConfigBuilder builder() {
      return new Airlock2FAAuthenticationDataValueMapProviderConfig.Airlock2FAAuthenticationDataValueMapProviderConfigBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAAuthenticationDataValueMapProviderConfig() {
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAAuthenticationDataValueMapProviderConfig(Airlock2FASettings airlock2faSettings) {
      this.airlock2faSettings = airlock2faSettings;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class Airlock2FAAuthenticationDataValueMapProviderConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Airlock2FASettings airlock2faSettings;

      @SuppressFBWarnings(justification = "generated code")
      Airlock2FAAuthenticationDataValueMapProviderConfigBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationDataValueMapProviderConfig.Airlock2FAAuthenticationDataValueMapProviderConfigBuilder airlock2faSettings(
         Airlock2FASettings airlock2faSettings
      ) {
         this.airlock2faSettings = airlock2faSettings;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAAuthenticationDataValueMapProviderConfig build() {
         return new Airlock2FAAuthenticationDataValueMapProviderConfig(this.airlock2faSettings);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Airlock2FAAuthenticationDataValueMapProviderConfig.Airlock2FAAuthenticationDataValueMapProviderConfigBuilder(airlock2faSettings="
            + this.airlock2faSettings
            + ")";
      }
   }
}
