package com.airlock.iam.oauth2.application.configuration.clientauthentication;

import com.airlock.iam.oauth2.api.application.configuration.clientauthentication.OAuth2ClientAuthenticationConfig;
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.PluginListProperty;
import com.airlock.iam.security.certificate.CertificateStatusChecker;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;

@Plugin(
   description = "Configures a client authentication that is based on a client certificate which is used in the TLS handshake.<p>The certificate from the TLS handshake is verified with the certificates of the client, which is either configured (static client) or stored in the database.</p><p><b>Note</b>: If a gateway is used, the corresponding Gateway Settings must be configured in the Loginapp.</p>",
   displayName = "OAuth 2.0 Client mTLS Authentication"
)
@PluginLicenseRestriction(moduleAffiliation = "OAuthServer")
public final class OAuth2ClientMTLSAuthenticationConfig implements OAuth2ClientAuthenticationConfig {
   @PluginListProperty(
      description = "A list of certificate status checker plug-ins used to check the revocation status of the client certificate. If more than one status checker plug-ins is configured, all of them are consulted and the certificate is considered to be revoked if at least one of them says so.",
      optional = true
   )
   private List<CertificateStatusChecker> certStatusCheckers;

   public List<CertificateStatusChecker> getCertStatusCheckers() {
      return this.certStatusCheckers;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ClientMTLSAuthenticationConfig(List<CertificateStatusChecker> certStatusCheckers) {
      this.certStatusCheckers = certStatusCheckers;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2ClientMTLSAuthenticationConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private List<CertificateStatusChecker> certStatusCheckers;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientMTLSAuthenticationConfig.OAuth2ClientMTLSAuthenticationConfigBuilder certStatusCheckers(
         List<CertificateStatusChecker> certStatusCheckers
      ) {
         this.certStatusCheckers = certStatusCheckers;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2ClientMTLSAuthenticationConfig.OAuth2ClientMTLSAuthenticationConfigBuilder(certStatusCheckers=" + this.certStatusCheckers + ")";
      }
   }
}
