|
@@ -155,6 +155,11 @@ public class EncryptExecutor {
|
|
|
* </pre>
|
|
* </pre>
|
|
|
*/
|
|
*/
|
|
|
private final Set<String> includeLibSet;
|
|
private final Set<String> includeLibSet;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 如果这次需要加密的lib本身就已经是被加密了的,那么这次不再对其进行加密
|
|
|
|
|
+ */
|
|
|
|
|
+ private final Set<String> protectedLibSet;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 不需要加密的类的全类名前缀(也可以精确匹配)
|
|
* 不需要加密的类的全类名前缀(也可以精确匹配)
|
|
@@ -223,7 +228,7 @@ public class EncryptExecutor {
|
|
|
private EncryptExecutor(String originJarOrWar, boolean originIsJar, String finalName, String targetRootDir,
|
|
private EncryptExecutor(String originJarOrWar, boolean originIsJar, String finalName, String targetRootDir,
|
|
|
String targetLibDir, String targetClassesDir, String password,
|
|
String targetLibDir, String targetClassesDir, String password,
|
|
|
Set<String> includeXmlPrefixSet, Set<String> excludeXmlPrefixSet, Set<String> toCleanXmlChildElementNameSet,
|
|
Set<String> includeXmlPrefixSet, Set<String> excludeXmlPrefixSet, Set<String> toCleanXmlChildElementNameSet,
|
|
|
- LinkedHashSet<String> includePrefixSet, Set<String> excludePrefixSet, Set<String> includeLibSet,
|
|
|
|
|
|
|
+ LinkedHashSet<String> includePrefixSet, Set<String> excludePrefixSet, Set<String> includeLibSet, Set<String> protectedLibSet,
|
|
|
String alreadyProtectedRootDir, Set<Pair<String, String>> alreadyProtectedLibSet,
|
|
String alreadyProtectedRootDir, Set<Pair<String, String>> alreadyProtectedLibSet,
|
|
|
String supportFile, Set<String> jvmArgCheckSet) {
|
|
String supportFile, Set<String> jvmArgCheckSet) {
|
|
|
this.originJarOrWar = originJarOrWar;
|
|
this.originJarOrWar = originJarOrWar;
|
|
@@ -239,6 +244,7 @@ public class EncryptExecutor {
|
|
|
this.includePrefixSet = includePrefixSet;
|
|
this.includePrefixSet = includePrefixSet;
|
|
|
this.excludePrefixSet = excludePrefixSet;
|
|
this.excludePrefixSet = excludePrefixSet;
|
|
|
this.includeLibSet = includeLibSet;
|
|
this.includeLibSet = includeLibSet;
|
|
|
|
|
+ this.protectedLibSet = protectedLibSet;
|
|
|
this.alreadyProtectedRootDir = alreadyProtectedRootDir;
|
|
this.alreadyProtectedRootDir = alreadyProtectedRootDir;
|
|
|
this.alreadyProtectedLibSet = alreadyProtectedLibSet;
|
|
this.alreadyProtectedLibSet = alreadyProtectedLibSet;
|
|
|
this.supportFile = supportFile;
|
|
this.supportFile = supportFile;
|
|
@@ -628,8 +634,8 @@ public class EncryptExecutor {
|
|
|
// 罗列出targetRootDir下的所有.jar文件
|
|
// 罗列出targetRootDir下的所有.jar文件
|
|
|
List<File> allJarFiles = IOUtil.listFileOnly(new File(targetRootDir), Constant.JAR_SUFFIX);
|
|
List<File> allJarFiles = IOUtil.listFileOnly(new File(targetRootDir), Constant.JAR_SUFFIX);
|
|
|
// 筛选出需要加密的lib包
|
|
// 筛选出需要加密的lib包
|
|
|
- List<File> neededEncryptedLibs = allJarFiles.stream().filter(jarFile -> includeLibSet.contains(jarFile.getName())).collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ List<File> neededEncryptedLibs = allJarFiles.stream().filter(jarFile -> !protectedLibSet.contains(jarFile.getName()) &&
|
|
|
|
|
+ includeLibSet.stream().anyMatch(s -> StrUtil.regMatched(s, jarFile.getName()))).collect(Collectors.toList());
|
|
|
// 依次解密
|
|
// 依次解密
|
|
|
neededEncryptedLibs.forEach(jar -> {
|
|
neededEncryptedLibs.forEach(jar -> {
|
|
|
// 假设: jarAbsolutePath为 /xyz/abc.jar
|
|
// 假设: jarAbsolutePath为 /xyz/abc.jar
|
|
@@ -1091,6 +1097,7 @@ public class EncryptExecutor {
|
|
|
", excludeXmlPrefixSet=" + excludeXmlPrefixSet +
|
|
", excludeXmlPrefixSet=" + excludeXmlPrefixSet +
|
|
|
", toCleanChildElementNameSet=" + toCleanXmlChildElementNameSet +
|
|
", toCleanChildElementNameSet=" + toCleanXmlChildElementNameSet +
|
|
|
", includeLibSet=" + includeLibSet +
|
|
", includeLibSet=" + includeLibSet +
|
|
|
|
|
+ ", protectedLibSet=" + protectedLibSet +
|
|
|
", alreadyProtectedLibSet=" + alreadyProtectedLibSet +
|
|
", alreadyProtectedLibSet=" + alreadyProtectedLibSet +
|
|
|
'}';
|
|
'}';
|
|
|
}
|
|
}
|
|
@@ -1281,12 +1288,14 @@ public class EncryptExecutor {
|
|
|
Set<String> excludePrefixSet = StrUtil.strToSet(excludePrefix);
|
|
Set<String> excludePrefixSet = StrUtil.strToSet(excludePrefix);
|
|
|
Set<String> includeLibSet = StrUtil.strToSet(includeLibs);
|
|
Set<String> includeLibSet = StrUtil.strToSet(includeLibs);
|
|
|
Set<Pair<String, String>> alreadyProtectedLibSet = parseAlreadyProtectedLibs();
|
|
Set<Pair<String, String>> alreadyProtectedLibSet = parseAlreadyProtectedLibs();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Set<String> matchAlreadyProtectedLibSet = new HashSet<>();
|
|
|
|
|
+
|
|
|
// 如果这次需要加密的lib本身就已经是被加密了的,那么这次不再对其进行加密
|
|
// 如果这次需要加密的lib本身就已经是被加密了的,那么这次不再对其进行加密
|
|
|
alreadyProtectedLibSet.stream().map(Pair::getLeft).forEach(lib -> {
|
|
alreadyProtectedLibSet.stream().map(Pair::getLeft).forEach(lib -> {
|
|
|
- if (includeLibSet.contains(lib)) {
|
|
|
|
|
|
|
+ if (includeLibSet.stream().anyMatch(s -> StrUtil.regMatched(s, lib))) {
|
|
|
Logger.warn(EncryptExecutor.class, "Ignore includeLibs item [" + lib + "], because this item already be protected by class-winter.");
|
|
Logger.warn(EncryptExecutor.class, "Ignore includeLibs item [" + lib + "], because this item already be protected by class-winter.");
|
|
|
- includeLibSet.remove(lib);
|
|
|
|
|
|
|
+ matchAlreadyProtectedLibSet.add(lib);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -1307,7 +1316,7 @@ public class EncryptExecutor {
|
|
|
|
|
|
|
|
return new EncryptExecutor(this.originJarOrWar, originIsJar, this.finalName, targetRootDir, targetLibDir, targetClassesDir,
|
|
return new EncryptExecutor(this.originJarOrWar, originIsJar, this.finalName, targetRootDir, targetLibDir, targetClassesDir,
|
|
|
password, includeXmlPrefixSet, excludeXmlPrefixSet, toCleanXmlChildElementNameSet, includePrefixSortSet,
|
|
password, includeXmlPrefixSet, excludeXmlPrefixSet, toCleanXmlChildElementNameSet, includePrefixSortSet,
|
|
|
- excludePrefixSet, includeLibSet, alreadyProtectedRootDir, alreadyProtectedLibSet, this.supportFile, jvmArgCheckSet);
|
|
|
|
|
|
|
+ excludePrefixSet, includeLibSet,matchAlreadyProtectedLibSet, alreadyProtectedRootDir, alreadyProtectedLibSet, this.supportFile, jvmArgCheckSet);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|