package com.airlock.iam.authentication.application.configuration.idpropagation;

import com.airlock.iam.authentication.api.application.configuration.idpropagation.ResponseAdderConfig;
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;

@Plugin(
   description = "<p>Appends the ticket string as a query parameter to the URL to which the Loginapp UI redirects the user upon\nsuccessful completion of an authentication flow.</p>\n<p>Multiple 'Forward Location Parameter Adder' can be configured, all will be evaluated by the Loginapp UI.</p>\n<p>This plugin only works in combination with the IAM Loginapp UI.</p>",
   displayName = "Forward Location Parameter Adder"
)
public final class ForwardLocationParameterAdderConfig implements ResponseAdderConfig {
   public static final String LOGINAPP_UI_FORWARD_LOCATION_PARAMETER_HEADER = "X-SSO";
   @StringProperty(
      description = "Name of the query parameter that is added to the URL to which the IAM Loginapp UI forwards the user upon\nsuccessful completion of an authentication flow. The value of the query parameter is the ticket string.",
      defaultValue = "sso",
      exampleValues = {"sso", "ticket"},
      optional = true
   )
   private String ticketParameterName;

   public String getTicketParameterName() {
      return this.ticketParameterName;
   }

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public ForwardLocationParameterAdderConfig.ForwardLocationParameterAdderConfigBuilder ticketParameterName(String ticketParameterName) {
         this.ticketParameterName = ticketParameterName;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "ForwardLocationParameterAdderConfig.ForwardLocationParameterAdderConfigBuilder(ticketParameterName=" + this.ticketParameterName + ")";
      }
   }
}
