|
@ -52,6 +52,16 @@ public class GuahaoService {
|
|
|
private String ORDER_INFO = "GetReservationRecord";//预约信息
|
|
|
private String REG_LIST = "GetRegList";//获取市民预约挂号信息
|
|
|
|
|
|
/** *//**
|
|
|
* RSA最大加密明文大小
|
|
|
*/
|
|
|
private static final int MAX_ENCRYPT_BLOCK = 117;
|
|
|
|
|
|
/** *//**
|
|
|
* RSA最大解密密文大小
|
|
|
*/
|
|
|
private static final int MAX_DECRYPT_BLOCK = 128;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
|
|
@ -1286,7 +1296,7 @@ public class GuahaoService {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取免疫接种机构列表
|
|
|
* @return
|
|
@ -1295,18 +1305,43 @@ public class GuahaoService {
|
|
|
String result = "";
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
String condition = "<root><zone>350203</zone><zone>350206</zone><zone>350205</zone><zone>350211</zone><zone>350212</zone><zone>350213</zone></root>";
|
|
|
|
|
|
|
|
|
ZysoftApi api = ZysoftApi.getSingleton();
|
|
|
|
|
|
condition = api.getConditionRSA(condition);
|
|
|
|
|
|
//加密后的东西
|
|
|
System.out.println("Condition: " + condition);
|
|
|
|
|
|
PublicKey publicKey=immPublicKeyget(api.getImmPublicKey());
|
|
|
|
|
|
byte[] encryptedBytes = this.encrypt(condition.getBytes(),publicKey);
|
|
|
|
|
|
condition = new String(encryptedBytes,"utf-8");
|
|
|
System.out.println(condition);
|
|
|
params.put("Condition", condition);
|
|
|
return immPostSecond("GetOrgImmuneList","计免预约-获取免疫接种机构列表",params);
|
|
|
}
|
|
|
|
|
|
|
|
|
public static byte[] encrypt(byte[] data, PublicKey publicKey) throws Exception{
|
|
|
Cipher cipher=Cipher.getInstance("RSA");//java默认"RSA"="RSA/ECB/PKCS1Padding"
|
|
|
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
|
|
|
|
|
int inputLen = data.length;
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
int offSet = 0;
|
|
|
byte[] cache;
|
|
|
int i = 0;
|
|
|
// 对数据分段加密
|
|
|
while (inputLen - offSet > 0) {
|
|
|
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
|
|
|
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
|
|
|
} else {
|
|
|
cache = cipher.doFinal(data, offSet, inputLen - offSet);
|
|
|
}
|
|
|
out.write(cache, 0, cache.length);
|
|
|
i++;
|
|
|
offSet = i * MAX_ENCRYPT_BLOCK;
|
|
|
}
|
|
|
byte[] encryptedData = out.toByteArray();
|
|
|
out.close();
|
|
|
return encryptedData;
|
|
|
}
|
|
|
|
|
|
public PublicKey immPublicKeyget(String filename) throws Exception {
|
|
|
File f = new File(filename);
|
|
|
FileInputStream fis = new FileInputStream(f);
|