parent
3b46cf5926
commit
9ac244038a
@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE sys_incremental_channels ADD COLUMN channel_pub_key TEXT DEFAULT NULL AFTER source_code;
|
||||||
|
ALTER TABLE sys_incremental_channels ADD COLUMN platform_pub_key TEXT DEFAULT NULL AFTER channel_pub_key;
|
||||||
|
ALTER TABLE sys_incremental_channels ADD COLUMN platform_pri_key TEXT DEFAULT NULL AFTER platform_pub_key;
|
@ -0,0 +1,14 @@
|
|||||||
|
package au.com.royalpay.payment.manage.appclient.core;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
public interface RetailRSvcService {
|
||||||
|
/**
|
||||||
|
* App通过service code获取用户信息
|
||||||
|
*
|
||||||
|
* @param device
|
||||||
|
* @param sourceCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode);
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package au.com.royalpay.payment.manage.appclient.core.impls;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
|
||||||
|
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
||||||
|
import au.com.royalpay.payment.tools.codec.AESCrypt;
|
||||||
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
||||||
|
import au.com.royalpay.payment.tools.encryptalgorithm.SignUtils;
|
||||||
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||||
|
import au.com.royalpay.payment.tools.mappers.CommonIncrementalChannelMapper;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.net.util.Base64;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.Key;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RetailRSvcServiceImpl implements RetailRSvcService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ClientManager clientManager;
|
||||||
|
@Resource
|
||||||
|
private DeviceSupport deviceSupport;
|
||||||
|
@Resource
|
||||||
|
private CommonIncrementalChannelMapper commonIncrementalChannelMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
|
||||||
|
String clientType = device.getString("client_type");
|
||||||
|
deviceSupport.findRegister(clientType);
|
||||||
|
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
|
||||||
|
if (svcInfo == null || StringUtils.isEmpty(svcInfo.getString("channel_pub_key"))
|
||||||
|
|| StringUtils.isEmpty(svcInfo.getString("platform_pub_key")) || StringUtils.isEmpty("platform_pri_key")) {
|
||||||
|
throw new BadRequestException("this channel config is wrong");
|
||||||
|
}
|
||||||
|
RSvcMchBean svcMchBean = clientManager.findSvcMchByAccountId(device.getString("account_id"));
|
||||||
|
String pubKeyEncCredentialCode = SignUtils.encData(svcMchBean.getCredentialCode(), svcInfo.getString("channel_pub_key"));
|
||||||
|
String aesKeyStr = Base64.encodeBase64String(AESCrypt.randomKey().getEncoded());
|
||||||
|
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(aesKeyStr));
|
||||||
|
String decCredentialCode = Base64.encodeBase64String(AESCrypt.encrypt(pubKeyEncCredentialCode.getBytes(StandardCharsets.UTF_8), key));
|
||||||
|
JSONObject result = (JSONObject) JSON.toJSON(svcMchBean);
|
||||||
|
result.put("sign_type", "RSA2");
|
||||||
|
result.put("enc_data", decCredentialCode);
|
||||||
|
result.put("nonce_str", aesKeyStr);
|
||||||
|
result.put("timestamp", System.currentTimeMillis());
|
||||||
|
result.put("sign", SignUtils.buildSign(result.toJSONString(), svcInfo.getString("platform_pri_key")));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package au.com.royalpay.payment.manage.appclient.web;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
|
||||||
|
import au.com.royalpay.payment.tools.CommonConsts;
|
||||||
|
import au.com.royalpay.payment.tools.device.advise.AppClientController;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@AppClientController
|
||||||
|
@RequestMapping("/api/v1.0/retail/rsvc")
|
||||||
|
public class RetailRSvcController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RetailRSvcService retailRSvcService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/{source_code}/userinfo")
|
||||||
|
public JSONObject findUserInfoBySourceCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String source_code) {
|
||||||
|
return retailRSvcService.findMchInfoBySourceCode(device, source_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue