当前位置: 首页>>代码示例>>Java>>正文


Java ApiKeyAuthDefinition类代码示例

本文整理汇总了Java中io.swagger.models.auth.ApiKeyAuthDefinition的典型用法代码示例。如果您正苦于以下问题:Java ApiKeyAuthDefinition类的具体用法?Java ApiKeyAuthDefinition怎么用?Java ApiKeyAuthDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ApiKeyAuthDefinition类属于io.swagger.models.auth包,在下文中一共展示了ApiKeyAuthDefinition类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: swaggerConfig

import io.swagger.models.auth.ApiKeyAuthDefinition; //导入依赖的package包/类
@Bean
public BeanConfig swaggerConfig() {
	final BeanConfig beanConfig = new BeanConfig();
	beanConfig.setResourcePackage("com.github.sbugat.samplerest.resource");
	beanConfig.setVersion("1.0.0");
	beanConfig.setHost("localhost:8080");
	beanConfig.setBasePath(servletContext.getContextPath());
	beanConfig.setTitle("Swagger CXF, JAX-RS 2.0 sample");
	beanConfig.setDescription("This is a Swagger CXF, JAX-RS 2.0 sample API.");
	beanConfig.setContact("Sylvain Bugat");
	beanConfig.setLicense("Apache 2.0");
	beanConfig.setLicenseUrl("https://github.com/Sylvain-Bugat/swagger-cxf-rest-skeleton/blob/master/LICENSE");

	beanConfig.getSwagger().addSecurityDefinition("api_token", new ApiKeyAuthDefinition("api_token", In.HEADER));

	beanConfig.setScan(true);

	return beanConfig;
}
 
开发者ID:Sylvain-Bugat,项目名称:swagger-cxf-rest-skeleton,代码行数:20,代码来源:ApplicationConfiguration.java

示例2: getAuthHandler

