package com.airlock.iam.login.app.misc.oneshot.impl;

import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;

@Plugin(displayName = "HTTP Signature Audit Logger", description = "Audit logging of HTTP Signature verification.")
public final class HttpSignatureAuditLoggerConfig {
   static final String LOGGER_NAME_PROPERTY_DISPLAYNAME = "Logger Name";
   @StringProperty(
      description = "<p>This property can be used to redirect the logs to a specific Log4J Logger. In the Log4J configuration this name can be used as follows:</p><pre><code>&lt;Logger name=&quot;<i>ConfiguredLoggerName</i>&quot; level=&quot;INFO&quot; additivity=&quot;false&quot;&gt;\n&#x9;&lt;AppenderRef ref=&quot;SECURED-LOG-DESTINATION&quot;/&gt;\n&lt;/Logger&gt;\n</code></pre><p><code>additivity=&quot;false&quot;</code> is used to filter messages from going to other appenders via the <code>&lt;Root&gt;</code> logger. <p>Please refer to the customer documentation for details on logging configuration.</p>",
      displayName = "Logger Name",
      optional = true
   )
   private String loggerName;

   public Optional<String> loggerName() {
      return Optional.ofNullable(this.loggerName).filter(StringUtils::isNotBlank);
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public HttpSignatureAuditLoggerConfig(String loggerName) {
      this.loggerName = loggerName;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class HttpSignatureAuditLoggerConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String loggerName;

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

      @SuppressFBWarnings(justification = "generated code")
      public HttpSignatureAuditLoggerConfig.HttpSignatureAuditLoggerConfigBuilder loggerName(String loggerName) {
         this.loggerName = loggerName;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "HttpSignatureAuditLoggerConfig.HttpSignatureAuditLoggerConfigBuilder(loggerName=" + this.loggerName + ")";
      }
   }
}
