Search in sources :

Example 1 with ProxyData

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

the class Admin method doGetProxy.

private void doGetProxy() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    ProxyData pd = config.getProxyData();
    String port = pd == null || pd.getPort() <= 0 ? "" : Caster.toString(pd.getPort());
    // sct.set("enabled",Caster.toBoolean(config.isProxyEnable()));
    sct.set("port", port);
    sct.set("server", pd == null ? "" : emptyIfNull(pd.getServer()));
    sct.set("username", pd == null ? "" : emptyIfNull(pd.getUsername()));
    sct.set("password", pd == null ? "" : emptyIfNull(pd.getPassword()));
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) Struct(lucee.runtime.type.Struct)

Example 2 with ProxyData

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

the class SchedulerImpl method setAttributes.

/**
 * sets all attributes in XML Element from Schedule Task
 * @param el
 * @param task
 */
private void setAttributes(Element el, ScheduleTask task) {
    if (el == null)
        return;
    NamedNodeMap atts = el.getAttributes();
    for (int i = atts.getLength() - 1; i >= 0; i--) {
        Attr att = (Attr) atts.item(i);
        el.removeAttribute(att.getName());
    }
    su.setString(el, "name", task.getTask());
    su.setFile(el, "file", task.getResource());
    su.setDateTime(el, "startDate", task.getStartDate());
    su.setDateTime(el, "startTime", task.getStartTime());
    su.setDateTime(el, "endDate", task.getEndDate());
    su.setDateTime(el, "endTime", task.getEndTime());
    su.setString(el, "url", task.getUrl().toExternalForm());
    su.setInt(el, "port", task.getUrl().getPort());
    su.setString(el, "interval", task.getIntervalAsString());
    su.setInt(el, "timeout", (int) task.getTimeout());
    su.setCredentials(el, "username", "password", task.getCredentials());
    ProxyData pd = task.getProxyData();
    su.setString(el, "proxyHost", StringUtil.emptyIfNull(pd == null ? "" : pd.getServer()));
    su.setString(el, "proxyUser", StringUtil.emptyIfNull(pd == null ? "" : pd.getUsername()));
    su.setString(el, "proxyPassword", StringUtil.emptyIfNull(pd == null ? "" : pd.getPassword()));
    su.setInt(el, "proxyPort", pd == null ? 0 : pd.getPort());
    su.setBoolean(el, "resolveUrl", task.isResolveURL());
    su.setBoolean(el, "publish", task.isPublish());
    su.setBoolean(el, "hidden", ((ScheduleTaskImpl) task).isHidden());
    su.setBoolean(el, "readonly", ((ScheduleTaskImpl) task).isReadonly());
    su.setBoolean(el, "autoDelete", ((ScheduleTaskImpl) task).isAutoDelete());
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ProxyData(lucee.runtime.net.proxy.ProxyData) Attr(org.w3c.dom.Attr)

Example 3 with ProxyData

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

the class Admin method doGetRemoteClient.

private void doGetRemoteClient() throws PageException {
    String url = getString("admin", action, "url");
    RemoteClient[] clients = config.getRemoteClients();
    RemoteClient client;
    for (int i = 0; i < clients.length; i++) {
        client = clients[i];
        if (client.getUrl().equalsIgnoreCase(url)) {
            Struct sct = new StructImpl();
            ProxyData pd = client.getProxyData();
            sct.setEL("label", client.getLabel());
            sct.setEL("usage", client.getUsage());
            sct.setEL("securityKey", client.getSecurityKey());
            sct.setEL("adminPassword", client.getAdminPassword());
            sct.setEL("ServerUsername", client.getServerUsername());
            sct.setEL("ServerPassword", client.getServerPassword());
            sct.setEL("type", client.getType());
            sct.setEL("url", client.getUrl());
            sct.setEL("proxyServer", pd == null ? "" : StringUtil.emptyIfNull(pd.getServer()));
            sct.setEL("proxyUsername", pd == null ? "" : StringUtil.emptyIfNull(pd.getUsername()));
            sct.setEL("proxyPassword", pd == null ? "" : StringUtil.emptyIfNull(pd.getPassword()));
            sct.setEL("proxyPort", pd == null ? "" : (pd.getPort() == -1 ? "" : Caster.toString(pd.getPort())));
            pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
            return;
        }
    }
    throw new ApplicationException("there is no remote client with url [" + url + "]");
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ProxyData(lucee.runtime.net.proxy.ProxyData) ApplicationException(lucee.runtime.exp.ApplicationException) RemoteClient(lucee.runtime.config.RemoteClient) Struct(lucee.runtime.type.Struct)

Example 4 with ProxyData

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

the class HTTPResource method getHTTPResponse.

private HTTPResponse getHTTPResponse(boolean create) throws IOException {
    if (create || http == null) {
        // URL url = HTTPUtil.toURL("http://"+data.host+":"+data.port+"/"+data.path);
        URL url = new URL(provider.getProtocol(), data.host, data.port, data.path);
        // TODO Support for proxy
        ProxyData pd = data.hasProxyData() ? data.proxyData : ProxyDataImpl.NO_PROXY;
        http = HTTPEngine.get(url, data.username, data.password, _getTimeout(), true, null, data.userAgent, pd, null);
    }
    return http;
}
Also used : ProxyData(lucee.runtime.net.proxy.ProxyData) URL(java.net.URL)

Example 5 with ProxyData

use of lucee.runtime.net.proxy.ProxyData 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)

Aggregations

ProxyData (lucee.runtime.net.proxy.ProxyData)15 URL (java.net.URL)5 Struct (lucee.runtime.type.Struct)5 StructImpl (lucee.runtime.type.StructImpl)5 ApplicationException (lucee.runtime.exp.ApplicationException)4 ProxyDataImpl (lucee.runtime.net.proxy.ProxyDataImpl)4 IOException (java.io.IOException)3 Resource (lucee.commons.io.res.Resource)3 RemoteClient (lucee.runtime.config.RemoteClient)3 QueryImpl (lucee.runtime.type.QueryImpl)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Header (lucee.commons.net.http.Header)2 PageException (lucee.runtime.exp.PageException)2 Query (lucee.runtime.type.Query)2 URLResolver (lucee.runtime.util.URLResolver)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 EOFException (java.io.EOFException)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1