本文整理汇总了Java中io.swagger.models.auth.SecuritySchemeDefinition类的典型用法代码示例。如果您正苦于以下问题:Java SecuritySchemeDefinition类的具体用法?Java SecuritySchemeDefinition怎么用?Java SecuritySchemeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecuritySchemeDefinition类属于io.swagger.models.auth包,在下文中一共展示了SecuritySchemeDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: afterScan
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
OAuth2Definition tokenScheme = new OAuth2Definition();
tokenScheme.setType("oauth2");
tokenScheme.setFlow("application");
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
tokenScheme.addScope("write:everything", "Full access");
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
swagger.setSecurityDefinitions(schemes);
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:SecurityDefinitionConfigurator.java
示例2: validateAuthTypes
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
/**
* Check if all operations contains valid authentication types
*/
private SwaggerModelInfo validateAuthTypes(final SwaggerModelInfo swaggerModelInfo) {
if (swaggerModelInfo.getModel() == null) {
return swaggerModelInfo;
}
final SwaggerModelInfo.Builder withWarnings = new SwaggerModelInfo.Builder().createFrom(swaggerModelInfo);
for (final Map.Entry<String, SecuritySchemeDefinition> definitionEntry : notNull(
swaggerModelInfo.getModel().getSecurityDefinitions()).entrySet()) {
final String authType = definitionEntry.getValue().getType();
if (!SUPPORTED_AUTH_TYPES.contains(authType)) {
withWarnings.addWarning(new Violation.Builder()//
.property("")//
.error("unsupported-auth")//
.message("Authentication type " + authType + " is currently not supported")//
.build());
}
}
return withWarnings.build();
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:SyndesisSwaggerValidationRules.java
示例3: processUris
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private void processUris(final Map<String, Path> swagger,
final Map<String, Model> definitionsMap,
final Map<String, SecuritySchemeDefinition> securityDefinitionsMap,
final int i) {
int j = 0;
while (env.containsProperty(String.format("swagger[%d].uris[%d].swagger", i, j))) {
try {
final URL swaggerUrl = env.getProperty(String.format("swagger[%d].uris[%d].swagger", i, j), URL.class);
final Swagger remoteSwagger = io.swagger.util.Json.mapper().readerFor(Swagger.class).readValue(swaggerUrl.openConnection().getInputStream());
processPaths(swagger, definitionsMap, securityDefinitionsMap, remoteSwagger, i, j);
++j;
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
}
开发者ID:trajano,项目名称:app-ms,代码行数:22,代码来源:SwaggerCollator.java
示例4: isApiKeyRequired
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private Boolean isApiKeyRequired(Operation op) {
Optional<Map.Entry<String, SecuritySchemeDefinition>> apiKeySecurityDefinition = Optional.empty();
if (swagger.getSecurityDefinitions() != null) {
apiKeySecurityDefinition = swagger.getSecurityDefinitions().entrySet()
.stream().filter(p -> p.getValue().getType().equals("apiKey")).findFirst();
}
if (!apiKeySecurityDefinition.isPresent()) {
return false;
}
String securityDefinitionName = apiKeySecurityDefinition.get().getKey();
if (op.getSecurity() != null) {
return op.getSecurity().stream().anyMatch(s -> s.containsKey(securityDefinitionName));
}
if (swagger.getSecurityRequirement() != null) {
return swagger.getSecurityRequirement().stream().anyMatch(s -> s.getName().equals(securityDefinitionName));
}
return false;
}
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:23,代码来源:ApiGatewaySdkSwaggerApiImporter.java
示例5: apply
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
String securitySchemeDefinitionName = params.securitySchemeDefinitionName;
SecuritySchemeDefinition securitySchemeDefinition = params.securitySchemeDefinition;
applySecurityDocumentExtension(new SecurityDocumentExtension.Context(Position.SECURITY_SCHEME_BEFORE, markupDocBuilder, securitySchemeDefinitionName, securitySchemeDefinition));
markupDocBuilder.sectionTitleWithAnchorLevel(params.titleLevel, securitySchemeDefinitionName);
applySecurityDocumentExtension(new SecurityDocumentExtension.Context(Position.SECURITY_SCHEME_BEGIN, markupDocBuilder, securitySchemeDefinitionName, securitySchemeDefinition));
String description = securitySchemeDefinition.getDescription();
if (isNotBlank(description)) {
markupDocBuilder.paragraph(markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, description));
}
buildSecurityScheme(markupDocBuilder, securitySchemeDefinition);
applySecurityDocumentExtension(new SecurityDocumentExtension.Context(Position.SECURITY_SCHEME_END, markupDocBuilder, securitySchemeDefinitionName, securitySchemeDefinition));
applySecurityDocumentExtension(new SecurityDocumentExtension.Context(Position.SECURITY_SCHEME_AFTER, markupDocBuilder, securitySchemeDefinitionName, securitySchemeDefinition));
return markupDocBuilder;
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:17,代码来源:SecuritySchemeDefinitionComponent.java
示例6: testSecuritySchemeDefinitionComponentWithOAuth
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
@Test
public void testSecuritySchemeDefinitionComponentWithOAuth() throws URISyntaxException {
//Given
Path file = Paths.get(SecuritySchemeDefinitionComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
Swagger swagger = converter.getContext().getSwagger();
SecuritySchemeDefinition securitySchemeDefinition = swagger.getSecurityDefinitions().get("petstore_auth");
Swagger2MarkupConverter.Context context = converter.getContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
markupDocBuilder = new SecuritySchemeDefinitionComponent(context).apply(
markupDocBuilder, SecuritySchemeDefinitionComponent.parameters("petstore_auth",
securitySchemeDefinition,
OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(oauthOutputDirectory, StandardCharsets.UTF_8);
Path expectedFile = getExpectedFile(O_AUTH_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, oauthOutputDirectory, getReportName(O_AUTH_NAME));
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:23,代码来源:SecuritySchemeDefinitionComponentTest.java
示例7: testSecuritySchemeDefinitionComponentWithApiKey
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
@Test
public void testSecuritySchemeDefinitionComponentWithApiKey() throws URISyntaxException {
//Given
Path file = Paths.get(SecuritySchemeDefinitionComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
Swagger swagger = converter.getContext().getSwagger();
SecuritySchemeDefinition securitySchemeDefinition = swagger.getSecurityDefinitions().get("api_key");
Swagger2MarkupConverter.Context context = converter.getContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
markupDocBuilder = new SecuritySchemeDefinitionComponent(context).apply(
markupDocBuilder, SecuritySchemeDefinitionComponent.parameters("api_key",
securitySchemeDefinition,
OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(apiKeyOutputDirectory, StandardCharsets.UTF_8);
Path expectedFile = getExpectedFile(API_KEY_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, apiKeyOutputDirectory, getReportName(API_KEY_NAME));
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:23,代码来源:SecuritySchemeDefinitionComponentTest.java
示例8: generateSecuritySchemeDefinitions
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
public Map<String, SecuritySchemeDefinition> generateSecuritySchemeDefinitions() throws GenerateException {
Map<String, SecuritySchemeDefinition> map = new HashMap<String, SecuritySchemeDefinition>();
List<JsonNode> securityDefinitions = new ArrayList<JsonNode>();
if (json != null || jsonPath != null) {
securityDefinitions = loadSecurityDefintionsFromJsonFile();
} else {
securityDefinitions.add(new ObjectMapper().valueToTree(this));
}
for (JsonNode securityDefinition : securityDefinitions) {
SecuritySchemeDefinition ssd = getSecuritySchemeDefinitionByType(securityDefinition.get("type").asText(), securityDefinition);
if (ssd != null) {
map.put(securityDefinition.get("name").asText(), ssd);
}
}
return map;
}
开发者ID:kongchen,项目名称:swagger-maven-plugin,代码行数:20,代码来源:SecurityDefinition.java
示例9: getSwagger
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
public ClonableSwagger getSwagger(final String basePath,
final UriInfo uriInfo) {
ClonableSwagger swagger = swaggerMap.get(basePath);
if (swagger == null) {
final int i = swaggerPaths.get(basePath);
swagger = new ClonableSwagger();
final String title = env.getProperty(String.format("swagger[%d].info.title", i));
final String version = env.getProperty(String.format("swagger[%d].info.version", i));
swagger.setBasePath('/' + basePath);
final Info info = new Info();
info.setTitle(title);
info.setVersion(version);
swagger.setInfo(info);
final Map<String, Path> pathsMap = new TreeMap<>();
final Map<String, Model> definitionsMap = new TreeMap<>();
final Map<String, SecuritySchemeDefinition> securityDefinitionsMap = new TreeMap<>();
processUris(pathsMap, definitionsMap, securityDefinitionsMap, i);
swagger.setPaths(pathsMap);
swagger.setDefinitions(definitionsMap);
swagger.setSecurityDefinitions(securityDefinitionsMap);
swaggerMap.putIfAbsent(basePath, swagger);
}
return swagger.withUriInfo(uriInfo);
}
开发者ID:trajano,项目名称:app-ms,代码行数:29,代码来源:SwaggerCollator.java
示例10: processPaths
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private void processPaths(final Map<String, Path> swagger,
final Map<String, Model> definitionsMap,
final Map<String, SecuritySchemeDefinition> securityDefinitionsMap,
final Swagger remoteSwagger,
final int i,
final int j) {
int k = 0;
while (env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k)) || env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d]", i, j, k))) {
if (env.containsProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k))) {
final String from = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d].from", i, j, k));
final String to = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d].to", i, j, k));
LOG.debug("getting path={} from paths={} and transform to={}", from, remoteSwagger.getPaths().keySet(), to);
Optional.ofNullable(remoteSwagger.getPaths())
.ifPresent(t -> remoteSwagger.getPaths().keySet().parallelStream()
.filter(s -> s.startsWith(from))
.forEach(p -> swagger.put(to + p.substring(from.length()), remoteSwagger.getPath(p))));
updateDefinitions(definitionsMap, securityDefinitionsMap, remoteSwagger);
} else {
final String path = env.getRequiredProperty(String.format("swagger[%d].uris[%d].paths[%d]", i, j, k));
if (LOG.isDebugEnabled()) {
LOG.debug("getting path={} from paths={}", path, remoteSwagger.getPaths().keySet());
}
if (remoteSwagger.getPaths() != null) {
remoteSwagger.getPaths().keySet().parallelStream()
.filter(s -> s.startsWith(path))
.forEach(p -> swagger.put(p, remoteSwagger.getPath(p)));
}
updateDefinitions(definitionsMap, securityDefinitionsMap, remoteSwagger);
}
++k;
}
}
开发者ID:trajano,项目名称:app-ms,代码行数:36,代码来源:SwaggerCollator.java
示例11: updateDefinitions
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
/**
* Update the current definition maps.
*
* @param currentDefinitionsMap
* current definitions map
* @param currentSecurityDefinitionsMap
* current security defintions map
* @param swagger
* remote swagger data
*/
private void updateDefinitions(final Map<String, Model> currentDefinitionsMap,
final Map<String, SecuritySchemeDefinition> currentSecurityDefinitionsMap,
final Swagger swagger) {
Optional.ofNullable(swagger.getDefinitions())
.ifPresent(t -> t.entrySet().parallelStream()
.forEach(e -> currentDefinitionsMap.put(e.getKey(), e.getValue())));
Optional.ofNullable(swagger.getSecurityDefinitions())
.ifPresent(t -> t.entrySet().parallelStream()
.forEach(e -> currentSecurityDefinitionsMap.put(e.getKey(), e.getValue())));
}
开发者ID:trajano,项目名称:app-ms,代码行数:23,代码来源:SwaggerCollator.java
示例12: getOAuth2Name
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private static String getOAuth2Name() {
String name = null;
Map<String, SecuritySchemeDefinition> defMap = swagger.getSecurityDefinitions();
if(defMap != null) {
for(Map.Entry<String, SecuritySchemeDefinition> entry : defMap.entrySet()) {
if(entry.getValue().getType().equals("oauth2")) {
name = entry.getKey();
break;
}
}
}
return name;
}
开发者ID:networknt,项目名称:light-rest-4j,代码行数:14,代码来源:SwaggerHelper.java
示例13: getAuthHandler
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的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
示例14: toScheme
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private static SecuritySchemeDefinition toScheme(
IssuerConfig issuerConfig, ImmutableSet<String> audiences) {
OAuth2Definition tokenDef = new OAuth2Definition().implicit("");
tokenDef.setVendorExtension("x-google-issuer", issuerConfig.getIssuer());
if (!com.google.common.base.Strings.isNullOrEmpty(issuerConfig.getJwksUri())) {
tokenDef.setVendorExtension("x-google-jwks_uri", issuerConfig.getJwksUri());
}
tokenDef.setVendorExtension("x-google-audiences", COMMA_JOINER.join(audiences));
return tokenDef;
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:11,代码来源:SwaggerGenerator.java
示例15: getOrCreateSecurityDefinitionMap
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private static Map<String, SecuritySchemeDefinition> getOrCreateSecurityDefinitionMap(
Swagger swagger) {
Map<String, SecuritySchemeDefinition> securityDefinitions = swagger.getSecurityDefinitions();
if (securityDefinitions == null) {
securityDefinitions = new HashMap<>();
swagger.setSecurityDefinitions(securityDefinitions);
}
return securityDefinitions;
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:10,代码来源:SwaggerGenerator.java
示例16: addNonConflictingSecurityDefinition
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
private static String addNonConflictingSecurityDefinition(
Swagger swagger, IssuerConfig issuerConfig, ImmutableSet<String> audiences)
throws ApiConfigException {
Map<String, SecuritySchemeDefinition> securityDefinitions =
getOrCreateSecurityDefinitionMap(swagger);
String issuerPlusHash = String.format("%s-%x", issuerConfig.getName(), audiences.hashCode());
SecuritySchemeDefinition existingDef = securityDefinitions.get(issuerConfig.getName());
SecuritySchemeDefinition newDef = toScheme(issuerConfig, audiences);
if (existingDef != null && !existingDef.equals(newDef)) {
throw new ApiConfigException(
"Multiple conflicting definitions found for issuer " + issuerConfig.getName());
}
swagger.securityDefinition(issuerPlusHash, newDef);
return issuerPlusHash;
}
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:16,代码来源:SwaggerGenerator.java
示例17: afterScan
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, Swagger swagger) {
OAuth2Definition tokenScheme = new OAuth2Definition();
tokenScheme.setType("oauth2");
tokenScheme.setFlow("application");
tokenScheme.setTokenUrl("https://" + swagger.getHost() + "/oauth2/token");
tokenScheme.setAuthorizationUrl("https://" + swagger.getHost() + "/oauth2/authorize");
tokenScheme.addScope("write:everything", "Full access");
Map<String, SecuritySchemeDefinition> schemes = new HashMap<>();
schemes.put(TOKEN_AUTH_SCHEME, tokenScheme);
swagger.setSecurityDefinitions(schemes);
//TODO: Have to add wso2-scopes to swagger definition from here
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:16,代码来源:SecurityDefinitionConfigurator.java
示例18: Context
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
/**
* @param position the current position
* @param docBuilder the MarkupDocBuilder
* @param securitySchemeName the name of the current securityScheme
* @param securityScheme the current security scheme securityScheme
*/
public Context(Position position, MarkupDocBuilder docBuilder, String securitySchemeName, SecuritySchemeDefinition securityScheme) {
super(docBuilder);
Validate.inclusiveBetween(Position.SECURITY_SCHEME_BEFORE, Position.SECURITY_SCHEME_AFTER, position);
Validate.notNull(securitySchemeName);
Validate.notNull(securityScheme);
this.position = position;
this.securitySchemeName = securitySchemeName;
this.securityScheme = securityScheme;
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:16,代码来源:SecurityDocumentExtension.java
示例19: Parameters
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
public Parameters(String securitySchemeDefinitionName,
SecuritySchemeDefinition securitySchemeDefinition,
int titleLevel) {
this.securitySchemeDefinitionName = Validate.notBlank(securitySchemeDefinitionName, "SecuritySchemeDefinitionName must not be empty");
this.securitySchemeDefinition = Validate.notNull(securitySchemeDefinition, "SecuritySchemeDefinition must not be null");
this.titleLevel = titleLevel;
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:8,代码来源:SecuritySchemeDefinitionComponent.java
示例20: apply
import io.swagger.models.auth.SecuritySchemeDefinition; //导入依赖的package包/类
/**
* Builds the security MarkupDocument.
*
* @return the security MarkupDocument
*/
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, SecurityDocument.Parameters params) {
Map<String, SecuritySchemeDefinition> definitions = params.securitySchemeDefinitions;
if (MapUtils.isNotEmpty(definitions)) {
applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupDocBuilder));
buildSecurityTitle(markupDocBuilder, labels.getLabel(SECURITY));
applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEGIN, markupDocBuilder));
buildSecuritySchemeDefinitionsSection(markupDocBuilder, definitions);
applySecurityDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder));
applySecurityDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder));
}
return markupDocBuilder;
}
开发者ID:Swagger2Markup,项目名称:swagger2markup,代码行数:19,代码来源:SecurityDocument.java
注:本文中的io.swagger.models.auth.SecuritySchemeDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论