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()));
}
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());
}
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 + "]");
}
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;
}
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;
}
Aggregations