io.swagger.models.Swagger.getSecurity()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中io.swagger.models.Swagger.getSecurity()方法的一些代码示例,展示了Swagger.getSecurity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Swagger.getSecurity()方法的具体详情如下:
包路径:io.swagger.models.Swagger
类名称:Swagger
方法名:getSecurity

Swagger.getSecurity介绍

暂无

代码示例

代码示例来源:origin: com.google.api/api-compiler

@Override
public void addFromSwagger(Service.Builder serviceBuilder, Swagger swagger) {
 if (swagger.getSecurityDefinitions() == null) {
  return;
 }
 TreeSet<String> swaggerSecurityDefNames =
   Sets.newTreeSet(swagger.getSecurityDefinitions().keySet());
 for (String swaggerSecurityDefName : swaggerSecurityDefNames) {
  addAuthProvider(
    serviceBuilder,
    swaggerSecurityDefName,
    swagger.getSecurityDefinitions().get(swaggerSecurityDefName));
 }
 addSecurityRequirementForEntireService(serviceBuilder, swagger.getSecurity());
 addSecurityRequirementExtensionForEntireService(serviceBuilder, swagger);
}

代码示例来源:origin: com.reprezen.genflow/genflow-api

public static void hoist(final Swagger model) {
    List<SecurityRequirement> modelSec = model.getSecurity();
    if (modelSec == null || modelSec.isEmpty()) {
      return; // nothing to hoist
    }
    SwaggerWalker.walk(model, new SwaggerWalker.Callbacks() {
      @Override
      public void operation(HttpMethod httpMethod, Operation operation) {
        if (operation.getSecurity() == null) {
          for (SecurityRequirement secReq : modelSec) {
            Map<String, List<String>> requirements = secReq.getRequirements();
            for (String reqName : requirements.keySet()) {
              operation.addSecurity(reqName, requirements.get(reqName));
            }
          }
        }
      }
    });
  }
}

代码示例来源:origin: googleapis/api-compiler

@Override
public void addFromSwagger(Service.Builder serviceBuilder, Swagger swagger) {
 if (swagger.getSecurityDefinitions() == null) {
  return;
 }
 TreeSet<String> swaggerSecurityDefNames =
   Sets.newTreeSet(swagger.getSecurityDefinitions().keySet());
 for (String swaggerSecurityDefName : swaggerSecurityDefNames) {
  addAuthProvider(
    serviceBuilder,
    swaggerSecurityDefName,
    swagger.getSecurityDefinitions().get(swaggerSecurityDefName));
 }
 addSecurityRequirementForEntireService(serviceBuilder, swagger.getSecurity());
 addSecurityRequirementExtensionForEntireService(serviceBuilder, swagger);
}

代码示例来源:origin: phiz71/vertx-swagger

private static AuthHandler getAuthHandler(SwaggerAuthHandlerFactory authHandlerFactory, Swagger swagger, Operation operation) {
  AuthHandler authHandler = null;
  if(authHandlerFactory != null) {
    if(operation.getSecurity() != null) {
      if(!operation.getSecurity().isEmpty()) {
        authHandler = authHandlerFactory.createAuthHandler(operation.getSecurity());
      }
    } else if(swagger.getSecurity() != null && !swagger.getSecurity().isEmpty()) {
      List<Map<String, List<String>>> security = swagger.getSecurity().stream()
          .map(SecurityRequirement::getRequirements)
          .collect(Collectors.toList());
      authHandler = authHandlerFactory.createAuthHandler(security);
    }
  }
  return authHandler;
}

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

List<SecurityRequirement> securityRequirements = swagger.getSecurity();

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

@Override
public List<String> getGlobalAssignedScopes(String resourceConfigJson) throws APIManagementException {
  SwaggerParser swaggerParser = new SwaggerParser();
  Swagger swagger = swaggerParser.parse(resourceConfigJson);
  String securityName = getOauthSecurityName(swagger);
  Set<String> scopes = new HashSet<>();
  List<SecurityRequirement> securityRequirements = swagger.getSecurity();
  if (securityRequirements != null) {
    for (SecurityRequirement securityRequirement : securityRequirements) {
      Map<String, List<String>> requirementMap = securityRequirement.getRequirements();
      if (requirementMap.containsKey(securityName)) {
        scopes.addAll(requirementMap.get(securityName));
      }
    }
  }
  return new ArrayList<>(scopes);
}

代码示例来源:origin: wso2/carbon-apimgt

List<SecurityRequirement> securityRequirements = swagger.getSecurity();

代码示例来源:origin: wso2/carbon-apimgt

@Override
public List<String> getGlobalAssignedScopes(String resourceConfigJson) throws APIManagementException {
  SwaggerParser swaggerParser = new SwaggerParser();
  Swagger swagger = swaggerParser.parse(resourceConfigJson);
  String securityName = getOauthSecurityName(swagger);
  Set<String> scopes = new HashSet<>();
  List<SecurityRequirement> securityRequirements = swagger.getSecurity();
  if (securityRequirements != null) {
    for (SecurityRequirement securityRequirement : securityRequirements) {
      Map<String, List<String>> requirementMap = securityRequirement.getRequirements();
      if (requirementMap.containsKey(securityName)) {
        scopes.addAll(requirementMap.get(securityName));
      }
    }
  }
  return new ArrayList<>(scopes);
}

代码示例来源:origin: outofcoffee/imposter

