区块链调试
This commit is contained in:
@ -22,11 +22,13 @@ import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -147,10 +149,15 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
* @return
|
||||
*/
|
||||
private String getSignValue(Object object){
|
||||
String signValue = "";
|
||||
try{
|
||||
log.debug("加密参数:"+JSONArray.toJSONString(object));
|
||||
URL pem = CrypConfigureServiceImpl.class.getClassLoader().getResource(PEM_PATH);
|
||||
String signValue = CrypServiceImpl.signObject(object,pem.getPath());
|
||||
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(PEM_PATH);
|
||||
signValue = CrypServiceImpl.signObject2(object,IOUtils.toString(is));
|
||||
log.debug("加密结果:"+signValue);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return signValue;
|
||||
}
|
||||
|
||||
@ -182,8 +189,8 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
reqhead.setSystemId("990001");
|
||||
reqhead.setSystemName("bidding");
|
||||
reqhead.setUserId(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"system");
|
||||
reqhead.setUserName(service.getCacheUser().getFullName()!=null?service.getCacheUser().getFullName():"电子招投标");
|
||||
reqhead.setUserId(service.getCacheUser().getUserId()!=null?service.getCacheUser().getUserId():"dzztb");
|
||||
reqhead.setUserName(service.getCacheUser().getFullName()!=null?service.getCacheUser().getFullName():"dzztb");
|
||||
//测试写死
|
||||
String accessToken = "MQjkzVoYoSHe6r/3uZm0MV/TLx+n8PS9ivfPhgY4bWmh+8DVxj7vTC15xbBkuV8oujD3XBZPP7PhcWag9UU5IzsUBT7PSwPhqi/fUqa+iAWhCWpvyihG/23BAY3rJyaoa3OdMNSnIh8woPDCJQTzCTpNtg0toKwdWnuc2mig7vI0Lm9lePvrx3XxFLSaFr+jB5C3qnAX4uUBioZzithSjtra1QUK6S1cb9DCmpj6NRI=";
|
||||
//String accessToken = AccessToken.tokenCreate("bidding");
|
||||
@ -213,9 +220,8 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
try{
|
||||
log.debug("解密参数:"+JSONArray.toJSONString(bean.getObject()));
|
||||
URL crt = CrypConfigureServiceImpl.class.getClassLoader().getResource(CRT_PATH);
|
||||
|
||||
Boolean b = CrypServiceImpl.verifyObject(bean.getSign(),bean.getObject(),crt.getPath());
|
||||
InputStream is = CrypConfigureServiceImpl.class.getClassLoader().getResourceAsStream(CRT_PATH);
|
||||
Boolean b = CrypServiceImpl.verifyValue(bean.getSign(),bean.getObject(),IOUtils.toString(is));
|
||||
return b;
|
||||
}catch (Exception e){
|
||||
|
||||
@ -226,35 +232,33 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, UnsupportedEncodingException {
|
||||
String token = AccessToken.tokenCreate("123");
|
||||
System.out.println(token);
|
||||
// String token = AccessToken.tokenCreate("123");
|
||||
// System.out.println(token);
|
||||
// example of HashMap entity, treeMap can also work out,
|
||||
// but LinkedHashMap is NOT supported
|
||||
// Map<String,Object> mapb= new HashMap<>();
|
||||
//
|
||||
// Map<String,String> map = new HashMap<>(1);
|
||||
// map.put("TENDERER_ID","8533");
|
||||
// map.put("SHOPPINGCART_ID","L3307");
|
||||
// map.put("AMOUNT","1000");
|
||||
// map.put("TP_ID","L3307A");
|
||||
// map.put("SECTION_ID","1111");
|
||||
//
|
||||
// List list = new ArrayList();
|
||||
// list.add(map);
|
||||
// //mapb.put("BODY_LIST",list);
|
||||
//
|
||||
// CrypConfigureServiceImpl crypService = new CrypConfigureServiceImpl();
|
||||
// CrypBean bean = crypService.signObject(list);
|
||||
// System.out.println(bean);
|
||||
Map<String,String> map = new HashMap<>(1);
|
||||
map.put("TENDERER_ID","8533");
|
||||
map.put("SHOPPINGCART_ID","L3307");
|
||||
map.put("AMOUNT","1000");
|
||||
map.put("TP_ID","L3307A");
|
||||
map.put("SECTION_ID","1111");
|
||||
|
||||
List list = new ArrayList();
|
||||
list.add(map);
|
||||
//mapb.put("BODY_LIST",list);
|
||||
|
||||
CrypConfigureServiceImpl crypService = new CrypConfigureServiceImpl();
|
||||
CrypBean bean = crypService.signObject(list);
|
||||
System.out.println(bean);
|
||||
|
||||
// System.out.println(mapb);
|
||||
//
|
||||
// String pkey = "-----BEGIN PRIVATE KEY-----\n" +
|
||||
// "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgfb0OcgWWFJGaOmVI\n" +
|
||||
// "LxEpIRTsICs0ssgJZqpuZQUhTIGhRANCAAQ8dPtVEfZfm2wXdqoqYpColaJ4MxiJ\n" +
|
||||
// "rFoUUMepAwuIQLaSZIH1+YbUkr/P+ybC1cbiBMrZjCxiAimk7dLxmUkx\n" +
|
||||
// "-----END PRIVATE KEY-----";
|
||||
// //"MEUCIQC0TNG+JlFa2kCwQOdYer69cA4psgDoK9ulqdKyK5BEwQIgFOlVofB+xDVOCSuj7t2Pp3z0fyyiuXPy5dRMsOMoh3U=";
|
||||
//"MEUCIQC0TNG+JlFa2kCwQOdYer69cA4psgDoK9ulqdKyK5BEwQIgFOlVofB+xDVOCSuj7t2Pp3z0fyyiuXPy5dRMsOMoh3U=";
|
||||
// String signature = CrypServiceImpl.signObject2(list,pkey);
|
||||
// System.out.println("signature of Map: "+signature);
|
||||
// boolean isOk = CrypServiceImpl.verifyObject(signature,list,CRT_PATH);
|
||||
|
Reference in New Issue
Block a user