Skip to content

Commit

Permalink
帮助文档优化
Browse files Browse the repository at this point in the history
  • Loading branch information
egzosn committed Jan 21, 2018
1 parent f7ba1f4 commit 7abcdab
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 175 deletions.
2 changes: 1 addition & 1 deletion pay-java-ali/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

```java

Map result = service..query("支付宝单号", "我方系统单号");
Map result = service.query("支付宝单号", "我方系统单号");

```

Expand Down
2 changes: 1 addition & 1 deletion pay-java-ali/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pay-java-parent</artifactId>
<groupId>com.egzosn</groupId>
<version>2.0.6-SNAPSHOT</version>
<version>2.0.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pay-java-ali</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pay-java-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pay-java-parent</artifactId>
<groupId>com.egzosn</groupId>
<version>2.0.6-SNAPSHOT</version>
<version>2.0.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* 请求实体
*
* @author egan
* @email [email protected]
* @date 2017/12/20
* <pre>
* email [email protected]
* date 2017/12/20
* </pre>
*/
public class HttpStringEntity extends StringEntity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public static String getMapToParameters(Map pe){
*
* @param str 需要解析的字符串
* @return 解析的结果map
* @throws UnsupportedEncodingException
*/
public static JSONObject getParametersToMap (String str) {

Expand Down
40 changes: 17 additions & 23 deletions pay-java-common/src/main/java/com/egzosn/pay/common/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import java.math.BigInteger;

public class Util
{
public class Util{
/**
* 整形转换成网络传输的字节流(字节数组)型数据
*
Expand Down Expand Up @@ -61,8 +60,8 @@ public static byte[] longToBytes(long num)
/**
* 大数字转换字节流(字节数组)型数据
*
* @param n
* @return
* @param n 大整形
* @return 字节数组
*/
public static byte[] byteConvert32Bytes(BigInteger n)
{
Expand Down Expand Up @@ -96,8 +95,8 @@ else if(n.toByteArray().length == 32)
/**
* 换字节流(字节数组)型数据转大数字
*
* @param b
* @return
* @param b 字节数组
* @return 大整形
*/
public static BigInteger byteConvertInteger(byte[] b)
{
Expand All @@ -114,8 +113,8 @@ public static BigInteger byteConvertInteger(byte[] b)
/**
* 根据字节数组获得值(十六进制数字)
*
* @param bytes
* @return
* @param bytes 字节数组
* @return 16进制字符串
*/
public static String getHexString(byte[] bytes)
{
Expand All @@ -125,9 +124,9 @@ public static String getHexString(byte[] bytes)
/**
* 根据字节数组获得值(十六进制数字)
*
* @param bytes
* @param upperCase
* @return
* @param bytes 字节数组
* @param upperCase 是否大写
* @return 转换后的字符串
*/
public static String getHexString(byte[] bytes, boolean upperCase)
{
Expand All @@ -142,7 +141,7 @@ public static String getHexString(byte[] bytes, boolean upperCase)
/**
* 打印十六进制字符串
*
* @param bytes
* @param bytes 字节数组
*/
public static void printHexString(byte[] bytes)
{
Expand Down Expand Up @@ -187,8 +186,7 @@ public static byte[] hexStringToBytes(String hexString)
/**
* Convert char to byte
*
* @param c
* char
* @param c char
* @return byte
*/
public static byte charToByte(char c)
Expand Down Expand Up @@ -327,8 +325,7 @@ protected static int toDigit(char ch, int index) {
/**
* 数字字符串转ASCII码字符串
*
* @param String
* 字符串
* @param content 字符串
* @return ASCII字符串
*/
public static String StringToAsciiString(String content) {
Expand Down Expand Up @@ -389,8 +386,7 @@ public static int hexStringToAlgorism(String hex) {
/**
* 十六转二进制
*
* @param hex
* 十六进制字符串
* @param hex 十六进制字符串
* @return 二进制字符串
*/
public static String hexStringToBinary(String hex) {
Expand Down Expand Up @@ -456,8 +452,7 @@ public static String hexStringToBinary(String hex) {
/**
* ASCII码字符串转数字字符串
*
* @param String
* ASCII字符串
* @param content ASCII字符串
* @return 字符串
*/
public static String AsciiStringToString(String content) {
Expand Down Expand Up @@ -532,8 +527,7 @@ public static int binaryToAlgorism(String binary) {
/**
* 十进制转换为十六进制字符串
*
* @param algorism
* int 十进制的数字
* @param algorism 十进制的数字
* @return String 对应的十六进制字符串
*/
public static String algorismToHEXString(int algorism) {
Expand Down Expand Up @@ -609,7 +603,7 @@ public static int parseToInt(String s, int defaultInt) {

/**
* 十六进制串转化为byte数组
*
*@param hex 16进制的字符
* @return the array of byte
*/
public static byte[] hexToByte(String hex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@


/**
* @ClassName: CertDescriptor
* @Description: acpsdk证书工具类,主要用于对证书的加载和使用
* @date 2016-7-22 下午2:46:20
* acpsdk证书工具类,主要用于对证书的加载和使用
* date 2016-7-22 下午2:46:20
* 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
*/
public class CertDescriptor {
Expand All @@ -46,8 +45,8 @@ public class CertDescriptor {

/**
* 通过证书路径初始化为公钥证书
* @param path
* @return
* @param path 证书地址
* @return X509 证书
*/
private static X509Certificate initCert(String path) {
X509Certificate encryptCertTemp = null;
Expand Down Expand Up @@ -79,7 +78,7 @@ private static X509Certificate initCert(String path) {
/**
* 通过keyStore 获取私钥签名证书PrivateKey对象
*
* @return
* @return PrivateKey 私钥
*/
public PrivateKey getSignCertPrivateKey(String pwd) {
try {
Expand Down Expand Up @@ -133,12 +132,9 @@ public String getSignCertId() {
/**
* 将签名私钥证书文件读取为证书存储对象
*
* @param signCertPath
* 证书文件名
* @param signCertPwd
* 证书密码
* @param signCertType
* 证书类型
* @param signCertPath 证书文件名
* @param signCertPwd 证书密码
* @param signCertType 证书类型
*/
public void initPrivateSignCert(String signCertPath, String signCertPwd, String signCertType) {

Expand All @@ -158,12 +154,9 @@ public void initPrivateSignCert(String signCertPath, String signCertPwd, String
/**
* 将签名私钥证书文件读取为证书存储对象
*
* @param pfxkeyfile
* 证书文件名
* @param keypwd
* 证书密码
* @param type
* 证书类型
* @param pfxkeyfile 证书文件名
* @param keypwd 证书密码
* @param type 证书类型
* @return 证书对象
* @throws IOException
*/
Expand Down Expand Up @@ -208,49 +201,12 @@ private String getCertIdIdByStore(KeyStore keyStore) {
return null;
}
}

/**
* 使用模和指数生成RSA公钥 注意:此代码用了默认补位方式,为RSA/None/PKCS1Padding,不同JDK默认的补位方式可能不同
*
* @param modulus
* 模
* @param exponent
* 指数
* @return
*/
private PublicKey getPublicKey(String modulus, String exponent) {
try {
BigInteger b1 = new BigInteger(modulus);
BigInteger b2 = new BigInteger(exponent);
KeyFactory keyFactory = KeyFactory.getInstance("RSA", "BC");
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(b1, b2);
return keyFactory.generatePublic(keySpec);
} catch (Exception e) {
log.error("构造RSA公钥失败:" + e);
return null;
}
}

/**
* 将字符串转换为X509Certificate对象.
*
* @param x509CertString
* @return
*/
public X509Certificate genCertificateByStr(String x509CertString) {
X509Certificate x509Cert = null;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC");
InputStream tIn = new ByteArrayInputStream(x509CertString.getBytes("ISO-8859-1"));
x509Cert = (X509Certificate) cf.generateCertificate(tIn);
} catch (Exception e) {
log.error("gen certificate error", e);
}
return x509Cert;
}



/**
* 加载中级证书
* 加载中级证书
* @param certPath 证书地址
*/
public void initPublicCert(String certPath) {
if (!StringUtils.isEmpty(certPath)) {
Expand All @@ -260,8 +216,10 @@ public void initPublicCert(String certPath) {
log.info("PublicKeyCert is empty");
}
}

/**
* 加载根证书
* @param certPath 证书地址
*/
public void initRootCert(String certPath) {
if (!StringUtils.isEmpty(certPath)) {
Expand All @@ -274,57 +232,24 @@ public void initRootCert(String certPath) {

/**
* 获取公钥/中级证书
* @return
* @return X509Certificate
*/
public X509Certificate getPublicCert() {
return publicKeyCert;
}

/**
* 获取中级证书
* @return
* @return X509Certificate
*/
public X509Certificate getRootCert() {
return rootKeyCert;
}


/**
* 获取证书的CN
* @param aCert
* @return
*/
private String getIdentitiesFromCertficate(X509Certificate aCert) {
String tDN = aCert.getSubjectDN().toString();
String tPart = "";
if ((tDN != null)) {
String tSplitStr[] = tDN.substring(tDN.indexOf("CN=")).split("@");
if (tSplitStr != null && tSplitStr.length > 2
&& tSplitStr[2] != null)
tPart = tSplitStr[2];
}
return tPart;
}





/**
* 证书文件过滤器
*
*/
static class CerFilter implements FilenameFilter {
public boolean isCer(String name) {
if (name.toLowerCase().endsWith(".cer")) {
return true;
} else {
return false;
}
}
public boolean accept(File dir, String name) {
return isCer(name);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
/**
* SHA1签名工具
* @author Actinia
* @email [email protected]
* @create 2017 2017/11/27 0027
* <pre>
* email [email protected]
*
* create 2017 2017/11/27 0027
* </pre>
*/
public class SHA1 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
/**
* @author Actinia
* @email [email protected]
* @create 2017 2017/11/27 0027
* <pre>
* email [email protected]
* create 2017 2017/11/27 0027
* </pre>
*/
public class SHA256 {

Expand Down
Loading

0 comments on commit 7abcdab

Please sign in to comment.