use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project Payara by payara.
the class SecurityRequirementImpl method createInstance.
public static SecurityRequirement createInstance(AnnotationModel annotation, ApiContext context) {
SecurityRequirement from = new SecurityRequirementImpl();
String name = annotation.getValue("name", String.class);
List<String> scopes = annotation.getValue("scopes", List.class);
from.addScheme(name, scopes != null ? scopes : Collections.emptyList());
return from;
}
use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.
the class OpenApiSerializer method writeSecurityRequirements.
/**
* Writes a list of {@link SecurityRequirement} to the JSON tree.
* @param parent
* @param models
*/
private void writeSecurityRequirements(ObjectNode parent, List<SecurityRequirement> models) {
if (models == null) {
return;
}
ArrayNode node = parent.putArray(OpenApiConstants.PROP_SECURITY);
for (SecurityRequirement securityRequirement : models) {
ObjectNode secNode = node.addObject();
writeSecurityRequirementToNode(secNode, securityRequirement);
}
}
use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readSecurity.
/**
* Reads any SecurityRequirement annotations. The annotation value is an array of
* SecurityRequirement annotations.
* @param value
*/
private List<SecurityRequirement> readSecurity(AnnotationValue securityRequirementAnnos) {
if (securityRequirementAnnos == null) {
return null;
}
LOG.debug("Processing an array of @SecurityRequirement annotations.");
AnnotationInstance[] nestedArray = securityRequirementAnnos.asNestedArray();
List<SecurityRequirement> requirements = new ArrayList<>();
for (AnnotationInstance requirementAnno : nestedArray) {
SecurityRequirement requirement = readSecurityRequirement(requirementAnno);
if (requirement != null) {
requirements.add(requirement);
}
}
return requirements;
}
use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readSecurityRequirement.
/**
* Reads a single SecurityRequirement annotation.
* @param annotation
*/
private SecurityRequirement readSecurityRequirement(AnnotationInstance annotation) {
String name = JandexUtil.stringValue(annotation, OpenApiConstants.PROP_NAME);
if (name != null) {
List<String> scopes = JandexUtil.stringListValue(annotation, OpenApiConstants.PROP_SCOPES);
SecurityRequirement requirement = new SecurityRequirementImpl();
if (scopes == null) {
requirement.addScheme(name);
} else {
requirement.addScheme(name, scopes);
}
return requirement;
}
return null;
}
use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.
the class FilterUtil method filterSecurity.
/**
* Filters the given model.
* @param filter
* @param models
*/
private static void filterSecurity(OASFilter filter, List<SecurityRequirement> models) {
if (models == null) {
return;
}
ListIterator<SecurityRequirement> iterator = models.listIterator();
while (iterator.hasNext()) {
SecurityRequirement model = iterator.next();
filterSecurityRequirement(filter, model);
}
}
Aggregations