All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.highway2urhell.transformer.Struts2Transformer Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.highway2urhell.transformer;

import javassist.CtClass;
import javassist.CtMethod;

public class Struts2Transformer extends AbstractLeechTransformer {

    public Struts2Transformer() {
        super("org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter");
        addImportPackage(
                "com.opensymphony.xwork2.config",
                "com.opensymphony.xwork2.config.entities",
                "java.util",
                "java.lang.reflect",
                "org.objectweb.asm");
    }

    @Override
    protected void doTransform(CtClass cc) throws Exception {

        CtMethod m = cc
                .getMethod("postInit",
                        "(Lorg/apache/struts2/dispatcher/Dispatcher;Ljavax/servlet/FilterConfig;)V");
        String h2hHookCode = "" +
                "List listEntryPath = new ArrayList();" +
                "ConfigurationManager cm = dispatcher.getConfigurationManager();" +
                "Configuration cf = cm.getConfiguration();" +
                "Collection colPackages = cf.getPackageConfigs().values();" +
                "if (colPackages != null) {" +
                "   Iterator ite = colPackages.iterator();" +
                "   while(ite.hasNext()) {" +
                "       PackageConfig pack = (PackageConfig) ite.next();" +
                "       Collection colActionConfigs = pack.getActionConfigs().values();" +
                "       Iterator iteCol = colActionConfigs.iterator();" +
                "       while(iteCol.hasNext()) {" +
                "           ActionConfig action = (ActionConfig) iteCol.next();" +
                "           if (action.getClassName() != null && !\"\".equals(action.getClassName())) {" +
                "              try {" +
                "                  Class c = Class.forName(action.getClassName());" +
                "                  Method[] tabM = c.getDeclaredMethods();" +
                "                  for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy