ncc token
This commit is contained in:
parent
cbec72c450
commit
e512b1278f
|
@ -7,5 +7,6 @@ public interface INccTokenService {
|
|||
|
||||
|
||||
SysExtensionApiEntity getNccToken(SysExtensionApiEntity entity);
|
||||
SysExtensionApiEntity getNccBill(SysExtensionApiEntity entity);
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.hzya.frame.ncc.v202005.service.INccTokenService;
|
|||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.util.bipV3.Encryption;
|
||||
import com.hzya.frame.util.bipV3.SHA256Util;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -62,4 +63,37 @@ public class NccTokenServiceImpl implements INccTokenService {
|
|||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SysExtensionApiEntity getNccBill(SysExtensionApiEntity entity) {
|
||||
try {
|
||||
Map<String, String> headers = entity.getHeaders();
|
||||
String client_id = headers.get("client_id");
|
||||
//token信息
|
||||
String access_token = headers.get("access_token");
|
||||
//公钥
|
||||
String pubKey = headers.get("pubKey");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(client_id);
|
||||
String parm = entity.getBodys();
|
||||
if (StringUtils.isNotBlank(parm)) {
|
||||
sb.append(parm);
|
||||
}
|
||||
sb.append(pubKey);
|
||||
// 签名
|
||||
String sign = SHA256Util.getSHA256(sb.toString(), pubKey);
|
||||
StringBuffer querys = new StringBuffer();
|
||||
querys.append("access_token="+access_token);
|
||||
querys.append("&signature="+sign);
|
||||
querys.append("&client_id="+client_id);
|
||||
entity.setQuerys(querys.toString());
|
||||
headers.put("signature",sign);
|
||||
// headers.put("content-type","application/x-www-form-urlencoded");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue