当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils类代码示例

本文整理汇总了Java中com.alipay.api.internal.util.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringUtils类属于com.alipay.api.internal.util包,在下文中一共展示了StringUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResponseCharset

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
private static String getResponseCharset(String ctype) {
    String charset = DEFAULT_CHARSET;

    if (!StringUtils.isEmpty(ctype)) {
        String[] params = ctype.split(";");
        for (String param : params) {
            param = param.trim();
            if (param.startsWith("charset")) {
                String[] pair = param.split("=", 2);
                if (pair.length == 2) {
                    if (!StringUtils.isEmpty(pair[1])) {
                        charset = pair[1].trim();
                    }
                }
                break;
            }
        }
    }

    return charset;
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:22,代码来源:AlipayMobilePublicMultiMediaClient.java

示例2: buildGetUrl

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
private static URL buildGetUrl(String strUrl, String query) throws IOException {
    URL url = new URL(strUrl);
    if (StringUtils.isEmpty(query)) {
        return url;
    }

    if (StringUtils.isEmpty(url.getQuery())) {
        if (strUrl.endsWith("?")) {
            strUrl = strUrl + query;
        } else {
            strUrl = strUrl + "?" + query;
        }
    } else {
        if (strUrl.endsWith("&")) {
            strUrl = strUrl + query;
        } else {
            strUrl = strUrl + "&" + query;
        }
    }

    return new URL(strUrl);
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:23,代码来源:AlipayMobilePublicMultiMediaClient.java

示例3: buildQuery

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
public static String buildQuery(Map<String, String> params, String charset) throws IOException {
    if (params == null || params.isEmpty()) {
        return null;
    }

    StringBuilder query = new StringBuilder();
    Set<Entry<String, String>> entries = params.entrySet();
    boolean hasParam = false;

    for (Entry<String, String> entry : entries) {
        String name = entry.getKey();
        String value = entry.getValue();

        if (StringUtils.areNotEmpty(name, value)) {
            if (hasParam) {
                query.append("&");
            } else {
                hasParam = true;
            }

            query.append(name).append("=").append(URLEncoder.encode(value, charset));
        }
    }

    return query.toString();
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:27,代码来源:AlipayMobilePublicMultiMediaClient.java

示例4: getSignItem

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
/** 
 * @see com.alipay.api.internal.mapping.Converter#getSignItem(com.alipay.api.AlipayRequest, String)
 */
public SignItem getSignItem(AlipayRequest<?> request, String responseBody)
                                                                          throws AlipayApiException {

    // 响应为空则直接返回
    if (StringUtils.isEmpty(responseBody)) {

        return null;
    }

    SignItem signItem = new SignItem();

    // 获取签名
    String sign = getSign(responseBody);
    signItem.setSign(sign);

    // 签名源串
    String signSourceData = getSignSourceData(request, responseBody);
    signItem.setSignSourceDate(signSourceData);

    return signItem;
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:25,代码来源:JsonConverter.java

示例5: getResponseAsString

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
protected static String getResponseAsString(HttpURLConnection conn) throws IOException {
    String charset = getResponseCharset(conn.getContentType());
    InputStream es = conn.getErrorStream();
    if (es == null) {
        return getStreamAsString(conn.getInputStream(), charset);
    } else {
        String msg = getStreamAsString(es, charset);
        if (StringUtils.isEmpty(msg)) {
            throw new IOException(conn.getResponseCode() + ":" + conn.getResponseMessage());
        } else {
            throw new IOException(msg);
        }
    }
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:15,代码来源:AlipayMobilePublicMultiMediaClient.java

示例6: isSuccess

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
public boolean isSuccess() {
    return StringUtils.isEmpty(subCode);
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:4,代码来源:AlipayResponse.java

示例7: checkResponseSign

import com.alipay.api.internal.util.StringUtils; //导入依赖的package包/类
/**
 *  检查响应签名
 * 
 * @param request
 * @param parser
 * @param responseBody
 * @param responseIsSucess
 * @throws AlipayApiException
 */
private <T extends AlipayResponse> void checkResponseSign(AlipayRequest<T> request,
                                                          AlipayParser<T> parser,
                                                          String responseBody,
                                                          boolean responseIsSucess) throws AlipayApiException {
    // 针对成功结果且有支付宝公钥的进行验签
    if (!StringUtils.isEmpty(this.alipayPublicKey)) {

        SignItem signItem = parser.getSignItem(request, responseBody);

        if (signItem == null) {

            throw new AlipayApiException("sign check fail: Body is Empty!");
        }

        if (responseIsSucess
            || (!responseIsSucess && !StringUtils.isEmpty(signItem.getSign()))) {

            boolean rsaCheckContent = AlipaySignature.rsaCheck(signItem.getSignSourceDate(),
                signItem.getSign(), this.alipayPublicKey, this.charset, this.sign_type);

            if (!rsaCheckContent) {

                // 针对JSON \/问题,替换/后再尝试做一次验证
                if (!StringUtils.isEmpty(signItem.getSignSourceDate())
                    && signItem.getSignSourceDate().contains("\\/")) {

                    String srouceData = signItem.getSignSourceDate().replace("\\/", "/");

                    boolean jsonCheck = AlipaySignature.rsaCheck(srouceData, signItem.getSign(),
                        this.alipayPublicKey, this.charset, this.sign_type);

                    if (!jsonCheck) {
                        throw new AlipayApiException(
                            "sign check fail: check Sign and Data Fail!JSON also!");
                    }
                } else {

                    throw new AlipayApiException("sign check fail: check Sign and Data Fail!");
                }
            }
        }

    }
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:54,代码来源:DefaultAlipayClient.java


注:本文中的com.alipay.api.internal.util.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。