package com.airlock.iam.oauth2.domain.model.consent;

import com.airlock.iam.common.api.domain.model.role.Role;
import com.airlock.iam.common.domain.service.jwt.encryption.JwtTicketDecrypter;
import com.airlock.iam.common.domain.service.jwt.encryption.JwtTicketEncrypter;
import com.airlock.iam.common.domain.service.jwt.signature.JwtSignatureVerifier;
import com.airlock.iam.common.domain.service.jwt.signature.JwtSigner;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.time.Duration;
import java.util.Optional;

public final class OAuth2RemoteConsentSettings implements OAuth2ConsentSettings {
   private final URI remoteConsentUri;
   private final JwtSigner signer;
   private final JwtTicketEncrypter encrypter;
   private final Duration validity;
   private final URI callbackUri;
   private final JwtSignatureVerifier verifier;
   private final JwtTicketDecrypter decrypter;
   private final Optional<Role> wafCredential;

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

   @SuppressFBWarnings(justification = "generated code")
   private OAuth2RemoteConsentSettings(
      URI remoteConsentUri,
      JwtSigner signer,
      JwtTicketEncrypter encrypter,
      Duration validity,
      URI callbackUri,
      JwtSignatureVerifier verifier,
      JwtTicketDecrypter decrypter,
      Optional<Role> wafCredential
   ) {
      this.remoteConsentUri = remoteConsentUri;
      this.signer = signer;
      this.encrypter = encrypter;
      this.validity = validity;
      this.callbackUri = callbackUri;
      this.verifier = verifier;
      this.decrypter = decrypter;
      this.wafCredential = wafCredential;
   }

   @SuppressFBWarnings(justification = "generated code")
   public URI remoteConsentUri() {
      return this.remoteConsentUri;
   }

   @SuppressFBWarnings(justification = "generated code")
   public JwtSigner signer() {
      return this.signer;
   }

   @SuppressFBWarnings(justification = "generated code")
   public JwtTicketEncrypter encrypter() {
      return this.encrypter;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Duration validity() {
      return this.validity;
   }

   @SuppressFBWarnings(justification = "generated code")
   public URI callbackUri() {
      return this.callbackUri;
   }

   @SuppressFBWarnings(justification = "generated code")
   public JwtSignatureVerifier verifier() {
      return this.verifier;
   }

   @SuppressFBWarnings(justification = "generated code")
   public JwtTicketDecrypter decrypter() {
      return this.decrypter;
   }

   @SuppressFBWarnings(justification = "generated code")
   public Optional<Role> wafCredential() {
      return this.wafCredential;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2RemoteConsentSettingsBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private URI remoteConsentUri;
      @SuppressFBWarnings(justification = "generated code")
      private JwtSigner signer;
      @SuppressFBWarnings(justification = "generated code")
      private JwtTicketEncrypter encrypter;
      @SuppressFBWarnings(justification = "generated code")
      private Duration validity;
      @SuppressFBWarnings(justification = "generated code")
      private URI callbackUri;
      @SuppressFBWarnings(justification = "generated code")
      private JwtSignatureVerifier verifier;
      @SuppressFBWarnings(justification = "generated code")
      private JwtTicketDecrypter decrypter;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Role> wafCredential;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder remoteConsentUri(URI remoteConsentUri) {
         this.remoteConsentUri = remoteConsentUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder signer(JwtSigner signer) {
         this.signer = signer;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder encrypter(JwtTicketEncrypter encrypter) {
         this.encrypter = encrypter;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder validity(Duration validity) {
         this.validity = validity;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder callbackUri(URI callbackUri) {
         this.callbackUri = callbackUri;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder verifier(JwtSignatureVerifier verifier) {
         this.verifier = verifier;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder decrypter(JwtTicketDecrypter decrypter) {
         this.decrypter = decrypter;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder wafCredential(Optional<Role> wafCredential) {
         this.wafCredential = wafCredential;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2RemoteConsentSettings build() {
         return new OAuth2RemoteConsentSettings(
            this.remoteConsentUri, this.signer, this.encrypter, this.validity, this.callbackUri, this.verifier, this.decrypter, this.wafCredential
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2RemoteConsentSettings.OAuth2RemoteConsentSettingsBuilder(remoteConsentUri="
            + this.remoteConsentUri
            + ", signer="
            + this.signer
            + ", encrypter="
            + this.encrypter
            + ", validity="
            + this.validity
            + ", callbackUri="
            + this.callbackUri
            + ", verifier="
            + this.verifier
            + ", decrypter="
            + this.decrypter
            + ", wafCredential="
            + this.wafCredential
            + ")";
      }
   }
}
