View Javadoc

1   package org.kuali.common.deploy;
2   
3   import java.util.Arrays;
4   import java.util.List;
5   
6   import org.jasypt.util.text.BasicTextEncryptor;
7   import org.junit.Test;
8   import org.kuali.common.util.secure.DefaultSecureChannel;
9   
10  public class AppDynamicsMonitoringTest {
11  
12  	@Test
13  	public void test() {
14  		try {
15  			DefaultSecureChannel channel = new DefaultSecureChannel();
16  			channel.setUsername("root");
17  			channel.setHostname("env16.ks.kuali.org");
18  			channel.setStrictHostKeyChecking(false);
19  			channel.setUseConfigFile(false);
20  			channel.setPrivateKeyStrings(getPrivateKeys());
21  
22  			AppDynamicsMonitoring adm = new AppDynamicsMonitoring();
23  			adm.setUser("tomcat");
24  			adm.setGroup("tomcat");
25  			adm.setMachineAgent(getMachineAgent());
26  			adm.setChannel(channel);
27  
28  			channel.open();
29  			adm.stop();
30  			adm.prepare();
31  			adm.start();
32  			channel.close();
33  
34  		} catch (Exception e) {
35  			e.printStackTrace();
36  		}
37  	}
38  
39  	protected MachineAgent getMachineAgent() {
40  		MachineAgent agent = new MachineAgent();
41  		agent.setTmpDir("/usr/local/machine-agent/tmp");
42  		agent.setLogsDir("/usr/local/machine-agent/logs");
43  		agent.setStartupCommand("java -jar /usr/local/machine-agent/machineagent.jar");
44  		return agent;
45  	}
46  
47  	protected List<String> getPrivateKeys() {
48  		BasicTextEncryptor bte = new BasicTextEncryptor();
49  		bte.setPassword(System.getProperty("kuali.enc.password"));
50  		String encryptedKey = "O3coQZzv5DtdDiYB3GfslTltWCrk1KIoAJDDGgAT7tP83GYs9Rxxe6JpdaX54Vk4akBu84y5IzHOQ356EYGT/IYL7IN4n8kYchGmuz5RHKD2m8dTuEUiUoHgIvhu80iBg/ZzMHanL/U64ZQK3tWXy/Uz1DaD8F+BXBFvAXfnwOW91j9TRsGkPOJRmJjgOb/CfXPUVVDfiVVw1LTseCejcE+yHsYWHONwquTqf3858k4vcWz1C+mTj89DVJpfZBNY/69YIaO8c2l1Il+6z8wR7ZIoDuVEsOjv0nud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knGR+k42TfIntILduOWBFPIr+ddwlozcXrHe6s09LcXg0oCxJGXdbKiLyJcKF42E1o/kKUCNe/smvp7XFIcqifFAcjyVGwF9JAfAqbv1X3xq08f49kmYGtmAim6SaQWrBmlhlFlzcg83NQdQJ0PpNq3zyPdJ+GHQ0pKcxy3ezZHz3Tvhtt+BeYa4tHxHdvNgjnxGKYcBPIZVbZ0+Ir65kP4IHrWeG4OvGOJh1LBYV2XkNCc9qTDHS1yAQI5lexFHvAdRbgEUcnc/InPtZY9NoLtid/gJGyuIK0LHvNpDusv46Ev0mlX1LBa0mW+koPobJoWT3ONb+iVb7rfVCewurGGwEMz2SSBcHS3VRUCGUmuGNoLypkgb0hXuX+PM393Ch4AJTCrYha2bk7qsLge4S0impcWeaccvJx7dDLGZOP5Vc+QiVdlMsy3tZKqTdN/VTphtQIEFN7SxnBgXRhqQLz4zdFQ2VIYt6KcdJTrb5/y6YzPWGxp85JcWg6GC/uT1M9vEqkBW4qvclYPyHaRSmcT1ezdxLulMAhsp2xJtG82Rn0AlNNfSG8PXyC5bCA4W3ogTKMe6eUJd7OXAPoiNNtFahnnXMprAQTXgAprx3ojbpJzFuOdcvafFXdQQqWhXZMcdsn3J70XhRKmmkgJ3Qtr67JPLCcphagOmz06TbPzo4VruEOdc25MD1CJLrviQ3w3ON11FW9dqATXbsFO6hQNkGOraltAZgc9t5w/eVbMVGM4B6xyV6khSg0g21f9wf84qW+yrhlmNcUJviA9iBhndSUPmNIBytOOV/h0Y+Y/e/inu4CSlylysK34ZZcsd41xtxFt3pWdj5df6r3UliDpqLLm9JaPBs10UJReA";
51  		String decryptedKey = bte.decrypt(encryptedKey);
52  		return Arrays.asList(decryptedKey);
53  	}
54  }