Java Code Examples for com.alipay.api.AlipayConstants

The following examples show how to use com.alipay.api.AlipayConstants. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: alipay-sdk-java-all   Source File: AlipayLogger.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 业务/系统错误日志
 */
public static void logBizDebug(String rsp) {
    if (!needEnableLogger) {
        return;
    }
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));
    sb.append("^_^");
    sb.append(rsp);

    if (blog.isDebugEnabled()) {
        blog.debug(sb.toString());
    }
}
 
Example 2
Source Project: alipay-sdk-java-all   Source File: AlipayLogger.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 业务/系统错误日志
 */
public static void logBizError(String rsp, Map<String, Long> costTimeMap) {
    if (!needEnableLogger) {
        return;
    }
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));
    sb.append("^_^");
    sb.append(rsp);
    sb.append("^_^");
    sb.append(costTimeMap.get("prepareCostTime"));
    sb.append("ms,");
    sb.append(costTimeMap.get("requestCostTime"));
    sb.append("ms,");
    sb.append(costTimeMap.get("postCostTime"));
    sb.append("ms");
    blog.error(sb.toString());
}
 
Example 3
Source Project: alipay-sdk-java-all   Source File: RSAEncryptor.java    License: Apache License 2.0 6 votes vote down vote up
protected String doSign(String content, String charset, String privateKey) throws Exception {
    PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
            new ByteArrayInputStream(privateKey.getBytes()));

    Signature signature = Signature.getInstance(getSignAlgorithm());

    signature.initSign(priKey);

    if (StringUtils.isEmpty(charset)) {
        signature.update(content.getBytes());
    } else {
        signature.update(content.getBytes(charset));
    }

    byte[] signed = signature.sign();

    return new String(Base64.encodeBase64(signed));
}
 
