|
@@ -41,9 +41,12 @@ import java.security.SecureRandom;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.Base64;
|
|
import java.util.Base64;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
|
+import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -131,7 +134,7 @@ public class EncryptExecutor {
|
|
|
* <br />
|
|
* <br />
|
|
|
* 注:可携带参数, 写法同url后面待参数 url?key1=value1&key2=value2
|
|
* 注:可携带参数, 写法同url后面待参数 url?key1=value1&key2=value2
|
|
|
*/
|
|
*/
|
|
|
- private final Set<String> includePrefixSet;
|
|
|
|
|
|
|
+ private final LinkedHashSet<String> includePrefixSet;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 要加密的lib包(若不指定,则加密筛选范围默认仅从项目代码本身进行筛选加密)。
|
|
* 要加密的lib包(若不指定,则加密筛选范围默认仅从项目代码本身进行筛选加密)。
|
|
@@ -220,7 +223,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,
|
|
|
- Set<String> includePrefixSet, Set<String> excludePrefixSet, Set<String> includeLibSet,
|
|
|
|
|
|
|
+ LinkedHashSet<String> includePrefixSet, Set<String> excludePrefixSet, Set<String> includeLibSet,
|
|
|
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;
|
|
@@ -1274,6 +1277,8 @@ public class EncryptExecutor {
|
|
|
Constant.WEB_INF, Constant.CLASSES);
|
|
Constant.WEB_INF, Constant.CLASSES);
|
|
|
|
|
|
|
|
Set<String> includePrefixSet = StrUtil.strToSet(includePrefix);
|
|
Set<String> includePrefixSet = StrUtil.strToSet(includePrefix);
|
|
|
|
|
+ LinkedHashSet<String> includePrefixSortSet = sortByPurePrefixLenthDesc(includePrefixSet);
|
|
|
|
|
+
|
|
|
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();
|
|
@@ -1302,10 +1307,30 @@ public class EncryptExecutor {
|
|
|
Set<String> toCleanXmlChildElementNameSet = StrUtil.strToSet(toCleanXmlChildElementName);
|
|
Set<String> toCleanXmlChildElementNameSet = StrUtil.strToSet(toCleanXmlChildElementName);
|
|
|
|
|
|
|
|
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, includePrefixSet,
|
|
|
|
|
|
|
+ password, includeXmlPrefixSet, excludeXmlPrefixSet, toCleanXmlChildElementNameSet, includePrefixSortSet,
|
|
|
excludePrefixSet, includeLibSet, alreadyProtectedRootDir, alreadyProtectedLibSet, this.supportFile, jvmArgCheckSet);
|
|
excludePrefixSet, includeLibSet, alreadyProtectedRootDir, alreadyProtectedLibSet, this.supportFile, jvmArgCheckSet);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按照(不带参数的)前缀的长度倒序
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param includePrefixSet 前缀集合
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return 倒序的前缀集合
|
|
|
|
|
+ */
|
|
|
|
|
+ private static LinkedHashSet<String> sortByPurePrefixLenthDesc(Set<String> includePrefixSet) {
|
|
|
|
|
+ List<String> includePrefixSortList = new ArrayList<>(includePrefixSet);
|
|
|
|
|
+ includePrefixSortList.sort(Comparator.comparingInt(x -> {
|
|
|
|
|
+ int idx = x.indexOf("?");
|
|
|
|
|
+ if (idx < 0) {
|
|
|
|
|
+ return x.length();
|
|
|
|
|
+ }
|
|
|
|
|
+ return x.substring(0, idx).length();
|
|
|
|
|
+ }));
|
|
|
|
|
+ Collections.reverse(includePrefixSortList);
|
|
|
|
|
+ return new LinkedHashSet<>(includePrefixSortList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 解析alreadyProtectedLibs信息为Set<Pair<String, String>>
|
|
* 解析alreadyProtectedLibs信息为Set<Pair<String, String>>
|
|
|
*/
|
|
*/
|