Search in sources :

Example 1 with KeyManagerConfigurationDataRetriever

use of org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever in project carbon-apimgt by wso2.

the class ServerStartupListener method startConfigureKeyManagerConfigurations.

private void startConfigureKeyManagerConfigurations() {
    KeyManagerConfigurationDataRetriever keyManagerConfigurationDataRetriever = new KeyManagerConfigurationDataRetriever(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    keyManagerConfigurationDataRetriever.startLoadKeyManagerConfigurations();
}
Also used : KeyManagerConfigurationDataRetriever(org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever)

Example 2 with KeyManagerConfigurationDataRetriever

use of org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever in project carbon-apimgt by wso2.

the class CommonConfigDeployer method createdConfigurationContext.

public void createdConfigurationContext(ConfigurationContext configurationContext) {
    final String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    try {
        // TODO adding only the policies to data wouldn't be sufficient. Need to figure out approach after tenant story has finalized
        // Add default set of policies to database
        ThrottleProperties.PolicyDeployer policyDeployer = configuration.getThrottleProperties().getPolicyDeployer();
        // Also this will avoid tenant login overhead as well
        if (policyDeployer.isEnabled()) {
            Thread t1 = new Thread(new Runnable() {

                public void run() {
                    try {
                        APIUtil.addDefaultTenantAdvancedThrottlePolicies(tenantDomain, tenantId);
                    } catch (APIManagementException e) {
                        log.error("Error while deploying throttle policies", e);
                    }
                }
            });
            t1.start();
        }
    } catch (Exception e) {
        log.error("Failed to load default policies to tenant" + tenantDomain, e);
    }
    try {
        // Check whether GatewayType is "Synapse" before attempting to load Custom-Sequences into registry
        String gatewayType = configuration.getFirstProperty(APIConstants.API_GATEWAY_TYPE);
        if (APIConstants.API_GATEWAY_TYPE_SYNAPSE.equalsIgnoreCase(gatewayType)) {
            APIUtil.writeDefinedSequencesToTenantRegistry(tenantId);
        }
    }// Need to continue the execution even if we encounter an error.
     catch (Exception e) {
        log.error("Failed to write defined sequences to tenant " + tenantDomain + "'s registry", e);
    }
    try {
        APIUtil.loadTenantExternalStoreConfig(tenantDomain);
    } catch (Exception e) {
        log.error("Failed to load external-stores.xml to tenant " + tenantDomain + "'s registry", e);
    }
    try {
        APIUtil.loadTenantGAConfig(tenantDomain);
    } catch (Exception e) {
        log.error("Failed to load ga-config.xml to tenant " + tenantDomain + "'s registry", e);
    }
    try {
        // load workflow-extension configuration to the registry
        APIUtil.loadTenantWorkFlowExtensions(tenantDomain);
    } catch (Exception e) {
        log.error("Failed to load workflow-extension.xml to tenant " + tenantDomain + "'s registry", e);
    }
    try {
        // load self signup configurations to the registry
        APIUtil.loadTenantSelfSignUpConfigurations(tenantDomain);
    } catch (Exception e) {
        log.error("Failed to load sign-up-config.xml to tenant " + tenantDomain + "'s registry", e);
    }
    try {
        APIUtil.loadAndSyncTenantConf(tenantDomain);
    } catch (APIManagementException e) {
        log.error("Failed to load " + APIConstants.API_TENANT_CONF + " for tenant " + tenantDomain, e);
    } catch (Exception e) {
        // The generic Exception is handled explicitly so execution does not stop during config deployment
        log.error("Exception when loading " + APIConstants.API_TENANT_CONF + " for tenant " + tenantDomain, e);
    }
    try {
        // Load common operation policies to tenant
        APIUtil.loadCommonOperationPolicies(tenantDomain);
    } catch (Exception e) {
        // The generic Exception is handled explicitly so execution does not stop during config deployment
        log.error("Exception when loading " + APIConstants.OPERATION_POLICIES + " for tenant " + tenantDomain, e);
    }
    try {
        APIUtil.createDefaultRoles(tenantId);
    } catch (APIManagementException e) {
        log.error("Failed create default roles for tenant " + tenantDomain, e);
    } catch (Exception e) {
        // The generic Exception is handled explicitly so execution does not stop during config deployment
        log.error("Exception when creating default roles for tenant " + tenantDomain, e);
    }
    try {
        CommonUtil.addDefaultLifecyclesIfNotAvailable(ServiceReferenceHolder.getInstance().getRegistryService().getConfigSystemRegistry(tenantId), CommonUtil.getRootSystemRegistry(tenantId));
    } catch (RegistryException e) {
        log.error("Error while accessing registry", e);
    } catch (FileNotFoundException e) {
        log.error("Error while find lifecycle.xml", e);
    } catch (XMLStreamException e) {
        log.error("Error while parsing Lifecycle.xml", e);
    }
    KeyManagerConfigurationDataRetriever keyManagerConfigurationDataRetriever = new KeyManagerConfigurationDataRetriever(tenantDomain);
    keyManagerConfigurationDataRetriever.startLoadKeyManagerConfigurations();
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) KeyManagerConfigurationDataRetriever(org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever) FileNotFoundException(java.io.FileNotFoundException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) FileNotFoundException(java.io.FileNotFoundException) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) XMLStreamException(javax.xml.stream.XMLStreamException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) XMLStreamException(javax.xml.stream.XMLStreamException) ThrottleProperties(org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)

Example 3 with KeyManagerConfigurationDataRetriever

use of org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever in project carbon-apimgt by wso2.

the class KeyManagerHolder method getTenantKeyManagerDto.

private static OrganizationKeyManagerDto getTenantKeyManagerDto(String tenantDomain) {
    OrganizationKeyManagerDto organizationKeyManagerDto = organizationWiseMap.get(tenantDomain);
    if (organizationKeyManagerDto == null) {
        synchronized ("KeyManagerHolder".concat(tenantDomain)) {
            if (organizationKeyManagerDto == null) {
                new KeyManagerConfigurationDataRetriever(tenantDomain).run();
                organizationKeyManagerDto = organizationWiseMap.get(tenantDomain);
            }
        }
    }
    return organizationKeyManagerDto;
}
Also used : KeyManagerConfigurationDataRetriever(org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever) OrganizationKeyManagerDto(org.wso2.carbon.apimgt.impl.dto.OrganizationKeyManagerDto)

Aggregations

KeyManagerConfigurationDataRetriever (org.wso2.carbon.apimgt.impl.loader.KeyManagerConfigurationDataRetriever)3 FileNotFoundException (java.io.FileNotFoundException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)1 OrganizationKeyManagerDto (org.wso2.carbon.apimgt.impl.dto.OrganizationKeyManagerDto)1 ThrottleProperties (org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1