src/main/java/com/se/simu/helper/RsaHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/se/simu/service/DbService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/se/simu/service/GedbService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/se/simu/helper/RsaHelper.java
@@ -137,4 +137,17 @@ return outStr; } public static String encrypt(String key, String str) throws Exception { byte[] decoded = Base64.decodeBase64(key); RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); return outStr; } } src/main/java/com/se/simu/service/DbService.java
@@ -57,7 +57,7 @@ private String getPublicKey() { Object obj = CaffeineHelper.get(PUBLIC_KEY); if (obj instanceof GeDb) { if (obj instanceof String) { return (String) obj; } @@ -86,9 +86,8 @@ map.put("count", vo.getCount()); map.put("start", vo.getStart()); map.put("querytype", vo.getQuerytype()); if (StringHelper.isEmpty(vo.getWhere())) { RsaHelper.setPublicKey(getPublicKey()); String where = RsaHelper.encrypt(vo.getWhere()); if (!StringHelper.isEmpty(vo.getWhere())) { String where = RsaHelper.encrypt(getPublicKey(), vo.getWhere()); map.put("where", vo.getWhere()); } if (!StringHelper.isEmpty(vo.getGeometry())) { src/main/java/com/se/simu/service/GedbService.java
@@ -109,7 +109,7 @@ return password; } private String getPublicKey() { public String getPublicKey() { //{"datetime":"2024-09-12 17:24:38","code":200,"data":"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtFwJCh2taVTEi05C8qT2oG7Y+rDmJhlO4zicpSeRtiro9LsytePeWI7BXM6sfDU0WeKun1izawcfgGkZgnoJuMBluAOKI1tL0uCrR+DreNLqMVtnXHwoWEIk/hGJedDWaf3q22aGDyEB5h9qCq0JklSShP1Ih4ppap4LmgxdTPQIDAQAB"} JSONObject obj = restTemplate.getForObject(config.getHost() + "account-service/security/publickey", JSONObject.class);