Class SecuritySchemeInfo

java.lang.Object
org.apache.juneau.bean.openapi3.OpenApiElement
org.apache.juneau.bean.openapi3.SecuritySchemeInfo

public class SecuritySchemeInfo extends OpenApiElement
Defines a security scheme that can be used by the operations.

The Security Scheme Object defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header or as a query parameter), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in RFC6749, and OpenID Connect Discovery.

OpenAPI Specification:

The Security Scheme Object is composed of the following fields:

  • type (string, REQUIRED) - The type of the security scheme. Values: "apiKey", "http", "oauth2", "openIdConnect"
  • description (string) - A short description for security scheme (CommonMark syntax may be used)
  • name (string) - The name of the header, query or cookie parameter to be used (for "apiKey" type)
  • in (string) - The location of the API key (for "apiKey" type). Values: "query", "header", "cookie"
  • scheme (string) - The name of the HTTP Authorization scheme to be used in the Authorization header (for "http" type)
  • bearerFormat (string) - A hint to the client to identify how the bearer token is formatted (for "http" type with "bearer" scheme)
  • flows (OAuthFlows) - An object containing configuration information for the flow types supported (for "oauth2" type)
  • openIdConnectUrl (string) - OpenId Connect URL to discover OAuth2 configuration values (for "openIdConnect" type)
Example:

// Create an API key security scheme SecuritySchemeInfo scheme = new SecuritySchemeInfo() .setType("apiKey") .setDescription("API key authentication") .setName("X-API-Key") .setIn("header");

// Create an OAuth2 security scheme SecuritySchemeInfo oauthScheme = new SecuritySchemeInfo() .setType("oauth2") .setDescription("OAuth2 authentication") .setFlows( new OAuthFlows() .setAuthorizationCode( new OAuthFlow() .setAuthorizationUrl("https://example.com/oauth/authorize") .setTokenUrl("https://example.com/oauth/token") .setScopes( JsonMap.of( "read", "Read access to resources", "write", "Write access to resources" ) ) ) );

See Also:
  • Constructor Details

  • Method Details

    • copy

      Make a deep copy of this object.
      Returns:
      A deep copy of this object.
    • get

      public <T> T get(String property, Class<T> type)
      Description copied from class: OpenApiElement
      Generic property getter.

      Can be used to retrieve non-standard Swagger fields such as "$ref".

      Overrides:
      get in class OpenApiElement
      Type Parameters:
      T - The datatype to cast the value to.
      Parameters:
      property - The property name to retrieve.
      type - The datatype to cast the value to.
      Returns:
      The property value, or null if the property does not exist or is not set.
    • getBearerFormat

      Bean property getter: bearerFormat.

      A hint to the client to identify how the bearer token is formatted.

      Returns:
      The property value, or null if it is not set.
    • getDescription

      Bean property getter: description.

      A short description for the security scheme.

      Returns:
      The property value, or null if it is not set.
    • getFlows

      public OAuthFlow getFlows()
      Bean property getter: flows.

      An object containing configuration information for the flow types supported.

      Returns:
      The property value, or null if it is not set.
    • getIn

      public String getIn()
      Bean property getter: in.

      The location of the API key.

      Returns:
      The property value, or null if it is not set.
    • getName

      public String getName()
      Bean property getter: name.

      The name of the header, query or cookie parameter to be used.

      Returns:
      The property value, or null if it is not set.
    • getOpenIdConnectUrl

      Bean property getter: openIdConnectUrl.

      OpenId Connect URL to discover OAuth2 configuration values.

      Returns:
      The property value, or null if it is not set.
    • getScheme

      public String getScheme()
      Bean property getter: scheme.

      The name of the HTTP Authorization scheme to be used in the Authorization header.

      Returns:
      The property value, or null if it is not set.
    • getType

      public String getType()
      Bean property getter: type.

      The type of the security scheme.

      Returns:
      The property value, or null if it is not set.
    • keySet

      public Set<String> keySet()
      Description copied from class: OpenApiElement
      Returns all the keys on this element.
      Overrides:
      keySet in class OpenApiElement
      Returns:
      All the keys on this element.
      Never null.
    • set

      public SecuritySchemeInfo set(String property, Object value)
      Description copied from class: OpenApiElement
      Generic property setter.

      Can be used to set non-standard Swagger fields such as "$ref".

      Overrides:
      set in class OpenApiElement
      Parameters:
      property - The property name to set. Must not be null, or an IllegalArgumentException is thrown.
      value - The new value for the property.
      Returns:
      This object
    • setBearerFormat

      Bean property setter: bearerFormat.

      A hint to the client to identify how the bearer token is formatted.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setDescription

      Bean property setter: description.

      A short description for the security scheme.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setFlows

      Bean property setter: flows.

      An object containing configuration information for the flow types supported.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setIn

      Bean property setter: in.

      The location of the API key.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "query"
      • "header"
      • "cookie"

      Can be null to unset the property.
      Returns:
      This object
    • setName

      Bean property setter: name.

      The name of the header, query or cookie parameter to be used.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setOpenIdConnectUrl

      Bean property setter: openIdConnectUrl.

      OpenId Connect URL to discover OAuth2 configuration values.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setScheme

      Bean property setter: scheme.

      The name of the HTTP Authorization scheme to be used in the Authorization header.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object
    • setType

      Bean property setter: type.

      The type of the security scheme.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "apiKey"
      • "http"
      • "oauth2"
      • "openIdConnect"

      Can be null to unset the property.
      Returns:
      This object
    • strict

      Description copied from class: OpenApiElement
      Sets strict mode on this bean.
      Overrides:
      strict in class OpenApiElement
      Parameters:
      value - The new value for this property.
      Non-boolean values will be converted to boolean using Boolean.valueOf(value.toString()).
      Can be null (interpreted as false).
      Returns:
      This object
    • strict

      Description copied from class: OpenApiElement
      Sets strict mode on this bean.
      Overrides:
      strict in class OpenApiElement
      Returns:
      This object