/**
* RSA方式加签
*
* @param custId
* @param forEncryptionStr
* @param charset
* @return
* @throws Exception
*/
public static String encryptByRSA(String forEncryptionStr) throws Exception {
SecureLink sl = new SecureLink();
int result = sl.SignMsg(RECV_MER_ID, MER_PRI_KEY_PATH, forEncryptionStr);
if (result < 0) {
// 打印日志
throw new Exception();
}
return sl.getChkValue();
}
/**
* 解签
* @param forEncryptionStr
* @param chkValue
* @return
* @throws Exception
*/
public static boolean verifyByRSA(String forEncryptionStr, String chkValue)
throws Exception {
try {
int verifySignResult = new SecureLink().VeriSignMsg(MER_PUB_KEY_PATH, forEncryptionStr, chkValue);
return verifySignResult == RAS_VERIFY_SIGN_SUCCESS;
} catch (Exception e) {
// 打印日志
throw new Exception();
}
}
/**
*
* @Title: doPost
* @Description: TODO(汇付接口 后台提交)
* @param @param params 请求参数
* @param @return
* @param @throws ClientProtocolException
* @param @throws IOException 参数说明
* @return String 返回类型
* @author cjm
* @throws
*/
// 如果关注性能问题可以考虑使用HttpClientConnectionManager
public static String doPost(Map<String, String> params) throws ClientProtocolException, IOException{
String result = null;
HttpPost httpPost = new HttpPost(HttpClientHandler.HTTP_HOST);
CloseableHttpClient httpclient = HttpClients.createDefault();
if (params != null)
{
UrlEncodedFormEntity formEntiry = HttpClientHandler.buildUrlEncodedFormEntity(params);
httpPost.setEntity(formEntiry);
CloseableHttpResponse response = httpclient.execute(httpPost);
try
{
HttpEntity entity = response.getEntity();
if (response.getStatusLine().getReasonPhrase().equals("OK") && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
result = EntityUtils.toString(entity, "UTF-8");
EntityUtils.consume(entity);
} finally
{
response.close();
}
}
return result;
}
<div class="article_title">
<a href="http://linyi.changtu.com/">临沂汽车总站</a>
</div>