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

import com.airlock.iam.oauth2.api.application.configuration.provider.scope.OAuth2ScopeConditionConfig;
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 = "Configures the OAuth 2.0 scope handling in the configured OAuth 2.0 Consent Step before presenting them to the user to confirm or implicitly granting them.",
   displayName = "OAuth 2.0 Custom Scopes Flow Settings"
)
@PluginLicenseRestriction(moduleAffiliation = "OAuthServer")
public class OAuth2CustomScopesSettingsConfig implements OAuth2ScopesSettingsConfig {
   @PluginListProperty(
      description = "Restricts the requested scopes. The list will be processed in the configured order. The first fulfilled condition allows the requested scope and no further conditions are evaluated.",
      optional = true
   )
   private List<OAuth2ScopeConditionConfig> conditions;

   public List<OAuth2ScopeConditionConfig> getConditions() {
      return this.conditions;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2CustomScopesSettingsConfig(List<OAuth2ScopeConditionConfig> conditions) {
      this.conditions = conditions;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2CustomScopesSettingsConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private List<OAuth2ScopeConditionConfig> conditions;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2CustomScopesSettingsConfig.OAuth2CustomScopesSettingsConfigBuilder conditions(List<OAuth2ScopeConditionConfig> conditions) {
         this.conditions = conditions;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2CustomScopesSettingsConfig.OAuth2CustomScopesSettingsConfigBuilder(conditions=" + this.conditions + ")";
      }
   }
}
