Merge remote-tracking branch 'origin/production' into production

master
dalong306 3 years ago
commit eef4c9b136

@ -51,6 +51,7 @@ orderWithChannel:
enum: enum:
- Alipay - Alipay
- Wechat - Wechat
- AlipayPlus
type: object type: object
required: required:
- channel - channel

@ -2700,16 +2700,27 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
public void writeAggregatePoster(JSONObject manager, String clientMoniker, OutputStream ous) { public void writeAggregatePoster(JSONObject manager, String clientMoniker, OutputStream ous) {
JSONObject client = clientDetail(manager, clientMoniker); JSONObject client = clientDetail(manager, clientMoniker);
try { try {
logger.debug("downloading aggregate poster from {}", clientMoniker); String url = PlatformEnvironment.getEnv().concatUrl("/static/images/new_aggregate_poster.png");
logger.debug("downloading aggregate poster from {}--{}", clientMoniker, url);
HttpRequestResult boardBackgroundResult = new HttpRequestGenerator( HttpRequestResult boardBackgroundResult = new HttpRequestGenerator(
PlatformEnvironment.getEnv().concatUrl("/static/images/new_aggregate_poster.png"), RequestMethod.GET).execute(); url, RequestMethod.GET).execute();
if (boardBackgroundResult.isSuccess()) { if (boardBackgroundResult.isSuccess()) {
InputStream ins = boardBackgroundResult.getResponseContentStream(); try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
BufferedImage background = ImageIO.read(ins); InputStream ins = boardBackgroundResult.getResponseContentStream();
IOUtils.closeQuietly(ins); BufferedImage background = ImageIO.read(ins);
ImageIO.write(background, "jpeg", ous); IOUtils.closeQuietly(ins);
ous.flush(); logger.debug("aggregate image size {}x{}", background.getWidth(), background.getHeight());
IOUtils.closeQuietly(ous); BufferedImage img = new BufferedImage(background.getWidth(), background.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
Graphics g = img.getGraphics();
g.drawImage(background, 0, 0, null);
g.dispose();
ImageIO.write(img, "jpeg", bos);
bos.flush();
byte[] imageBytes = bos.toByteArray();
logger.debug("aggregate image length {}", imageBytes.length);
ous.write(imageBytes);
IOUtils.closeQuietly(ous);
}
} else { } else {
logger.error("get aggregate poster file failed:[{}]-{}", boardBackgroundResult.getStatusCode(), logger.error("get aggregate poster file failed:[{}]-{}", boardBackgroundResult.getStatusCode(),
boardBackgroundResult.getResponseContentString(), boardBackgroundResult.getException()); boardBackgroundResult.getResponseContentString(), boardBackgroundResult.getException());

@ -21,9 +21,11 @@ public class ShopifyRequestValidator {
return HmacVerificationUtil.hmacSHA256(message.toString(),clientSecret,parameter.getHmac()); return HmacVerificationUtil.hmacSHA256(message.toString(),clientSecret,parameter.getHmac());
} }
public boolean verifyPermission(String shopifyStoreHost, String hmac, String timestamp) { public boolean verifyPermission(String shop, String hmac, String timestamp, String host) {
StringBuilder message =new StringBuilder(); StringBuilder message =new StringBuilder();
message.append("shop=").append(shopifyStoreHost) message
.append("host=").append(host)
.append("&shop=").append(shop)
.append("&timestamp=").append(timestamp); .append("&timestamp=").append(timestamp);
return HmacVerificationUtil.hmacSHA256(message.toString(),clientSecret,hmac); return HmacVerificationUtil.hmacSHA256(message.toString(),clientSecret,hmac);
} }

@ -38,13 +38,14 @@ public class ShopifyAuthTemplateController {
*/ */
@GetMapping("/auth") @GetMapping("/auth")
@ShopifyEndpoint @ShopifyEndpoint
public String shopifyStorePermission(@RequestParam("shop") String shop, public String shopifyStorePermission(@RequestParam("hmac") String hmac,
@RequestParam("hmac") String hmac, @RequestParam("host") String host,
@RequestParam("shop") String shop,
@RequestParam("timestamp") String timestamp) { @RequestParam("timestamp") String timestamp) {
if (!Pattern.matches("^[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.myshopify\\.com", shop)) { if (!Pattern.matches("^[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.myshopify\\.com", shop)) {
throw new BadRequestException("Parameter shop is invalid."); throw new BadRequestException("Parameter shop is invalid.");
} }
if (!shopifyRequestValidator.verifyPermission(shop, hmac, timestamp)) { if (!shopifyRequestValidator.verifyPermission(shop, hmac, timestamp,host)) {
throw new ShopifyRequestVerifyException("This request parameters is invalid"); throw new ShopifyRequestVerifyException("This request parameters is invalid");
} }
ShopifyPermissionURL shopifyPermissionURL = shopifyMerchantAuthApplication.getShopifyPermissionUrl(shop); ShopifyPermissionURL shopifyPermissionURL = shopifyMerchantAuthApplication.getShopifyPermissionUrl(shop);

Loading…
Cancel
Save