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

import com.airlock.iam.oauth2.application.configuration.tokenexchange.rules.OAuth2TokenExchangeRuleConfig;
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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;

@Plugin(
   description = "<p>Configuration of the token endpoint for token exchange (see <a href=\"https://datatracker.ietf.org/doc/html/rfc8693\" target=\"_blank\">RFC8693</a>).</p><p>The token endpoint supports the grant type \"urn:ietf:params:oauth:grant-type:token-exchange\" and exchanges tokens according to the configuration.</p>",
   displayName = "OAuth 2.0 Token Exchange"
)
@PluginLicenseRestriction(moduleAffiliation = "OAuthTokenExchange")
public final class OAuth2TokenExchangeGrantConfig {
   @PluginListProperty(description = "List of token exchange rules that define the issued token.", optional = false, minElements = 1)
   private List<OAuth2TokenExchangeRuleConfig> tokenExchangeRules;

   public List<OAuth2TokenExchangeRuleConfig> getTokenExchangeRules() {
      return this.tokenExchangeRules;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2TokenExchangeGrantConfig(List<OAuth2TokenExchangeRuleConfig> tokenExchangeRules) {
      this.tokenExchangeRules = tokenExchangeRules;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2TokenExchangeGrantConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private List<OAuth2TokenExchangeRuleConfig> tokenExchangeRules;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2TokenExchangeGrantConfig.OAuth2TokenExchangeGrantConfigBuilder tokenExchangeRules(List<OAuth2TokenExchangeRuleConfig> tokenExchangeRules) {
         this.tokenExchangeRules = tokenExchangeRules;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2TokenExchangeGrantConfig.OAuth2TokenExchangeGrantConfigBuilder(tokenExchangeRules=" + this.tokenExchangeRules + ")";
      }
   }
}
