|
|
@@ -1,36 +1,222 @@
|
|
|
-# class-winter
|
|
|
+#### 郑重声明
|
|
|
+  class-winter是本人在学习完[class-final(v1.1.9)](https://gitee.com/roseboy/classfinal)后,仿照class-final进行编写的,整体思路与class-final一致,代码部分(约20%~30%)复用了class-final中的代码。一定程度上,可将class-winter看作是class-fianl的一个分支。
|
|
|
|
|
|
-#### Description
|
|
|
-{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
|
|
+## 功能与特性
|
|
|
+- 支持war加密。
|
|
|
+- 支持jar(普通jar+可执行jar)加密。
|
|
|
|
|
|
-#### Software Architecture
|
|
|
-Software architecture description
|
|
|
+## 加密方式
|
|
|
+- 方式一:通过maven插件自动加密。
|
|
|
+ ```xml
|
|
|
+ <!--
|
|
|
+ class-winter插件
|
|
|
+ 注:自Maven3.0.3起, 绑定到同一phase的Maven插件将按照pom.xml中声明的顺序执行
|
|
|
+ 注:此插件最好放置在同一phase的最后执行。
|
|
|
+ -->
|
|
|
+ <plugin>
|
|
|
+ <groupId>com.idea-aedi</groupId>
|
|
|
+ <artifactId>class-winter-maven-plugin</artifactId>
|
|
|
+ <version>1.0.0</version>
|
|
|
+ <!-- 相关配置 -->
|
|
|
+ <configuration>
|
|
|
+ <!-- <finalName></finalName>-->
|
|
|
+ <includePrefix>加密范围</includePrefix>
|
|
|
+ <!-- <excludePrefix></excludePrefix>-->
|
|
|
+ <!-- <password></password>-->
|
|
|
+ <!-- <includeLibs></includeLibs>-->
|
|
|
+ <!-- <alreadyProtectedLibs></alreadyProtectedLibs>-->
|
|
|
+ <!-- <supportFile></supportFile>-->
|
|
|
+ <!-- <tips></tips>-->
|
|
|
+ <!-- <debug></debug>-->
|
|
|
+ </configuration>
|
|
|
+ <executions>
|
|
|
+ <execution>
|
|
|
+ <phase>package</phase>
|
|
|
+ <goals>
|
|
|
+ <goal>class-winter</goal>
|
|
|
+ </goals>
|
|
|
+ </execution>
|
|
|
+ </executions>
|
|
|
+ </plugin>
|
|
|
+ ```
|
|
|
|
|
|
-#### Installation
|
|
|
+- 方式二:通过class-winter-core.jar主动加密。
|
|
|
|
|
|
-1. xxxx
|
|
|
-2. xxxx
|
|
|
-3. xxxx
|
|
|
+ ```bash
|
|
|
+ java -jar class-winter-core-${version}.jar originJarOrWar=${要加密的项目.jar或.war包} includePrefix=${加密范围} [k3=v3 k4=v4 ...]
|
|
|
+ # 对于复杂的参数值,可以使用引号引起来
|
|
|
+ # linux
|
|
|
+ java -jar class-winter-core-${version}.jar k1='v1' k2='v2'
|
|
|
+ # windows
|
|
|
+ java -jar class-winter-core-${version}.jar k1="v1" k2="v2"
|
|
|
+ ```
|
|
|
|
|
|
-#### Instructions
|
|
|
+## 加密参数说明
|
|
|
+<table>
|
|
|
+ <tr align="center">
|
|
|
+ <td>参数</td>
|
|
|
+ <td>是否必填</td>
|
|
|
+ <td>说明</td>
|
|
|
+ <td>示例</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>originJarOrWar</td>
|
|
|
+ <td>是</td>
|
|
|
+ <td>指定要加密的jar/war文件</td>
|
|
|
+ <td>originJarOrWar=/my-project.jar</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>includePrefix</td>
|
|
|
+ <td>是</td>
|
|
|
+ <td>通过前缀匹配的形式定位要加密的class
|
|
|
+注:多个通过逗号分割。</td>
|
|
|
+ <td>includePrefix=com
|
|
|
+includePrefix=com,org</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>excludePrefix</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>通过前缀匹配的形式排除class,不对其加密
|
|
|
+注:多个通过逗号分割。
|
|
|
+注:excludePrefix优先级高于includePrefix。</td>
|
|
|
+ <td>excludePrefix=com.example.service,com.example.util.StrUtil.class</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>finalName</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指定加密后生成的jar包名
|
|
|
+注:若finalName与加密的包一致,那么生成的加密后的包会覆盖原来的包。</td>
|
|
|
+ <td>finalName=mine-project</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>password</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>主动指定密码
|
|
|
+注:密码不能包含空格和逗号。</td>
|
|
|
+ <td>password=123456</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>includeLibs</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指定将lib包也纳入加密范围内
|
|
|
+注:多个通过逗号分割。
|
|
|
+注:lib中的class是否会被加密,还得由includePrefix和excludePrefix决定。</td>
|
|
|
+ <td>includeLibs=a.jar,b.jar</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>alreadyProtectedLibs</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指明项目所以来的lib中,哪些lib本身就已经是被class-winter加密了的
|
|
|
+注:多个通过逗号分割。
|
|
|
+注:主要用于处理第三方提供的由class-winter加密了的依赖包的场景。
|
|
|
+注:若lib需要密码,那么需要在指定lib的同时通过冒号接上密码。
|
|
|
+注:如果lib有密码,那么密码不能包含逗号。</td>
|
|
|
+ <td>alreadyProtectedLibs=a.jar,b.jar
|
|
|
+alreadyProtectedLibs=a.jar,b.jar:pwd123
|
|
|
+alreadyProtectedLibs=a.jar:pwd1,b.jar:2</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>supportFile</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指定一个加密辅助jar文件(或jar文件所在的目录)
|
|
|
+注:当为目录时,该目录(含子孙目录)下的所有jar都会被作采集作为辅助文件。
|
|
|
+注:主要用于解决因ClassNotFound导致的加密失败问题。</td>
|
|
|
+ <td>supportFile=/abc.jar
|
|
|
+supportFile=/libs</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>tips</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指定提示语。
|
|
|
+注:当直接使用加密后的jar/war时,用到了加密了的类后,会先System.err.println输出此tips,然后System.exit退出程序。</td>
|
|
|
+ <td>windows示例:tips=”请不要直接使用混淆后的jar/war”
|
|
|
|
|
|
-1. xxxx
|
|
|
-2. xxxx
|
|
|
-3. xxxx
|
|
|
+linux示例:tips=’请不要直接使用混淆后的jar/war’</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>debug</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>是否开启debug模式</td>
|
|
|
+ <td>debug=true</td>
|
|
|
+ </tr>
|
|
|
+</table>
|
|
|
|
|
|
-#### Contribution
|
|
|
|
|
|
-1. Fork the repository
|
|
|
-2. Create Feat_xxx branch
|
|
|
-3. Commit your code
|
|
|
-4. Create Pull Request
|
|
|
+## 解密(启动)
|
|
|
+通过-javaagent指定代理进行解密启动。
|
|
|
+#### jar解密(启动)
|
|
|
+示例说明
|
|
|
|
|
|
+```bash
|
|
|
+# 假设your-project-encrypted.jar是由class-winter加密后的包,那么你可以这么启动
|
|
|
+java -javaagent:/your-project-encrypted.jar -jar /your-project-encrypted.jar
|
|
|
+# 也可以用class-winter-core-1.0.0.jar
|
|
|
+java -javaagent:/class-winter-core-1.0.0.jar -jar /your-project-encrypted.jar
|
|
|
+# 或者指定参数
|
|
|
+# java -javaagent:/your-project-encrypted.jar=debug=true,password=pwd12345 -jar /your-project-encrypted.jar
|
|
|
+# 参数可以引起来(linux)
|
|
|
+# java -javaagent:/your-project-encrypted.jar='debug=true,password=pwd12345' -jar /your-project-encrypted.jar
|
|
|
+# 参数可以引起来(windows)
|
|
|
+# java -javaagent:/your-project-encrypted.jar="debug=true,password=pwd12345" -jar /your-project-encrypted.jar
|
|
|
+```
|
|
|
|
|
|
-#### Gitee Feature
|
|
|
+#### war解密(启动):
|
|
|
+- linux方式一
|
|
|
|
|
|
-1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
|
|
-2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
|
|
-3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
|
|
-4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
|
|
-5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
|
|
-6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
|
|
+ 编辑tomcat/bin/catalina.sh文件,在最上面加上
|
|
|
+
|
|
|
+ ```bash
|
|
|
+ # 如果你有参数, 那么 -javaagent:/class-winter-core-1.0.0.jar=k1=v1,k2=v2
|
|
|
+ CATALINA_OPTS="$CATALINA_OPTS -javaagent:/class-winter-core-1.0.0.jar=debug=true";
|
|
|
+ export CATALINA_OPTS;
|
|
|
+ ```
|
|
|
+
|
|
|
+- linux方式二
|
|
|
+
|
|
|
+ 在tomcat/bin目录下创建setenv.sh文件,并写上
|
|
|
+
|
|
|
+ ```bash
|
|
|
+ # 如果你有参数, 那么 -javaagent:/class-winter-core-1.0.0.jar=k1=v1,k2=v2
|
|
|
+ JAVA_OPTS="$JAVA_OPTS -javaagent:/class-winter-core-1.0.0.jar=debug=true";
|
|
|
+ export JAVA_OPTS;
|
|
|
+ ```
|
|
|
+
|
|
|
+- windows方式一
|
|
|
+
|
|
|
+ 编辑tomcat/bin/catalina.bat文件,在@echo off后加上catalina参数
|
|
|
+
|
|
|
+ ```bash
|
|
|
+ rem 如果你有参数, 那么 -javaagent:D:/class-winter-core-1.0.0.jar=k1=v1,k2=v2
|
|
|
+ set CATALINA_OPTS="-javaagent:D:/class-winter-core-1.0.0.jar"
|
|
|
+ ```
|
|
|
+
|
|
|
+- windows方式二
|
|
|
+
|
|
|
+ 在tomcat/bin目录下创建setenv.bat文件,并写上
|
|
|
+
|
|
|
+ ```bash
|
|
|
+ rem 如果你有参数, 那么 -javaagent:D:/class-winter-core-1.0.0.jar=k1=v1,k2=v2
|
|
|
+ set JAVA_OPTS="-javaagent:D:/class-winter-core-1.0.0.jar"
|
|
|
+ ```
|
|
|
+
|
|
|
+## 解密参数说明
|
|
|
+<table>
|
|
|
+ <tr align="center">
|
|
|
+ <td>参数</td>
|
|
|
+ <td>是否必填</td>
|
|
|
+ <td>说明</td>
|
|
|
+ <td>示例</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>password</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>指定解密密码</td>
|
|
|
+ <td>password=pwd123</td>
|
|
|
+ </tr>
|
|
|
+ <tr align="center">
|
|
|
+ <td>debug</td>
|
|
|
+ <td>否</td>
|
|
|
+ <td>是否开启debug模式</td>
|
|
|
+ <td>debug=true</td>
|
|
|
+ </tr>
|
|
|
+</table>
|