use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIAuthenticationHandlerTestCase method testDestroy.
/*
* This method will test for destroy()
* */
@Test
public void testDestroy() {
APIAuthenticationHandler apiAuthenticationHandler = new APIAuthenticationHandler();
apiAuthenticationHandler.destroy();
SynapseEnvironment synapseEnvironment = Mockito.mock(SynapseEnvironment.class);
SynapseConfiguration synapseConfiguration = Mockito.mock(SynapseConfiguration.class);
AxisConfiguration axisConfiguration = Mockito.mock(AxisConfiguration.class);
Mockito.when(synapseEnvironment.getSynapseConfiguration()).thenReturn(synapseConfiguration);
Mockito.when(synapseConfiguration.getAxisConfiguration()).thenReturn(axisConfiguration);
PowerMockito.mockStatic(Util.class);
PowerMockito.when(Util.getTenantDomain()).thenReturn("carbon.super");
apiAuthenticationHandler.init(synapseEnvironment);
apiAuthenticationHandler.destroy();
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIUtil method getManagementTransportPort.
public static int getManagementTransportPort(String mgtTransport) {
if (StringUtils.isEmpty(mgtTransport)) {
mgtTransport = APIConstants.HTTPS_PROTOCOL;
}
AxisConfiguration axisConfiguration = ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration();
int mgtTransportPort = CarbonUtils.getTransportProxyPort(axisConfiguration, mgtTransport);
if (mgtTransportPort <= 0) {
mgtTransportPort = CarbonUtils.getTransportPort(axisConfiguration, mgtTransport);
}
return mgtTransportPort;
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class APIUtil method isProxyPortEnabled.
/*
* Checks whether the proxy port is configured.
* @param transport The transport
* @return boolean proxyport is enabled
* */
public static boolean isProxyPortEnabled(String mgtTransport) {
AxisConfiguration axisConfiguration = ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration();
int mgtTransportProxyPort = CarbonUtils.getTransportProxyPort(axisConfiguration, mgtTransport);
return mgtTransportProxyPort > 0;
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class TenantLoadMessageSenderTest method testGetClusteringAgent.
@Test
public void testGetClusteringAgent() {
PowerMockito.mockStatic(ServiceReferenceHolder.class);
ConfigurationContextService configurationContextService = PowerMockito.mock(ConfigurationContextService.class);
PowerMockito.when(ServiceReferenceHolder.getContextService()).thenReturn(configurationContextService);
ConfigurationContext serverConfigContext = PowerMockito.mock(ConfigurationContext.class);
PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext()).thenReturn(serverConfigContext);
AxisConfiguration axisConfiguration = PowerMockito.mock(AxisConfiguration.class);
PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration()).thenReturn(axisConfiguration);
ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class);
PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration().getClusteringAgent()).thenReturn(clusteringAgent);
tenantLoadMessageSender.getClusteringAgent();
}
use of org.apache.axis2.engine.AxisConfiguration in project carbon-apimgt by wso2.
the class TenantServiceCreator method createdConfigurationContext.
public void createdConfigurationContext(ConfigurationContext configurationContext) {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
log.info("Initializing APIM TenantServiceCreator for the tenant domain : " + tenantDomain);
try {
// first check which configuration should be active
org.wso2.carbon.registry.core.Registry registry = (org.wso2.carbon.registry.core.Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
// initialize the lock
Lock lock = new ReentrantLock();
axisConfig.addParameter("synapse.config.lock", lock);
// creates the synapse configuration directory hierarchy if not exists
// useful at the initial tenant creation
File tenantAxis2Repo = new File(configurationContext.getAxisConfiguration().getRepository().getFile());
File synapseConfigsDir = new File(tenantAxis2Repo, "synapse-configs");
if (!synapseConfigsDir.exists()) {
if (!synapseConfigsDir.mkdir()) {
log.fatal("Couldn't create the synapse-config root on the file system " + "for the tenant domain : " + tenantDomain);
return;
}
}
String synapseConfigsDirLocation = synapseConfigsDir.getAbsolutePath();
// set the required configuration parameters to initialize the ESB
axisConfig.addParameter(SynapseConstants.Axis2Param.SYNAPSE_CONFIG_LOCATION, synapseConfigsDirLocation);
// init the multiple configuration tracker
ConfigurationManager manger = new ConfigurationManager((UserRegistry) registry, configurationContext);
manger.init();
File synapseConfigDir = new File(synapseConfigsDir, manger.getTracker().getCurrentConfigurationName());
StringBuilder filepath = new StringBuilder();
filepath.append(synapseConfigsDir).append('/').append(manger.getTracker().getCurrentConfigurationName()).append('/').append(MultiXMLConfigurationBuilder.SEQUENCES_DIR).append('/').append(authFailureHandlerSequenceName).append(".xml");
File authFailureHandlerSequenceNameFile = new File(filepath.toString());
// sequence synapse configurations by using resource artifacts
if (!authFailureHandlerSequenceNameFile.exists()) {
createTenantSynapseConfigHierarchy(synapseConfigDir, tenantDomain);
}
String graphqlFilepath = String.valueOf(synapseConfigsDir) + '/' + manger.getTracker().getCurrentConfigurationName() + '/' + MultiXMLConfigurationBuilder.SEQUENCES_DIR + '/' + graphqlAuthFailureHandlerSequenceName + ".xml";
File graphqlFailureHandlerSequenceNameFile = new File(graphqlFilepath);
if (!graphqlFailureHandlerSequenceNameFile.exists()) {
createTenantSynapseConfigHierarchy(synapseConfigDir, tenantDomain);
}
String threatFaultConfigLocation = synapseConfigsDir.getAbsolutePath() + File.separator + manger.getTracker().getCurrentConfigurationName() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + threatFaultSequenceName + ".xml";
File threatFaultXml = new File(threatFaultConfigLocation);
if (!threatFaultXml.exists()) {
FileUtils.copyFile(new File(synapseConfigRootPath + threatFaultSequenceName + ".xml"), new File(synapseConfigDir.getAbsolutePath() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + threatFaultSequenceName + ".xml"));
}
String blockingSequenceLocation = synapseConfigsDir.getAbsolutePath() + File.separator + manger.getTracker().getCurrentConfigurationName() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + blockingSequence + ".xml";
File blockingSequenceXml = new File(blockingSequenceLocation);
if (!blockingSequenceXml.exists()) {
FileUtils.copyFile(new File(synapseConfigRootPath + blockingSequence + ".xml"), new File(synapseConfigDir.getAbsolutePath() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + blockingSequence + ".xml"));
}
String backEndFailureSequence = synapseConfigsDir.getAbsolutePath() + File.separator + manger.getTracker().getCurrentConfigurationName() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + backendFailureSequenceName + ".xml";
File backendSequenceXml = new File(backEndFailureSequence);
if (!backendSequenceXml.exists()) {
FileUtils.copyFile(new File(synapseConfigRootPath + backendFailureSequenceName + ".xml"), new File(synapseConfigDir.getAbsolutePath() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + backendFailureSequenceName + ".xml"));
}
String opaPolicyFailureSequence = synapseConfigsDir.getAbsolutePath() + File.separator + manger.getTracker().getCurrentConfigurationName() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + opaPolicyFailureHandlerSequenceName + ".xml";
File opaPolicyFailureSequenceXml = new File(opaPolicyFailureSequence);
if (!opaPolicyFailureSequenceXml.exists()) {
FileUtils.copyFile(new File(synapseConfigRootPath + opaPolicyFailureHandlerSequenceName + ".xml"), new File(synapseConfigDir.getAbsolutePath() + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR + File.separator + opaPolicyFailureHandlerSequenceName + ".xml"));
}
} catch (RemoteException e) {
log.error("Failed to create Tenant's synapse sequences.", e);
} catch (Exception e) {
log.error("Failed to create Tenant's synapse sequences.", e);
}
// Create caches for tenants
CacheProvider.removeAllCaches();
CacheProvider.createGatewayKeyCache();
CacheProvider.createResourceCache();
CacheProvider.createGatewayTokenCache();
CacheProvider.createInvalidTokenCache();
CacheProvider.createGatewayBasicAuthResourceCache();
CacheProvider.createGatewayUsernameCache();
CacheProvider.createInvalidUsernameCache();
// Initialize product REST API token caches
CacheProvider.createRESTAPITokenCache();
CacheProvider.createRESTAPIInvalidTokenCache();
CacheProvider.createGatewayJWTTokenCache();
CacheProvider.createTenantConfigCache();
CacheProvider.createRecommendationsCache();
CacheProvider.createParsedSignJWTCache();
CacheProvider.createInvalidGatewayApiKeyCache();
CacheProvider.createGatewayInternalKeyCache();
CacheProvider.createGatewayInternalKeyDataCache();
CacheProvider.createInvalidInternalKeyCache();
}
Aggregations