produces.addAll(getOrEmpty(spec.getProduces()));
childSchemes.addAll(getOrEmpty(spec.getSchemes()));
security.addAll(getOrEmpty(spec.getSecurity()));
securityDefinitions.putAll(getOrEmpty(spec.getSecurityDefinitions()));
definitions.putAll(getOrEmpty(spec.getDefinitions()));

代码示例来源:origin: wso2/carbon-apimgt

List<SecurityRequirement> securityRequirementList = swagger.getSecurity();
if (securityRequirementList != null) {
  for (SecurityRequirement securityRequirement : securityRequirementList) {

代码示例来源:origin: com.reprezen.genflow/genflow-api

if (swagger.getSecurity() != null) {
  for (SecurityRequirement requirement : swagger.getSecurity()) {
    callbacks.securityRequirement(requirement);
    callbacks.any(requirement);

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

List<SecurityRequirement> securityRequirementList = swagger.getSecurity();
if (securityRequirementList != null) {
  for (SecurityRequirement securityRequirement : securityRequirementList) {

代码示例来源:origin: com.reprezen.genflow/genflow-api

@Override
public void swagger(Swagger swagger) {
  swagger.setSchemes(fillList(swagger.getSchemes()));
  swagger.setConsumes(fillList(swagger.getConsumes()));
  swagger.setProduces(fillList(swagger.getProduces()));
  swagger.setPaths(fillMap(swagger.getPaths()));
  swagger.setDefinitions(fillMap(swagger.getDefinitions()));
  swagger.setParameters(fillMap(swagger.getParameters()));
  swagger.setResponses(fillMap(swagger.getResponses()));
  swagger.setSecurityDefinitions(fillMap(swagger.getSecurityDefinitions()));
  swagger.setSecurity(fillList(swagger.getSecurity()));
  swagger.setTags(fillList(swagger.getTags()));
}

代码示例来源:origin: com.google.api/api-compiler

/** Adds auth security requirement for the entire service. */
public void addSecurityRequirementExtensionForEntireService(
  Service.Builder serviceBuilder, Swagger swagger) {
 AuthenticationRule.Builder builder = AuthenticationRule.newBuilder();
 Map<String, SecurityRequirementModel> authRequirements =
   authRuleGenerator.getSecurityRequirements(
     swagger.getSecurity() != null
       ? Iterables.transform(swagger.getSecurity(), SecurityRequirementsExtractor.INSTANCE)
       : null,
     swagger.getVendorExtensions(),
     new SimpleLocation("OpenAPI"));
 if (authRequirements != null && !authRequirements.isEmpty()) {
  builder.addAllRequirements(SecurityRequirementModel.createAuthRequirements(authRequirements));
  builder.setSelector("*");
  Authentication.Builder authenticationBuilder = serviceBuilder.getAuthenticationBuilder();
  authenticationBuilder.addRules(builder.build());
 }
}

代码示例来源:origin: swagger-api/swagger-parser

if (swagger.getSecurity() != null && swagger.getSecurity().size() > 0) {
  openAPI.setSecurity(convertSecurityRequirements(swagger.getSecurity()));

代码示例来源:origin: googleapis/api-compiler

/** Adds auth security requirement for the entire service. */
public void addSecurityRequirementExtensionForEntireService(
  Service.Builder serviceBuilder, Swagger swagger) {
 AuthenticationRule.Builder builder = AuthenticationRule.newBuilder();
 Map<String, SecurityRequirementModel> authRequirements =
   authRuleGenerator.getSecurityRequirements(
     swagger.getSecurity() != null
       ? Iterables.transform(swagger.getSecurity(), SecurityRequirementsExtractor.INSTANCE)
       : null,
     swagger.getVendorExtensions(),
     new SimpleLocation("OpenAPI"));
 if (authRequirements != null && !authRequirements.isEmpty()) {
  builder.addAllRequirements(SecurityRequirementModel.createAuthRequirements(authRequirements));
  builder.setSelector("*");
  Authentication.Builder authenticationBuilder = serviceBuilder.getAuthenticationBuilder();
  authenticationBuilder.addRules(builder.build());
 }
}

代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v2-converter

if (swagger.getSecurity() != null && swagger.getSecurity().size() > 0) {
  openAPI.setSecurity(convertSecurityRequirements(swagger.getSecurity()));

代码示例来源:origin: com.holon-platform.jaxrs/holon-jaxrs-swagger-v2

api.setExternalDocs(config.getExternalDocs());
if (api.getSecurity() == null || api.getSecurity().isEmpty()) {
  if (config.getSecurity() != null) {
    if (api.getSecurity() == null) {
      api.setSecurity(new LinkedList<>());
    config.getSecurity().forEach(s -> api.getSecurity().add(s));

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.core

String securityName = getOauthSecurityName(swagger);
if (!StringUtils.isEmpty(securityName)) {
  List<SecurityRequirement> securityRequirements = swagger.getSecurity();
  if (securityRequirements != null) {
    for (SecurityRequirement securityRequirement : securityRequirements) {

代码示例来源:origin: wso2/carbon-apimgt

String securityName = getOauthSecurityName(swagger);
if (!StringUtils.isEmpty(securityName)) {
  List<SecurityRequirement> securityRequirements = swagger.getSecurity();
  if (securityRequirements != null) {
    for (SecurityRequirement securityRequirement : securityRequirements) {

相关文章