use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method init.
/**
* To initialize the publisherRoleCache configurations, based on configurations.
*/
public static void init() throws APIManagementException {
APIManagerConfiguration apiManagerConfiguration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String isPublisherRoleCacheEnabledConfiguration = apiManagerConfiguration.getFirstProperty(APIConstants.PUBLISHER_ROLE_CACHE_ENABLED);
isPublisherRoleCacheEnabled = isPublisherRoleCacheEnabledConfiguration == null || Boolean.parseBoolean(isPublisherRoleCacheEnabledConfiguration);
try {
eventPublisherFactory = ServiceReferenceHolder.getInstance().getEventPublisherFactory();
eventPublishers.putIfAbsent(EventPublisherType.ASYNC_WEBHOOKS, eventPublisherFactory.getEventPublisher(EventPublisherType.ASYNC_WEBHOOKS));
eventPublishers.putIfAbsent(EventPublisherType.CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.CACHE_INVALIDATION));
eventPublishers.putIfAbsent(EventPublisherType.GLOBAL_CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.GLOBAL_CACHE_INVALIDATION));
eventPublishers.putIfAbsent(EventPublisherType.NOTIFICATION, eventPublisherFactory.getEventPublisher(EventPublisherType.NOTIFICATION));
eventPublishers.putIfAbsent(EventPublisherType.TOKEN_REVOCATION, eventPublisherFactory.getEventPublisher(EventPublisherType.TOKEN_REVOCATION));
eventPublishers.putIfAbsent(EventPublisherType.BLOCKING_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.BLOCKING_EVENT));
eventPublishers.putIfAbsent(EventPublisherType.KEY_TEMPLATE, eventPublisherFactory.getEventPublisher(EventPublisherType.KEY_TEMPLATE));
eventPublishers.putIfAbsent(EventPublisherType.KEYMGT_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.KEYMGT_EVENT));
} catch (EventPublisherException e) {
log.error("Could not initialize the event publishers. Events might not be published properly.");
throw new APIManagementException(e);
}
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method isAllowedScope.
/**
* Determines if the scope is specified in the whitelist.
*
* @param scope - The scope key to check
* @return - 'true' if the scope is white listed. 'false' if not.
*/
public static boolean isAllowedScope(String scope) {
if (allowedScopes == null) {
APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
// Read scope whitelist from Configuration.
List<String> whitelist = configuration.getProperty(APIConstants.ALLOWED_SCOPES);
// If whitelist is null, default scopes will be put.
if (whitelist == null) {
whitelist = new ArrayList<String>();
whitelist.add(APIConstants.OPEN_ID_SCOPE_NAME);
whitelist.add(APIConstants.DEVICE_SCOPE_PATTERN);
}
allowedScopes = new HashSet<String>(whitelist);
}
for (String scopeTobeSkipped : allowedScopes) {
if (scope.matches(scopeTobeSkipped)) {
return true;
}
}
return false;
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getRESTApiGroupingExtractorImplementation.
/**
* Read the REST API group id extractor class reference from api-manager.xml.
*
* @return REST API group id extractor class reference.
*/
public static String getRESTApiGroupingExtractorImplementation() {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String restApiGroupingExtractor = config.getFirstProperty(APIConstants.API_STORE_REST_API_GROUP_EXTRACTOR_IMPLEMENTATION);
if (StringUtils.isEmpty(restApiGroupingExtractor)) {
restApiGroupingExtractor = getGroupingExtractorImplementation();
}
return restApiGroupingExtractor;
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getExternalIDPOrigin.
/**
* Get the External IDP host name when UIs use an external IDP for SSO or other purpose
* By default this is equal to $ref{server.base_path} (i:e https://localhost:9443)
*
* @return Origin string of the external IDP
*/
public static String getExternalIDPOrigin() throws APIManagementException {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String idpEndpoint = config.getFirstProperty(APIConstants.IDENTITY_PROVIDER_SERVER_URL);
if (idpEndpoint == null) {
return getServerURL();
} else {
return idpEndpoint;
}
}
use of org.wso2.carbon.apimgt.impl.APIManagerConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getOAuthConfigurationFromAPIMConfig.
/**
* This method is used to get the authorization configurations from the api manager configurations
*
* @param property The configuration to get from api-manager.xml
* @return The configuration read from api-manager.xml or else null
* @throws APIManagementException Throws if the registry resource doesn't exist
* or the content cannot be parsed to JSON
*/
public static String getOAuthConfigurationFromAPIMConfig(String property) throws APIManagementException {
// If tenant registry doesn't have the configuration, then read it from api-manager.xml
APIManagerConfiguration apimConfig = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String oAuthConfiguration = apimConfig.getFirstProperty(APIConstants.OAUTH_CONFIGS + property);
if (!StringUtils.isBlank(oAuthConfiguration)) {
return oAuthConfiguration;
}
return null;
}
Aggregations