|
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -112,9 +113,14 @@ public class EmailConfigServiceImpl implements EmailConfigService {
|
|
ResultVo vo = new ResultVo(ResultCode.CONNECT_SUCCESS);
|
|
ResultVo vo = new ResultVo(ResultCode.CONNECT_SUCCESS);
|
|
MailboxInfoDTO mailboxInfoDTO = new MailboxInfoDTO();
|
|
MailboxInfoDTO mailboxInfoDTO = new MailboxInfoDTO();
|
|
mailboxInfoDTO.setAccount(mailboxInfoVO.getEmail());
|
|
mailboxInfoDTO.setAccount(mailboxInfoVO.getEmail());
|
|
- String publicKey = this.properties.getSecurityRsa().getPublicKey();
|
|
|
|
- String password = new RSA(null, publicKey).decryptStr(mailboxInfoVO.getPassword(), KeyType.PublicKey);
|
|
|
|
- mailboxInfoDTO.setPassword(password);
|
|
|
|
|
|
+ try{
|
|
|
|
+ String publicKey = this.properties.getSecurityRsa().getPublicKey();
|
|
|
|
+ String privateKey = this.properties.getSecurityRsa().getPrivateKey();
|
|
|
|
+ String password = new RSA(privateKey, publicKey).decryptStr(mailboxInfoVO.getPassword(), KeyType.PrivateKey);
|
|
|
|
+ mailboxInfoDTO.setPassword(password);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
|
+ }
|
|
mailboxInfoDTO.setPort(mailboxInfoVO.getPort());
|
|
mailboxInfoDTO.setPort(mailboxInfoVO.getPort());
|
|
mailboxInfoDTO.setHost(mailboxInfoVO.getServer());
|
|
mailboxInfoDTO.setHost(mailboxInfoVO.getServer());
|
|
mailboxInfoDTO.setProtocol(mailboxInfoVO.getProtocol());
|
|
mailboxInfoDTO.setProtocol(mailboxInfoVO.getProtocol());
|
|
@@ -135,12 +141,12 @@ public class EmailConfigServiceImpl implements EmailConfigService {
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
- public void deleteEmailConfig(List<Integer> idList) {
|
|
|
|
|
|
+ public void deleteEmailConfig(Integer id) {
|
|
//删除定时任务
|
|
//删除定时任务
|
|
- for(Integer id : idList){
|
|
|
|
- MailboxInfoDO mailboxInfoDO = emailConfigMapper.searchEmailConfigById(id);
|
|
|
|
- QuartzUtils.deleteScheduleJob(scheduler,mailboxInfoDO.getEmail(),groupName);
|
|
|
|
- }
|
|
|
|
|
|
+ MailboxInfoDO mailboxInfoDO = emailConfigMapper.searchEmailConfigById(id);
|
|
|
|
+ QuartzUtils.deleteScheduleJob(scheduler,mailboxInfoDO.getEmail(),groupName);
|
|
|
|
+ List<Integer> idList = new ArrayList<>();
|
|
|
|
+ idList.add(id);
|
|
emailConfigMapper.deleteEmailConfigByIds(idList);
|
|
emailConfigMapper.deleteEmailConfigByIds(idList);
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
@@ -213,7 +219,15 @@ public class EmailConfigServiceImpl implements EmailConfigService {
|
|
MailboxInfoDO mailboxInfoDO = emailConfigMapper.searchEmailConfigById(id);
|
|
MailboxInfoDO mailboxInfoDO = emailConfigMapper.searchEmailConfigById(id);
|
|
MailboxInfoDTO mailboxInfoDTO = new MailboxInfoDTO();
|
|
MailboxInfoDTO mailboxInfoDTO = new MailboxInfoDTO();
|
|
mailboxInfoDTO.setAccount(mailboxInfoDO.getEmail());
|
|
mailboxInfoDTO.setAccount(mailboxInfoDO.getEmail());
|
|
- mailboxInfoDTO.setPassword(mailboxInfoDO.getPassword());
|
|
|
|
|
|
+ String password = mailboxInfoDO.getPassword();
|
|
|
|
+ try{
|
|
|
|
+ String publicKey = this.properties.getSecurityRsa().getPublicKey();
|
|
|
|
+ String privateKey = this.properties.getSecurityRsa().getPrivateKey();
|
|
|
|
+ password = new RSA(privateKey, publicKey).decryptStr(password, KeyType.PrivateKey);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
|
+ }
|
|
|
|
+ mailboxInfoDTO.setPassword(password);
|
|
mailboxInfoDTO.setPort(mailboxInfoDO.getPort());
|
|
mailboxInfoDTO.setPort(mailboxInfoDO.getPort());
|
|
mailboxInfoDTO.setHost(mailboxInfoDO.getServer());
|
|
mailboxInfoDTO.setHost(mailboxInfoDO.getServer());
|
|
mailboxInfoDTO.setProtocol(mailboxInfoDO.getProtocol());
|
|
mailboxInfoDTO.setProtocol(mailboxInfoDO.getProtocol());
|