Search in sources :

Example 1 with ProxyDataImpl

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

the class WebserviceProxy method readArgs.

private static Data readArgs(Struct args) throws PageException {
    if (args != null) {
        // basic security
        ProxyDataImpl proxy = null;
        String user = Caster.toString(args.get("username", null));
        String 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 new Data(user, pass, proxy);
    }
    return EMPTY;
}
Also used : ProxyData(lucee.runtime.net.proxy.ProxyData) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl)

Example 2 with ProxyDataImpl

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

the class Feed method doStartTag.

@Override
public int doStartTag() throws PageException {
    if (source instanceof HTTPResource) {
        HTTPResource httpSource = (HTTPResource) source;
        if (!StringUtil.isEmpty(proxyServer, true)) {
            ProxyData data = new ProxyDataImpl(proxyServer, proxyPort, proxyUser, proxyPassword);
            httpSource.setProxyData(data);
        }
        if (!StringUtil.isEmpty(userAgent))
            httpSource.setUserAgent(userAgent);
        if (timeout > -1)
            httpSource.setTimeout(timeout * 1000);
    }
    try {
        if (ACTION_CREATE == action)
            doActionCreate();
        else if (ACTION_READ == action)
            doActionRead();
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
    return SKIP_BODY;
}
Also used : ProxyData(lucee.runtime.net.proxy.ProxyData) HTTPResource(lucee.commons.io.res.type.http.HTTPResource) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl) PageException(lucee.runtime.exp.PageException) IOException(java.io.IOException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) SAXException(org.xml.sax.SAXException)

Example 3 with ProxyDataImpl

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

the class ObjectTag method doStartTag.

@Override
public int doStartTag() throws PageException {
    if (component != null) {
        pageContext.setVariable(name, CreateObject.doComponent(pageContext, component));
    } else if (type.equals("java")) {
        checkAccess(pageContext, type);
        checkClass();
        pageContext.setVariable(name, CreateObject.doJava(pageContext, clazz, context, delimiters));
    } else if (type.equals("com")) {
        checkAccess(pageContext, type);
        checkClass();
        pageContext.setVariable(name, CreateObject.doCOM(pageContext, clazz));
    } else if (type.equals("webservice")) {
        checkAccess(pageContext, type);
        checkWebservice();
        ProxyData proxy = null;
        if (proxyServer != null) {
            proxy = new ProxyDataImpl(proxyServer, proxyPort, proxyUser, proxyPassword);
        }
        pageContext.setVariable(name, CreateObject.doWebService(pageContext, webservice, username, password, proxy));
    } else {
        if (type == null)
            throw new ApplicationException("to less attributes defined for tag object");
        throw new ApplicationException("wrong value for attribute type", "types are com,java,corba and the only supported type (at the moment) are com,component,java");
    }
    return SKIP_BODY;
}
Also used : ProxyData(lucee.runtime.net.proxy.ProxyData) ApplicationException(lucee.runtime.exp.ApplicationException) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl)

Example 4 with ProxyDataImpl

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

the class Admin method doVerifyRemoteClient.

private void doVerifyRemoteClient() throws PageException {
    // SNSN
    /*
		 * SerialNumber sn = config.getSerialNumber(); if(sn.getVersion()==SerialNumber.VERSION_COMMUNITY) throw new
		 * SecurityException("can not verify remote client with "+sn.getStringVersion()+" version of Lucee");
		 */
    ProxyData pd = null;
    String proxyServer = getString("proxyServer", null);
    if (!StringUtil.isEmpty(proxyServer)) {
        String proxyUsername = getString("proxyUsername", null);
        String proxyPassword = getString("proxyPassword", null);
        int proxyPort = getInt("proxyPort", -1);
        pd = new ProxyDataImpl();
        pd.setServer(proxyServer);
        if (!StringUtil.isEmpty(proxyUsername))
            pd.setUsername(proxyUsername);
        if (!StringUtil.isEmpty(proxyPassword))
            pd.setPassword(proxyPassword);
        if (proxyPort != -1)
            pd.setPort(proxyPort);
    }
    RemoteClient client = new RemoteClientImpl(getString("admin", action, "label"), type == TYPE_WEB ? "web" : "server", getString("admin", action, "url"), getString("serverUsername", null), getString("serverPassword", null), getString("admin", action, "adminPassword"), pd, getString("admin", action, "securityKey"), getString("admin", action, "usage"));
    Struct attrColl = new StructImpl();
    attrColl.setEL("action", "connect");
    try {
        new RemoteClientTask(null, client, attrColl, getCallerId(), "synchronisation").execute(config);
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        throw Caster.toPageException(t);
    }
}
Also used : ProxyData(lucee.runtime.net.proxy.ProxyData) StructImpl(lucee.runtime.type.StructImpl) RemoteClientImpl(lucee.runtime.config.RemoteClientImpl) RemoteClient(lucee.runtime.config.RemoteClient) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl) Struct(lucee.runtime.type.Struct) RemoteClientTask(lucee.runtime.spooler.remote.RemoteClientTask)

