Search in sources :

Example 6 with ProxyDataImpl

use of lucee.runtime.net.proxy.ProxyDataImpl in project Lucee by lucee.

the class CreateObject method call.

public static Object call(PageContext pc, String type, String className, Object context, Object serverName) throws PageException {
    type = StringUtil.toLowerCase(type);
    // JAVA
    if (type.equals("java")) {
        checkAccess(pc, type);
        return doJava(pc, className, context, Caster.toString(serverName));
    }
    // COM
    if (type.equals("com")) {
        return doCOM(pc, className);
    }
    // Component
    if (type.equals("component") || type.equals("cfc")) {
        return doComponent(pc, className);
    }
    // Webservice
    if (type.equals("webservice") || type.equals("wsdl")) {
        String user = null;
        String pass = null;
        ProxyDataImpl proxy = null;
        if (context != null) {
            Struct args = (serverName != null) ? Caster.toStruct(serverName) : Caster.toStruct(context);
            // basic security
            user = Caster.toString(args.get("username", null));
            pass = Caster.toString(args.get("password", null));
            // proxy
            String proxyServer = Caster.toString(args.get("proxyServer", null));
            String proxyPort = Caster.toString(args.get("proxyPort", null));
            String proxyUser = Caster.toString(args.get("proxyUser", null));
            if (StringUtil.isEmpty(proxyUser))
                proxyUser = Caster.toString(args.get("proxyUsername", null));
            String proxyPassword = Caster.toString(args.get("proxyPassword", null));
            if (!StringUtil.isEmpty(proxyServer)) {
                proxy = new ProxyDataImpl(proxyServer, Caster.toIntValue(proxyPort, -1), proxyUser, proxyPassword);
            }
        }
        return doWebService(pc, className, user, pass, proxy);
    }
    if (type.equals("http")) {
        String user = null;
        String pass = null;
        ProxyDataImpl proxy = null;
        if (context != null) {
            Struct args = (serverName != null) ? Caster.toStruct(serverName) : Caster.toStruct(context);
            // basic security
            user = Caster.toString(args.get("username", null));
            pass = Caster.toString(args.get("password", null));
            // proxy
            String proxyServer = Caster.toString(args.get("proxyServer", null));
            String proxyPort = Caster.toString(args.get("proxyPort", null));
            String proxyUser = Caster.toString(args.get("proxyUser", null));
            if (StringUtil.isEmpty(proxyUser))
                proxyUser = Caster.toString(args.get("proxyUsername", null));
            String proxyPassword = Caster.toString(args.get("proxyPassword", null));
            if (!StringUtil.isEmpty(proxyServer)) {
                proxy = new ProxyDataImpl(proxyServer, Caster.toIntValue(proxyPort, -1), proxyUser, proxyPassword);
            }
        }
        return doHTTP(pc, className, user, pass, proxy);
    }
    // .net
    if (type.equals(".net") || type.equals("dotnet")) {
        return doDotNet(pc, className);
    }
    throw new ExpressionException("Invalid argument for function createObject, first argument (type), " + "must be (com, java, webservice or component) other types are not supported");
}
Also used : ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl) ExpressionException(lucee.runtime.exp.ExpressionException) Struct(lucee.runtime.type.Struct)

Aggregations

ProxyDataImpl (lucee.runtime.net.proxy.ProxyDataImpl)6 ProxyData (lucee.runtime.net.proxy.ProxyData)5 Struct (lucee.runtime.type.Struct)3 ApplicationException (lucee.runtime.exp.ApplicationException)2 ExpressionException (lucee.runtime.exp.ExpressionException)2 StructImpl (lucee.runtime.type.StructImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 lucee.aprint (lucee.aprint)1 Resource (lucee.commons.io.res.Resource)1 HTTPResource (lucee.commons.io.res.type.http.HTTPResource)1 RemoteClient (lucee.runtime.config.RemoteClient)1 RemoteClientImpl (lucee.runtime.config.RemoteClientImpl)1 PageException (lucee.runtime.exp.PageException)1 SpoolerEngineImpl (lucee.runtime.spooler.SpoolerEngineImpl)1 RemoteClientTask (lucee.runtime.spooler.remote.RemoteClientTask)1 Element (org.w3c.dom.Element)1 SAXException (org.xml.sax.SAXException)1