org.wso2.carbon.base.CarbonBaseUtils Java Examples
The following examples show how to use
org.wso2.carbon.base.CarbonBaseUtils.
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: AbstractKeyManagerConnectorConfiguration.java From carbon-apimgt with Apache License 2.0 | 6 votes |
private void convertJsonToConnectorConfiguration() { confiListMap.put(CONNECTOR_CONFIGURATION, Collections.emptyList()); confiListMap.put(APPLICATION_CONFIGURATIONS, Collections.EMPTY_LIST); String connectorConfigPath = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "resources" + File.separator + "keyManager-extensions" +File.separator+ keyManagerType + ".json"; File file = new File(connectorConfigPath); if (file.exists()) { try (FileInputStream fileInputStream = new FileInputStream(file)) { String content = IOUtils.toString(fileInputStream); Gson gson = new Gson(); Type configurationDtoType = new TypeToken<Map<String, List<ConfigurationDto>>>() { }.getType(); confiListMap = gson.fromJson(content, configurationDtoType); } catch (IOException e) { log.error("Error while reading connector configuration", e); } } }
Example #2
Source File: TestRabbitMQSecureVaultSupport.java From micro-integrator with Apache License 2.0 | 5 votes |
@BeforeClass(alwaysRun = true) public void init() throws Exception { super.init(); serverConfigurationManager = new ServerConfigurationManager(context); String secureVaultConfDir = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator + "securevault" + File.separator; String confDir = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator; //copy deployment.toml String srcToml = secureVaultConfDir + TOML_FILE; String targetToml = confDir + TOML_FILE; File srcTomlFile = new File(srcToml); File targetTomlFile = new File(targetToml); serverConfigurationManager.applyConfigurationWithoutRestart(srcTomlFile, targetTomlFile, true); //copy password-tmp String srcPasswordTemp = secureVaultConfDir + PASSWD_FILE; String targetPasswordTemp = CarbonBaseUtils.getCarbonHome() + File.separator + PASSWD_FILE; File srcPasswordTempFile = new File(srcPasswordTemp); File targetPasswordTempFile = new File(targetPasswordTemp); serverConfigurationManager.applyConfigurationWithoutRestart(srcPasswordTempFile, targetPasswordTempFile, false); //start server with new configs serverConfigurationManager.restartGracefully(); super.init(); sender = RabbitMQServerInstance.createProducerWithDeclaration(RABBITMQ_EXCHANGE, RABBITMQ_RX_QUEUE); //The consumer proxy cannot be pre-deployed since the queue declaration(which is done in 'initRabbitMQBroker') // must happen before deployment. loadESBConfigurationFromClasspath( "artifacts" + File.separator + "ESB" + File.separator + "securevault" + File.separator + SYNAPSE_CONFIG_FILE); }
Example #3
Source File: ESBJAVA5216CallMediatorPerAPILogTest.java From micro-integrator with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "Test PerAPI log print after call mediator") public void perAPILogPrintTest() throws Exception { String logFileLocation = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "logs" + File.separator + "api" + File.separator + "test" + File.separator + "LogPrint.log"; HttpResponse httpResponse = HttpRequestUtil.doPost(new URL(getApiInvocationURL("logprint")), ""); assertTrue(httpResponse.getResponseCode() == 200); assertTrue(httpResponse.getData() != null); String fileContent = FileManager.readFile(logFileLocation); log.info("Log file content: " + fileContent); assertTrue(fileContent.contains("After")); }
Example #4
Source File: HotDeploymentTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
private void deleteEndpoint() throws Exception { File f = new File(CarbonBaseUtils.getCarbonHome() + "/repository/deployment/server/synapse-configs/default/endpoints/hotUnDeploymentEp.xml"); if (f.exists()) { f.delete(); } }
Example #5
Source File: HotDeploymentTestCase.java From micro-integrator with Apache License 2.0 | 5 votes |
private boolean verifyFileIsAvailable() throws Exception { boolean available = false; File f = new File(CarbonBaseUtils.getCarbonHome() + "/repository/deployment/server/synapse-configs/default/endpoints/hotUnDeploymentEp.xml"); if (f.exists()) { available = true; } return available; }
Example #6
Source File: Sample651TestCase.java From product-ei with Apache License 2.0 | 5 votes |
@BeforeClass(alwaysRun = true) public void startJMSBrokerAndConfigureESB() throws Exception { super.init(); serverManager = new ServerConfigurationManager(context); String sourceLog4j = FrameworkPathUtil.getSystemResourceLocation() + File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig" + File.separator + "observer" + File.separator + "log4j.properties"; String targetLog4j = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "log4j.properties"; File sourceLog4jFile = new File(sourceLog4j); File targetLog4jFile = new File(targetLog4j); serverManager.applyConfigurationWithoutRestart(sourceLog4jFile, targetLog4jFile, true); String sourceSynapsePrp = FrameworkPathUtil.getSystemResourceLocation() + File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig" + File.separator + "observer" + File.separator + "synapse.properties"; String targetSynapsePrp = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "synapse.properties"; File sourceSynapsePrpFile = new File(sourceSynapsePrp); File targetSynapsePrpFile = new File(targetSynapsePrp); serverManager.applyConfiguration(sourceSynapsePrpFile, targetSynapsePrpFile); super.init(); logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); loadSampleESBConfiguration(100); }
Example #7
Source File: ESBJAVA5216CallMediatorPerAPILogTest.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "Test PerAPI log print after call mediator") public void perAPILogPrintTest() throws Exception { String logFileLocation = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "logs" + File.separator + "api" + File.separator + "test" + File.separator + "LogPrint.log"; HttpResponse httpResponse = HttpRequestUtil.doPost(new URL(getApiInvocationURL("logprint")), ""); assertTrue(httpResponse.getResponseCode() == 200); assertTrue(httpResponse.getData() != null); String fileContent = FileManager.readFile(logFileLocation); log.info("Log file content: " + fileContent); assertTrue(fileContent.contains("After")); }
Example #8
Source File: HotDeploymentTestCase.java From product-ei with Apache License 2.0 | 5 votes |
private void deleteEndpoint() throws Exception { File f = new File(CarbonBaseUtils.getCarbonHome() + "/repository/deployment/server/synapse-configs/default/endpoints/hotUnDeploymentEp.xml"); if (f.exists()) { f.delete(); } }
Example #9
Source File: HotDeploymentTestCase.java From product-ei with Apache License 2.0 | 5 votes |
private boolean verifyFileIsAvailable() throws Exception { boolean available = false; File f = new File(CarbonBaseUtils.getCarbonHome() + "/repository/deployment/server/synapse-configs/default/endpoints/hotUnDeploymentEp.xml"); if (f.exists()) { available = true; } return available; }
Example #10
Source File: CustomSSLProfileWithSecureVault.java From micro-integrator with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void init() throws Exception { super.init(); //cipher-text.properties file update serverConfigurationManager = new ServerConfigurationManager(context); String sourceCText = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "cipher-text.properties"; String targetCText = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "cipher-text.properties"; File sourceFileCText = new File(sourceCText); File targetFileCText = new File(targetCText); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileCText, targetFileCText, true); //cipher-tool.properties file update String sourceCTool = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "cipher-tool.properties"; String targetCTool = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "cipher-tool.properties"; File sourceFileCTool = new File(sourceCTool); File targetFileCTool = new File(targetCTool); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileCTool, targetFileCTool, true); //secret-conf.properties file update String sourceSecret = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "secret-conf.properties"; String targetSecret = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "secret-conf.properties"; File sourceFileSecret = new File(sourceSecret); File targetFileSecret = new File(targetSecret); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileSecret, targetFileSecret, true); //axis2.xml file update String sourceAxis2 = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "axis2.xml"; String targetAxis2 = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml"; File sourceFileAxis2 = new File(sourceAxis2); File targetFileAxis2 = new File(targetAxis2); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileAxis2, targetFileAxis2, true); //catalina-server.xml file update - this is required after carbon kernel 4.4.1 String sourceTomcat = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "catalina-server.xml"; String targetTomcat = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "tomcat" + File.separator + "catalina-server.xml"; File sourceFileTomcat = new File(sourceTomcat); File targetFileTomcat = new File(targetTomcat); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileTomcat, targetFileTomcat, true); //password-tmp file update String sourcePassTmp = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "password-tmp"; String targetPassTmp = CarbonBaseUtils.getCarbonHome() + separator + "password-tmp"; File sourceFilePassTmp = new File(sourcePassTmp); File targetFilePassTmp = new File(targetPassTmp); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFilePassTmp, targetFilePassTmp, false); serverConfigurationManager.restartGracefully(); super.init(); }
Example #11
Source File: ESBJAVA4770VFSPasswordSecurityWithLargekeyTestCase.java From micro-integrator with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void runFTPServer() throws Exception { String pathToFtpDir = getClass().getResource("/artifacts/ESB/synapseconfig/vfsTransport/").getPath(); // Local folder of the FTP server root File FTPFolder = new File(pathToFtpDir + "securePasswordFTP"); sampleFileFolder = new File(pathToFtpDir); // create FTP server root folder if not exists if (FTPFolder.exists()) { FileUtils.deleteDirectory(FTPFolder); } Assert.assertTrue(FTPFolder.mkdir(), "FTP root file folder not created"); // create a directory under FTP server root inputFolder = new File(FTPFolder.getAbsolutePath() + File.separator + inputFolderName); // create a directory under FTP server root outputFolder = new File(FTPFolder.getAbsolutePath() + File.separator + outputFolderName); if (inputFolder.exists()) { FileUtils.deleteDirectory(inputFolder); } if (outputFolder.exists()) { FileUtils.deleteDirectory(outputFolder); } Assert.assertTrue(inputFolder.mkdir(), "FTP data /in folder not created"); Assert.assertTrue(outputFolder.mkdir(), "FTP data /in folder not created"); //create and start sftp server which has user name and pass SFTPUser:SFTP321 sftpServerRunner = new SftpServerRunner(FTPPort, FTPFolder.getAbsolutePath(), USERNAME, PASSWORD); sftpServerRunner.start(); super.init(); File jksFile = new File( getClass().getResource("/artifacts/ESB/synapseconfig/vfsTransport" + "/ESBJAVA4770/vfsKeystore.jks") .getPath()); File destinationJks = Paths .get(CarbonBaseUtils.getCarbonHome(), "repository", "resources", "security", "vfsKeystore.jks") .toFile(); //copy keystore which contains key with keystrength 2048 copyFile(jksFile, destinationJks); // replace the axis2.xml enabled vfs transfer and restart the ESB server gracefully. serverConfigurationManager = new ServerConfigurationManager(context); serverConfigurationManager.applyMIConfiguration(new File( getClass().getResource("/artifacts/ESB/synapseconfig/" + "vfsTransport/ESBJAVA4770/deployment.toml") .getPath())); super.init(); }
Example #12
Source File: CustomSSLProfileWithSecureVault.java From product-ei with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void init() throws Exception { super.init(); //cipher-text.properties file update serverConfigurationManager = new ServerConfigurationManager(context); String sourceCText = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "cipher-text.properties"; String targetCText = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "cipher-text.properties"; File sourceFileCText = new File(sourceCText); File targetFileCText = new File(targetCText); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileCText, targetFileCText, true); //cipher-tool.properties file update String sourceCTool = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "cipher-tool.properties"; String targetCTool = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "cipher-tool.properties"; File sourceFileCTool = new File(sourceCTool); File targetFileCTool = new File(targetCTool); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileCTool, targetFileCTool, true); //secret-conf.properties file update String sourceSecret = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "secret-conf.properties"; String targetSecret = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator + "secret-conf.properties"; File sourceFileSecret = new File(sourceSecret); File targetFileSecret = new File(targetSecret); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileSecret, targetFileSecret, true); //axis2.xml file update String sourceAxis2 = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "axis2.xml"; String targetAxis2 = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml"; File sourceFileAxis2 = new File(sourceAxis2); File targetFileAxis2 = new File(targetAxis2); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileAxis2, targetFileAxis2, true); //catalina-server.xml file update - this is required after carbon kernel 4.4.1 String sourceTomcat = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "catalina-server.xml"; String targetTomcat = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "tomcat" + File.separator + "catalina-server.xml"; File sourceFileTomcat = new File(sourceTomcat); File targetFileTomcat = new File(targetTomcat); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFileTomcat, targetFileTomcat, true); //password-tmp file update String sourcePassTmp = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + separator + "synapseconfig" + separator + "customSSLprofileWithsecurevault" + separator + "password-tmp"; String targetPassTmp = CarbonBaseUtils.getCarbonHome() + separator + "password-tmp"; File sourceFilePassTmp = new File(sourcePassTmp); File targetFilePassTmp = new File(targetPassTmp); serverConfigurationManager.applyConfigurationWithoutRestart(sourceFilePassTmp, targetFilePassTmp, false); serverConfigurationManager.restartGracefully(); super.init(); }
Example #13
Source File: ESBJAVA4770VFSPasswordSecurityWithLargekeyTestCase.java From product-ei with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void runFTPServer() throws Exception { String pathToFtpDir = getClass().getResource("/artifacts/ESB/synapseconfig/vfsTransport/").getPath(); // Local folder of the FTP server root File FTPFolder = new File(pathToFtpDir + "securePasswordFTP"); sampleFileFolder = new File(pathToFtpDir); // create FTP server root folder if not exists if (FTPFolder.exists()) { FileUtils.deleteDirectory(FTPFolder); } Assert.assertTrue(FTPFolder.mkdir(), "FTP root file folder not created"); // create a directory under FTP server root inputFolder = new File(FTPFolder.getAbsolutePath() + File.separator + inputFolderName); // create a directory under FTP server root outputFolder = new File(FTPFolder.getAbsolutePath() + File.separator + outputFolderName); if (inputFolder.exists()) { FileUtils.deleteDirectory(inputFolder); } if (outputFolder.exists()) { FileUtils.deleteDirectory(outputFolder); } Assert.assertTrue(inputFolder.mkdir(), "FTP data /in folder not created"); Assert.assertTrue(outputFolder.mkdir(), "FTP data /in folder not created"); //create and start sftp server which has user name and pass SFTPUser:SFTP321 sftpServerRunner = new SftpServerRunner(FTPPort, FTPFolder.getAbsolutePath(), USERNAME, PASSWORD); sftpServerRunner.start(); super.init(); File jksFile = new File(getClass().getResource("/artifacts/ESB/synapseconfig/vfsTransport" + "/ESBJAVA4770/vfsKeystore.jks").getPath()); File destinationJks = Paths.get(CarbonBaseUtils.getCarbonHome(),"repository" ,"resources","security","vfsKeystore.jks").toFile(); //copy keystore which contains key with keystrength 2048 copyFile(jksFile, destinationJks); // replace the axis2.xml enabled vfs transfer and restart the ESB server gracefully. serverConfigurationManager = new ServerConfigurationManager(context); serverConfigurationManager.applyConfiguration( new File(getClass().getResource("/artifacts/ESB/synapseconfig/" + "vfsTransport/ESBJAVA4770/axis2.xml").getPath())); super.init(); }
Example #14
Source File: TestRabbitMQSecureVaultSupport.java From product-ei with Apache License 2.0 | 4 votes |
@BeforeClass(alwaysRun = true) public void init() throws Exception { super.init(); serverConfigurationManager = new ServerConfigurationManager(context); String secureVaultConfDir = FrameworkPathUtil.getSystemResourceLocation() + "artifacts" + File.separator + "ESB" + File.separator + "securevault" + File.separator; String carbonSecurityDir = CarbonBaseUtils.getCarbonHome() + File.separator + "conf" + File.separator + "security" + File.separator; //copy cipher-tool.properties String srcCipherTool = secureVaultConfDir + CIPHER_TOOL_PROP_FILE; String targetCipherTool = carbonSecurityDir + CIPHER_TOOL_PROP_FILE; File srcCipherToolFile = new File(srcCipherTool); File targetCipherToolFile = new File(targetCipherTool); serverConfigurationManager.applyConfigurationWithoutRestart(srcCipherToolFile, targetCipherToolFile, true); //copy cipher-text.properties String srcCipherText = secureVaultConfDir + CIPHER_TEXT_PROP_FILE; String targetCipherText = carbonSecurityDir + CIPHER_TEXT_PROP_FILE; File srcCipherTextFile = new File(srcCipherText); File targetCipherTextFile = new File(targetCipherText); serverConfigurationManager.applyConfigurationWithoutRestart(srcCipherTextFile, targetCipherTextFile, true); //copy secret-conf.properties String srcSecretConf = secureVaultConfDir + SECRET_CONF_PROP_FILE; String targetSecretConf = carbonSecurityDir + SECRET_CONF_PROP_FILE; File srcSecretConfFile = new File(srcSecretConf); File targetSecretConfFile = new File(targetSecretConf); serverConfigurationManager.applyConfigurationWithoutRestart(srcSecretConfFile, targetSecretConfFile, true); //copy axis2.xml String srcAxis2Xml = secureVaultConfDir + AXIS2_XML_FILE; String targetAxis2Xml = CarbonBaseUtils.getCarbonHome() + File.separator + "conf"+ File.separator + "axis2" + File.separator + AXIS2_XML_FILE; File srcAxis2XmlFile = new File(srcAxis2Xml); File targetAxis2XmlFile = new File(targetAxis2Xml); serverConfigurationManager.applyConfigurationWithoutRestart(srcAxis2XmlFile, targetAxis2XmlFile, true); //copy password-tmp String srcPasswordTemp = secureVaultConfDir + PASSWD_FILE; String targetPasswordTemp = CarbonBaseUtils.getCarbonHome() + File.separator + PASSWD_FILE; File srcPasswordTempFile = new File(srcPasswordTemp); File targetPasswordTempFile = new File(targetPasswordTemp); serverConfigurationManager.applyConfigurationWithoutRestart(srcPasswordTempFile, targetPasswordTempFile, false); //start server with new configs serverConfigurationManager.restartGracefully(); super.init(); sender = RabbitMQServerInstance.createProducerWithDeclaration(RABBITMQ_EXCHANGE, RABBITMQ_RX_QUEUE); //The consumer proxy cannot be pre-deployed since the queue declaration(which is done in 'initRabbitMQBroker') // must happen before deployment. loadESBConfigurationFromClasspath("artifacts" + File.separator + "ESB" + File.separator + "securevault" + File.separator + SYNAPSE_CONFIG_FILE); }