/** 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 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; }