import io.swagger.models.auth.ApiKeyAuthDefinition; //导入依赖的package包/类
private AuthHandler getAuthHandler(String name) {
    AuthHandler authHandler = this.authHandlers.get(name);
    if (authHandler != null) {
        return authHandler;
    }

    AuthProvider authProvider = getAuthProviderFactory().getAuthProviderByName(name);
    if (authProvider == null) {
        return null;
    }

    SecuritySchemeDefinition securityScheme = this.securitySchemes.get(name);
    if(securityScheme != null) {
     switch (securityScheme.getType()) {
         case "apiKey":
             ApiKeyAuthDefinition apiKeyAuthDefinition = (ApiKeyAuthDefinition) securityScheme;
             Location apiKeyLocation = Location.valueOf(apiKeyAuthDefinition.getIn().name());
             authHandler = ApiKeyAuthHandler.create(authProvider, apiKeyLocation, apiKeyAuthDefinition.getName());
             break;
         case "basic":
             authHandler = BasicAuthHandler.create(authProvider);
             break;
         case "oauth2":
             vertxLogger.warn("OAuth2 authentication has not been implemented yet!");
             break;
         default:
             vertxLogger.warn("SecurityScheme is not authorized : " + securityScheme.getType());
             break;
     }
     
	
     if (authHandler != null) {
         this.authHandlers.put(name, authHandler);
     }
    } else {
        vertxLogger.warn("No securityScheme definition in swagger file for auth provider: " + name);
    }

    return authHandler;
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:41,代码来源:SwaggerAuthHandlerFactory.java

示例3: isValidApiKeyDefinition

import io.swagger.models.auth.ApiKeyAuthDefinition; //导入依赖的package包/类
/**
 * Checks if the defined apiKey is valid or not. Only apiKey definition with name as 'key' and
 * 'in' as 'query' are allowed"
 */
private boolean isValidApiKeyDefinition(ApiKeyAuthDefinition apiKeydef) {
  if (apiKeydef.getName().equalsIgnoreCase("key") || apiKeydef.getIn() == In.QUERY) {
    return true;
  } else {
    diagCollector.addDiag(
        Diag.warning(
            SimpleLocation.UNKNOWN,
            "apiKey '%s' is ignored. Only apiKey with 'name' as 'key' and 'in' as 'query' are "
                + "supported",
            apiKeydef.getName()));
    return false;
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:18,代码来源:AuthBuilder.java

示例4: buildSecurityScheme

import io.swagger.models.auth.ApiKeyAuthDefinition; //导入依赖的package包/类
private MarkupDocBuilder buildSecurityScheme(MarkupDocBuilder markupDocBuilder, SecuritySchemeDefinition securityScheme) {
    String type = securityScheme.getType();
    MarkupDocBuilder paragraphBuilder = copyMarkupDocBuilder(markupDocBuilder);

    paragraphBuilder.italicText(labels.getLabel(TYPE)).textLine(COLON + type);

    if (securityScheme instanceof ApiKeyAuthDefinition) {
        paragraphBuilder.italicText(labels.getLabel(NAME)).textLine(COLON + ((ApiKeyAuthDefinition) securityScheme).getName());
        paragraphBuilder.italicText(labels.getLabel(IN)).textLine(COLON + ((ApiKeyAuthDefinition) securityScheme).getIn());

        return markupDocBuilder.paragraph(paragraphBuilder.toString(), true);
    } else if (securityScheme instanceof OAuth2Definition) {
        OAuth2Definition oauth2Scheme = (OAuth2Definition) securityScheme;
        String flow = oauth2Scheme.getFlow();
        paragraphBuilder.italicText(labels.getLabel(FLOW)).textLine(COLON + flow);
        if (isNotBlank(oauth2Scheme.getAuthorizationUrl())) {
            paragraphBuilder.italicText(labels.getLabel(AUTHORIZATION_URL)).textLine(COLON + oauth2Scheme.getAuthorizationUrl());
        }
        if (isNotBlank(oauth2Scheme.getTokenUrl())) {
            paragraphBuilder.italicText(labels.getLabel(TOKEN_URL)).textLine(COLON + oauth2Scheme.getTokenUrl());
        }

        markupDocBuilder.paragraph(paragraphBuilder.toString(), true);

        if (oauth2Scheme.getScopes() != null && !oauth2Scheme.getScopes().isEmpty()) {
            StringColumn.Builder nameColumnBuilder = StringColumn.builder(StringColumnId.of(labels.getLabel(NAME_COLUMN)))
                    .putMetaData(TableComponent.WIDTH_RATIO, "3")
                    .putMetaData(TableComponent.HEADER_COLUMN, "true");
            StringColumn.Builder descriptionColumnBuilder = StringColumn.builder(StringColumnId.of(labels.getLabel(DESCRIPTION_COLUMN)))
                    .putMetaData(TableComponent.WIDTH_RATIO, "17")
                    .putMetaData(TableComponent.HEADER_COLUMN, "true");

            for (Map.Entry<String, String> scope : oauth2Scheme.getScopes().entrySet()) {
                nameColumnBuilder.add(scope.getKey());
                descriptionColumnBuilder.add(scope.getValue());
            }

            return tableComponent.apply(markupDocBuilder, TableComponent.parameters(nameColumnBuilder.build(),
                    descriptionColumnBuilder.build()));
        } else {

            return markupDocBuilder;
        }

    } else {
        return markupDocBuilder.paragraph(paragraphBuilder.toString(), true);
    }
}
 
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:49,代码来源:SecuritySchemeDefinitionComponent.java

示例5: apiKeyAuth

import io.swagger.models.auth.ApiKeyAuthDefinition; //导入依赖的package包/类
public static ApiKeyAuthDefinition apiKeyAuth(String name, In in) {
    return new ApiKeyAuthDefinition(name, in);
}
 
开发者ID:tminglei,项目名称:binder-swagger-java,代码行数:4,代码来源:SwaggerContext.java


注:本文中的io.swagger.models.auth.ApiKeyAuthDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。