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

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.BooleanProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(description = "IAM will display a consent page to the user to confirm OAuth 2.0 scopes.", displayName = "OAuth 2.0 Local Consent")
@PluginLicenseRestriction(moduleAffiliation = "OAuthServer")
public final class OAuth2LocalConsentConfig implements OAuth2ConsentConfig {
   @BooleanProperty(
      defaultValue = "false",
      description = "If enabled, consents are stored in the \"Consent Storage Repository\" configured in the Authorization Server\nconfiguration. Otherwise, no consents will be persisted and the user will have to explicitly grant consents\nevery time.",
      optional = true
   )
   private boolean enableConsentStorage;
   public static final String ENABLE_CONSENT_STORAGE_PROPERTY = "enableConsentStorage";

   @Override
   public boolean isEnableConsentStorage() {
      return this.enableConsentStorage;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2LocalConsentConfig(boolean enableConsentStorage) {
      this.enableConsentStorage = enableConsentStorage;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2LocalConsentConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private boolean enableConsentStorage;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2LocalConsentConfig.OAuth2LocalConsentConfigBuilder enableConsentStorage(boolean enableConsentStorage) {
         this.enableConsentStorage = enableConsentStorage;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2LocalConsentConfig.OAuth2LocalConsentConfigBuilder(enableConsentStorage=" + this.enableConsentStorage + ")";
      }
   }
}
