之前的的pay配置文件 ,现在需要做相关修改
该怎么编译出来
https://dangxia.lanzouf.com/imHuZ04rvj5c
给你反编译好了。
下载地址:
链接:https://pan.baidu.com/s/18tsR7O28rBpxnGreH8KI8Q
提取码:vkkq
这个class的package是什么,发一下
怎么不用IDE
直接反编译出来时这样的
package pay.wechat;
import cn.com.lj.util.pay.wechat.HttpClientUtil;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WeiXinHttpClient {
Logger logger = LoggerFactory.getLogger(cn.com.lj.util.pay.wechat.WeiXinHttpClient.class);
private static final String USER_AGENT_VALUE = "Mozilla/4.0 (compatible; MSIE 6.0; Windows XP)";
private static final String JKS_CA_FILENAME = "tenpay_cacert.jks";
private static final String JKS_CA_ALIAS = "tenpay";
private static final String JKS_CA_PASSWORD = "";
private File caFile;
private File certFile;
private String certPasswd;
private String reqContent;
private String resContent;
private String method;
private String errInfo;
private int timeOut;
private int responseCode;
private String charset;
private InputStream inputStream;
public WeiXinHttpClient() {
this.caFile = null;
this.certFile = null;
this.certPasswd = "";
this.reqContent = "";
this.resContent = "";
this.method = "POST";
this.errInfo = "";
this.timeOut = 30;
this.responseCode = 0;
this.charset = "UTF-8";
this.inputStream = null;
}
public void setCertInfo(File certFile, String certPasswd) {
this.certFile = certFile;
this.certPasswd = certPasswd;
}
public void setCaInfo(File caFile) {
this.caFile = caFile;
}
public void setReqContent(String reqContent) {
this.reqContent = reqContent;
}
public String getResContent() {
try {
doResponse();
} catch (IOException e) {
this.errInfo = e.getMessage();
}
return this.resContent;
}
public void setMethod(String method) {
this.method = method;
}
public String getErrInfo() {
return this.errInfo;
}
public void setTimeOut(int timeOut) {
this.timeOut = timeOut;
}
public int getResponseCode() {
return this.responseCode;
}
public boolean call() {
boolean isRet = false;
if (null == this.caFile && null == this.certFile) {
try {
callHttp();
isRet = true;
} catch (IOException e) {
this.errInfo = e.getMessage();
}
return isRet;
}
try {
callHttps();
isRet = true;
} catch (UnrecoverableKeyException e) {
this.errInfo = e.getMessage();
} catch (KeyManagementException e) {
this.errInfo = e.getMessage();
} catch (CertificateException e) {
this.errInfo = e.getMessage();
} catch (KeyStoreException e) {
this.errInfo = e.getMessage();
} catch (NoSuchAlgorithmException e) {
this.errInfo = e.getMessage();
} catch (IOException e) {
this.errInfo = e.getMessage();
}
return isRet;
}
protected void callHttp() throws IOException {
if ("POST".equals(this.method.toUpperCase())) {
String url = HttpClientUtil.getURL(this.reqContent);
String queryString = HttpClientUtil.getQueryString(this.reqContent);
byte[] postData = queryString.getBytes(this.charset);
httpPostMethod(url, postData);
return;
}
httpGetMethod(this.reqContent);
}
public boolean callHttpPost(String url, String postdata) {
boolean flag = false;
try {
byte[] postData = postdata.getBytes(this.charset);
httpPostMethod(url, postData);
flag = true;
} catch (IOException e1) {
e1.printStackTrace();
}
return flag;
}
protected void callHttps() throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException {
String caPath = this.caFile.getParent();
File jksCAFile = new File(caPath + "/" + "tenpay_cacert.jks");
if (!jksCAFile.isFile()) {
X509Certificate cert = (X509Certificate)HttpClientUtil.getCertificate(this.caFile);
FileOutputStream out = new FileOutputStream(jksCAFile);
HttpClientUtil.storeCACert(cert, "tenpay", "", out);
out.close();
}
FileInputStream trustStream = new FileInputStream(jksCAFile);
FileInputStream keyStream = new FileInputStream(this.certFile);
SSLContext sslContext = HttpClientUtil.getSSLContext(trustStream, "", keyStream, this.certPasswd);
keyStream.close();
trustStream.close();
if ("POST".equals(this.method.toUpperCase())) {
String url = HttpClientUtil.getURL(this.reqContent);
String queryString = HttpClientUtil.getQueryString(this.reqContent);
byte[] postData = queryString.getBytes(this.charset);
httpsPostMethod(url, postData, sslContext);
return;
}
httpsGetMethod(this.reqContent, sslContext);
}
protected void httpPostMethod(String url, byte[] postData) throws IOException {
HttpURLConnection conn = HttpClientUtil.getHttpURLConnection(url);
doPost(conn, postData);
}
protected void httpGetMethod(String url) throws IOException {
HttpURLConnection httpConnection = HttpClientUtil.getHttpURLConnection(url);
setHttpRequest(httpConnection);
httpConnection.setRequestMethod("GET");
this.responseCode = httpConnection.getResponseCode();
this.inputStream = httpConnection.getInputStream();
}
protected void httpsGetMethod(String url, SSLContext sslContext) throws IOException {
SSLSocketFactory sf = sslContext.getSocketFactory();
HttpsURLConnection conn = HttpClientUtil.getHttpsURLConnection(url);
conn.setSSLSocketFactory(sf);
doGet(conn);
}
protected void httpsPostMethod(String url, byte[] postData, SSLContext sslContext) throws IOException {
SSLSocketFactory sf = sslContext.getSocketFactory();
HttpsURLConnection conn = HttpClientUtil.getHttpsURLConnection(url);
conn.setSSLSocketFactory(sf);
doPost(conn, postData);
}
protected void setHttpRequest(HttpURLConnection httpConnection) {
httpConnection.setConnectTimeout(this.timeOut * 1000);
httpConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows XP)");
httpConnection.setUseCaches(false);
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
}
protected void doResponse() throws IOException {
if (null == this.inputStream)
return;
BufferedReader reader = new BufferedReader(new InputStreamReader(this.inputStream, this.charset));
this.resContent = HttpClientUtil.bufferedReader2String(reader);
reader.close();
this.inputStream.close();
}
protected void doPost(HttpURLConnection conn, byte[] postData) throws IOException {
conn.setRequestMethod("POST");
setHttpRequest(conn);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded ");
BufferedOutputStream out = new BufferedOutputStream(conn.getOutputStream());
int len = 1024;
HttpClientUtil.doOutput(out, postData, 1024);
out.close();
this.responseCode = conn.getResponseCode();
this.inputStream = conn.getInputStream();
}
protected void doGet(HttpURLConnection conn) throws IOException {
conn.setRequestMethod("GET");
setHttpRequest(conn);
this.responseCode = conn.getResponseCode();
this.inputStream = conn.getInputStream();
}
public String sendPostMsg(String reqUrl, String requestUrl) {
String result = "";
OutputStreamWriter out = null;
BufferedReader in = null;
try {
URL url = new URL(reqUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setConnectTimeout(60000);
conn.setReadTimeout(60000);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Length", requestUrl.length() + "");
String encode = "UTF-8";
out = new OutputStreamWriter(conn.getOutputStream(), encode);
out.write(requestUrl);
out.flush();
if (conn.getResponseCode() != 200)
return null;
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = "";
StringBuffer strBuf = new StringBuffer();
while ((line = in.readLine()) != null)
strBuf.append(line).append("\n");
result = strBuf.toString().trim();
} catch (Exception e) {
this.logger.error("sendPostMsg--error--is:", e);
} finally {
try {
in.close();
out.close();
} catch (IOException e) {
this.logger.error("sendPostMsg--closeio--error--is:", e);
}
}
return result;
}
}