settlement mail password source

master
yixian 6 years ago
parent d23de1a885
commit 61dc277d62

@ -4,6 +4,8 @@ import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.beans.NoticeBean; import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
@ -18,6 +20,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
@ -26,10 +30,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -53,7 +60,11 @@ public class MailServiceImp implements MailService {
@Resource @Resource
private MailUnsubMapper mailUnsubMapper; private MailUnsubMapper mailUnsubMapper;
@Resource @Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientManager clientManager; private ClientManager clientManager;
@Value("${app.settle.aes-key}")
private String settleAESKey;
/* @Override /* @Override
public void sendEmail(NoticeBean noticeBean) { public void sendEmail(NoticeBean noticeBean) {
@ -120,10 +131,6 @@ public class MailServiceImp implements MailService {
String postUrl = mailHost + "/mail?" + generateMailSignParam(); String postUrl = mailHost + "/mail?" + generateMailSignParam();
HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute(); HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute();
if (result.isSuccess()) { if (result.isSuccess()) {
String mail_id = result.getResponseContentJSONObj().getString("mail_id"); String mail_id = result.getResponseContentJSONObj().getString("mail_id");
@ -234,8 +241,13 @@ public class MailServiceImp implements MailService {
mailClients.add(mailClient); mailClients.add(mailClient);
noticeBean.setMailClients(mailClients); noticeBean.setMailClients(mailClients);
noticeBean.setContent(content); noticeBean.setContent(content);
noticeBean.setSenderAddress("settlement@royalpay.com.au"); JSONObject sysConfig = sysConfigManager.getSysConfig();
noticeBean.setPassword("MMKdMn7dJj49jp"); noticeBean.setSenderAddress(sysConfig.getString("settle.email.address"));
String mailPwdEncrypted = sysConfig.getString("settle.email.password");
Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "Settlement mail pwd not configured");
Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(settleAESKey));
String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8);
noticeBean.setPassword(mailPwd);
noticeBean.setAttachFiles(attachFiles); noticeBean.setAttachFiles(attachFiles);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam(); String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null; HttpRequestResult result = null;

@ -115,7 +115,7 @@ royalpay.sms.appkey=43390d81e20c5191c278fbf4cd275be2
im.openim.appkey=24986533 im.openim.appkey=24986533
im.openim.secret=96e28e7be21a874177211c31834b5174 im.openim.secret=96e28e7be21a874177211c31834b5174
app.settle.aes-key=EPrfsM2JE69ZPR7BhXn34g==
#清算银行配置 #清算银行配置
settle.abafile.default-bank=CBA settle.abafile.default-bank=CBA
settle.abafile.remains-to=ANZ settle.abafile.remains-to=ANZ

@ -0,0 +1,29 @@
package au.com.royalpay.payment.manage.process.aes;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import org.apache.commons.net.util.Base64;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.security.Key;
/**
* Create by yixian at 2018-09-17 12:55
*/
public class AESTest {
@Test
public void initAESKey() {
System.out.println(Base64.encodeBase64String(AESCrypt.randomKey().getEncoded()));
}
@Test
public void testEncrypt() {
String keyStr = "EPrfsM2JE69ZPR7BhXn34g==";
String source = "123456";
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(keyStr));
byte[] encrypted = AESCrypt.encrypt(source.getBytes(StandardCharsets.UTF_8), key);
System.out.println("encrypted: " + Base64.encodeBase64String(encrypted));
System.out.println("validate: " + new String(AESCrypt.decrypt(encrypted, key), StandardCharsets.UTF_8));
}
}
Loading…
Cancel
Save