public void printBody() throws Exception { if (!request.actionAllowed("_preference")) { throw new HTTPRequestException(557); } String s = request.getValue("operation"); if (request.isPost()) { if (s.equals("save") || s.equals("setup")) { savePreferences(); if (request.getValue("submit").startsWith("Save")) { if (com.dragonflow.Properties.JdbcConfig.getJdbcConfig() .testDBConnection( request.getValue("configJdbcURL"), request.getValue("configJdbcDriver"), request.getValue("configJdbcUser"), com.dragonflow.Properties.StringProperty.getPrivate( request, "configJdbcPassword", "jdbcSuff", null, null))) { com.dragonflow.SiteView.SiteViewGroup.currentSiteView().StartDDC(); } else { com.dragonflow.Page.jdbcConfigPrefsPage.removeDBConnection(request); com.dragonflow.SiteView.SiteViewGroup.currentSiteView().StopDDC(); } } else if (request.getValue("submit").startsWith("Remove")) { com.dragonflow.Page.jdbcConfigPrefsPage.removeDBConnection(request); com.dragonflow.SiteView.SiteViewGroup.currentSiteView().StopDDC(); } else if (request.getValue("submit").startsWith("Sync SiteView")) { com.dragonflow.Properties.JdbcConfig.getJdbcConfig().execute(); } else { com.dragonflow.Properties.JdbcConfig.syncDBFromSS(); } printRefreshPage("/SiteView/" + request.getAccountDirectory() + "/SiteView.html", 0); } } else { printForm(); } }
void savePreferences() { try { // jgl.HashMap hashmap = getMasterConfig(); /* hashmap.put("_configJdbcPassword", com.dragonflow.Properties.StringProperty.getPrivate(request, "configJdbcPassword", "jdbcSuff", null, null)); hashmap.put("_configJdbcURL", request.getValue("configJdbcURL")); hashmap.put("_configJdbcUser", request.getValue("configJdbcUser")); hashmap.put("_configJdbcDriver", request.getValue("configJdbcDriver")); hashmap.put("_configJdbcCheckFrequency", request.getValue("configJdbcCheckFrequency")); hashmap.put("_jdbcConfigdisabled", request.getValue("jdbcConfigdisabled")); */ Config.configPut( "_configJdbcPassword", com.dragonflow.Properties.StringProperty.getPrivate( request, "configJdbcPassword", "jdbcSuff", null, null)); Config.configPut("_configJdbcURL", request.getValue("configJdbcURL")); Config.configPut("_configJdbcUser", request.getValue("configJdbcUser")); Config.configPut("_configJdbcDriver", request.getValue("configJdbcDriver")); Config.configPut("_configJdbcCheckFrequency", request.getValue("configJdbcCheckFrequency")); Config.configPut("_jdbcConfigdisabled", request.getValue("jdbcConfigdisabled")); com.dragonflow.SiteView.SiteViewGroup siteviewgroup = com.dragonflow.SiteView.SiteViewGroup.currentSiteView(); // saveMasterConfig(hashmap); if (request.getValue("initializeDatabaseFromFiles").length() > 0) { initializeDatabase(); } int i = siteviewgroup.getSettingAsLong("_fileCheckFrequency", 120) * 1000; if (siteviewgroup.maintenanceScheduler != null) { siteviewgroup.maintenanceScheduler.scheduleRepeatedPeriodicAction( siteviewgroup.checkConfiguration, i); } printPreferencesSaved(); } catch (Exception ioexception) { printError( "The preferences could not be saved", "master.config file could not be saved", "10"); } }
public jgl.Array exec(String s, com.dragonflow.SiteView.Machine machine, boolean flag) { super.exec(s, machine, flag); long l = com.dragonflow.Properties.StringProperty.toLong( machine.getProperty(com.dragonflow.SiteView.Machine.pTimeout)); if (l == 0L) { l = 60000L; } else { l *= 1000L; } java.net.Socket socket = null; Object obj = null; java.io.PrintWriter printwriter = null; java.io.BufferedInputStream bufferedinputstream = null; String s1 = machine.getProperty(com.dragonflow.SiteView.Machine.pHost); int i = 513; int j = s1.indexOf(':'); if (j != -1) { i = com.dragonflow.Utils.TextUtils.readInteger(s1, j + 1); s1 = s1.substring(0, j); } String s2 = machine.getProperty(com.dragonflow.SiteView.Machine.pLogin); String s3 = machine.getProperty(com.dragonflow.SiteView.Machine.pPassword); String s4 = machine.getProperty(com.dragonflow.SiteView.Machine.pLocalUser); String s5 = machine.getProperty(com.dragonflow.SiteView.Machine.pPasswordPrompt); String s6 = machine.getProperty(com.dragonflow.SiteView.Machine.pPrompt); String s7 = ""; String s8 = "tty/9600"; int k = com.dragonflow.StandardMonitor.URLMonitor.kURLok; byte abyte0[] = new byte[s2.length() + s4.length() + s8.length() + 4]; int i1 = 0; abyte0[i1++] = 0; for (int j1 = 0; j1 < s4.length(); j1++) { abyte0[i1++] = (byte) s4.charAt(j1); } abyte0[i1++] = 0; for (int k1 = 0; k1 < s2.length(); k1++) { abyte0[i1++] = (byte) s2.charAt(k1); } abyte0[i1++] = 0; for (int l1 = 0; l1 < s8.length(); l1++) { abyte0[i1++] = (byte) s8.charAt(l1); } abyte0[i1++] = 0; traceMessage(s2 + "," + s4 + "," + s8, machine, TO_REMOTE); StringBuffer stringbuffer = new StringBuffer(); progressMessage("Connecting to " + s1 + "..."); try { socket = com.dragonflow.Utils.RloginCommandLine.getReservedPort(s1, i); progressMessage("Logging In..."); java.io.OutputStream outputstream = socket.getOutputStream(); outputstream.write(abyte0); outputstream.flush(); printwriter = com.dragonflow.Utils.FileUtils.MakeOutputWriter(outputstream, "Cp1252"); bufferedinputstream = new BufferedInputStream(socket.getInputStream()); long l2 = com.dragonflow.SiteView.Platform.timeMillis() + l * 1000L; int j2 = 0; boolean flag1 = false; boolean flag2 = false; do { if (j2 == -1) { break; } j2 = readChar(bufferedinputstream, socket, l2); if (j2 == 65535) { for (int k2 = 0; k2 < 11; k2++) { j2 = readChar(bufferedinputstream, socket, l2); } byte abyte1[] = new byte[12]; abyte1[0] = -1; abyte1[1] = -1; abyte1[2] = 115; abyte1[3] = 115; abyte1[4] = 0; abyte1[5] = 24; abyte1[6] = 0; abyte1[7] = 80; abyte1[8] = 4; abyte1[9] = 0; abyte1[10] = 4; abyte1[11] = 0; outputstream.write(abyte1); outputstream.flush(); continue; } if (j2 == -1) { continue; } stringbuffer.append(j2); String s10 = toEncoding(stringbuffer.toString()); if (detail && progressStream != null) { progressStream.print(j2); } if (s7.length() > 0 && s10.endsWith(s7)) { progressMessage("Login Failed"); k = 401; break; } if (!flag2 && stringbuffer.length() < 15) { if (s10.endsWith(s5)) { traceMessage( "Password: "******"Sending Password..."); printwriter.print(s3 + '\n'); printwriter.flush(); stringbuffer = new StringBuffer(); s7 = machine.getProperty("_loginIncorrectPrompt"); if (s7.length() == 0) { s7 = "ogin incorrect"; } } continue; } if (!s10.endsWith(s6)) { continue; } if (flag1) { progressMessage("Command completed..."); break; } progressMessage("Running command..."); traceMessage(s, machine, TO_REMOTE); printwriter.print(s + '\n'); printwriter.flush(); stringbuffer = new StringBuffer(); resetBuffer(); flag1 = true; flag2 = true; s7 = ""; } while (true); } catch (java.net.UnknownHostException unknownhostexception) { k = com.dragonflow.StandardMonitor.URLMonitor.kURLBadHostNameError; } catch (java.net.SocketException socketexception) { if (com.dragonflow.SiteView.Platform.noRoute(socketexception)) { k = com.dragonflow.StandardMonitor.URLMonitor.kURLNoRouteToHostError; } else { k = com.dragonflow.StandardMonitor.URLMonitor.kURLNoConnectionError; } } catch (java.io.InterruptedIOException interruptedioexception) { k = com.dragonflow.StandardMonitor.URLMonitor.kURLTimeoutError; } catch (Exception exception) { exception.printStackTrace(); System.err.println(exception + " error: " + exception.getMessage()); k = com.dragonflow.StandardMonitor.URLMonitor.kURLUnknownError; } finally { try { if (printwriter != null) { printwriter.close(); } if (bufferedinputstream != null) { bufferedinputstream.close(); } if (socket != null) { socket.close(); } } catch (java.io.IOException ioexception) { System.err.println("Could not close FTP streams"); } } jgl.Array array = null; if (k == com.dragonflow.StandardMonitor.URLMonitor.kURLok) { array = com.dragonflow.SiteView.Platform.split('\n', toEncoding(stringbuffer.toString())); if (!flag) { if (array.size() > 0) { array.popFront(); } int i2 = com.dragonflow.SiteView.Machine.stringToOS( machine.getProperty(com.dragonflow.SiteView.Machine.pOS)); if ((com.dragonflow.SiteView.Platform.isSGI(i2) || com.dragonflow.SiteView.Platform.isSolaris(i2)) && array.size() > 0) { String s9 = (String) array.at(0); if (s9.trim().length() == 0) { array.popFront(); } } if (array.size() > 0) { array.popBack(); } } traceMessage(array, machine, FROM_REMOTE); } else { progressMessage("Connection failed: " + com.dragonflow.SiteView.Monitor.lookupStatus(k)); array = new Array(); traceMessage("ERROR - STATUS = " + k, machine, FROM_REMOTE); exitValue = k; } return array; }
void savePreferences() { String s = ""; try { jgl.HashMap hashmap = getMasterConfig(); // add by hailong.yi 2008/8/20 jgl.HashMap hashmapSave = new jgl.HashMap(); String s1 = com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_httpPort"); String s2 = request.getValue("httpPort").trim(); if (!s1.equals(s2) && s2.length() > 0) { int i = com.dragonflow.Properties.StringProperty.toInteger(s2); if (i == 0) { s = s + "\tHTTP Port must be a number greater than 0"; } else { try { java.net.ServerSocket serversocket = new ServerSocket(i); serversocket.close(); } catch (java.io.IOException ioexception1) { s = s + "\tPort " + i + " could not be opened: " + ioexception1.getMessage(); } } } String s3 = request.getValue("authorizedIP"); if (s3.length() > 0 && !com.dragonflow.Utils.TextUtils.onlyChars(s3, "0123456789,.*")) { s = s + "\tThe IP Address allowed access contained illegal characters"; } if (s3.length() == 0 && request.getValue("checkAddressAndLogin").length() > 0) { s = s + "\tTo enable <B>Require both IP address and Login</B> you must fill in authorized IP address(es)"; } String s4 = request.getValue("license").trim(); if (!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap, hashmapSave)) // if(!com.dragonflow.Utils.LUtils.setLicenseKey(s4, hashmap)) { s = s + com.dragonflow.Utils.LUtils.getLicenseErrorString(s4); } /* hashmap.put("_httpPort", s2); hashmap.put("_authorizedIP", s3); hashmap.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin")); hashmap.put("_localeEnabled", request.getValue("localeEnabled")); */ hashmapSave.put("_httpPort", s2); hashmapSave.put("_authorizedIP", s3); hashmapSave.put("_checkAddressAndLogin", request.getValue("checkAddressAndLogin")); hashmapSave.put("_localeEnabled", request.getValue("localeEnabled")); if (s.length() == 0) { // saveMasterConfig(hashmap); Config.configPut(hashmapSave); if (!s1.equals(s2)) { byte byte0 = 15; String s5 = "Waiting 15 seconds for " + com.dragonflow.SiteView.Platform.productName + "'s web server to restart..."; if (s2.length() == 0) { s5 = ""; byte0 = 0; } else if (s1.length() == 0) { s5 = "Waiting 15 seconds for " + com.dragonflow.SiteView.Platform.productName + "'s web server to start..."; } String s6 = com.dragonflow.Page.portalGeneralPrefsPage.getValue(hashmap, "_webserverAddress"); String s7 = "http://" + s6 + ":" + s2 + "/"; printPreferencesSaved(s7, "<H2>Preferences have been saved</H2><P>" + s5, byte0); } else { printPreferencesSaved(); } } else { printErrorPage(s); } } catch (Exception ioexception) { printError( "The preferences could not be saved", "master.config file could not be saved", "10"); } }
void printForm() { jgl.HashMap hashmap = getMasterConfig(); StringBuffer stringbuffer = new StringBuffer(); StringBuffer stringbuffer1 = new StringBuffer(); com.dragonflow.Properties.StringProperty.getPrivate( com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcPassword"), "configJdbcPassword", "jdbcSuff", stringbuffer, stringbuffer1); printBodyHeader("Database Driven Configuration"); printButtonBar("DBDrivenConfigs.htm", "", getSecondNavItems(request)); printPrefsBar("DDC"); String s = ""; if (com.dragonflow.Utils.TextUtils.getValue(hashmap, "_configJdbcURL").length() == 0) { s = "CHECKED"; } outputStream.print( getPagePOST("jdbcConfigPrefs", "save") + "<HR><CENTER><H2>Database Driven Configuration</H2></CENTER><BR>\n" + "SiteView can optionally read monitor settings and configurations " + " from a database, and save configurations" + " to a database. Any database which supports the ODBC or JDBC standards can be used, including Microsoft SQL Server and Oracle.\n" + "<p>For additional information on this feature go to our Customer Support <a href=\"http://support.dragonflow.com/\">Knowledge Base</a> and " + " search for Storing monitor configurations in a database. " + "<p><b>(note:</b> changes to Configuration Database preferences do not take effect until the next time SiteView is restarted)\n" + "<hr><TABLE border=0 width=100% cellspacing=0 cellpadding=5>" + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Connection URL:</TD>" + "<TD VALIGN=TOP><input type=text name=configJdbcURL size=40 value=\"" + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcURL") + "\">\n" + "</TD><TD VALIGN=TOP>" + "Enter the URL to the database connection</TD></TR>" + "<tr><td> </td><td spancol=2>If you're using an ODBC connection: use - <b><i>jdbc:odbc:myDSNName</i></b><br>" + "If you're using a SQL connection: use - <b><i>jdbc:inetdae:myserver.mycompany.com:1433?database=master</i></b></TD></TR>" + "<tr><td colspan=3><hr></td></tr>" + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Driver:</TD>" + "<TD VALIGN=TOP><input type=text name=configJdbcDriver size=40 value=\"" + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcDriver") + "\">\n" + "</TD><TD VALIGN=TOP>" + "Driver used to connect to the database</TD></TR>" + "<tr><td> </td><td spancol=2>If you're using an ODBC connection: use - <b><i>sun.jdbc.odbc.JdbcOdbcDriver</i></b><br>" + "If you're using a SQL connection: use - <b><i>com.inet.tds.TdsDriver</i></b><br>" + "For all other DBs, go to their web site and install their JDBC thin driver.</TD></TR>" + "<tr><td colspan=3><hr></td></tr>" + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Username:</TD>" + "<TD VALIGN=TOP><input type=text name=configJdbcUser size=40 value=\"" + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcUser") + "\">\n" + "</TD><TD VALIGN=TOP>" + "Enter the username used to connect to the database.</TD></TR>" + "<tr><td colspan=3><hr></td></tr>" + "<TR><TD ALIGN=LEFT VALIGN=TOP WIDTH=20%>Database Password:</TD>" + "<TD VALIGN=TOP>" + stringbuffer.toString() + " size=40>\n" + stringbuffer1.toString() + "</TD><TD VALIGN=TOP>" + "Enter the password used to connect to the database.</TD></TR>" + "<tr><td colspan=3><hr></td></tr>" + "</table>\n" + "<p><table><tr><td><input type=submit name=submit value=\"Save Changes\"></td>\n"); if (com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcURL").length() > 0 && com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcDriver").length() > 0) { outputStream.print( "<td><input type=submit name=submit value=\"Remove DataBase Connection\"></td>"); outputStream.print( "<td><input type=submit name=submit value=\"Sync SiteView From DB\"></td>"); if (com.dragonflow.Page.jdbcConfigPrefsPage .getValue(hashmap, "_configJdbcSyncDBFromFiles") .length() > 0) { outputStream.print( "<td><input type=submit name=submit value=\"Sync DB From SiteView\"></td>"); } } outputStream.print("</tr></table>"); String s1 = com.dragonflow.Utils.TextUtils.getValue(hashmap, "_jdbcConfigdisabled"); String s2 = ""; if (s1.length() > 0) { s2 = "CHECKED"; } outputStream.print( "<p><HR><CENTER><H3>Advanced Options</H3></CENTER><DL><P><DT><input type=checkbox name=jdbcConfigdisabled " + s2 + ">Disable syncing configuration files from database.<P>\n" + "<P><DT><input type=checkbox name=initializeDatabaseFromFiles " + s + ">Initialize database from current configuration files<P>\n" + "<DD>If you would like the database initialized with the current contents of the configuration files, check this box.\n" + "<B>Warning: checking this box will delete the current configurations stored in the database for this server - we advise using this feature\n" + "only when initially setting up database configuration.</B>" + "</DL>" + "<P><DT>Configuration Update Frequency: <input type=text name=configJdbcCheckFrequency size=40 value=\"" + com.dragonflow.Page.jdbcConfigPrefsPage.getValue(hashmap, "_configJdbcCheckFrequency") + "\"><P>\n" + "<DD>Enter the configuration update frequnce (seconds).\n" + "</FORM>\n" + "<br>\n" + "<CENTER><B>Version " + com.dragonflow.SiteView.Platform.getVersion() + "</B><p>\n"); printFooter(outputStream); }