Java Code Examples for org.wso2.carbon.apimgt.impl.APIConstants#API_SECURITY_MUTUAL_SSL
The following examples show how to use
org.wso2.carbon.apimgt.impl.APIConstants#API_SECURITY_MUTUAL_SSL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAS2Parser.java From carbon-apimgt with Apache License 2.0 | 4 votes |
/** * This method returns api that is attached with api extensions related to micro-gw * * @param apiDefinition String * @param api API * @param isBasepathExtractedFromSwagger boolean * @return API */ @Override public API setExtensionsToAPI(String apiDefinition, API api, boolean isBasepathExtractedFromSwagger) throws APIManagementException { Swagger swagger = getSwagger(apiDefinition); Map<String, Object> extensions = swagger.getVendorExtensions(); if (extensions == null) { return api; } //Setup Custom auth header for API String authHeader = OASParserUtil.getAuthorizationHeaderFromSwagger(extensions); if (StringUtils.isNotBlank(authHeader)) { api.setAuthorizationHeader(authHeader); } //Setup mutualSSL configuration String mutualSSL = OASParserUtil.getMutualSSLEnabledFromSwagger(extensions); if (StringUtils.isNotBlank(mutualSSL)) { String securityList = api.getApiSecurity(); if (StringUtils.isBlank(securityList)) { securityList = APIConstants.DEFAULT_API_SECURITY_OAUTH2; } if (APIConstants.OPTIONAL.equals(mutualSSL)) { securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL; } else if (APIConstants.MANDATORY.equals(mutualSSL)) { securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL_MANDATORY; } api.setApiSecurity(securityList); } //Setup CORSConfigurations CORSConfiguration corsConfiguration = OASParserUtil.getCorsConfigFromSwagger(extensions); if (corsConfiguration != null) { api.setCorsConfiguration(corsConfiguration); } //Setup Response cache enabling boolean responseCacheEnable = OASParserUtil.getResponseCacheFromSwagger(extensions); if (responseCacheEnable) { api.setResponseCache(APIConstants.ENABLED); } //Setup cache timeOut int cacheTimeOut = OASParserUtil.getCacheTimeOutFromSwagger(extensions); if (cacheTimeOut != 0) { api.setCacheTimeout(cacheTimeOut); } //Setup Transports String transports = OASParserUtil.getTransportsFromSwagger(extensions); if (StringUtils.isNotBlank(transports)) { api.setTransports(transports); } //Setup Throttlingtiers String throttleTier = OASParserUtil.getThrottleTierFromSwagger(extensions); if (StringUtils.isNotBlank(throttleTier)) { api.setApiLevelPolicy(throttleTier); } //Setup Basepath String basePath = OASParserUtil.getBasePathFromSwagger(extensions); if (StringUtils.isNotBlank(basePath) && isBasepathExtractedFromSwagger) { basePath = basePath.replace("{version}", api.getId().getVersion()); api.setContextTemplate(basePath); api.setContext(basePath); } return api; }
Example 2
Source File: OAS3Parser.java From carbon-apimgt with Apache License 2.0 | 4 votes |
/** * This method returns api that is attached with api extensions related to micro-gw * * @param apiDefinition String * @param api API * @param isBasepathExtractedFromSwagger boolean * @return API */ @Override public API setExtensionsToAPI(String apiDefinition, API api, boolean isBasepathExtractedFromSwagger) throws APIManagementException { OpenAPI openAPI = getOpenAPI(apiDefinition); Map<String, Object> extensions = openAPI.getExtensions(); if (extensions == null) { return api; } //Setup Custom auth header for API String authHeader = OASParserUtil.getAuthorizationHeaderFromSwagger(extensions); if (StringUtils.isNotBlank(authHeader)) { api.setAuthorizationHeader(authHeader); } //Setup mutualSSL configuration String mutualSSL = OASParserUtil.getMutualSSLEnabledFromSwagger(extensions); if (StringUtils.isNotBlank(mutualSSL)) { String securityList = api.getApiSecurity(); if (StringUtils.isBlank(securityList)) { securityList = APIConstants.DEFAULT_API_SECURITY_OAUTH2; } if (APIConstants.OPTIONAL.equals(mutualSSL)) { securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL; } else if (APIConstants.MANDATORY.equals(mutualSSL)) { securityList = securityList + "," + APIConstants.API_SECURITY_MUTUAL_SSL_MANDATORY; } api.setApiSecurity(securityList); } //Setup CORSConfigurations CORSConfiguration corsConfiguration = OASParserUtil.getCorsConfigFromSwagger(extensions); if (corsConfiguration != null) { api.setCorsConfiguration(corsConfiguration); } //Setup Response cache enabling boolean responseCacheEnable = OASParserUtil.getResponseCacheFromSwagger(extensions); if (responseCacheEnable) { api.setResponseCache(APIConstants.ENABLED); } //Setup cache timeOut int cacheTimeOut = OASParserUtil.getCacheTimeOutFromSwagger(extensions); if (cacheTimeOut != 0) { api.setCacheTimeout(cacheTimeOut); } //Setup Transports String transports = OASParserUtil.getTransportsFromSwagger(extensions); if (StringUtils.isNotBlank(transports)) { api.setTransports(transports); } //Setup Throttlingtiers String throttleTier = OASParserUtil.getThrottleTierFromSwagger(extensions); if (StringUtils.isNotBlank(throttleTier)) { api.setApiLevelPolicy(throttleTier); } //Setup Basepath String basePath = OASParserUtil.getBasePathFromSwagger(extensions); if (StringUtils.isNotBlank(basePath) && isBasepathExtractedFromSwagger) { basePath = basePath.replace("{version}", api.getId().getVersion()); api.setContextTemplate(basePath); api.setContext(basePath); } return api; }