Skip to content

Commit

Permalink
1. 整理目录结构
Browse files Browse the repository at this point in the history
2. 增加正则表达式/Ant表达式过滤器和“非”not逻辑运算过滤器
3. 将XEntryFilters工具类整合在XKit类中
4. 缺省情况下Spring-Boot JAR包加密的资源只限定在BOOT-INF/classes/下
  • Loading branch information
core-lib committed Jan 23, 2019
1 parent c4add5c commit 0844a38
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
10 changes: 2 additions & 8 deletions src/main/java/io/xjar/boot/XBootDecryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@
* 2018/11/22 15:27
*/
public class XBootDecryptor extends XEntryDecryptor<JarArchiveEntry> implements XDecryptor, XConstants {
// 安全过滤器,避免由于用户自定义过滤器时把其他无关资源加密了造成无法运行
private final XEntryFilter<JarArchiveEntry> safeFilter = new XBootClassesFilter();
private final int level;

public XBootDecryptor(XDecryptor xEncryptor) {
this(xEncryptor, null);
this(xEncryptor, new XBootClassesFilter());
}

public XBootDecryptor(XDecryptor xDecryptor, XEntryFilter<JarArchiveEntry> filter) {
this(xDecryptor, Deflater.DEFLATED, filter);
}

public XBootDecryptor(XDecryptor xEncryptor, int level) {
this(xEncryptor, level, null);
this(xEncryptor, level, new XBootClassesFilter());
}

public XBootDecryptor(XDecryptor xDecryptor, int level, XEntryFilter<JarArchiveEntry> filter) {
Expand Down Expand Up @@ -121,8 +119,4 @@ public void decrypt(XKey key, InputStream in, OutputStream out) throws IOExcepti
}
}

@Override
public boolean filtrate(JarArchiveEntry entry) {
return super.filtrate(entry) && safeFilter.filtrate(entry);
}
}
10 changes: 2 additions & 8 deletions src/main/java/io/xjar/boot/XBootEncryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
* 2018/11/22 15:27
*/
public class XBootEncryptor extends XEntryEncryptor<JarArchiveEntry> implements XEncryptor, XConstants {
// 安全过滤器,避免由于用户自定义过滤器时把其他无关资源加密了造成无法运行
private final XEntryFilter<JarArchiveEntry> safeFilter = new XBootClassesFilter();
private final int level;

public XBootEncryptor(XEncryptor xEncryptor) {
this(xEncryptor, null);
this(xEncryptor, new XBootClassesFilter());
}

public XBootEncryptor(XEncryptor xEncryptor, XEntryFilter<JarArchiveEntry> filter) {
this(xEncryptor, Deflater.DEFLATED, filter);
}

public XBootEncryptor(XEncryptor xEncryptor, int level) {
this(xEncryptor, level, null);
this(xEncryptor, level, new XBootClassesFilter());
}

public XBootEncryptor(XEncryptor xEncryptor, int level, XEntryFilter<JarArchiveEntry> filter) {
Expand Down Expand Up @@ -150,8 +148,4 @@ public void encrypt(XKey key, InputStream in, OutputStream out) throws IOExcepti
}
}

@Override
public boolean filtrate(JarArchiveEntry entry) {
return super.filtrate(entry) && safeFilter.filtrate(entry);
}
}
4 changes: 4 additions & 0 deletions src/main/java/io/xjar/jar/XJarDecryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,8 @@ public void decrypt(XKey key, InputStream in, OutputStream out) throws IOExcepti
}
}

@Override
public boolean filtrate(JarArchiveEntry entry) {
return super.filtrate(entry) && !entry.getName().equals(META_INF_MANIFEST);
}
}
10 changes: 2 additions & 8 deletions src/main/java/io/xjar/war/XWarDecryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
* 2018/11/22 15:27
*/
public class XWarDecryptor extends XEntryDecryptor<JarArchiveEntry> implements XDecryptor, XConstants {
// 安全过滤器,避免由于用户自定义过滤器时把其他无关资源加密了造成无法运行
private final XEntryFilter<JarArchiveEntry> safeFilter = new XWarAllFilter();
private final int level;

public XWarDecryptor(XDecryptor xEncryptor) {
this(xEncryptor, null);
this(xEncryptor, new XWarClassesFilter());
}

public XWarDecryptor(XDecryptor xDecryptor, XEntryFilter<JarArchiveEntry> filter) {
this(xDecryptor, Deflater.DEFLATED, filter);
}

public XWarDecryptor(XDecryptor xEncryptor, int level) {
this(xEncryptor, level, null);
this(xEncryptor, level, new XWarClassesFilter());
}

public XWarDecryptor(XDecryptor xDecryptor, int level, XEntryFilter<JarArchiveEntry> filter) {
Expand Down Expand Up @@ -98,8 +96,4 @@ public void decrypt(XKey key, InputStream in, OutputStream out) throws IOExcepti
}
}

@Override
public boolean filtrate(JarArchiveEntry entry) {
return super.filtrate(entry) && safeFilter.filtrate(entry);
}
}
10 changes: 2 additions & 8 deletions src/main/java/io/xjar/war/XWarEncryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@
* 2018/11/22 15:27
*/
public class XWarEncryptor extends XEntryEncryptor<JarArchiveEntry> implements XEncryptor, XConstants {
// 安全过滤器,避免由于用户自定义过滤器时把其他无关资源加密了造成无法运行
private final XEntryFilter<JarArchiveEntry> safeFilter = new XWarAllFilter();
private final int level;

public XWarEncryptor(XEncryptor xEncryptor) {
this(xEncryptor, null);
this(xEncryptor, new XWarClassesFilter());
}

public XWarEncryptor(XEncryptor xEncryptor, XEntryFilter<JarArchiveEntry> filter) {
this(xEncryptor, Deflater.DEFLATED, filter);
}

public XWarEncryptor(XEncryptor xEncryptor, int level) {
this(xEncryptor, level, null);
this(xEncryptor, level, new XWarClassesFilter());
}

public XWarEncryptor(XEncryptor xEncryptor, int level, XEntryFilter<JarArchiveEntry> filter) {
Expand Down Expand Up @@ -121,8 +119,4 @@ public void encrypt(XKey key, InputStream in, OutputStream out) throws IOExcepti
}
}

@Override
public boolean filtrate(JarArchiveEntry entry) {
return super.filtrate(entry) && safeFilter.filtrate(entry);
}
}

0 comments on commit 0844a38

Please sign in to comment.