use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.
the class APIServiceTest method upload.
// @Test
public void upload() {
String url = "http://192.168.101.246:8080/portal/api/auth/upload";
// String url = "http://124.205.224.179:9018/portal/api/auth/upload";
String appId = "6175a9f8ae6c46";
String orderNumber = "20180103155436353349";
String image1 = this.getImgBase64();
String image2 = null;
String type = "6";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("appId", appId);
map.add("orderNumber", orderNumber);
map.add("image1", image1);
// map.add("image2", image2);
map.add("type", type);
try {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + orderNumber + image1 + image2 + type, "961cd91d5f7e4e658c2a133febf6cb5d"), false));
System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(getParam(), "961cd91d5f7e4e658c2a133febf6cb5d"), false));
HttpEntity httpEntity = new HttpEntity(map, headers);
ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
System.out.println("statusCode:" + resStr.getStatusCode());
System.out.println("body:" + resStr.getBody());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.
the class APIServiceTest method searchTest.
// @Test
public void searchTest() {
String url = "http://124.205.224.179:9018/portal/api/auth/search";
String appId = "41327e98e63e40";
String orderNumber = "20180115105237670994";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("appId", appId);
map.add("orderNumber", orderNumber);
try {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + orderNumber, "71fe63307ea64d698655452d8f99ff12"), false));
System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(appId + orderNumber, "71fe63307ea64d698655452d8f99ff12"), false));
HttpEntity httpEntity = new HttpEntity(map, headers);
ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
System.out.println("statusCode:" + resStr.getStatusCode());
System.out.println("body:" + resStr.getBody());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.
the class CertServiceTest method testSm2.
// @Test
public void testSm2() {
String url = "http://127.0.0.1:8080/portal/cert/make/sm2";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("csr", "MIHVMHoCAQAwGDEWMBQGA1UEAxMNaVRydXNVS0VZIFNESzBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABCIF8ZOhgigFw6loNoM3y6Qh17/QkxNqjmPBZ/TlmcvqaIn8EWPhLT4W7AzKSc/CoY31oK1LfpuC1LcFDxqY3R6gADAMBggqgRzPVQGDdQUAA0kAMEYCIQCsmotzp7xI8JbZUClqeIGIpfD/rmuY51uHM0zkUEndUAIhAJPXkPB13inIxaX8ECWifUS7FNnFbXY1D3qkicmDTApj");
map.add("userName", "zhanghl");
map.add("userEmail", "zhang@sina.com");
map.add("period", 10);
try {
HttpHeaders headers = new HttpHeaders();
// headers.add("authHmac", Base64.encode(HMACSHA1.getHmacSHA1(csr+billId+uid+userId, "xe3T+vTjGaSORTtfN2/KnQjfmlY="), false));
// System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(csr+billId+uid+userId, "xe3T+vTjGaSORTtfN2/KnQjfmlY="), false));
HttpEntity httpEntity = new HttpEntity(map, headers);
ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
System.out.println("statusCode:" + resStr.getStatusCode());
System.out.println("body:" + resStr.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.
the class DownVerifyTest method testName.
@Test
public void testName() throws Exception {
String url = "http://192.168.100.104:5082/storage/download";
String buid = "2cbf89ea555841b5a9b3fbd6b693e640";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("buid", buid);
try {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", AuthService.getHeader().get("Authorization"));
HttpEntity httpEntity = new HttpEntity(map, headers);
ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
System.out.println("statusCode:" + resStr.getStatusCode());
System.out.println("body:" + resStr.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.
the class GetRaInfoTask method getRaInfo.
/**
* 定时获取RA信息的定时器 心跳更新。启动时执行一次,之后每一天执行一次 1000*60*60*24
* @Scheduled(fixedRate = 1000 * 60 * 60 * 24)
* 设置为每天凌晨2点触发
* @Scheduled(cron = "0 0 2 * * ?")
*/
@Scheduled(cron = "0 0 2 * * ?")
public void getRaInfo() {
// 系统是否配置同步ra信息主机
SysConfig sysConfigHost = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoHost");
if (null == sysConfigHost) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
String host = sysConfigHost.getConfig();
host = host.replaceAll(" ", "");
String[] hosts = host.split(",");
// 获取本机主机名称
InetAddress ia = null;
try {
ia = ia.getLocalHost();
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}
String hostName = ia.getHostName();
boolean flag = false;
for (String str : hosts) {
if (hostName.equals(str.replaceAll(" ", ""))) {
flag = true;
}
}
// 判断本地主机名称是否与系统配置的ra信息同步主机名称一致,不一致则返回
if (!flag) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
// 系统是否配置同步ra信息开关
SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "openGetRaInfo");
if (null == sysConfig) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
if (sysConfig.getConfig().equals("false")) {
// LogUtil.syslog(sqlSession, type, info);
return;
}
// 系统是否配置同步ra信息地址
SysConfig sysConfigurl = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoUrl");
if (null == sysConfigurl) {
String type = "同步RA信息错误";
String info = "系统未配置RA信息同步地址";
LogUtil.syslog(sqlSession, type, info);
return;
}
// if(!isSyncGetRa()){
// return;
// }
// 证书ID的最大值
Integer maxCertId = 0;
// 每次更新的数目,默认是1000
Integer limit = 1000;
// 每天同步的数量
Integer everyDayNum = 1;
// 每天需要同步的次数
Integer count = 0;
// 每天成功同步的信息数量
successNum = new AtomicInteger(0);
SysConfig sysConfigNum = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", "raInfoNum");
if (null != sysConfigNum && StringUtils.isNotBlank(sysConfigNum.getConfig())) {
everyDayNum = Integer.parseInt(sysConfigNum.getConfig());
} else {
String type = "同步RA信息";
String info = "系统未配置RA信息同步数量";
LogUtil.syslog(sqlSession, type, info);
}
// 请求的url
String url = sysConfigurl.getConfig() + "/getRaList.jsp";
String limitString = limit.toString();
// 计算需要同步的次数
count = (everyDayNum + limit - 1) / limit;
for (int i = 0; i < count; i++) {
maxCertId = sqlSession.selectOne("com.itrus.portal.db.RaInfoMapper.selectMaxCertId");
if (null == maxCertId || maxCertId < 1) {
maxCertId = 0;
}
String maxCertIdString = maxCertId.toString();
// 设置请求参数
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("certId", maxCertIdString);
map.add("limit", limitString);
try {
// 发送请求
String resStr = restTemplate.postForObject(url, map, String.class);
// 解析响应信息
List<Map<String, Object>> list = jsonTool.readValue(resStr, List.class);
// 获取状态信息,0为错误,1为成功
Map<String, Object> statusMap = list.get(list.size() - 1);
Integer status = (Integer) statusMap.get("status");
if (0 == status) {
String type = "同步RA信息错误";
String info = (String) statusMap.get("message");
LogUtil.syslog(sqlSession, type, info);
return;
} else {
insertRaInfosIntoDB(list);
}
} catch (Exception e) {
e.printStackTrace();
String type = "同步RA信息出现异常";
String info = "成功同步:" + successNum + "条信息,异常信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG同步RA信息 {}", info);
return;
}
}
String type = "同步RA信息成功";
String info = "成功同步:" + successNum + "条信息";
LogUtil.syslog(sqlSession, type, info);
}
Aggregations