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.
    • strict

      Description copied from class: OpenApiElement
      Sets strict mode on this bean.
      Overrides:
      strict in class OpenApiElement
      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
    • getName

      public String getName()
      Bean property getter: name.

      The name of the parameter.

      Notes:
      • Parameter names are case sensitive.
      • If in is "path", the name field MUST correspond to the associated path segment from the path field in the paths object.
      • For all other cases, the name corresponds to the parameter name used based on the in property.
      Returns:
      The property value, or null if it is not set.
    • setName

      Bean property setter: name.

      The name of the parameter.

      Notes:
      • Parameter names are case sensitive.
      • If in is "path", the name field MUST correspond to the associated path segment from the path field in the paths object.
      • For all other cases, the name corresponds to the parameter name used based on the in property.
      Parameters:
      value - The new value for this property.
      Property value is required.
      Can be null to unset the property.
      Returns:
      This object
    • getIn

      public String getIn()
      Bean property getter: in.

      The location of the parameter.

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

      Bean property setter: in.

      The location of the parameter.

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

      Property value is required.
      Can be null to unset the property.
      Returns:
      This object
    • getDescription

      Bean property getter: description.

      A brief description of the parameter.
      This could contain examples of use.

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

      Bean property setter: description.

      A brief description of the parameter.
      This could contain examples of use.

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

      public String getScheme()
      Bean property getter: schema.

      The schema defining the type used for the body parameter.

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

      Bean property setter: schema.

      The schema defining the type used for the body parameter.

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

      public String getType()
      Bean property getter: type.

      The type of the parameter.

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

      Bean property setter: type.

      The type of the parameter.

      Parameters:
      value - The new value for this property.
      Valid values:
      • "string"
      • "number"
      • "integer"
      • "boolean"
      • "array"
      • "file"

      If type is "file", the consumes MUST be either "multipart/form-data", "application/x-www-form-urlencoded" or both and the parameter MUST be in "formData".
      Property value is required.
      Can be null to unset the property.
      Returns:
      This object
    • getBearerFormat

      Bean property getter: format.

      The extending format for the previously mentioned type.

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

      Bean property setter: format.

      The extending format for the previously mentioned type.

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

      public OAuthFlow getFlows()
      Bean property getter: items.

      Describes the type of items in the array.

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

      Bean property setter: items.

      Describes the type of items in the array.

      Parameters:
      value - The new value for this property.
      Property value is required if type is "array".
      Can be null to unset the property.
      Returns:
      This object
    • getOpenIdConnectUrl

      Bean property getter: collectionFormat.

      Determines the format of the array if type array is used.

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

      Bean property setter: collectionFormat.

      Determines the format of the array if type array is used.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      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.
    • 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.
      value - The new value for the property.
      Returns:
      This object
    • 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.