Example 5 with ProxyDataImpl

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

the class XMLConfigWebFactory method loadRemoteClient.

private static void loadRemoteClient(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManagerImpl.TYPE_REMOTE);
    // SNSN
    // RemoteClientUsage
    // boolean hasCS=configServer!=null;
    Element _clients = getChildByName(doc.getDocumentElement(), "remote-clients");
    // usage
    String strUsage = getAttr(_clients, "usage");
    Struct sct;
    if (!StringUtil.isEmpty(strUsage))
        // config.setRemoteClientUsage(toStruct(strUsage));
        sct = toStruct(strUsage);
    else
        sct = new StructImpl();
    // TODO make this generic
    if (configServer != null) {
        String sync = Caster.toString(configServer.getRemoteClientUsage().get("synchronisation", ""), "");
        if (!StringUtil.isEmpty(sync)) {
            sct.setEL("synchronisation", sync);
        }
    }
    config.setRemoteClientUsage(sct);
    // max-threads
    int maxThreads = Caster.toIntValue(getAttr(_clients, "max-threads"), -1);
    if (maxThreads < 1 && configServer != null) {
        SpoolerEngineImpl engine = (SpoolerEngineImpl) configServer.getSpoolerEngine();
        if (engine != null)
            maxThreads = engine.getMaxThreads();
    }
    if (maxThreads < 1)
        maxThreads = 20;
    // directory
    Resource file = ConfigWebUtil.getFile(config.getRootDirectory(), _clients.getAttribute("directory"), "client-task", config.getConfigDir(), FileUtil.TYPE_DIR, config);
    config.setRemoteClientDirectory(file);
    Element[] clients;
    Element client;
    if (!hasAccess)
        clients = new Element[0];
    else
        clients = getChildren(_clients, "remote-client");
    java.util.List<RemoteClient> list = new ArrayList<RemoteClient>();
    for (int i = 0; i < clients.length; i++) {
        client = clients[i];
        // type
        String type = getAttr(client, "type");
        if (StringUtil.isEmpty(type))
            type = "web";
        // url
        String url = getAttr(client, "url");
        String label = getAttr(client, "label");
        if (StringUtil.isEmpty(label))
            label = url;
        String sUser = getAttr(client, "server-username");
        String sPass = ConfigWebUtil.decrypt(getAttr(client, "server-password"));
        String aPass = ConfigWebUtil.decrypt(getAttr(client, "admin-password"));
        String aCode = ConfigWebUtil.decrypt(getAttr(client, "security-key"));
        // if(aCode!=null && aCode.indexOf('-')!=-1)continue;
        String usage = getAttr(client, "usage");
        if (usage == null)
            usage = "";
        String pUrl = getAttr(client, "proxy-server");
        int pPort = Caster.toIntValue(getAttr(client, "proxy-port"), -1);
        String pUser = getAttr(client, "proxy-username");
        String pPass = ConfigWebUtil.decrypt(getAttr(client, "proxy-password"));
        ProxyData pd = null;
        if (!StringUtil.isEmpty(pUrl, true)) {
            pd = new ProxyDataImpl();
            pd.setServer(pUrl);
            if (!StringUtil.isEmpty(pUser)) {
                pd.setUsername(pUser);
                pd.setPassword(pPass);
            }
            if (pPort > 0)
                pd.setPort(pPort);
        }
        list.add(new RemoteClientImpl(label, type, url, sUser, sPass, aPass, pd, aCode, usage));
    }
    if (list.size() > 0)
        config.setRemoteClients(list.toArray(new RemoteClient[list.size()]));
    else
        config.setRemoteClients(new RemoteClient[0]);
    // init spooler engine
    Resource dir = config.getRemoteClientDirectory();
    if (dir != null && !dir.exists())
        dir.mkdirs();
    if (config.getSpoolerEngine() == null) {
        config.setSpoolerEngine(new SpoolerEngineImpl(config, dir, "Remote Client Spooler", config.getLog("remoteclient"), maxThreads));
    } else {
        SpoolerEngineImpl engine = (SpoolerEngineImpl) config.getSpoolerEngine();
        engine.setConfig(config);
        engine.setLog(config.getLog("remoteclient"));
        engine.setPersisDirectory(dir);
        engine.setMaxThreads(maxThreads);
    }
}
Also used : Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) ArrayList(java.util.ArrayList) ProxyDataImpl(lucee.runtime.net.proxy.ProxyDataImpl) lucee.aprint(lucee.aprint) Struct(lucee.runtime.type.Struct) StructImpl(lucee.runtime.type.StructImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) SpoolerEngineImpl(lucee.runtime.spooler.SpoolerEngineImpl)

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