// Path: src/main/java/ysoserial/payloads/util/Reflections.java
// @SuppressWarnings ( "restriction" )
// public class Reflections {
// 
//     public static void setAccessible(AccessibleObject member) {
//         String versionStr = System.getProperty("java.version");
//         int javaVersion = Integer.parseInt(versionStr.split("\\.")[0]);
//         if (javaVersion < 12) {
//           // quiet runtime warnings from JDK9+
//           Permit.setAccessible(member);
//         } else {
//           // not possible to quiet runtime warnings anymore...
//           // see https://bugs.openjdk.java.net/browse/JDK-8210522
//           // to understand impact on Permit (i.e. it does not work
//           // anymore with Java >= 12)
//           member.setAccessible(true);
//         }
//     }
// 
// 	public static Field getField(final Class<?> clazz, final String fieldName) {
//         Field field = null;
// 	try {
// 	    field = clazz.getDeclaredField(fieldName);
// 	    setAccessible(field);
//         }
//         catch (NoSuchFieldException ex) {
//             if (clazz.getSuperclass() != null)
//                 field = getField(clazz.getSuperclass(), fieldName);
//         }
// 		return field;
// 	}
// 
// 	public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		field.set(obj, value);
// 	}
// 
// 	public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		return field.get(obj);
// 	}
// 
// 	public static Constructor<?> getFirstCtor(final String name) throws Exception {
// 		final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
// 	    setAccessible(ctor);
// 	    return ctor;
// 	}
// 
// 	public static Object newInstance(String className, Object ... args) throws Exception {
//         return getFirstCtor(className).newInstance(args);
//     }
// 
//     public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
//     }
// 
//     @SuppressWarnings ( {"unchecked"} )
//     public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         Constructor<? super T> objCons = constructorClass.getDeclaredConstructor(consArgTypes);
// 	    setAccessible(objCons);
//         Constructor<?> sc = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(classToInstantiate, objCons);
// 	    setAccessible(sc);
//         return (T)sc.newInstance(consArgs);
//     }
// 
// }
// 
// Path: src/test/java/ysoserial/test/CustomDeserializer.java
// public interface CustomDeserializer {
// 
// 
//     Class<?> getCustomDeserializer ();
// 
// }
// 
// Path: src/main/java/ysoserial/Deserializer.java
// public class Deserializer implements Callable<Object> {
// 	private final byte[] bytes;
// 
// 	public Deserializer(byte[] bytes) { this.bytes = bytes; }
// 
// 	public Object call() throws Exception {
// 		return deserialize(bytes);
// 	}
// 
// 	public static Object deserialize(final byte[] serialized) throws IOException, ClassNotFoundException {
// 		final ByteArrayInputStream in = new ByteArrayInputStream(serialized);
// 		return deserialize(in);
// 	}
// 
// 	public static Object deserialize(final InputStream in) throws ClassNotFoundException, IOException {
// 		final ObjectInputStream objIn = new ObjectInputStream(in);
// 		return objIn.readObject();
// 	}
// 
// 	public static void main(String[] args) throws ClassNotFoundException, IOException {
// 		final InputStream in = args.length == 0 ? System.in : new FileInputStream(new File(args[0]));
// 		Object object = deserialize(in);
// 	}
// }


import java.beans.FeatureDescriptor;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.el.BeanELResolver;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.MapELResolver;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import org.apache.myfaces.el.CompositeELResolver;
import org.apache.myfaces.el.unified.FacesELContext;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import ysoserial.payloads.util.Reflections;
import ysoserial.test.CustomDeserializer;
import ysoserial.Deserializer;

            @Override
            public boolean isReadOnly ( ELContext context, Object base, Object property ) {
                return true;
            }


            @Override
            public Iterator<FeatureDescriptor> getFeatureDescriptors ( ELContext context, Object base ) {
                return null;
            }


            @Override
            public Class<?> getCommonPropertyType ( ELContext context, Object base ) {
                return null;
            }

        }

        public MyfacesDeserializer ( byte[] bytes ) {
            super(bytes);
        }


        @Override
        public Object call () throws Exception {
            java.lang.reflect.Method setFC = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class);
            Reflections.setAccessible(setFC);
            ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
