public class AlipaySignature extends Object
| Constructor and Description |
|---|
AlipaySignature() |
| Modifier and Type | Method and Description |
|---|---|
static String |
checkSignAndDecrypt(Map<String,String> params,
String alipayPublicKey,
String cusPrivateKey,
boolean isCheckSign,
boolean isDecrypt)
验签并解密
|
static String |
checkSignAndDecrypt(Map<String,String> params,
String alipayPublicKey,
String cusPrivateKey,
boolean isCheckSign,
boolean isDecrypt,
String signType)
验签并解密
|
static String |
encryptAndSign(String bizContent,
String alipayPublicKey,
String cusPrivateKey,
String charset,
boolean isEncrypt,
boolean isSign)
加密并签名
目前适用于公众号 |
static String |
encryptAndSign(String bizContent,
String alipayPublicKey,
String cusPrivateKey,
String charset,
boolean isEncrypt,
boolean isSign,
String signType)
加密并签名
目前适用于公众号 |
static PrivateKey |
getPrivateKeyFromPKCS8(String algorithm,
InputStream ins)
Gets private key from pkcs 8.
|
static PublicKey |
getPublicKeyFromX509(String algorithm,
InputStream ins)
Gets public key from x 509.
|
static String |
getSignatureContent(RequestParametersHolder requestHolder)
Gets signature content.
|
static String |
getSignCheckContentV1(Map<String,String> params)
Gets sign check content v 1.
|
static String |
getSignCheckContentV2(Map<String,String> params)
Gets sign check content v 2.
|
static String |
getSignContent(Map<String,String> sortedParams)
Gets sign content.
|
static Map<String,String> |
getSortedMap(RequestParametersHolder requestHolder)
Gets sorted map.
|
static boolean |
rsa256CheckContent(String content,
String sign,
String publicKey,
String charset)
Rsa 256 check content boolean.
|
static String |
rsa256Sign(String content,
String privateKey,
String charset)
sha256WithRsa 加签
|
static boolean |
rsaCheck(String content,
String sign,
String publicKey,
String charset,
String signType)
Rsa check boolean.
|
static boolean |
rsaCheckContent(String content,
String sign,
String publicKey,
String charset)
Rsa check content boolean.
|
static boolean |
rsaCheckV1(Map<String,String> params,
String publicKey,
String charset)
Rsa check v 1 boolean.
|
static boolean |
rsaCheckV1(Map<String,String> params,
String publicKey,
String charset,
String signType)
Rsa check v 1 boolean.
|
static boolean |
rsaCheckV2(Map<String,String> params,
String publicKey,
String charset)
Rsa check v 2 boolean.
|
static boolean |
rsaCheckV2(Map<String,String> params,
String publicKey,
String charset,
String signType)
Rsa check v 2 boolean.
|
static String |
rsaDecrypt(String content,
String privateKey,
String charset)
私钥解密
|
static String |
rsaEncrypt(String content,
String publicKey,
String charset)
公钥加密
|
static String |
rsaSign(Map<String,String> params,
String privateKey,
String charset)
Rsa sign string.
|
static String |
rsaSign(String content,
String privateKey,
String charset)
sha1WithRsa 加签
|
static String |
rsaSign(String content,
String privateKey,
String charset,
String signType)
rsa内容签名
|
public static String getSignatureContent(RequestParametersHolder requestHolder)
requestHolder - the request holderpublic static Map<String,String> getSortedMap(RequestParametersHolder requestHolder)
requestHolder - the request holderpublic static String getSignContent(Map<String,String> sortedParams)
sortedParams - the sorted paramspublic static String rsaSign(String content, String privateKey, String charset, String signType) throws AlipayApiException
content - the contentprivateKey - the private keycharset - the charsetsignType - the sign typeAlipayApiException - the alipay api exceptionpublic static String rsa256Sign(String content, String privateKey, String charset) throws AlipayApiException
content - the contentprivateKey - the private keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static String rsaSign(String content, String privateKey, String charset) throws AlipayApiException
content - the contentprivateKey - the private keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static String rsaSign(Map<String,String> params, String privateKey, String charset) throws AlipayApiException
params - the paramsprivateKey - the private keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static PrivateKey getPrivateKeyFromPKCS8(String algorithm, InputStream ins) throws Exception
algorithm - the algorithmins - the insException - the exceptionpublic static String getSignCheckContentV1(Map<String,String> params)
params - the paramspublic static String getSignCheckContentV2(Map<String,String> params)
params - the paramspublic static boolean rsaCheckV1(Map<String,String> params, String publicKey, String charset) throws AlipayApiException
params - the paramspublicKey - the public keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static boolean rsaCheckV1(Map<String,String> params, String publicKey, String charset, String signType) throws AlipayApiException
params - the paramspublicKey - the public keycharset - the charsetsignType - the sign typeAlipayApiException - the alipay api exceptionpublic static boolean rsaCheckV2(Map<String,String> params, String publicKey, String charset) throws AlipayApiException
params - the paramspublicKey - the public keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static boolean rsaCheckV2(Map<String,String> params, String publicKey, String charset, String signType) throws AlipayApiException
params - the paramspublicKey - the public keycharset - the charsetsignType - the sign typeAlipayApiException - the alipay api exceptionpublic static boolean rsaCheck(String content, String sign, String publicKey, String charset, String signType) throws AlipayApiException
content - the contentsign - the signpublicKey - the public keycharset - the charsetsignType - the sign typeAlipayApiException - the alipay api exceptionpublic static boolean rsa256CheckContent(String content, String sign, String publicKey, String charset) throws AlipayApiException
content - the contentsign - the signpublicKey - the public keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static boolean rsaCheckContent(String content, String sign, String publicKey, String charset) throws AlipayApiException
content - the contentsign - the signpublicKey - the public keycharset - the charsetAlipayApiException - the alipay api exceptionpublic static PublicKey getPublicKeyFromX509(String algorithm, InputStream ins) throws Exception
algorithm - the algorithmins - the insException - the exceptionpublic static String checkSignAndDecrypt(Map<String,String> params, String alipayPublicKey, String cusPrivateKey, boolean isCheckSign, boolean isDecrypt) throws AlipayApiException
目前适用于公众号
params参数示例:
{
biz_content=M0qGiGz+8kIpxe8aF4geWJdBn0aBTuJRQItLHo9R7o5JGhpic/MIUjvXo2BLB++BbkSq2OsJCEQFDZ0zK5AJYwvBgeRX30gvEj6eXqXRt16/IkB9HzAccEqKmRHrZJ7PjQWE0KfvDAHsJqFIeMvEYk1Zei2QkwSQPlso7K0oheo/iT+HYE8aTATnkqD/ByD9iNDtGg38pCa2xnnns63abKsKoV8h0DfHWgPH62urGY7Pye3r9FCOXA2Ykm8X4/Bl1bWFN/PFCEJHWe/HXj8KJKjWMO6ttsoV0xRGfeyUO8agu6t587Dl5ux5zD/s8Lbg5QXygaOwo3Fz1G8EqmGhi4+soEIQb8DBYanQOS3X+m46tVqBGMw8Oe+hsyIMpsjwF4HaPKMr37zpW3fe7xOMuimbZ0wq53YP/jhQv6XWodjT3mL0H5ACqcsSn727B5ztquzCPiwrqyjUHjJQQefFTzOse8snaWNQTUsQS7aLsHq0FveGpSBYORyA90qPdiTjXIkVP7mAiYiAIWW9pCEC7F3XtViKTZ8FRMM9ySicfuAlf3jtap6v2KPMtQv70X+hlmzO/IXB6W0Ep8DovkF5rB4r/BJYJLw/6AS0LZM9w5JfnAZhfGM2rKzpfNsgpOgEZS1WleG4I2hoQC0nxg9IcP0Hs+nWIPkEUcYNaiXqeBc=,
sign=rlqgA8O+RzHBVYLyHmrbODVSANWPXf3pSrr82OCO/bm3upZiXSYrX5fZr6UBmG6BZRAydEyTIguEW6VRuAKjnaO/sOiR9BsSrOdXbD5Rhos/Xt7/mGUWbTOt/F+3W0/XLuDNmuYg1yIC/6hzkg44kgtdSTsQbOC9gWM7ayB4J4c=,
sign_type=RSA,
charset=UTF-8
}
params - the paramsalipayPublicKey - 支付宝公钥cusPrivateKey - 商户私钥isCheckSign - 是否验签isDecrypt - 是否解密AlipayApiException - the alipay api exceptionpublic static String checkSignAndDecrypt(Map<String,String> params, String alipayPublicKey, String cusPrivateKey, boolean isCheckSign, boolean isDecrypt, String signType) throws AlipayApiException
目前适用于公众号
params参数示例:
{
biz_content=M0qGiGz+8kIpxe8aF4geWJdBn0aBTuJRQItLHo9R7o5JGhpic/MIUjvXo2BLB++BbkSq2OsJCEQFDZ0zK5AJYwvBgeRX30gvEj6eXqXRt16/IkB9HzAccEqKmRHrZJ7PjQWE0KfvDAHsJqFIeMvEYk1Zei2QkwSQPlso7K0oheo/iT+HYE8aTATnkqD/ByD9iNDtGg38pCa2xnnns63abKsKoV8h0DfHWgPH62urGY7Pye3r9FCOXA2Ykm8X4/Bl1bWFN/PFCEJHWe/HXj8KJKjWMO6ttsoV0xRGfeyUO8agu6t587Dl5ux5zD/s8Lbg5QXygaOwo3Fz1G8EqmGhi4+soEIQb8DBYanQOS3X+m46tVqBGMw8Oe+hsyIMpsjwF4HaPKMr37zpW3fe7xOMuimbZ0wq53YP/jhQv6XWodjT3mL0H5ACqcsSn727B5ztquzCPiwrqyjUHjJQQefFTzOse8snaWNQTUsQS7aLsHq0FveGpSBYORyA90qPdiTjXIkVP7mAiYiAIWW9pCEC7F3XtViKTZ8FRMM9ySicfuAlf3jtap6v2KPMtQv70X+hlmzO/IXB6W0Ep8DovkF5rB4r/BJYJLw/6AS0LZM9w5JfnAZhfGM2rKzpfNsgpOgEZS1WleG4I2hoQC0nxg9IcP0Hs+nWIPkEUcYNaiXqeBc=,
sign=rlqgA8O+RzHBVYLyHmrbODVSANWPXf3pSrr82OCO/bm3upZiXSYrX5fZr6UBmG6BZRAydEyTIguEW6VRuAKjnaO/sOiR9BsSrOdXbD5Rhos/Xt7/mGUWbTOt/F+3W0/XLuDNmuYg1yIC/6hzkg44kgtdSTsQbOC9gWM7ayB4J4c=,
sign_type=RSA,
charset=UTF-8
}
params - the paramsalipayPublicKey - 支付宝公钥cusPrivateKey - 商户私钥isCheckSign - 是否验签isDecrypt - 是否解密signType - the sign typeAlipayApiException - the alipay api exceptionpublic static String encryptAndSign(String bizContent, String alipayPublicKey, String cusPrivateKey, String charset, boolean isEncrypt, boolean isSign) throws AlipayApiException
bizContent - 待加密、签名内容alipayPublicKey - 支付宝公钥cusPrivateKey - 商户私钥charset - 字符集,如UTF-8, GBK, GB2312isEncrypt - 是否加密,true-加密 false-不加密isSign - 是否签名,true-签名 false-不签名 返回示例:
AlipayApiException - the alipay api exceptionpublic static String encryptAndSign(String bizContent, String alipayPublicKey, String cusPrivateKey, String charset, boolean isEncrypt, boolean isSign, String signType) throws AlipayApiException
bizContent - 待加密、签名内容alipayPublicKey - 支付宝公钥cusPrivateKey - 商户私钥charset - 字符集,如UTF-8, GBK, GB2312isEncrypt - 是否加密,true-加密 false-不加密isSign - 是否签名,true-签名 false-不签名signType - the sign type 返回示例:
AlipayApiException - the alipay api exceptionpublic static String rsaEncrypt(String content, String publicKey, String charset) throws AlipayApiException
content - 待加密内容publicKey - 公钥charset - 字符集,如UTF-8, GBK, GB2312AlipayApiException - the alipay api exceptionpublic static String rsaDecrypt(String content, String privateKey, String charset) throws AlipayApiException
content - 待解密内容privateKey - 私钥charset - 字符集,如UTF-8, GBK, GB2312AlipayApiException - the alipay api exceptionCopyright © 2018. All rights reserved.