Calendar created = JDBCUtil.getCalendar(rs, "date_created");
Calendar amended = JDBCUtil.getCalendar(rs, "date_amended");
int realmID = rs.getInt("realm_id");
if (type == WebForward.TYPE_PATH_BASED_REVERSE_PROXY || type == WebForward.TYPE_HOST_BASED_REVERSE_PROXY) {
JDBCPreparedStatement ps2 = db.getStatement("getWebForward.reverseProxy.selectById");
try {
ps2.setInt(1, id);
ResultSet rs2 = ps2.executeQuery();
try {
StringBuffer paths = new StringBuffer();
String hostHeader = "";
while (rs2.next()) {
if (paths.length() > 0) {
paths.append('\n');
}
paths.append(rs2.getString("path"));
}
JDBCPreparedStatement ps3 = db.getStatement("getWebForward.reverseProxyOptions.selectById");
try {
ps3.setInt(1, id);
ResultSet rs3 = ps3.executeQuery();
try {
String authUsername = "";
String authPassword = "";
String preferredAuthScheme = HttpAuthenticatorFactory.BASIC;
boolean activeDNS = false;
String formType = "";
String formParameters = "";
String charset = null;
if (rs3.next()) {
authUsername = rs3.getString("authentication_username");
authPassword = rs3.getString("authentication_password");
preferredAuthScheme = rs3.getString("preferred_authentication_scheme");
activeDNS = rs3.getInt("active_dns") == 1;
hostHeader = rs3.getString("host_header");
formType = rs3.getString("form_type");
formParameters = rs3.getString("form_parameters");
charset = rs3.getString("charset");
}
return new ReverseProxyWebForward(realmID, id, type, url, name, description, category, authUsername, authPassword,
preferredAuthScheme, formType, formParameters, paths.toString(), hostHeader, activeDNS, autoStart,
created, amended, charset);
} finally {
rs3.close();
}
} finally {
ps3.releasePreparedStatement();
}
} finally {
rs2.close();
}
} finally {
ps2.releasePreparedStatement();
}
} else if (type == WebForward.TYPE_REPLACEMENT_PROXY) {
JDBCPreparedStatement ps3 = db.getStatement("getWebForward.replacementProxyOptions.selectById");
try {
ps3.setInt(1, id);
ResultSet rs3 = ps3.executeQuery();
try {
String authUsername = "";
String authPassword = "";
String preferredAuthScheme = HttpAuthenticatorFactory.BASIC;
String encoding = "";
String formType = "";
String formParameters = "";
PropertyList restrictToHosts = new PropertyList();
if (rs3.next()) {
authUsername = rs3.getString("authentication_username");
authPassword = rs3.getString("authentication_password");
preferredAuthScheme = rs3.getString("preferred_authentication_scheme");
encoding = rs3.getString("encoding");
restrictToHosts.setAsPropertyText(rs3.getString("restrict_to_hosts"));
formType = rs3.getString("form_type");
formParameters = rs3.getString("form_parameters");
}
return new ReplacementProxyWebForward(realmID, id, url, name, description, category, authUsername, authPassword,
preferredAuthScheme, encoding, restrictToHosts, formType, formParameters, autoStart, created, amended);
} finally {
rs3.close();
}
} finally {
ps3.releasePreparedStatement();
}
} else {
return new TunneledSiteWebForward(realmID, id, url, name, description, category, autoStart, created, amended);
}