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

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

@Plugin(
   description = "<p><a target=\"_blank\" href=\"https://tools.ietf.org/html/rfc7662\">RFC 7662</a> Token Introspection endpoint allows authenticated clients to fetch information about Access and Refresh Tokens.</p><p>The endpoint will be available under <tt>/&lt;loginapp-uri&gt;/rest/oauth2/authorization-servers/<i>&lt;as-identifier&gt;</i>/introspect</tt></p>",
   displayName = "OAuth 2.0 Token Introspection Endpoint"
)
@PluginLicenseRestriction(moduleAffiliation = "OAuthServer")
public class OAuth2TokenIntrospectionConfig {
   @PluginProperty(description = "Defines how callers authenticate against this endpoint.", optional = false)
   private BasicAuthTokenIntrospectionAuthenticationConfig authenticationSettings;

   public BasicAuthTokenIntrospectionAuthenticationConfig getAuthenticationSettings() {
      return this.authenticationSettings;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2TokenIntrospectionConfig(BasicAuthTokenIntrospectionAuthenticationConfig authenticationSettings) {
      this.authenticationSettings = authenticationSettings;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2TokenIntrospectionConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private BasicAuthTokenIntrospectionAuthenticationConfig authenticationSettings;

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

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2TokenIntrospectionConfig.OAuth2TokenIntrospectionConfigBuilder authenticationSettings(
         BasicAuthTokenIntrospectionAuthenticationConfig authenticationSettings
      ) {
         this.authenticationSettings = authenticationSettings;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2TokenIntrospectionConfig.OAuth2TokenIntrospectionConfigBuilder(authenticationSettings=" + this.authenticationSettings + ")";
      }
   }
}
