feat:多机证书导入功能
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package sample;
|
||||
|
||||
import com.sunyard.SydApiException;
|
||||
import com.sunyard.entity.ServerConfig;
|
||||
import com.sunyard.proto.Util;
|
||||
import com.sunyard.snmp.SnmpTrapSender;
|
||||
import com.sunyard.util.CertUtil;
|
||||
import com.sunyard.util.SYMUtil;
|
||||
import org.junit.After;
|
||||
@@ -10,8 +12,10 @@ import org.junit.Test;
|
||||
import racal.sunyard.main.SydApi4j;
|
||||
import racal.sunyard.main.SydApiBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
@@ -25,21 +29,26 @@ public class Test4NongxinCW {
|
||||
|
||||
byte[] orgData = new byte[100];
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
// 通过设置debug的属性开启debug,如果不设置则默认不打开
|
||||
api = (SydApi4j) new SydApi4j().connect("172.16.17.34", 8889, null, 1000);
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
try {
|
||||
this.api.disconnect();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// @Before
|
||||
// public void before() {
|
||||
// // 通过设置debug的属性开启debug,如果不设置则默认不打开
|
||||
// api = (SydApi4j) new SydApi4j().connect("172.16.17.34", 8889, null, 1000);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void connection() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @After
|
||||
// public void after() {
|
||||
// try {
|
||||
// this.api.disconnect();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void nakeSign(){
|
||||
@@ -163,4 +172,38 @@ public class Test4NongxinCW {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importAllCert() {
|
||||
List<String> masterNodes = new ArrayList<>();
|
||||
masterNodes.add("192.168.55.80:3336");
|
||||
masterNodes.add("172.16.128.2:8889");
|
||||
masterNodes.add("172.16.128.3:8889");
|
||||
masterNodes.add("172.16.128.4:8889");
|
||||
int timeout = 1000;
|
||||
String pwd = null;
|
||||
String cert = "";
|
||||
SydApi4j sydApi4j = new SydApi4j();
|
||||
// sydApi4j.initSnmpTrapConfig("");
|
||||
sydApi4j.importCertToServers(masterNodes, timeout, cert);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void snmpTest() {
|
||||
try {
|
||||
SnmpTrapSender sender = SnmpTrapSender.getInstance();
|
||||
|
||||
// 发送不同级别的日志
|
||||
sender.sendTrap("Application started", 0);
|
||||
sender.sendTrap("High CPU usage", 1);
|
||||
sender.sendTrap("Database connection lost", 5);
|
||||
|
||||
sender.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user