package com.airlock.iam.factor.domain.service.airlock2fa;

import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAAuthenticationException;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FADevices;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAFactorSet;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAPreAuthenticationData;
import com.airlock.iam.factor.domain.model.airlock2fa.UserStatus;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;

public interface Airlock2FAPreAuthenticationService {
   Airlock2FAPreAuthenticationService.PreAuthenticationAnswer preAuthenticate(Airlock2FAPreAuthenticationData var1) throws Airlock2FAAuthenticationException;

   final class PreAuthenticationAnswer {
      private final Airlock2FAFactorSet allowedFactors;
      private final Airlock2FAPreAuthenticationService.PreAuthenticationResult result;
      private final Optional<UserStatus> userStatus;
      private final Airlock2FADevices devices;

      public boolean isAuthenticationAllowed() {
         return this.result.isAuthenticationAllowed();
      }

      @SuppressFBWarnings(justification = "generated code")
      public PreAuthenticationAnswer(
         Airlock2FAFactorSet allowedFactors,
         Airlock2FAPreAuthenticationService.PreAuthenticationResult result,
         Optional<UserStatus> userStatus,
         Airlock2FADevices devices
      ) {
         this.allowedFactors = allowedFactors;
         this.result = result;
         this.userStatus = userStatus;
         this.devices = devices;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAFactorSet getAllowedFactors() {
         return this.allowedFactors;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FAPreAuthenticationService.PreAuthenticationResult getResult() {
         return this.result;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Optional<UserStatus> getUserStatus() {
         return this.userStatus;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Airlock2FADevices getDevices() {
         return this.devices;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public boolean equals(Object o) {
         if (o == this) {
            return true;
         } else if (!(o instanceof Airlock2FAPreAuthenticationService.PreAuthenticationAnswer other)) {
            return false;
         } else {
            Object this$allowedFactors = this.allowedFactors;
            Object other$allowedFactors = other.allowedFactors;
            if (this$allowedFactors == null ? other$allowedFactors == null : this$allowedFactors.equals(other$allowedFactors)) {
               Object this$result = this.result;
               Object other$result = other.result;
               if (this$result == null ? other$result == null : this$result.equals(other$result)) {
                  Object this$userStatus = this.userStatus;
                  Object other$userStatus = other.userStatus;
                  if (this$userStatus == null ? other$userStatus == null : this$userStatus.equals(other$userStatus)) {
                     Object this$devices = this.devices;
                     Object other$devices = other.devices;
                     return this$devices == null ? other$devices == null : this$devices.equals(other$devices);
                  } else {
                     return false;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         }
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public int hashCode() {
         int PRIME = 59;
         int result = 1;
         Object $allowedFactors = this.allowedFactors;
         result = result * 59 + ($allowedFactors == null ? 43 : $allowedFactors.hashCode());
         Object $result = this.result;
         result = result * 59 + ($result == null ? 43 : $result.hashCode());
         Object $userStatus = this.userStatus;
         result = result * 59 + ($userStatus == null ? 43 : $userStatus.hashCode());
         Object $devices = this.devices;
         return result * 59 + ($devices == null ? 43 : $devices.hashCode());
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Airlock2FAPreAuthenticationService.PreAuthenticationAnswer(allowedFactors="
            + this.getAllowedFactors()
            + ", result="
            + this.getResult()
            + ", userStatus="
            + this.getUserStatus()
            + ", devices="
            + this.getDevices()
            + ")";
      }
   }

   enum PreAuthenticationResult {
      AUTH("auth", true),
      ALLOW("allow", false),
      DENY("deny", false),
      UNKNOWN("unknown", false);

      private final String value;
      private final boolean authenticationAllowed;

      @SuppressFBWarnings(justification = "generated code")
      PreAuthenticationResult(final String value, final boolean authenticationAllowed) {
         this.value = value;
         this.authenticationAllowed = authenticationAllowed;
      }

      @SuppressFBWarnings(justification = "generated code")
      public String getValue() {
         return this.value;
      }

      @SuppressFBWarnings(justification = "generated code")
      public boolean isAuthenticationAllowed() {
         return this.authenticationAllowed;
      }
   }
}
