/** 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); } }
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(); }
protected void setTrays() { String strPath = FileUtil.openPath(TRAYINFO); if (strPath == null) return; setTrayPresent(strPath); setTrayActive(m_strDir); repaint(); }
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); } }
/** * 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(); }
protected static boolean unixPassword(String strUser, char[] password) { password = getPassword(password); boolean bSu = true; String strSu; PrintWriter fout = null; if (!Util.iswindows()) { String filepath = FileUtil.savePath("USER/PERSISTENCE/passwd"); if (filepath == null) { filepath = FileUtil.savePath("USER/PERSISTENCE/tmp_passwd"); } try { fout = new PrintWriter(new FileWriter(filepath)); if (fout != null) fout.println(String.valueOf(password)); } catch (IOException er) { } finally { try { if (fout != null) fout.close(); } catch (Exception e) { } } /** * ******** String strPath = new StringBuffer().append(LOGIN).append(" ").append( * strUser).append(" \"").append(String.valueOf( password)).append("\"").toString(); ******** */ String strPath = new StringBuffer() .append(LOGIN) .append(" ") .append(strUser) .append(" \"") .append(filepath) .append("\"") .toString(); String[] cmd = {WGlobal.SHTOOLCMD, WGlobal.SHTOOLOPTION, strPath}; WMessage objMessage = WUtil.runScript(cmd, false); bSu = objMessage.isNoError(); strSu = objMessage.getMsg(); } else { String strQuotes = "\"\""; if (password.length == 0) strQuotes = "\""; String cmd = new StringBuffer() .append(LOGIN_WIN) .append(" ") .append(strUser) .append(" ") .append(strQuotes) .append(String.valueOf(password)) .append(strQuotes) .toString(); WMessage objMessage = WUtil.runScript(cmd, false); bSu = objMessage.isNoError(); strSu = objMessage.getMsg(); } if (bSu) { if (strSu != null) strSu = strSu.toLowerCase(); if (strSu == null || strSu.trim().equals("") || strSu.indexOf("killed") >= 0 || strSu.indexOf("error") >= 0) bSu = false; } return bSu; }