Browse Source

1、证书续期发布订阅同步

master
bjang03 6 months ago
parent
commit
8806c9bbeb
  1. 8
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java

8
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java

@ -10,6 +10,7 @@ import javax.annotation.Resource;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@Component
public class ModuleAuthenUtils {
@ -17,7 +18,7 @@ public class ModuleAuthenUtils {
public static final String LICENCES_UPDATE_MESSAGE = "system.licences.message";
public static final String ALGORITHM = "AES";
public static String secretKey;
public static Map<String,String> module;
public static Map<String,String> module = new HashMap<>();
@Resource RedisTemplate redisTemplate;
public String decrypt(String encryptedData,String secretKey) throws Exception {
SecretKeySpec secretKeySpec = new SecretKeySpec(Base64.decode(secretKey), ALGORITHM);
@ -34,12 +35,15 @@ public class ModuleAuthenUtils {
return Base64.encode(encryptedBytes);
}
public void updateLicences(LicencesMessage ...message){
if(message != null){
if(message != null && message.length>0){
ModuleAuthenUtils.secretKey = message[0].getSecretKey();
ModuleAuthenUtils.module = message[0].getData();
return;
}
JSONObject json = new JSONObject(redisTemplate.opsForValue().get(ModuleAuthenUtils.LICENCES_REDIS_KEY));
if(json.isEmpty()){
return;
}
ModuleAuthenUtils.secretKey = json.getStr("secretKey");
ModuleAuthenUtils.module = json.getJSONObject("data").toBean(Map.class);
}

Loading…
Cancel
Save