// Path: src/main/java/ysoserial/payloads/util/Reflections.java
// @SuppressWarnings ( "restriction" )
// public class Reflections {
// 
//     public static void setAccessible(AccessibleObject member) {
//         String versionStr = System.getProperty("java.version");
//         int javaVersion = Integer.parseInt(versionStr.split("\\.")[0]);
//         if (javaVersion < 12) {
//           // quiet runtime warnings from JDK9+
//           Permit.setAccessible(member);
//         } else {
//           // not possible to quiet runtime warnings anymore...
//           // see https://bugs.openjdk.java.net/browse/JDK-8210522
//           // to understand impact on Permit (i.e. it does not work
//           // anymore with Java >= 12)
//           member.setAccessible(true);
//         }
//     }
// 
// 	public static Field getField(final Class<?> clazz, final String fieldName) {
//         Field field = null;
// 	try {
// 	    field = clazz.getDeclaredField(fieldName);
// 	    setAccessible(field);
//         }
//         catch (NoSuchFieldException ex) {
//             if (clazz.getSuperclass() != null)
//                 field = getField(clazz.getSuperclass(), fieldName);
//         }
// 		return field;
// 	}
// 
// 	public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		field.set(obj, value);
// 	}
// 
// 	public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
// 		final Field field = getField(obj.getClass(), fieldName);
// 		return field.get(obj);
// 	}
// 
// 	public static Constructor<?> getFirstCtor(final String name) throws Exception {
// 		final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
// 	    setAccessible(ctor);
// 	    return ctor;
// 	}
// 
// 	public static Object newInstance(String className, Object ... args) throws Exception {
//         return getFirstCtor(className).newInstance(args);
//     }
// 
//     public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
//     }
// 
//     @SuppressWarnings ( {"unchecked"} )
//     public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
//             throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
//         Constructor<? super T> objCons = constructorClass.getDeclaredConstructor(consArgTypes);
// 	    setAccessible(objCons);
//         Constructor<?> sc = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(classToInstantiate, objCons);
// 	    setAccessible(sc);
//         return (T)sc.newInstance(consArgs);
//     }
// 
// }
// 
// Path: src/test/java/ysoserial/test/CustomDeserializer.java
// public interface CustomDeserializer {
// 
// 
//     Class<?> getCustomDeserializer ();
// 
// }
// 
// Path: src/main/java/ysoserial/Deserializer.java
// public class Deserializer implements Callable<Object> {
// 	private final byte[] bytes;
// 
// 	public Deserializer(byte[] bytes) { this.bytes = bytes; }
// 
// 	public Object call() throws Exception {
// 		return deserialize(bytes);
// 	}
// 
// 	public static Object deserialize(final byte[] serialized) throws IOException, ClassNotFoundException {
// 		final ByteArrayInputStream in = new ByteArrayInputStream(serialized);
// 		return deserialize(in);
// 	}
// 
// 	public static Object deserialize(final InputStream in) throws ClassNotFoundException, IOException {
// 		final ObjectInputStream objIn = new ObjectInputStream(in);
// 		return objIn.readObject();
// 	}
// 
// 	public static void main(String[] args) throws ClassNotFoundException, IOException {
// 		final InputStream in = args.length == 0 ? System.in : new FileInputStream(new File(args[0]));
// 		Object object = deserialize(in);
// 	}
// }


// Path: src/test/java/ysoserial/test/payloads/MyfacesTest.java
import java.beans.FeatureDescriptor;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.el.BeanELResolver;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.MapELResolver;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import org.apache.myfaces.el.CompositeELResolver;
import org.apache.myfaces.el.unified.FacesELContext;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import ysoserial.payloads.util.Reflections;
import ysoserial.test.CustomDeserializer;
import ysoserial.Deserializer;


            @Override
            public boolean isReadOnly ( ELContext context, Object base, Object property ) {
                return true;
            }


            @Override
            public Iterator<FeatureDescriptor> getFeatureDescriptors ( ELContext context, Object base ) {
                return null;
            }


            @Override
            public Class<?> getCommonPropertyType ( ELContext context, Object base ) {
                return null;
            }

        }

        public MyfacesDeserializer ( byte[] bytes ) {
            super(bytes);
        }


        @Override
        public Object call () throws Exception {
            java.lang.reflect.Method setFC = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class);
            Reflections.setAccessible(setFC);
            ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());