Merge branch 'hotfix-mailpassword' into develop

master
yixian 6 years ago
commit b70b34f55f

@ -5,7 +5,7 @@
<parent>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId>
<version>0.2.0-dev</version>
<version>0.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -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.notice.beans.NoticeBean;
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.NotFoundException;
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.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -26,10 +30,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.ArrayList;
import java.util.List;
@ -53,7 +60,11 @@ public class MailServiceImp implements MailService {
@Resource
private MailUnsubMapper mailUnsubMapper;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientManager clientManager;
@Value("${app.settle.aes-key}")
private String settleAESKey;
/* @Override
public void sendEmail(NoticeBean noticeBean) {
@ -120,10 +131,6 @@ public class MailServiceImp implements MailService {
String postUrl = mailHost + "/mail?" + generateMailSignParam();
HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute();
if (result.isSuccess()) {
String mail_id = result.getResponseContentJSONObj().getString("mail_id");
@ -234,8 +241,13 @@ public class MailServiceImp implements MailService {
mailClients.add(mailClient);
noticeBean.setMailClients(mailClients);
noticeBean.setContent(content);
noticeBean.setSenderAddress("settlement@royalpay.com.au");
noticeBean.setPassword("MMKdMn7dJj49jp");
JSONObject sysConfig = sysConfigManager.getSysConfig();
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);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;

@ -115,7 +115,7 @@ royalpay.sms.appkey=43390d81e20c5191c278fbf4cd275be2
im.openim.appkey=24986533
im.openim.secret=96e28e7be21a874177211c31834b5174
app.settle.aes-key=EPrfsM2JE69ZPR7BhXn34g==
#清算银行配置
settle.abafile.default-bank=CBA
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