/** Write file with position and size of the login box */ public static void writePersistence() { Messages.postDebug("LoginBox", "LoginBox.writePersistence"); // If the panel has not been created, don't try to write a file if (position == null) return; String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel"); FileWriter fw; PrintWriter os; try { File file = new File(filepath); fw = new FileWriter(file); os = new PrintWriter(fw); os.println("Login Panel"); os.println(height); os.println(width); double xd = position.getX(); int xi = (int) xd; os.println(xi); double yd = position.getY(); int yi = (int) yd; os.println(yi); os.close(); } catch (Exception er) { Messages.postError("Problem creating " + filepath); Messages.writeStackTrace(er); } }
private void processMessage(Message message) throws IOException { if (message.getType().equals("SimpleMessage")) { MessageType messageType = (MessageType) message.getValue(); String receiver = messageType.getToUser(); history.get(receiver).add(messageType); } if (message.getType().equals("ConnectUserMessage")) { String user = (String) message.getValue(); Messages messages = history.get(user); Operations.sendHistory(messages.getLastFiveWith(user), out); } }
protected String getSampleName(String strDir, String strTray) { String strSampleName = ""; String strSample; int nTray = 0; try { nTray = Integer.parseInt(strTray); } catch (Exception e) { } if (nTray <= 0) return strSampleName; String cmd = "SELECT loc_,studystatus from study WHERE (autodir=\'" + strDir + "\') AND (hostname=\'" + getHost() + "\')"; // NB: bArrSample[0] is not used; array implicitly initialized false boolean[] bArrSample = new boolean[nTray + 1]; m_dbResult = null; try { m_dbResult = getdbmanager().executeQuery(cmd); } catch (Exception e) { return strSampleName; } if (m_dbResult == null) return strSampleName; try { while (m_dbResult.next()) { strSample = m_dbResult.getString(1); int nSample = 0; nSample = Integer.parseInt(strSample); try { bArrSample[nSample] = true; } catch (IndexOutOfBoundsException ioobe) { Messages.postDebug("getSampleName: index out of bounds: " + nSample); } } for (int i = 1; i < bArrSample.length; i++) { if (!bArrSample[i]) { strSampleName = String.valueOf(i); break; } } } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } return strSampleName; }
private void createResults_() { results = new LinkedList(); String dateTime = dateFormatter2_.format(date); // Messages.debug(3, "Rag::createResults_ dateTime=%1", dateTime); String regExp = "HREF=\\/(rapp[\\/a-zA-Z0-9]*" + dateTime + "[a-zA-Z0-9_\\.]*)>"; Messages.debug(3, "Rag::createResults_ regExp=%1", regExp); Regexp reg = Regexp.compile(regExp); // Messages.debug(3, "Rag::createResults_ compiled regexp"); Result result; int pos = 0; while ((result = reg.searchForward(buffer_, pos, charsread_ - pos)) != null) { pos = result.getMatchEnd() + 1; Messages.debug(3, "Rag:: gotResult:" + result.getMatch(1)); results.add(RESULT_ADDRESS_ + result.getMatch(1)); } }
protected String gettitle(String strFreq) { StringBuffer sbufTitle = new StringBuffer().append("VnmrJ "); String strPath = FileUtil.openPath(FileUtil.SYS_VNMR + "/vnmrrev"); BufferedReader reader = WFileUtil.openReadFile(strPath); String strLine; String strtype = ""; if (reader == null) return sbufTitle.toString(); try { while ((strLine = reader.readLine()) != null) { strtype = strLine; } strtype = strtype.trim(); if (strtype.equals("merc")) strtype = "Mercury"; else if (strtype.equals("mercvx")) strtype = "Mercury-Vx"; else if (strtype.equals("mercplus")) strtype = "MERCURY plus"; else if (strtype.equals("inova")) strtype = "INOVA"; String strHostName = m_strHostname; if (strHostName == null) strHostName = ""; sbufTitle.append(" ").append(strHostName); sbufTitle.append(" ").append(strtype); sbufTitle.append(" - ").append(strFreq); reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.logError(e.toString()); } return sbufTitle.toString(); }
public void removeThread(WorkerThread thread) { threads.remove(thread); Logger.log(Level.DEBUG, Messages.getString("connection_closed", Settings.getLocale())); if (FancyFileServer.getGUI() != null) { FancyFileServer.getGUI().updateConnectionsCounter(); } }
public MSSqlServerInfo(String host) throws SQLException { try { InetAddress addr = InetAddress.getByName(host); DatagramSocket socket = new DatagramSocket(); byte[] msg = new byte[] {0x02}; DatagramPacket p = new DatagramPacket(msg, msg.length, addr, 1434); socket.send(p); byte[] buf = new byte[4096]; p = new DatagramPacket(buf, buf.length); socket.setSoTimeout(m_timeout); for (int i = 0; i < m_numRetries; i++) { try { socket.receive(p); String infoString = extractString(buf, p.getLength()); m_serverInfoStrings = split(infoString, ';'); return; } catch (InterruptedIOException toEx) { } } } catch (Exception e) { // Ignore... } throw new SQLException(Messages.get("error.msinfo.badinfo", host), "HY000"); }
public void setVisible(boolean bShow, String title) { if (bShow) { String strDir = ""; String strFreq = ""; String strTraynum = ""; m_strHelpFile = getHelpFile(title); String strSampleName = getSampleName(title); String frameBounds = getFrameBounds(title); StringTokenizer tok = new QuotedStringTokenizer(title); if (tok.hasMoreTokens()) strDir = tok.nextToken(); if (tok.hasMoreTokens()) strFreq = tok.nextToken(); if (tok.hasMoreTokens()) strTraynum = tok.nextToken(); else { try { Integer.parseInt(strDir); // if strdir is number, then strdir is empty, and the // strfreq is the number strTraynum = strFreq; strFreq = strDir; strDir = ""; } catch (Exception e) { } } try { setTitle(gettitle(strFreq)); m_lblSampleName.setText("3"); boolean bVast = isVast(strTraynum); CardLayout layout = (CardLayout) m_pnlSampleName.getLayout(); if (!bVast) { if (strSampleName == null) { strSampleName = getSampleName(strDir, strTraynum); } m_lblSampleName.setText(strSampleName); layout.show(m_pnlSampleName, OTHER); } else { m_strDir = strDir; setTrays(); layout.show(m_pnlSampleName, VAST); m_trayTimer.start(); } boolean bSample = bVast || !strSampleName.trim().equals(""); m_pnlSampleName.setVisible(bSample); m_lblLogin.setForeground(getBackground()); m_lblLogin.setVisible(false); m_passwordField.setText(""); m_passwordField.setCaretPosition(0); } catch (Exception e) { Messages.writeStackTrace(e); } setBounds(frameBounds); ExpPanel exp = Util.getActiveView(); if (exp != null) exp.waitLogin(true); } writePersistence(); setVisible(bShow); }
public Object next() { if (resultIterator_ != null) { String tmp = null; try { // parse date and further information from result tmp = (String) resultIterator_.next(); Messages.debug(-1, "Rag::next before parse"); Date d = dateFormatter3_.parse(tmp.substring(59, 73)); Messages.debug(-1, "Rag::next after parse"); h_.put("URL", tmp); tmp = RandomDate.format(d); h_.put("U_DATETIME", EtcUtil.makeURLish(tmp)); h_.put("DATETIME", tmp); } catch (Exception e) { Messages.debug( -1, "Rag::exception during parsing of s=%1 (%2)", tmp.substring(59, 73), e); // e.printStackTrace(); } } return h_; }
public void runImpl() throws Exception { // create the URL corresponding to the date URL u = new URL(ADDRESS_ + dateFormatter1_.format(date)); Messages.debug(3, "Rag::runImpl - reading data from URL=%1", u); // fetch the page into the buffer buffer_ = new char[BUF_SIZE_]; Reader r = new InputStreamReader(u.openStream()); int size = 1; charsread_ = 0; while (charsread_ < BUF_SIZE_ && size > 0) { size = r.read(buffer_, 0, BUF_SIZE_ - charsread_); if (size != -1) charsread_ += size; Messages.debug(3, "Rag::runImpl - read %1 chars", String.valueOf(size)); if (!r.ready()) break; } r.close(); Messages.debug(3, "Rag::runImpl - buffer=\"%1\"XXXXXXX", new String(buffer_, 0, charsread_)); // create the results createResults_(); }
public Object next() { if (resultIterator_ != null) { try { // parse date and further information from result String urlString = (String) resultIterator_.next(); h_.put("URL", urlString); determineAttributes_(h_, urlString); } catch (Exception e) { Messages.warn(1, "Soho::exception during parsing of (%2)", e); // e.printStackTrace(); } } return h_; }
/** * Call getInfo() before calling this method. It parses the info string returned from SQL Server * and looks for the port for the given named instance. If it can't be found, or if getInfo() * hadsn't been called, it returns -1. * * @param instanceName * @return port the given instance is listening on, or -1 if it can't be found. */ public int getPortForInstance(String instanceName) throws SQLException { if (m_serverInfoStrings == null) { return -1; } // NOTE: default instance is called MSSQLSERVER if (instanceName == null || instanceName.length() == 0) { instanceName = "MSSQLSERVER"; } String curInstance = null; String curPort = null; for (int index = 0; index < m_serverInfoStrings.length; index++) { if (m_serverInfoStrings[index].length() == 0) { curInstance = null; curPort = null; } else { String key = m_serverInfoStrings[index]; String value = ""; index++; if (index < m_serverInfoStrings.length) { value = m_serverInfoStrings[index]; } if (key.equals("InstanceName")) { curInstance = value; } if (key.equals("tcp")) { curPort = value; } if (curInstance != null && curPort != null && curInstance.equalsIgnoreCase(instanceName)) { try { return Integer.parseInt(curPort); } catch (NumberFormatException e) { throw new SQLException(Messages.get("error.msinfo.badport", instanceName), "HY000"); } } } } // didn't find it... return -1; }
/** * Loads the configuration * * @throws ConfigurationException */ public void load() throws ConfigurationException { System.out.println("Loading configuration..."); // $NON-NLS-1$ properties.clear(); fixedProperties.clear(); System.out.println("-> loading default properties"); loadDefaultCfg(); System.out.println("-> loading fixed properties"); loadFixedCfg(); System.out.println("-> loading system properties"); loadSystemCfgFile(); System.out.println("-> loading local properties"); loadLocalCfgFile(); // Try to define userHome from the config file System.out.println("-> setting user home"); userHome = new File(System.getProperty("user.home")); String confHome = getProperty(USER_HOME_P); if ((confHome != null) && !confHome.equals("")) userHome = new File(confHome); String myDocString = getProperty(USER_DIRNAME_P); if ((myDocString != null) && (!myDocString.equals(""))) { File myDocDir = new File(userHome, myDocString); if (myDocDir.exists()) userHome = myDocDir; } // Check if we are in execution mode System.out.println("-> checking execution mode"); testExecutionMode(); System.out.println("-> loading scripting languages"); loadScriptingLanguages(fixedProperties); System.out.println("-> langage " + getLanguage() + " is used"); defaultLanguage = (getLanguage().compareTo(getDefaultLanguage()) == 0); System.out.println("-> loading localized messages"); // Load localized messages try { // loads the language Messages.loadLocalizedResource(getLanguage()); org.colombbus.tangara.net.Messages.loadLocalizedResource(getLanguage()); } catch (Throwable th) { System.err.println("error while loading language configuration: " + th); } System.out.println("-> loading package info"); loadPackageInfo(fixedProperties); System.out.println("-> loading engine"); loadEngine(defaultEngineName); System.out.println("-> loading objects"); loadObjects(); System.out.println("Configuration loaded"); // $NON-NLS-1$ }
protected void setTrayPresent(String strPath) { String strzone = "zones"; BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; try { // if the zones are set to 0, then there is no tray present // set rackInfo(1,zones) 3 => tray 1 present // set rackInfo(2,zones) 0 => tray 2 not present while ((strLine = reader.readLine()) != null) { int index = strLine.indexOf(strzone); if (index < 0) continue; String strTray = strLine.substring(index - 2, index - 1); int nTray = 0; try { nTray = Integer.parseInt(strTray); } catch (Exception e) { } if (nTray <= 0) continue; int nZone = 0; try { strTray = strLine.substring(index + strzone.length() + 2, strLine.length()); nZone = Integer.parseInt(strTray); } catch (Exception e) { } Color colorbg = Color.white; String strTooltip = TRAY; if (nZone <= 0) { colorbg = Color.black; strTooltip = NOTRAY; } VBox pnlVast = m_pnlVast[nTray - 1]; pnlVast.setbackground(colorbg); pnlVast.setToolTipText(Util.getTooltipString(strTooltip)); } reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } }
protected void setTrayActive(String strDir) { String strTray; String strStudy; String strActive = "Active"; String cmd = "SELECT vrack_,studystatus from study WHERE (autodir=\'" + strDir + "\') AND (hostname=\'" + getHost() + "\')"; m_dbResult = null; try { m_dbResult = getdbmanager().executeQuery(cmd); } catch (Exception e) { return; } if (m_dbResult == null) return; int nTray = 0; try { while (m_dbResult.next()) { strTray = m_dbResult.getString(1); strStudy = m_dbResult.getString(2); if (strStudy != null && strStudy.equalsIgnoreCase(strActive)) { try { nTray = Integer.parseInt(strTray); } catch (Exception e) { } if (nTray > 0) { m_pnlVast[nTray - 1].setbackground(Color.blue); m_pnlVast[nTray - 1].setToolTipText(Util.getTooltipString(TRAYACTIVE)); break; } } } } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } }
protected static boolean vnmrjPassword(String strUser, char[] password) { boolean blogin = false; try { PasswordService objPassword = PasswordService.getInstance(); String encrPassword = objPassword.encrypt(new String(password)); if (pwprops == null) { String strPath = FileUtil.openPath(WUserUtil.PASSWORD); if (strPath == null) return blogin; pwprops = new Properties(); FileInputStream fis = new FileInputStream(strPath); pwprops.load(fis); fis.close(); } String stoPassword = pwprops.getProperty(strUser); if (encrPassword.equals(stoPassword)) blogin = true; } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } return blogin; }
protected void setVast() { String strPath = FileUtil.openPath("SYSTEM/asm/gilsonNumber"); if (strPath == null) return; BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; int i = 0; try { while ((strLine = reader.readLine()) != null) { strLine = strLine.trim(); if (i == 0 || !m_aStrVast[i - 1].equals(strLine)) { m_aStrVast[i] = strLine; i = i + 1; } } reader.close(); } catch (Exception e) { // e.printStackTrace(); Messages.writeStackTrace(e); } }
private void prepareClient() throws IOException { logger.info("Waiting for client's name"); Message mes = Operations.receive(in); setClientName((String) mes.getValue()); logger.info("Username for " + s.getInetAddress() + " received: " + userName); users.add(this); logger.info("User " + getClientName() + " has been added to the userlist."); messages = new Messages(); logger.info("Message list created"); if (!history.containsKey(userName)) { history.put(userName, messages); } else { messages = history.get(userName); } messages.addObserver(this); logger.info("Message list assigned to history"); logger.info("Sending the list of users."); Operations.sendUserNamesList(users.getUserNames(), out); logger.info("Userlist has been sent"); }
protected authDialog( AESemaphore _sem, Display display, String realm, String tracker, String torrent_name) { sem = _sem; if (display.isDisposed()) { sem.release(); return; } shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // tracker Label tracker_label = new Label(shell, SWT.NULL); Messages.setLanguageText(tracker_label, "authenticator.tracker"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; tracker_label.setLayoutData(gridData); Label tracker_value = new Label(shell, SWT.NULL); tracker_value.setText(tracker.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; tracker_value.setLayoutData(gridData); if (torrent_name != null) { Label torrent_label = new Label(shell, SWT.NULL); Messages.setLanguageText(torrent_label, "authenticator.torrent"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; torrent_label.setLayoutData(gridData); Label torrent_value = new Label(shell, SWT.NULL); torrent_value.setText(torrent_name.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; torrent_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); shell.forceActive(); }
protected void enterLogin() { char[] password = m_passwordField.getPassword(); String strUser = (String) m_cmbUser.getSelectedItem(); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean blogin = WUserUtil.isOperatorNameok(strUser, false); if (blogin) { blogin = vnmrjPassword(strUser, password); if (!blogin) blogin = unixPassword(strUser, password); } if (blogin) { m_lblLogin.setForeground(Color.black); m_lblLogin.setText("Login Successful"); m_lblLogin.setVisible(true); // Get the Email column string for access to the operator data String emStr = vnmr.util.Util.getLabel("_admin_Email"); String stremail = WUserUtil.getOperatordata(strUser, emStr); // Get the Panel Level column string for access to the operator data String plStr = vnmr.util.Util.getLabel("_admin_Panel_Level"); String strPanel = WUserUtil.getOperatordata(strUser, plStr); if (stremail == null || stremail.equals("null")) stremail = ""; try { Integer.parseInt(strPanel); } catch (Exception e) { strPanel = WGlobal.PANELLEVEL; } m_trayTimer.stop(); Messages.postDebug(" Login: "******"appdir('reset','") .append(strUser) .append("','") .append(stremail) .append("',") .append(strPanel) .append(")") .toString()); exp.sendToVnmr("vnmrjcmd('util', 'bgReady')\n"); } setVisible(false); // Save the current position and size of this panel in case it // was changed Dimension size = getSize(); width = size.width; height = size.height; position = getLocation(); writePersistence(); // Call the macro to update this operator's // ExperimentSelector_operatorName.xml file // from the protocols themselves. This macro will // cause an update of the ES when it is finished // Util.getAppIF().sendToVnmr("updateExpSelector"); // I am not sure why we need to force updates since updateExpSelector // should have caused an update by writing to ES_op.xml file. // However, it works better if we do the force update. // ExpSelector.setForceUpdate(true); } else { m_lblLogin.setForeground(DisplayOptions.getColor("Error")); // m_lblLogin.setText("<HTML>Incorrect username/password <p> Please try again </HTML>"); m_lblLogin.setVisible(true); } setCursor(Cursor.getDefaultCursor()); }
public void run() { try { this.serverSocket = new ServerSocket(Settings.getPropertyInteger("server_port")); } catch (Exception e) { Logger.log( Level.WARNING, Messages.getString("can_not_open_port_", Settings.getLocale()) + Settings.getPropertyInteger("server_port")); if (FancyFileServer.getGUI() != null) { FancyFileServer.getGUI().updateServerStatus(); } return; } running = true; this.parameters = new BasicHttpParams(); this.parameters.setIntParameter(HttpConnectionParams.SO_TIMEOUT, 5000); this.parameters.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); this.parameters.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false); this.parameters.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); this.parameters.setParameter( HttpProtocolParams.ORIGIN_SERVER, FancyFileServer.NAME.replaceAll("\\s", "-") + "/" + FancyFileServer.VERSION); Logger.log(Level.INFO, Messages.getString("server_started", Settings.getLocale())); try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface i = (NetworkInterface) interfaces.nextElement(); if (i.isLoopback() || i.isVirtual()) { continue; } Enumeration<InetAddress> addresses = i.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress a = (InetAddress) addresses.nextElement(); if (a instanceof Inet4Address) { Logger.log( Level.INFO, Messages.getString("server_address_", Settings.getLocale()) + "http://" + a.getHostAddress() + ":" + serverSocket.getLocalPort() + "/"); } } } } catch (Exception e) { Logger.log( Level.WARNING, Messages.getString("can_not_get_server_address_", Settings.getLocale()) + e.getMessage()); } if (FancyFileServer.getGUI() != null) { FancyFileServer.getGUI().updateServerStatus(); } while (running) { try { /** Set up HTTP connection */ Socket socket = this.serverSocket.accept(); DefaultHttpServerConnection connection = new DefaultHttpServerConnection(); Logger.log( Level.DEBUG, Messages.getString("incoming_connection_from_", Settings.getLocale()) + socket.getInetAddress().getHostAddress()); connection.bind(socket, this.parameters); /** Set up HTTP protocol processor */ BasicHttpProcessor processor = new BasicHttpProcessor(); processor.addInterceptor(new ResponseDate()); processor.addInterceptor(new ResponseServer()); processor.addInterceptor(new ResponseContent()); processor.addInterceptor(new ResponseConnControl()); /** Set up HTTP request handlers */ HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry(); registry.register("*", new FileHandler()); /** Set up HTTP service */ HttpService service = new HttpService( processor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), registry, this.parameters); /** Start worker thread */ WorkerThread t = new WorkerThread(this, service, connection); t.setDaemon(true); t.start(); } catch (IOException e) { if (running) { running = false; Logger.log( Level.SEVERE, Messages.getString("i_o_error_", Settings.getLocale()) + e.getMessage()); break; } } } if (FancyFileServer.getGUI() != null) { FancyFileServer.getGUI().updateServerStatus(); } Logger.log(Level.INFO, Messages.getString("server_stopped", Settings.getLocale())); }
protected authDialog( AESemaphore _sem, Display display, String realm, boolean is_tracker, String target, String details) { sem = _sem; if (display.isDisposed()) { sem.releaseForever(); return; } final String ignore_key = "IgnoreAuth:" + realm + ":" + target + ":" + details; if (RememberedDecisionsManager.getRememberedDecision(ignore_key) == 1) { Debug.out( "Authentication for " + realm + "/" + target + "/" + details + " ignored as told not to ask again"); sem.releaseForever(); return; } shell = ShellFactory.createMainShell(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); Utils.setShellIcon(shell); Messages.setLanguageText(shell, "authenticator.title"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gridData; // realm Label realm_label = new Label(shell, SWT.NULL); Messages.setLanguageText(realm_label, "authenticator.realm"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; realm_label.setLayoutData(gridData); Label realm_value = new Label(shell, SWT.NULL); realm_value.setText(realm.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; realm_value.setLayoutData(gridData); // target Label target_label = new Label(shell, SWT.NULL); Messages.setLanguageText( target_label, is_tracker ? "authenticator.tracker" : "authenticator.location"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; target_label.setLayoutData(gridData); Label target_value = new Label(shell, SWT.NULL); target_value.setText(target.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; target_value.setLayoutData(gridData); if (details != null) { Label details_label = new Label(shell, SWT.NULL); Messages.setLanguageText( details_label, is_tracker ? "authenticator.torrent" : "authenticator.details"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; details_label.setLayoutData(gridData); Label details_value = new Label(shell, SWT.NULL); details_value.setText(details.replaceAll("&", "&&")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; details_value.setLayoutData(gridData); } // user Label user_label = new Label(shell, SWT.NULL); Messages.setLanguageText(user_label, "authenticator.user"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; user_label.setLayoutData(gridData); final Text user_value = new Text(shell, SWT.BORDER); user_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; user_value.setLayoutData(gridData); user_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { username = user_value.getText(); } }); // password Label password_label = new Label(shell, SWT.NULL); Messages.setLanguageText(password_label, "authenticator.password"); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; password_label.setLayoutData(gridData); final Text password_value = new Text(shell, SWT.BORDER); password_value.setEchoChar('*'); password_value.setText(""); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 2; password_value.setLayoutData(gridData); password_value.addListener( SWT.Modify, new Listener() { public void handleEvent(Event event) { password = password_value.getText(); } }); // persist Label blank_label = new Label(shell, SWT.NULL); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; blank_label.setLayoutData(gridData); final Button checkBox = new Button(shell, SWT.CHECK); checkBox.setText(MessageText.getString("authenticator.savepassword")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; checkBox.setLayoutData(gridData); checkBox.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { persist = checkBox.getSelection(); } }); final Button dontAsk = new Button(shell, SWT.CHECK); dontAsk.setText(MessageText.getString("general.dont.ask.again")); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; dontAsk.setLayoutData(gridData); dontAsk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { RememberedDecisionsManager.setRemembered(ignore_key, dontAsk.getSelection() ? 1 : 0); } }); // line Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; labelSeparator.setLayoutData(gridData); // buttons new Label(shell, SWT.NULL); Button bOk = new Button(shell, SWT.PUSH); Messages.setLanguageText(bOk, "Button.ok"); gridData = new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END | GridData.HORIZONTAL_ALIGN_FILL); gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 70; bOk.setLayoutData(gridData); bOk.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(true); } }); Button bCancel = new Button(shell, SWT.PUSH); Messages.setLanguageText(bCancel, "Button.cancel"); gridData = new GridData(GridData.HORIZONTAL_ALIGN_END); gridData.grabExcessHorizontalSpace = false; gridData.widthHint = 70; bCancel.setLayoutData(gridData); bCancel.addListener( SWT.Selection, new Listener() { public void handleEvent(Event e) { close(false); } }); shell.setDefaultButton(bOk); shell.addListener( SWT.Traverse, new Listener() { public void handleEvent(Event e) { if (e.character == SWT.ESC) { close(false); } } }); shell.pack(); Utils.centreWindow(shell); shell.open(); }
/* Broken: * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/nanc_164Mz_fd_2023_1046.gif * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/nanc_164Mz_fd_2023_0916.gif * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000123/meud_halph_fd_2023_1356.gif * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000213/nanc_164Mz_fd_2113_0919.gif * * Ok: * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000212/pdmo_cogha_fd_20000212_0814.gif * http://sohowww.nascom.nasa.gov/data/synoptic/gif/000212/pdmo_cogha_fd_20000212_0945.gif */ private static void determineAttributes_(Hashtable h, String url) { int idxl = url.lastIndexOf('/') + 1; int idxr = url.indexOf('_'); String tmp = null; try { // Messages.debug(2, "Soho:DeterminAttrib1 idxl=%1 idxr=%2 url=%3", String.valueOf(idxl), // String.valueOf(idxr), url); tmp = (String) INSTITUTE_CODES_.get(url.substring(idxl, idxr)); h.put("U_INSTITUTE_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp)); h.put("INSTITUTE_CODE", tmp); idxl = idxr + 1; idxr = url.indexOf('_', idxl); // Messages.debug(2, "Soho:DeterminAttrib2 idxl=%1 idxr=%2", String.valueOf(idxl), // String.valueOf(idxr)); tmp = (String) TYPE_CODES_.get(url.substring(idxl, idxr)); h.put("U_TYPE_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp)); h.put("TYPE_CODE", tmp); idxl = idxr + 1; idxr = url.indexOf('_', idxl); // Messages.debug(2, "Soho:DeterminAttrib3 idxl=%1 idxr=%2", String.valueOf(idxl), // String.valueOf(idxr)); tmp = (String) INFO_CODES_.get(url.substring(idxl, idxr)); h.put("U_INFO_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp)); idxl = idxr + 1; idxr = url.indexOf('_', idxl); // Messages.debug(2, "Soho:DeterminAttrib4 idxl=%1 idxr=%2", String.valueOf(idxl), // String.valueOf(idxr)); tmp = url.substring(idxl, idxr); idxl = idxr + 1; idxr = url.indexOf('.', idxl); // Messages.debug(2, "Soho:DeterminAttrib5 idxl=%1 idxr=%2", String.valueOf(idxl), // String.valueOf(idxr)); tmp += url.substring(idxl, idxr); Date d = null; if (tmp.length() == 12) { // Messages.debug(1, "Soho::determineAttributes before parse"); d = dateFormatter2_.parse(tmp); tmp = RandomDate.format(d); } else if (tmp.length() == 8) tmp = "date not parsed"; h.put("U_DATETIME", EtcUtil.makeURLish(tmp)); h.put("DATETIME", tmp); idxl = url.lastIndexOf("."); // Messages.debug(2, "Soho:DeterminAttrib6 idxl=%1", String.valueOf(idxl)); tmp = (String) FORMAT_CODES_.get(url.substring(idxl + 1)); // Messages.debug(1, "Soho::determineAttributes formatcode=%1", tmp); h.put("U_FORMAT_CODE", (tmp == null) ? "unknown" : EtcUtil.makeURLish(tmp)); // Messages.debug(3, SOH02_, url); } catch (Exception e) { Messages.warn(0, SOH01_, url); // Messages.debug(1, "Soho::exception during parsing (%1)", e); // e.printStackTrace(); if (h.get("INSTITUTE_CODE") == null) h.put("INSTITUTE_CODE", "unknown"); if (h.get("U_INSTITUTE_CODE") == null) h.put("U_INSTITUTE_CODE", "unknown"); if (h.get("TYPE_CODE") == null) h.put("TYPE_CODE", "unknown"); if (h.get("U_TYPE_CODE") == null) h.put("U_TYPE_CODE", "unknown"); if (h.get("U_INFO_CODE") == null) h.put("U_INFO_CODE", "unknown"); if (h.get("DATE_TIME") == null) h.put("DATE_TIME", "unknown"); if (h.get("U_DATE_TIME") == null) h.put("U_DATE_TIME", "unknown"); if (h.get("U_FORMAT_CODE") == null) h.put("U_FORMAT_CODE", "unknown"); } }
/** * Read position and size of the login box from a given abstract path. * * @param abstractPath The path to the file. */ public void readPersistence(String abstractPath) { String filepath = FileUtil.openPath(abstractPath); if (filepath != null) { BufferedReader in; String line; try { File file = new File(filepath); in = new BufferedReader(new FileReader(file)); // File must start with 'Login Panel' if ((line = in.readLine()) != null) { if (!line.startsWith("Login Panel")) { Messages.postWarning("The " + filepath + " file is " + "corrupted and being removed"); // Remove the corrupted file. file.delete(); // Set the size and position to the full vnmrj frame setDefaultSizePosition(); return; } } String h = null, w = null, x = null, y = null; int xi, yi; if (in.ready()) h = in.readLine().trim(); if (in.ready()) w = in.readLine().trim(); if (in.ready()) x = in.readLine().trim(); if (in.ready()) y = in.readLine().trim(); in.close(); // Save width and height for later use also height = Integer.decode(h).intValue(); width = Integer.decode(w).intValue(); xi = Integer.decode(x).intValue(); yi = Integer.decode(y).intValue(); // Save point for later use also position = new Point(xi, yi); // Set them setSize(width, height); setLocation(position); // If we got what we need and set the size and position, // just return now. return; } // If an exception, continue below catch (Exception e) { } } // No file or an excpetion happened, set default size and position // Be sure the file is gone try { if (filepath != null) { File file = new File(filepath); if (file != null) file.delete(); } } // If an exception, just continue below catch (Exception e) { } // Set the size and position to the full vnmrj frame setDefaultSizePosition(); }