diff --git a/pom.xml b/pom.xml index 49ecfbab973d4fa4f967f660b62650319bc7fa2a..6e6cdb651d900511884a6b97dbc72f5af3d71e10 100644 --- a/pom.xml +++ b/pom.xml @@ -85,11 +85,14 @@ org.powermock powermock-api-mockito2 + test ${powermock.version} + org.powermock powermock-module-junit4 + test ${powermock.version} @@ -157,7 +160,6 @@ - dev diff --git a/spring-brick-bootstrap/pom.xml b/spring-brick-bootstrap/pom.xml index 2c7d6aa13ffa73ae5f1fae1045055d570029ac62..5e1c5c6a4ce96373b51e0f22ce232fe3f82cddc9 100644 --- a/spring-brick-bootstrap/pom.xml +++ b/spring-brick-bootstrap/pom.xml @@ -13,13 +13,9 @@ spring-brick-bootstrap jar - 插件引导模块 + 插件启动引导模块 - 1.8 - UTF-8 - 3.8.1 - 1.9.6 1.7.7 2.11.3 @@ -36,11 +32,13 @@ aspectjweaver ${aspectj.version} + org.slf4j slf4j-api ${slf4j.version} + com.gitee.starblues spring-brick @@ -48,11 +46,13 @@ provided true + com.fasterxml.jackson.core jackson-databind ${jackson.version} + org.springframework.boot spring-boot @@ -60,6 +60,7 @@ provided true + org.springframework spring-webmvc @@ -67,6 +68,7 @@ provided true + org.springdoc springdoc-openapi-common @@ -74,6 +76,7 @@ provided true + javax.servlet javax.servlet-api diff --git a/spring-brick-common/pom.xml b/spring-brick-common/pom.xml index 460059ed32d30789ca04b514ff564f7a3c4ac4db..a0e3e5a5f1b8d3eaec38fda773810fca3ae42043 100644 --- a/spring-brick-common/pom.xml +++ b/spring-brick-common/pom.xml @@ -11,12 +11,7 @@ spring-brick-common + 框架公共模块 jar - - 1.8 - UTF-8 - 3.8.1 - - \ No newline at end of file diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java new file mode 100644 index 0000000000000000000000000000000000000000..52373cae632e5623e69d9daafc17471926a3eaec --- /dev/null +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java @@ -0,0 +1,81 @@ +/** + * Copyright [2019-2022] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.common.cipher; + +import com.gitee.starblues.utils.Assert; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +/** + * AES 加密 + * + * @author starBlues + * @version 3.0.1 + */ +public class AesPluginCipher extends AbstractPluginCipher{ + + public final static String SECRET_KEY = "secretKey"; + + private static final String INSTANCE_KEY = "AES/ECB/PKCS5Padding"; + private static final String AES_KEY = "AES"; + + @Override + protected String encryptImpl(String sourceStr) throws Exception { + Key convertSecretKey = getKey(); + Cipher cipher = Cipher.getInstance(INSTANCE_KEY); + cipher.init(Cipher.ENCRYPT_MODE, convertSecretKey); + byte[] result = cipher.doFinal(sourceStr.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(result); + } + + @Override + protected String decryptImpl(String cryptoStr) throws Exception { + Key convertSecretKey = getKey(); + Cipher cipher = Cipher.getInstance(INSTANCE_KEY); + cipher.init(Cipher.DECRYPT_MODE, convertSecretKey); + byte[] decode = Base64.getDecoder().decode(cryptoStr); + byte[] result = cipher.doFinal(decode); + return new String(result, StandardCharsets.UTF_8); + } + + + private Key getKey() throws Exception{ + String secretKey = super.parameters.getString(SECRET_KEY); + Assert.isNotEmpty(secretKey, SECRET_KEY + " 不能为空"); + byte[] keyBytes = Base64.getDecoder().decode(secretKey); + return new SecretKeySpec(keyBytes, AES_KEY); + } + + /** + * 获取秘钥 + * @return 秘钥字符串 + * @throws NoSuchAlgorithmException NoSuchAlgorithmException + */ + public static String generateKey() throws Exception { + KeyGenerator keyGenerator = KeyGenerator.getInstance(AES_KEY); + keyGenerator.init(128); + Key secretKey = keyGenerator.generateKey(); + byte[] keyBytes = secretKey.getEncoded(); + return Base64.getEncoder().encodeToString(keyBytes); + } + +} diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java index b5d17daf717ce8b5b87d0914ed6d10d5874870b8..26dbff2f9745394cc4a471bf10e8ff5ee44c823b 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java @@ -28,7 +28,6 @@ import java.security.interfaces.RSAPublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; import java.util.Base64; -import java.util.Map; /** * 非对称插件加解密 @@ -52,7 +51,6 @@ public class RsaPluginCipher extends AbstractPluginCipher{ RSAPublicKey pubKey = (RSAPublicKey) KeyFactory .getInstance("RSA") .generatePublic(new X509EncodedKeySpec(decoded)); - //RSA加密 Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); return Base64.getEncoder().encodeToString(cipher.doFinal(sourceStr.getBytes(StandardCharsets.UTF_8))); @@ -62,12 +60,9 @@ public class RsaPluginCipher extends AbstractPluginCipher{ protected String decryptImpl(String cryptoStr) throws Exception { String privateKey = super.parameters.getString(PRIVATE_KEY); Assert.isNotEmpty(privateKey, PRIVATE_KEY + " 不能为空"); - //64位解码加密后的字符串 byte[] inputByte = Base64.getDecoder().decode(cryptoStr.getBytes(StandardCharsets.UTF_8)); - //base64编码的私钥 byte[] decoded = Base64.getDecoder().decode(privateKey); RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded)); - //RSA解密 Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, priKey); return new String(cipher.doFinal(inputByte)); diff --git a/spring-brick-loader/pom.xml b/spring-brick-loader/pom.xml index b340b56ef1a4357900b58340351a20a0295fb546..8fc2cb2e2f300a787bc32672b253f99c7630e6de 100644 --- a/spring-brick-loader/pom.xml +++ b/spring-brick-loader/pom.xml @@ -10,7 +10,7 @@ 4.0.0 spring-brick-loader - + 加载插件模块 \ No newline at end of file diff --git a/spring-brick-maven-packager/pom.xml b/spring-brick-maven-packager/pom.xml index 9a5b4c68396b9526a51ed31a0f005b9c2e98ec33..1037304504d7c5bc91621fed7d3757c7a4eece2f 100644 --- a/spring-brick-maven-packager/pom.xml +++ b/spring-brick-maven-packager/pom.xml @@ -13,7 +13,7 @@ spring-brick-maven-packager jar - 打包插件 + 用于打包主程序/插件模块 8 @@ -36,49 +36,50 @@ + com.gitee.starblues spring-brick-common ${project.version} + org.apache.maven maven-plugin-api ${maven-plugin-api.version} + org.apache.maven.plugin-tools maven-plugin-annotations ${maven-plugin-annotations.version} + org.apache.maven.shared maven-common-artifact-filters ${maven-common-artifact-filters.version} + org.apache.commons commons-compress ${commons-compress.version} + commons-io commons-io ${commons-io.version} - - org.projectlombok - lombok - ${lombok.version} - provided - true - + junit junit ${junit.version} test + diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java index c786d713c2f80e054cf621e50ca0fffdd7ebc7be..8fe7148d1e9272be0cdd31460fed24c4207e9a8c 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java @@ -19,9 +19,7 @@ package com.gitee.starblues.plugin.pack; import com.gitee.starblues.common.Constants; import com.gitee.starblues.plugin.pack.dev.DevConfig; import com.gitee.starblues.plugin.pack.dev.DevRepackager; -import com.gitee.starblues.plugin.pack.encrypt.EncryptConfig; -import com.gitee.starblues.plugin.pack.encrypt.RsaConfig; -import com.gitee.starblues.plugin.pack.encrypt.RsaEncryptPlugin; +import com.gitee.starblues.plugin.pack.encrypt.*; import com.gitee.starblues.plugin.pack.main.MainConfig; import com.gitee.starblues.plugin.pack.main.MainRepackager; import com.gitee.starblues.plugin.pack.prod.ProdConfig; @@ -36,6 +34,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -121,15 +120,10 @@ public class RepackageMojo extends AbstractPackagerMojo { if(encryptConfig == null){ return; } - RsaConfig rsa = encryptConfig.getRsa(); - if(rsa != null){ - String publicKey = rsa.getPublicKey(); - if(ObjectUtils.isEmpty(publicKey)){ - throw new MojoExecutionException("encryptConfig.rsa.publicKey can't be empty"); - } - RsaEncryptPlugin rsaEncryptPlugin = new RsaEncryptPlugin(publicKey); - PluginInfo encryptPluginInfo = rsaEncryptPlugin.encrypt(getPluginInfo()); - setPluginInfo(encryptPluginInfo); + EncryptPlugin encryptPlugin = new EncryptPluginFactory(); + PluginInfo pluginInfo = encryptPlugin.encrypt(encryptConfig, getPluginInfo()); + if(pluginInfo != null){ + setPluginInfo(pluginInfo); } } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..44cf434931c0a34835b1b78effc45bd74d524367 --- /dev/null +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java @@ -0,0 +1,32 @@ +/** + * Copyright [2019-2022] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.plugin.pack.encrypt; + +import lombok.Data; + +/** + * aes 加密配置 + * + * @author starBlues + * @version 3.0.1 + */ +@Data +public class AesConfig { + + private String secretKey; + +} diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java new file mode 100644 index 0000000000000000000000000000000000000000..2087232a127fb754c5256060ed41f42abd8e82c9 --- /dev/null +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java @@ -0,0 +1,43 @@ +package com.gitee.starblues.plugin.pack.encrypt; + +import com.gitee.starblues.common.cipher.AbstractPluginCipher; +import com.gitee.starblues.common.cipher.AesPluginCipher; +import com.gitee.starblues.common.cipher.RsaPluginCipher; +import com.gitee.starblues.plugin.pack.PluginInfo; +import com.gitee.starblues.utils.ObjectUtils; +import org.apache.maven.plugin.MojoExecutionException; + +import java.util.HashMap; +import java.util.Map; + +/** + * rsa 加密者 + * + * @author starBlues + * @version 3.0.1 + */ +public class AesEncryptPlugin implements EncryptPlugin{ + + + @Override + public PluginInfo encrypt(EncryptConfig encryptConfig, PluginInfo pluginInfo) throws Exception{ + AesConfig aesConfig = encryptConfig.getAes(); + if(aesConfig == null){ + return null; + } + + String secretKey = aesConfig.getSecretKey(); + if(ObjectUtils.isEmpty(secretKey)){ + throw new MojoExecutionException("encryptConfig.aes.secretKey can't be empty"); + } + AbstractPluginCipher pluginCipher = new AesPluginCipher(); + Map params = new HashMap<>(); + params.put(AesPluginCipher.SECRET_KEY, secretKey); + pluginCipher.initParams(params); + + String bootstrapClass = pluginInfo.getBootstrapClass(); + String encrypt = pluginCipher.encrypt(bootstrapClass); + pluginInfo.setBootstrapClass(encrypt); + return pluginInfo; + } +} diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java index acc0404a45c1d4433f3f84a16f1337e1aa341730..8aa5b2233ab0b57b0aaeb294dd068eb7e5fa65fb 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java @@ -28,5 +28,6 @@ import lombok.Data; public class EncryptConfig { private RsaConfig rsa; + private AesConfig aes; } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java index 9a64a861474e1a953cc89d5ec80b94cef8de6454..b995f9d73d18cacc6e33e5d337f15dfdd6cc5b6c 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java @@ -26,12 +26,14 @@ import com.gitee.starblues.plugin.pack.PluginInfo; */ public interface EncryptPlugin { + /** - * 加密插件信息 - * @param pluginInfo 插件信息 - * @return 加密后的插件信息 + * 加密 + * @param pluginInfo 当前插件信息 + * @param encryptConfig 加密配置 + * @return 加密后得字符 * @throws Exception 加密异常 */ - PluginInfo encrypt(PluginInfo pluginInfo) throws Exception; + PluginInfo encrypt(EncryptConfig encryptConfig, PluginInfo pluginInfo) throws Exception; } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..f8a2c5b41adf0b9e138024550f89a871f8ae017e --- /dev/null +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java @@ -0,0 +1,49 @@ +/** + * Copyright [2019-2022] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.plugin.pack.encrypt; + +import com.gitee.starblues.plugin.pack.PluginInfo; + +import java.util.ArrayList; +import java.util.List; + +/** + * 加密插件工厂 + * + * @author starBlues + * @version 3.0.1 + */ +public class EncryptPluginFactory implements EncryptPlugin { + + private final List encryptPlugins = new ArrayList<>(); + + public EncryptPluginFactory(){ + encryptPlugins.add(new AesEncryptPlugin()); + encryptPlugins.add(new RsaEncryptPlugin()); + } + + @Override + public PluginInfo encrypt(EncryptConfig encryptConfig, PluginInfo pluginInfo) throws Exception{ + for (EncryptPlugin encryptPlugin : encryptPlugins) { + PluginInfo encrypt = encryptPlugin.encrypt(encryptConfig, pluginInfo); + if(encrypt != null){ + return encrypt; + } + } + return pluginInfo; + } +} diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java index 3d1554c7351c18b7ddf7218a77e23150b443a6ec..b8f4e5d6e04e9091b802db9ef5a911187df1b9e0 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java @@ -19,6 +19,8 @@ package com.gitee.starblues.plugin.pack.encrypt; import com.gitee.starblues.common.cipher.AbstractPluginCipher; import com.gitee.starblues.common.cipher.RsaPluginCipher; import com.gitee.starblues.plugin.pack.PluginInfo; +import com.gitee.starblues.utils.ObjectUtils; +import org.apache.maven.plugin.MojoExecutionException; import java.util.HashMap; import java.util.Map; @@ -31,20 +33,24 @@ import java.util.Map; */ public class RsaEncryptPlugin implements EncryptPlugin{ - private final AbstractPluginCipher pluginCipher; + @Override + public PluginInfo encrypt(EncryptConfig encryptConfig, PluginInfo pluginInfo) throws Exception { + RsaConfig rsaConfig = encryptConfig.getRsa(); + if(rsaConfig == null){ + return null; + } - public RsaEncryptPlugin(String publicKey) { - this.pluginCipher = new RsaPluginCipher(); + String publicKey = rsaConfig.getPublicKey(); + if(ObjectUtils.isEmpty(publicKey)){ + throw new MojoExecutionException("encryptConfig.rsa.publicKey can't be empty"); + } + AbstractPluginCipher pluginCipher = new RsaPluginCipher(); Map params = new HashMap<>(); params.put(RsaPluginCipher.PUBLIC_KEY, publicKey); - this.pluginCipher.initParams(params); - } + pluginCipher.initParams(params); - @Override - public PluginInfo encrypt(PluginInfo pluginInfo) throws Exception { String bootstrapClass = pluginInfo.getBootstrapClass(); - String encrypt = pluginCipher.encrypt(bootstrapClass); - pluginInfo.setBootstrapClass(encrypt); + pluginInfo.setBootstrapClass(pluginCipher.encrypt(bootstrapClass)); return pluginInfo; } } diff --git a/spring-brick/pom.xml b/spring-brick/pom.xml index 092ba2d2fa268f3b1dd2553b994e6ea75d053681..385671a2241abbe5716da622f92d184f8713ecb2 100644 --- a/spring-brick/pom.xml +++ b/spring-brick/pom.xml @@ -13,7 +13,7 @@ spring-brick jar - spring boot 插件式开发集成包 + 核心集成包, 用于框架集成 2.10.1 @@ -36,26 +36,31 @@ spring-brick-common ${project.version} + com.gitee.starblues spring-brick-loader ${project.version} + org.slf4j slf4j-api ${slf4j.version} + commons-io commons-io ${commons-io.version} + com.github.zafarkhaja java-semver ${java-semver.version} + org.springframework.boot spring-boot @@ -63,6 +68,7 @@ provided true + org.springframework spring-webmvc @@ -70,6 +76,7 @@ provided true + org.thymeleaf thymeleaf-spring5 @@ -77,6 +84,7 @@ provided true + javax.servlet javax.servlet-api @@ -84,6 +92,7 @@ provided true + io.springfox springfox-spring-web @@ -91,6 +100,7 @@ provided true + org.springdoc springdoc-openapi-ui @@ -98,12 +108,6 @@ provided true - - junit - junit - ${junit.version} - test - \ No newline at end of file diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java index edc72927b62837a06a3934e5be79989918fe0f9d..dd88e4bdab7228d59060b4b221125c5e8c07a9bf 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java @@ -313,7 +313,8 @@ public class DefaultPluginManager implements PluginManager{ log.info("更新插件[{}]成功", MsgUtils.getPluginUnique(upgradePluginDescriptor)); return upgradePlugin; } catch (Exception e){ - throw PluginException.getPluginException(e, ()-> new PluginException(upgradePluginDescriptor, "更新失败", e)); + throw PluginException.getPluginException(e, ()-> + new PluginException(upgradePluginDescriptor, "更新失败", e)); } } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginLauncher.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginLauncher.java index 1783a51d2650eef5efea24883192cbf830654ffc..538c35486670333522523e0cb53bbffd5d13dd33 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginLauncher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginLauncher.java @@ -23,8 +23,8 @@ import com.gitee.starblues.loader.classloader.GenericClassLoader; import com.gitee.starblues.loader.classloader.resource.loader.DefaultResourceLoaderFactory; import com.gitee.starblues.loader.classloader.resource.loader.ResourceLoaderFactory; import com.gitee.starblues.loader.launcher.AbstractLauncher; -import com.gitee.starblues.loader.launcher.ResourceLoaderFactoryGetter; import com.gitee.starblues.spring.SpringPluginHook; +import com.gitee.starblues.utils.MsgUtils; import java.util.Map; import java.util.WeakHashMap; @@ -61,7 +61,8 @@ public class PluginLauncher extends AbstractLauncher { protected synchronized PluginClassLoader getPluginClassLoader() throws Exception { String pluginId = pluginDescriptor.getPluginId(); - PluginClassLoader classLoader = CLASS_LOADER_CACHE.get(pluginId); + String key = MsgUtils.getPluginUnique(pluginDescriptor); + PluginClassLoader classLoader = CLASS_LOADER_CACHE.get(key); if(classLoader != null){ return classLoader; } @@ -69,7 +70,7 @@ public class PluginLauncher extends AbstractLauncher { pluginId, getParentClassLoader(), mainResourcePatternDefiner, getResourceLoaderFactory() ); - CLASS_LOADER_CACHE.put(pluginId, pluginClassLoader); + CLASS_LOADER_CACHE.put(key, pluginClassLoader); return pluginClassLoader; } diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java index 4edff5abd463f91391af6de41fd183158094bf06..111210212c5e126773d76821832427e5d3e65687 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java @@ -16,6 +16,7 @@ package com.gitee.starblues.integration.decrypt; +import com.gitee.starblues.common.cipher.AesPluginCipher; import com.gitee.starblues.common.cipher.RsaPluginCipher; import lombok.Data; @@ -40,9 +41,12 @@ public class DecryptConfiguration { /** * 加解密实现类名称. * 通过类加载器加载, 然后从Spring容器中获取, 获取不到, 对其直接实例化 - * 默认: {@link RsaPluginCipher} + * 默认: {@link AesPluginCipher} + * 可选: + * @see com.gitee.starblues.common.cipher.AesPluginCipher + * @see com.gitee.starblues.common.cipher.RsaPluginCipher */ - private String className = RsaPluginCipher.class.getName(); + private String className = AesPluginCipher.class.getName(); /** * 总配置 diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java index af9d919caa012e8a5f8dccef498f2bf841615be8..8111151460967efe2dcdcb122efdf23882d3e584 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java @@ -302,6 +302,8 @@ public class DefaultPluginOperator implements PluginOperator { } // 然后进入更新模式 pluginInfo = pluginManager.upgrade(tempFilePath, isUnpackPluginFile); + // 删除旧插件包 + FileUtils.delete(oldPluginPath.toFile()); } else { // 不存在则进入安装插件模式 pluginInfo = pluginManager.install(tempFilePath, isUnpackPluginFile); diff --git a/update.md b/update.md new file mode 100644 index 0000000000000000000000000000000000000000..0589fe80bf2b8ecf578b47254921a1e77eb07f37 --- /dev/null +++ b/update.md @@ -0,0 +1,5 @@ +1. 新增插件包启动时可进行密码校验功能。 +2. 修复插件动态安装的问题。 +3. 修复主程序打包为生产环境jar包后,启动问题。 +4. 修复插件更新时, 版本校验问题。 +5. 修复插件排序、启用、禁用配置无效的问题。 \ No newline at end of file