use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getSkipRolesByRegex.
/**
* return skipRolesByRegex config
*/
public static String getSkipRolesByRegex() {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String skipRolesByRegex = config.getFirstProperty(APIConstants.SKIP_ROLES_BY_REGEX);
return skipRolesByRegex;
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method isAllowDisplayMultipleVersions.
public static boolean isAllowDisplayMultipleVersions() {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String displayMultiVersions = config.getFirstProperty(APIConstants.API_STORE_DISPLAY_MULTIPLE_VERSIONS);
if (displayMultiVersions == null) {
log.warn("The configurations related to show multiple versions of API in APIStore " + "are missing in api-manager.xml.");
return false;
}
return Boolean.parseBoolean(displayMultiVersions);
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getInternalApiKeyAlias.
public static String getInternalApiKeyAlias() {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String alias = config.getFirstProperty(APIConstants.API_PUBLISHER_INTERNAL_API_KEY_ALIAS);
if (alias == null) {
log.warn("The configurations related to Api Key alias in API Publisher " + "are missing in api-manager.xml. Hence returning the default value.");
return APIConstants.GATEWAY_PUBLIC_CERTIFICATE_ALIAS;
}
return alias;
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getHttpClient.
/**
* Return a http client instance
*
* @param port - server port
* @param protocol- service endpoint protocol http/https
* @return
*/
public static HttpClient getHttpClient(int port, String protocol) {
APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String maxTotal = configuration.getFirstProperty(APIConstants.HTTP_CLIENT_MAX_TOTAL);
String defaultMaxPerRoute = configuration.getFirstProperty(APIConstants.HTTP_CLIENT_DEFAULT_MAX_PER_ROUTE);
String proxyEnabled = configuration.getFirstProperty(APIConstants.PROXY_ENABLE);
String proxyHost = configuration.getFirstProperty(APIConstants.PROXY_HOST);
String proxyPort = configuration.getFirstProperty(APIConstants.PROXY_PORT);
String proxyUsername = configuration.getFirstProperty(APIConstants.PROXY_USERNAME);
String proxyPassword = configuration.getFirstProperty(APIConstants.PROXY_PASSWORD);
String nonProxyHosts = configuration.getFirstProperty(APIConstants.NON_PROXY_HOSTS);
String proxyProtocol = configuration.getFirstProperty(APIConstants.PROXY_PROTOCOL);
if (proxyProtocol != null) {
protocol = proxyProtocol;
}
PoolingHttpClientConnectionManager pool = null;
try {
pool = getPoolingHttpClientConnectionManager(protocol);
} catch (APIManagementException e) {
log.error("Error while getting http client connection manager", e);
}
pool.setMaxTotal(Integer.parseInt(maxTotal));
pool.setDefaultMaxPerRoute(Integer.parseInt(defaultMaxPerRoute));
RequestConfig params = RequestConfig.custom().build();
HttpClientBuilder clientBuilder = HttpClients.custom().setConnectionManager(pool).setDefaultRequestConfig(params);
if (Boolean.parseBoolean(proxyEnabled)) {
HttpHost host = new HttpHost(proxyHost, Integer.parseInt(proxyPort), protocol);
DefaultProxyRoutePlanner routePlanner;
if (!StringUtils.isBlank(nonProxyHosts)) {
routePlanner = new ExtendedProxyRoutePlanner(host, configuration);
} else {
routePlanner = new DefaultProxyRoutePlanner(host);
}
clientBuilder = clientBuilder.setRoutePlanner(routePlanner);
if (!StringUtils.isBlank(proxyUsername) && !StringUtils.isBlank(proxyPassword)) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(proxyHost, Integer.parseInt(proxyPort)), new UsernamePasswordCredentials(proxyUsername, proxyPassword));
clientBuilder = clientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
}
return clientBuilder.build();
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method isSupportedFileType.
/**
* Check whether the file type is supported.
* @param filename name
* @return true if supported
*/
public static boolean isSupportedFileType(String filename) {
if (log.isDebugEnabled()) {
log.debug("File name " + filename);
}
if (StringUtils.isEmpty(filename)) {
return false;
}
String fileType = FilenameUtils.getExtension(filename);
List<String> list = null;
APIManagerConfiguration apiManagerConfiguration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String supportedTypes = apiManagerConfiguration.getFirstProperty(APIConstants.API_PUBLISHER_SUPPORTED_DOC_TYPES);
if (!StringUtils.isEmpty(supportedTypes)) {
String[] definedTypesArr = supportedTypes.trim().split("\\s*,\\s*");
list = Arrays.asList(definedTypesArr);
} else {
String[] defaultType = { "pdf", "txt", "doc", "docx", "xls", "xlsx", "odt", "ods", "json", "yaml", "md" };
list = Arrays.asList(defaultType);
}
return list.contains(fileType.toLowerCase());
}
Aggregations