From 685a6df62b7e5e17b5e07b29cbe589785dccbe61 Mon Sep 17 00:00:00 2001 From: luoyang Date: Thu, 24 Oct 2019 11:47:40 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E9=82=AE=E4=BB=B6=E5=AF=86=E7=A0=81=20sy?= =?UTF-8?q?sconfig=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../notice/core/impls/MailServiceImp.java | 50 +++++++++++++++---- src/main/resources/application.properties | 4 ++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index fa68d26b5..37cbbffdf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 manage - 1.2.42 + 1.2.43 UTF-8 diff --git a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java index 807446c6c..fc3b70d66 100644 --- a/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/notice/core/impls/MailServiceImp.java @@ -65,6 +65,12 @@ public class MailServiceImp implements MailService { private ClientManager clientManager; @Value("${app.settle.aes-key}") private String settleAESKey; + @Value("${app.partner.aes-key}") + private String partnerAESKey; + @Value("${app.risk.aes-key}") + private String riskAESKey; + @Value("${app.risk.control.aes-key}") + private String riskControlAESKey; /* @Override public void sendEmail(NoticeBean noticeBean) { @@ -126,8 +132,13 @@ public class MailServiceImp implements MailService { if (files.size() > 0) { noticeBean.setFiles(files.toString()); } - noticeBean.setSenderAddress("info@royalpay.com.au"); - noticeBean.setPassword("Rpay2018"); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + noticeBean.setSenderAddress(sysConfig.getString("partner.email.address")); + String mailPwdEncrypted = sysConfig.getString("partner.email.password"); + Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "partner mail pwd not configured"); + Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(partnerAESKey)); + String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8); + noticeBean.setPassword(mailPwd); String postUrl = mailHost + "/mail?" + generateMailSignParam(); @@ -163,8 +174,13 @@ public class MailServiceImp implements MailService { mailClients.add(mailClient); noticeBean.setMailClients(mailClients); noticeBean.setContent(content); - noticeBean.setSenderAddress("info@royalpay.com.au"); - noticeBean.setPassword("Rpay2018"); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + noticeBean.setSenderAddress(sysConfig.getString("partner.email.address")); + String mailPwdEncrypted = sysConfig.getString("partner.email.password"); + Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "partner mail pwd not configured"); + Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(partnerAESKey)); + String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8); + noticeBean.setPassword(mailPwd); String postUrl = mailHost + "/mail/single?" + generateMailSignParam(); HttpRequestResult result = null; try { @@ -194,8 +210,13 @@ public class MailServiceImp implements MailService { mailClients.add(mailClient); noticeBean.setMailClients(mailClients); noticeBean.setContent(content); - noticeBean.setSenderAddress("info@royalpay.com.au"); - noticeBean.setPassword("Rpay2018"); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + noticeBean.setSenderAddress(sysConfig.getString("partner.email.address")); + String mailPwdEncrypted = sysConfig.getString("partner.email.password"); + Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "partner mail pwd not configured"); + Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(partnerAESKey)); + String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8); + noticeBean.setPassword(mailPwd); String postUrl = mailHost + "/mail/single?" + generateMailSignParam(); HttpRequestResult result = null; try { @@ -312,11 +333,20 @@ public class MailServiceImp implements MailService { noticeBean.setMailClients(mailClients); noticeBean.setContent(content); noticeBean.setAttachFiles(attachFiles); - noticeBean.setSenderAddress("riskcontrol@royalpay.com.au"); - noticeBean.setPassword("RPrisk123"); + JSONObject sysConfig = sysConfigManager.getSysConfig(); + noticeBean.setSenderAddress(sysConfig.getString("riskControl.email.address")); + String riskControlMailPwdEncrypted = sysConfig.getString("riskControl.email.password"); + Assert.isTrue(StringUtils.isNotEmpty(riskControlMailPwdEncrypted), "riskControl mail pwd not configured"); + Key riskControlAesKey = AESCrypt.fromKeyString(Base64.decodeBase64(riskControlAESKey)); + String riskControlMailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(riskControlMailPwdEncrypted), riskControlAesKey), StandardCharsets.UTF_8); + noticeBean.setPassword(riskControlMailPwd); if(order_type == 1 || order_type == 2){ - noticeBean.setSenderAddress("risk@royalpay.com.au"); - noticeBean.setPassword("Tunnelrisk123"); + String riskMailPwdEncrypted = sysConfig.getString("risk.email.password"); + Assert.isTrue(StringUtils.isNotEmpty(riskMailPwdEncrypted), "risk mail pwd not configured"); + Key riskAesKey = AESCrypt.fromKeyString(Base64.decodeBase64(riskAESKey)); + String riskMailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(riskMailPwdEncrypted), riskAesKey), StandardCharsets.UTF_8); + noticeBean.setSenderAddress(sysConfig.getString("risk.email.address")); + noticeBean.setPassword(riskMailPwd); } String postUrl = mailHost + "/mail/single?" + generateMailSignParam(); HttpRequestResult result = null; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 961852e6a..4d4b10548 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -113,6 +113,10 @@ im.openim.appkey=24986533 im.openim.secret=96e28e7be21a874177211c31834b5174 app.settle.aes-key=EPrfsM2JE69ZPR7BhXn34g== +app.partner.aes-key=xyc7Ya6TmL8/csM1ygtviA== +app.risk.aes-key=NRvwd9dgbT2Cdz6zJz9AWA== +app.risk.control.aes-key=Aa+MtthC4Ztq4Kfa9aL+UA== + #清算银行配置 settle.abafile.default-bank=CBA settle.abafile.remains-to=ANZ