Search in sources :

Example 1 with JeeccgBaseConfig

use of org.jeecg.config.JeeccgBaseConfig in project jeecg-boot by jeecgboot.

the class SignUtil method getParamsSign.

/**
 * @param params
 *            所有的请求参数都会在这里进行排序加密
 * @return 得到签名
 */
public static String getParamsSign(SortedMap<String, String> params) {
    // 去掉 Url 里的时间戳
    params.remove("_t");
    String paramsJsonStr = JSONObject.toJSONString(params);
    log.info("Param paramsJsonStr : {}", paramsJsonStr);
    // 设置签名秘钥
    JeeccgBaseConfig jeeccgBaseConfig = SpringContextUtils.getBean(JeeccgBaseConfig.class);
    String signatureSecret = jeeccgBaseConfig.getSignatureSecret();
    if (oConvertUtils.isEmpty(signatureSecret) || signatureSecret.contains("${")) {
        throw new JeecgBootException("签名密钥 ${jeecg.signatureSecret} 缺少配置 !!");
    }
    return DigestUtils.md5DigestAsHex((paramsJsonStr + signatureSecret).getBytes()).toUpperCase();
}
Also used : JeeccgBaseConfig(org.jeecg.config.JeeccgBaseConfig) JeecgBootException(org.jeecg.common.exception.JeecgBootException)

Aggregations

JeecgBootException (org.jeecg.common.exception.JeecgBootException)1 JeeccgBaseConfig (org.jeecg.config.JeeccgBaseConfig)1