fix sysconfig email pwd update

master
yixian 4 years ago
parent 27a6123a64
commit e12c6cee69

@ -8,13 +8,16 @@ import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.EmailPasswordDecryptUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by yixian on 2017-01-06. * Created by yixian on 2017-01-06.
@ -22,6 +25,8 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/sysconfig") @RequestMapping("/sysconfig")
public class SysConfigController { public class SysConfigController {
@Resource
private EmailPasswordDecryptUtils emailPasswordDecryptUtils;
@Resource @Resource
private SysConfigManager sysConfigManager; private SysConfigManager sysConfigManager;
@Resource @Resource
@ -30,8 +35,15 @@ public class SysConfigController {
private SysPaymentConfig sysPaymentConfig; private SysPaymentConfig sysPaymentConfig;
@ManagerMapping(value = "/base", method = RequestMethod.GET) @ManagerMapping(value = "/base", method = RequestMethod.GET)
public JSONObject getBaseConfig() { public Map<String, Object> getBaseConfig() {
return sysConfigManager.getSysConfig(); JSONObject config = sysConfigManager.getSysConfig();
return config.entrySet().stream()
.peek(entry -> {
if (emailPasswordDecryptUtils.checkPrefix(entry.getKey())) {
String decrypted = emailPasswordDecryptUtils.decoding(entry.getKey(), entry.getValue().toString());
entry.setValue(decrypted);
}
}).collect(HashMap::new,(map,entry)->map.put(entry.getKey(),entry.getValue()), Map::putAll);
} }
@ManagerMapping(value = "/base", method = RequestMethod.PUT, role = ManagerRole.DEVELOPER) @ManagerMapping(value = "/base", method = RequestMethod.PUT, role = ManagerRole.DEVELOPER)

@ -28,7 +28,7 @@ public class AESTest {
@Test @Test
public void decode() { public void decode() {
String mailPwdEncrypted = "pLkLTFw8Xf3aa6US7USSwOQ2v/q+m7HTTFhk39l4BWI="; String mailPwdEncrypted = "31/5F7bKHYHaF0x0zk42lQ==";
String decodeKey = "EPrfsM2JE69ZPR7BhXn34g=="; String decodeKey = "EPrfsM2JE69ZPR7BhXn34g==";
Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(decodeKey)); Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(decodeKey));
String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8); String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8);

Loading…
Cancel
Save