diff --git a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java index e4c3b72..8a555f5 100644 --- a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java +++ b/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 module; + public static Map 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); }