Example 4
@Override
public String toString() {
    JsonObject json = new JsonObject();
    json.put("out_trade_no", this.outTradeNo);
    json.put("total_amount", CommonUtils.getStringFromIntFen(Integer.parseInt(this.totalAmount)));
    json.put("subject", this.subject);
    json.put("product_code", "QUICK_WAP_PAY");

    if (null != this.passbackParams) {
        try {
            json.put("passback_params", URLEncoder.encode(this.passbackParams, AlipayConstants.CHARSET_UTF8));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    return json.toString();
}
 
Example 5
/**
 * 该方法实现了支付宝手机网页的支付功能;
 * 方法将调用支付宝支付页面需要用到的数据拼接和设置好,然后,写到响应中,前台会自动弹出支付宝支付页面;
 * 其中,支付金额要求大于0.01,并且小于100000000,需要调用者自己检查该值再传进来,否则页面会报获取不到订单信息错误;
 *
 * @param aliAccountInfo 保存了支付宝账户的信息,包括appId、用户私钥、支付宝公钥和回调地址等,具体参考AliAccountInfo类的属性说明
 * @param payBizContent 保存了订单信息,包括本地订单号、金额等,具体参考BizContent类的属性说明
 * Create by quandong
 */
public static void wapPay(AliAccountInfo aliAccountInfo, PayBizContent payBizContent, HttpServerResponse httpResponse) throws IOException {
    AlipayClient alipayClient = AliPayCliFactory.getAlipayClient(aliAccountInfo); // 从客户端工厂中获取AlipayClient
    AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest(); // 创建API对应的request
    String form = "";

    alipayRequest.setReturnUrl(aliAccountInfo.getReturnUrl()); // 设置回跳地址
    alipayRequest.setNotifyUrl(aliAccountInfo.getNotifyUrl()); // 设置通知地址
    alipayRequest.setBizContent(payBizContent.toString()); // 填充业务参数

    try {
        form = alipayClient.pageExecute(alipayRequest).getBody(); // 调用SDK生成表单
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }

    httpResponse.putHeader("Content-Type", "text/html;charset=" + AlipayConstants.CHARSET_UTF8); // 设置文本类型及编码
    httpResponse.end(form); // 直接将完整的表单html输出到页面
}
 
Example 6
Source Project: alipay-sdk   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private String getSignSourceData(AlipayRequest<?> request, String body) {

    // 加签源串起点
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    // 成功或者新版接口
    if (indexOfRootNode > 0) {

        return parseSignSourceData(body, rootNode, indexOfRootNode);

        // 老版本失败接口
    } else if (indexOfErrorRoot > 0) {

        return parseSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 7
Source Project: alipay-sdk   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *   获取签名源串内容
 *    
 * 
 * @param body
 * @param rootNode
 * @param indexOfRootNode
 * @return
 */
private String parseSignSourceData(String body, String rootNode, int indexOfRootNode) {

    //  第一个字母+长度+引号和分号
    int signDataStartIndex = indexOfRootNode + rootNode.length() + 2;
    int indexOfSign = body.indexOf("\"" + AlipayConstants.SIGN + "\"");

    if (indexOfSign < 0) {

        return null;
    }

    // 签名前-逗号
    int signDataEndIndex = indexOfSign - 1;

    return body.substring(signDataStartIndex, signDataEndIndex);
}
 
Example 8
Source Project: alipay-sdk   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  获取JSON响应加签内容串
 * 
 * @param request
 * @param body
 * @return
 */
private ResponseParseItem getJSONSignSourceData(AlipayRequest<?> request, String body) {

    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    if (indexOfRootNode > 0) {

        return parseJSONSignSourceData(body, rootNode, indexOfRootNode);

    } else if (indexOfErrorRoot > 0) {

        return parseJSONSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 9
Source Project: alipay-sdk   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private String getSignSourceData(AlipayRequest<?> request, String body) {

    // XML不同的节点
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    // 成功或者新版接口
    if (indexOfRootNode > 0) {

        return parseSignSourceData(body, rootNode, indexOfRootNode);
        // 老版本接口
    } else if (indexOfErrorRoot > 0) {

        return parseSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 10
Source Project: alipay-sdk   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  获取签名
 *  
 * @param body
 * @return
 */
private String getSign(String body) {

    String signNodeName = "<" + AlipayConstants.SIGN + ">";
    String signEndNodeName = "</" + AlipayConstants.SIGN + ">";

    int indexOfSignNode = body.indexOf(signNodeName);
    int indexOfSignEndNode = body.indexOf(signEndNodeName);

    if (indexOfSignNode < 0 || indexOfSignEndNode < 0) {
        return null;
    }

    //  签名
    return body.substring(indexOfSignNode + signNodeName.length(), indexOfSignEndNode);
}
 
Example 11
Source Project: alipay-sdk   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *   签名源串
 *   
 * @param body
 * @param rootNode
 * @param indexOfRootNode
 * @return
 */
private String parseSignSourceData(String body, String rootNode, int indexOfRootNode) {

    //  第一个字母+长度+>
    int signDataStartIndex = indexOfRootNode + rootNode.length() + 1;
    int indexOfSign = body.indexOf("<" + AlipayConstants.SIGN);

    if (indexOfSign < 0) {

        return null;
    }

    // 签名前减去
    int signDataEndIndex = indexOfSign;

    return body.substring(signDataStartIndex, signDataEndIndex);
}
 
Example 12
Source Project: alipay-sdk   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private ResponseParseItem getXMLSignSourceData(AlipayRequest<?> request, String body) {

    // XML涓�������������
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    if (indexOfRootNode > 0) {

        return parseXMLSignSourceData(body, rootNode, indexOfRootNode);

    } else if (indexOfErrorRoot > 0) {

        return parseXMLSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 13
Source Project: alipay-sdk   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean rsa256CheckContent(String content, String sign, String publicKey,
                                         String charset) throws AlipayApiException {
    try {
        PublicKey pubKey = getPublicKeyFromX509("RSA",
            new ByteArrayInputStream(publicKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_SHA256RSA_ALGORITHMS);

        signature.initVerify(pubKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        return signature.verify(Base64.decodeBase64(sign.getBytes()));
    } catch (Exception e) {
        throw new AlipayApiException(
            "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
    }
}
 
Example 14
Source Project: alipay-sdk   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean rsaCheckContent(String content, String sign, String publicKey,
                                      String charset) throws AlipayApiException {
    try {
        PublicKey pubKey = getPublicKeyFromX509("RSA",
            new ByteArrayInputStream(publicKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_ALGORITHMS);

        signature.initVerify(pubKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        return signature.verify(Base64.decodeBase64(sign.getBytes()));
    } catch (Exception e) {
        throw new AlipayApiException(
            "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
    }
}
 
Example 15
Source Project: alipay-sdk   Source File: AlipayLogger.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 业务/系统错误日志
 */
public static void logBizDebug(String rsp) {
    if (!needEnableLogger) {
        return;
    }
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));
    sb.append("^_^");
    sb.append(rsp);

    if (blog.isDebugEnabled()) {
        blog.debug(sb.toString());
    }
}
 
Example 16
Source Project: pay   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private String getSignSourceData(AlipayRequest<?> request, String body) {

    // 加签源串起点
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    // 成功或者新版接口
    if (indexOfRootNode > 0) {

        return parseSignSourceData(body, rootNode, indexOfRootNode);

        // 老版本失败接口
    } else if (indexOfErrorRoot > 0) {

        return parseSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 17
Source Project: pay   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *   获取签名源串内容
 *    
 * 
 * @param body
 * @param rootNode
 * @param indexOfRootNode
 * @return
 */
private String parseSignSourceData(String body, String rootNode, int indexOfRootNode) {

    //  第一个字母+长度+引号和分号
    int signDataStartIndex = indexOfRootNode + rootNode.length() + 2;
    int indexOfSign = body.indexOf("\"" + AlipayConstants.SIGN + "\"");

    if (indexOfSign < 0) {

        return null;
    }

    // 签名前-逗号
    int signDataEndIndex = indexOfSign - 1;

    return body.substring(signDataStartIndex, signDataEndIndex);
}
 
Example 18
Source Project: pay   Source File: JsonConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  获取JSON响应加签内容串
 * 
 * @param request
 * @param body
 * @return
 */
private ResponseParseItem getJSONSignSourceData(AlipayRequest<?> request, String body) {

    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    if (indexOfRootNode > 0) {

        return parseJSONSignSourceData(body, rootNode, indexOfRootNode);

    } else if (indexOfErrorRoot > 0) {

        return parseJSONSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 19
Source Project: pay   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private String getSignSourceData(AlipayRequest<?> request, String body) {

    // XML不同的节点
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    // 成功或者新版接口
    if (indexOfRootNode > 0) {

        return parseSignSourceData(body, rootNode, indexOfRootNode);
        // 老版本接口
    } else if (indexOfErrorRoot > 0) {

        return parseSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 20
Source Project: pay   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  获取签名
 *  
 * @param body
 * @return
 */
private String getSign(String body) {

    String signNodeName = "<" + AlipayConstants.SIGN + ">";
    String signEndNodeName = "</" + AlipayConstants.SIGN + ">";

    int indexOfSignNode = body.indexOf(signNodeName);
    int indexOfSignEndNode = body.indexOf(signEndNodeName);

    if (indexOfSignNode < 0 || indexOfSignEndNode < 0) {
        return null;
    }

    //  签名
    return body.substring(indexOfSignNode + signNodeName.length(), indexOfSignEndNode);
}
 
Example 21
Source Project: pay   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *   签名源串
 *   
 * @param body
 * @param rootNode
 * @param indexOfRootNode
 * @return
 */
private String parseSignSourceData(String body, String rootNode, int indexOfRootNode) {

    //  第一个字母+长度+>
    int signDataStartIndex = indexOfRootNode + rootNode.length() + 1;
    int indexOfSign = body.indexOf("<" + AlipayConstants.SIGN);

    if (indexOfSign < 0) {

        return null;
    }

    // 签名前减去
    int signDataEndIndex = indexOfSign;

    return body.substring(signDataStartIndex, signDataEndIndex);
}
 
Example 22
Source Project: pay   Source File: XmlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param request
 * @param body
 * @return
 */
private ResponseParseItem getXMLSignSourceData(AlipayRequest<?> request, String body) {

    // XML涓�������������
    String rootNode = request.getApiMethodName().replace('.', '_')
                      + AlipayConstants.RESPONSE_SUFFIX;
    String errorRootNode = AlipayConstants.ERROR_RESPONSE;

    int indexOfRootNode = body.indexOf(rootNode);
    int indexOfErrorRoot = body.indexOf(errorRootNode);

    if (indexOfRootNode > 0) {

        return parseXMLSignSourceData(body, rootNode, indexOfRootNode);

    } else if (indexOfErrorRoot > 0) {

        return parseXMLSignSourceData(body, errorRootNode, indexOfErrorRoot);
    } else {
        return null;
    }
}
 
Example 23
Source Project: pay   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static String rsa256Sign(String content, String privateKey,
                                String charset) throws AlipayApiException {

    try {
        PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
            new ByteArrayInputStream(privateKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_SHA256RSA_ALGORITHMS);

        signature.initSign(priKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        byte[] signed = signature.sign();

        return new String(Base64.encodeBase64(signed));
    } catch (Exception e) {
        throw new AlipayApiException("RSAcontent = " + content + "; charset = " + charset, e);
    }

}
 
Example 24
Source Project: pay   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static String rsaSign(String content, String privateKey,
                             String charset) throws AlipayApiException {
    try {
        PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
            new ByteArrayInputStream(privateKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_ALGORITHMS);

        signature.initSign(priKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        byte[] signed = signature.sign();

        return new String(Base64.encodeBase64(signed));
    } catch (InvalidKeySpecException ie) {
        throw new AlipayApiException("RSA私钥格式不正确,请检查是否正确配置了PKCS8格式的私钥", ie);
    } catch (Exception e) {
        throw new AlipayApiException("RSAcontent = " + content + "; charset = " + charset, e);
    }
}
 
Example 25
Source Project: pay   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean rsa256CheckContent(String content, String sign, String publicKey,
                                         String charset) throws AlipayApiException {
    try {
        PublicKey pubKey = getPublicKeyFromX509("RSA",
            new ByteArrayInputStream(publicKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_SHA256RSA_ALGORITHMS);

        signature.initVerify(pubKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        return signature.verify(Base64.decodeBase64(sign.getBytes()));
    } catch (Exception e) {
        throw new AlipayApiException(
            "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
    }
}
 
Example 26
Source Project: pay   Source File: AlipaySignature.java    License: Apache License 2.0 6 votes vote down vote up
public static boolean rsaCheckContent(String content, String sign, String publicKey,
                                      String charset) throws AlipayApiException {
    try {
        PublicKey pubKey = getPublicKeyFromX509("RSA",
            new ByteArrayInputStream(publicKey.getBytes()));

        java.security.Signature signature = java.security.Signature
            .getInstance(AlipayConstants.SIGN_ALGORITHMS);

        signature.initVerify(pubKey);

        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }

        return signature.verify(Base64.decodeBase64(sign.getBytes()));
    } catch (Exception e) {
        throw new AlipayApiException(
            "RSAcontent = " + content + ",sign=" + sign + ",charset = " + charset, e);
    }
}
 
Example 27
Source Project: alipay-sdk-java-all   Source File: LoadTestUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static Map<String, String> getParamsWithLoadTestFlag(Map<String, String> params) {
    Map<String, String> result = new HashMap<String, String>(params);
    if (result.containsKey(AlipayConstants.APP_ID)) {
        String appId = result.get(AlipayConstants.APP_ID);
        result.put(AlipayConstants.APP_ID, appId + TEST_LOAD_FLAG);
    }
    return result;
}
 
Example 28
Source Project: alipay-sdk-java-all   Source File: AntCertificationUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取根证书序列号
 *
 * @param rootCertContent
 * @return
 */
public static String getRootCertSN(String rootCertContent, String signType) {
    if (AlipayConstants.SIGN_TYPE_SM2.equals(signType)) {
        String rootCertSN = null;
        try {
            X509Certificate[] x509Certificates = readPemCertChain(rootCertContent);
            MessageDigest md = MessageDigest.getInstance("MD5");
            for (X509Certificate c : x509Certificates) {
                if (c.getSigAlgOID().startsWith("1.2.156.10197.1.501")) {
                    md.update((c.getIssuerX500Principal().getName() + c.getSerialNumber()).getBytes());
                    String certSN = new BigInteger(1, md.digest()).toString(16);
                    //BigInteger会把0省略掉,需补全至32位
                    certSN = fillMD5(certSN);
                    if (StringUtils.isEmpty(rootCertSN)) {
                        rootCertSN = certSN;
                    } else {
                        rootCertSN = rootCertSN + "_" + certSN;
                    }
                }
            }
        } catch (Exception e) {
            AlipayLogger.logBizError(("提取根证书失败"));
        }
        return rootCertSN;

    } else {
        return getRootCertSN(rootCertContent);
    }

}
 
Example 29
Source Project: alipay-sdk-java-all   Source File: AlipayHashMap.java    License: Apache License 2.0 5 votes vote down vote up
public String put(String key, Object value) {
    String strValue;

    if (value == null) {
        strValue = null;
    } else if (value instanceof String) {
        strValue = (String) value;
    } else if (value instanceof Integer) {
        strValue = ((Integer) value).toString();
    } else if (value instanceof Long) {
        strValue = ((Long) value).toString();
    } else if (value instanceof Float) {
        strValue = ((Float) value).toString();
    } else if (value instanceof Double) {
        strValue = ((Double) value).toString();
    } else if (value instanceof Boolean) {
        strValue = ((Boolean) value).toString();
    } else if (value instanceof Date) {
        DateFormat format = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
        format.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
        strValue = format.format((Date) value);
    } else {
        strValue = value.toString();
    }

    return this.put(key, strValue);
}
 
Example 30
Source Project: alipay-sdk-java-all   Source File: AlipayLogger.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 通讯错误日志
 */
private static void _logCommError(Exception e, HttpURLConnection conn, String url,
                                  String appKey, String method, Map<String, String> params) {
    DateFormat df = new SimpleDateFormat(AlipayConstants.DATE_TIME_FORMAT);
    df.setTimeZone(TimeZone.getTimeZone(AlipayConstants.DATE_TIMEZONE));
    String sdkName = AlipayConstants.SDK_VERSION;
    String urlStr = null;
    String rspCode = "";
    if (conn != null) {
        try {
            urlStr = conn.getURL().toString();
            rspCode = "HTTP_ERROR_" + conn.getResponseCode();
        } catch (IOException ioe) {
        }
    } else {
        urlStr = url;
        rspCode = "";
    }
    StringBuilder sb = new StringBuilder();
    sb.append(df.format(new Date()));// 时间
    sb.append("^_^");
    sb.append(method);// API
    sb.append("^_^");
    sb.append(appKey);// APP
    sb.append("^_^");
    sb.append(getIp());// IP地址
    sb.append("^_^");
    sb.append(osName);// 操作系统
    sb.append("^_^");
    sb.append(sdkName);// SDK名字,这是例子,请换成其他名字
    sb.append("^_^");
    sb.append(urlStr);// 请求URL
    sb.append("^_^");
    sb.append(rspCode);
    sb.append("^_^");
    sb.append((e.getMessage() + "").replaceAll("\r\n", " "));
    clog.error(sb.toString());
}