|
|
@@ -39,6 +39,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.security.SecureRandom;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
|
@@ -194,7 +195,7 @@ public class EncryptExecutor {
|
|
|
/**
|
|
|
* 在启动jar包时,需要进行的jvm输入参数校验
|
|
|
*/
|
|
|
- private final Set<String> jvmStartCheckSet;
|
|
|
+ private final Set<String> jvmArgCheckSet;
|
|
|
|
|
|
/**
|
|
|
* 要加密的lib jar文件的绝对路径 & 其对应的加密临时目录
|
|
|
@@ -206,7 +207,7 @@ public class EncryptExecutor {
|
|
|
String targetLibDir, String targetClassesDir, String password,
|
|
|
Set<String> includeXmlPrefixSet, Set<String> excludeXmlPrefixSet, Set<String> toCleanXmlChildElementNameSet,
|
|
|
Set<String> includePrefixSet, Set<String> excludePrefixSet, Set<String> includeLibSet,
|
|
|
- Set<Pair<String, String>> alreadyProtectedLibSet, String supportFile, Set<String> jvmStartCheckSet) {
|
|
|
+ Set<Pair<String, String>> alreadyProtectedLibSet, String supportFile, Set<String> jvmArgCheckSet) {
|
|
|
this.originJarOrWar = originJarOrWar;
|
|
|
this.originIsJar = originIsJar;
|
|
|
this.finalName = finalName;
|
|
|
@@ -222,7 +223,7 @@ public class EncryptExecutor {
|
|
|
this.includeLibSet = includeLibSet;
|
|
|
this.alreadyProtectedLibSet = alreadyProtectedLibSet;
|
|
|
this.supportFile = supportFile;
|
|
|
- this.jvmStartCheckSet = jvmStartCheckSet;
|
|
|
+ this.jvmArgCheckSet = jvmArgCheckSet;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -265,9 +266,9 @@ public class EncryptExecutor {
|
|
|
showProcess("step05", lastStep, "record-seal");
|
|
|
generateSealFile();
|
|
|
|
|
|
- // step5. 记录sss(在解密时,可通过 checklist + 印章 判断一个class是否是被class-winter加密过)
|
|
|
- showProcess("step06", lastStep, "record-jvm-start-check-items");
|
|
|
- generateJvmStartCheckItems();
|
|
|
+ // step5. 设置启动jar包时需要检查的jvm参数项
|
|
|
+ showProcess("step06", lastStep, "setting-jvm-arg-check-items");
|
|
|
+ settingJvmArgCheckItems();
|
|
|
|
|
|
// step6. 混淆原.class文件(即:清空方法体)
|
|
|
clearClassMethod(allNeedEncryptedClassFileList);
|
|
|
@@ -643,23 +644,22 @@ public class EncryptExecutor {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 生成记录启动jar包时需要检查的输入参数项文件
|
|
|
+ * 设置启动jar包时需要检查的jvm参数项
|
|
|
*/
|
|
|
- private void generateJvmStartCheckItems() {
|
|
|
+ private void settingJvmArgCheckItems() {
|
|
|
String content;
|
|
|
- if (jvmStartCheckSet == null || jvmStartCheckSet.size() == 0) {
|
|
|
- content = Constant.JVM_START_CHECK_NO_ITEM_CONTENT;
|
|
|
+ if (jvmArgCheckSet == null || jvmArgCheckSet.size() == 0) {
|
|
|
+ content = Constant.JVM_ARG_CHECK_NO_ITEM_CONTENT;
|
|
|
} else {
|
|
|
StringBuilder sb = new StringBuilder(64);
|
|
|
- for (String checkItem : jvmStartCheckSet) {
|
|
|
+ for (String checkItem : jvmArgCheckSet) {
|
|
|
sb.append(checkItem).append(Constant.WHITE_SPACE);
|
|
|
}
|
|
|
content = sb.toString();
|
|
|
}
|
|
|
- Logger.debug(EncryptExecutor.class, "Generate jvmStartCheckItems -> " + content);
|
|
|
-// content = Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8));
|
|
|
-// final byte[] encryptedBytes = EncryptUtil.encrypt(content.getBytes(StandardCharsets.UTF_8), obtainPassword());
|
|
|
- IOUtil.toFile(content.getBytes(StandardCharsets.UTF_8), new File(targetRootDir, Constant.JVM_START_CHECK_FILE), true);
|
|
|
+ Logger.debug(EncryptExecutor.class, "SeDtting jvmArgCheckItems -> " + content);
|
|
|
+ byte[] encryptedBytes = EncryptUtil.encrypt(content.getBytes(StandardCharsets.UTF_8), obtainPassword());
|
|
|
+ IOUtil.toFile(Base64.getEncoder().encode(encryptedBytes), new File(targetRootDir, Constant.JVM_ARG_CHECK_FILE), true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -934,7 +934,7 @@ public class EncryptExecutor {
|
|
|
// 密码脱敏
|
|
|
", password='" + (StrUtil.isBlank(password) ? null : "******") + '\'' +
|
|
|
", supportFile='" + supportFile + '\'' +
|
|
|
- ", jvmStartCheckSet='" + jvmStartCheckSet + '\'' +
|
|
|
+ ", jvmArgCheckSet='" + jvmArgCheckSet + '\'' +
|
|
|
", includePrefixSet=" + includePrefixSet +
|
|
|
", excludePrefixSet=" + excludePrefixSet +
|
|
|
", includeXmlPrefixSet=" + includeXmlPrefixSet +
|
|
|
@@ -976,7 +976,7 @@ public class EncryptExecutor {
|
|
|
|
|
|
private String supportFile;
|
|
|
|
|
|
- private String jvmStartCheck;
|
|
|
+ private String jvmArgCheck;
|
|
|
|
|
|
private Boolean debug = false;
|
|
|
|
|
|
@@ -1037,8 +1037,8 @@ public class EncryptExecutor {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public Builder jvmStartCheck(String jvmStartCheck) {
|
|
|
- this.jvmStartCheck = jvmStartCheck;
|
|
|
+ public Builder jvmArgCheck(String jvmArgCheck) {
|
|
|
+ this.jvmArgCheck = jvmArgCheck;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
@@ -1141,13 +1141,13 @@ public class EncryptExecutor {
|
|
|
|
|
|
// xml相关参数解析
|
|
|
Set<String> includeXmlPrefixSet = StrUtil.strToSet(includeXmlPrefix);
|
|
|
- Set<String> jvmStartCheckSet = StrUtil.strToSet(jvmStartCheck);
|
|
|
+ Set<String> jvmArgCheckSet = StrUtil.strToSet(jvmArgCheck);
|
|
|
Set<String> excludeXmlPrefixSet = StrUtil.strToSet(excludeXmlPrefix);
|
|
|
toCleanXmlChildElementName = StrUtil.isBlank(toCleanXmlChildElementName) ? Constant.DEFAULT_XML_NODE_NAMES : toCleanXmlChildElementName;
|
|
|
Set<String> toCleanXmlChildElementNameSet = StrUtil.strToSet(toCleanXmlChildElementName);
|
|
|
return new EncryptExecutor(this.originJarOrWar, originIsJar, this.finalName, targetRootDir, targetLibDir, targetClassesDir,
|
|
|
password, includeXmlPrefixSet, excludeXmlPrefixSet, toCleanXmlChildElementNameSet, includePrefixSet,
|
|
|
- excludePrefixSet, includeLibSet, alreadyProtectedLibSet, this.supportFile, jvmStartCheckSet);
|
|
|
+ excludePrefixSet, includeLibSet, alreadyProtectedLibSet, this.supportFile, jvmArgCheckSet);
|
|
|
}
|
|
|
|
|
|
/**
|