org.eclipse.microprofile.openapi.annotations.security.SecurityRequirementsSet Maven / Gradle / Ivy
/**
* Copyright 2017 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.openapi.annotations.security;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
/**
* This annotation represents a set of security requirements which permit access to an operation if all of them are
* satisfied.
*
* If this annotation is applied to a method which corresponds to an operation, then the requirements will be added to
* that operation.
*
* If this annotation is applied to a class which contains methods which correspond to operations, then the requirements
* will be added to all operations corresponding to methods within that class which don't specify any other
* requirements.
*
* Security requirements can be specified for the whole API using {@link OpenAPIDefinition#securitySets()}. Security
* requirements specified for individual operations override those specified for the whole API.
*
* If multiple security requirement sets are specified for an operation, then a user must satisfy all of the
* requirements within any one of the sets to access the operation.
*
* An empty security requirement set indicates that authentication is not required.
*
* A {@code SecurityRequirementSet} annotation corresponds to a map of security requirements in an OpenAPI document.
*
*
* Example:
* security:
* - api_secret: []
* oauth_implicit: []
*
*
* @see OpenAPI Specification Security
* Requirement Object
**/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(SecurityRequirementsSets.class)
@Inherited
public @interface SecurityRequirementsSet {
/**
* The security requirements which make up the set
*
* @return the array of the SecurityRequirement annotations, may be empty
**/
SecurityRequirement[] value() default {};
}