📄 install.java
字号:
answer = getAnswer(); } this.superadminpasswd = answer; } private void getJavaCACertsPasswd(){ System.out.print(text.getProperty("ENTERCACERTSPASSWORD")); String answer = getAnswer(); while(!answerLegalPassword(answer)){ System.out.print(text.getProperty("ILLEGALCACERTSPASSWORD")); System.out.print(text.getProperty("ENTERCACERTSPASSWORD")); answer = getAnswer(); } this.javacacertspasswd = answer; } private boolean isDataCorrect(){ System.out.print(text.getProperty("YOUHAVEENTEREDTHEFOLLOWING")); System.out.println(text.getProperty("CANAME") + " " + this.caname); System.out.println(text.getProperty("CADN") + " " + this.cadn); System.out.println(text.getProperty("KEYSIZE") + " " + this.keysize); System.out.println(text.getProperty("VALIDITY") + " " + this.validity); System.out.print(text.getProperty("POLICYID") + " "); if(this.policyid.equalsIgnoreCase("null")) System.out.println(text.getProperty("NOPOLICYID")); else System.out.println(this.policyid); System.out.println(text.getProperty("COMPUTERNAME") + " " + this.computername); System.out.println(text.getProperty("SERVERDN") + " " + this.servercertdn); System.out.println(text.getProperty("SUPERADMINPASSWORD") + " " + this.superadminpasswd); boolean correct = false; System.out.print(text.getProperty("ISTHISCORRECT")); String answer = getAnswer(); while(!this.answerInBoolean(answer) && !answer.equalsIgnoreCase("e") && !answer.equalsIgnoreCase("exit")){ System.out.print(text.getProperty("PLEASETYPEEITHERYESNOEXIT")); answer = getAnswer(); } if(answer.equalsIgnoreCase("e") || answer.equalsIgnoreCase("Exit")) System.exit(0); return getBooleanAnswer(answer); } private void runInstall(){ displayInstallingMessage(); if(this.os == OS_WINDOWS){ try { String[] command = new String[7]; command[0] = "ca.cmd"; command[1] = "init"; command[2] = this.caname; command[3] = "\"" + this.cadn + "\""; command[4] = Integer.toString(this.keysize); command[5] = Integer.toString(this.validity); command[6] = this.policyid.trim(); Process runcainit = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(runcainit.getInputStream())); Thread.sleep(1000); String line = ""; while((line = br.readLine()) != null){ System.out.println(line); } if(runcainit.waitFor() != 0){ System.out.println(text.getProperty("ERRORINITCA")); System.exit(-1); } } catch (Exception e) { System.out.println(text.getProperty("ERRORINITCA") + e); System.exit(-1); } System.out.print(text.getProperty("SETUPOFADMINWEB")); try { String[] command = new String[7]; command[0] = "setup-adminweb.cmd"; command[1] = this.caname; command[2] = "\"" + this.servercertdn + "\""; command[3] = this.serverkeystorepasswd; command[4] = this.superadminpasswd; command[5] = "dummy"; command[6] = this.computername; Process setupadminweb = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(setupadminweb.getInputStream())); Thread.sleep(1000); String line = ""; while((line = br.readLine()) != null); if(setupadminweb.waitFor() != 0){ System.out.println(text.getProperty("ERRORSETTINGUPADMINWEB")); System.exit(-1); } command = new String[5]; command[0] = "ca.cmd"; command[1] = "getrootcert"; command[2] = this.caname; command[3] = "tmp\\rootca.der"; command[4] = "-der"; Process getrootcert = Runtime.getRuntime().exec(command); if(getrootcert.waitFor() != 0){ System.out.println(text.getProperty("ERRORSETTINGUPADMINWEB")); System.exit(-1); } } catch (Exception e) { System.out.println(text.getProperty("ERRORSETTINGUPADMINWEB") + e); System.exit(-1); } } if(os == OS_UNIX){ try { String[] command = new String[7]; command[0] = "./ca.sh"; command[1] = "init"; command[2] = this.caname; command[3] = this.cadn; command[4] = Integer.toString(this.keysize); command[5] = Integer.toString(this.validity); command[6] = this.policyid.trim(); Process runcainit = Runtime.getRuntime().exec(command); BufferedReader br = new BufferedReader(new InputStreamReader(runcainit.getInputStream())); Thread.sleep(1000); String line = ""; while((line = br.readLine()) != null){ System.out.println(line); } if(runcainit.waitFor() != 0){ System.out.println(text.getProperty("ERRORINITCA")); System.exit(-1); } } catch (Exception e) { System.out.println(text.getProperty("ERRORINITCA") + e); System.exit(-1); } System.out.print(text.getProperty("SETUPOFADMINWEB")); try { String[] command = new String[7]; command[0] = "./setup-adminweb.sh"; command[1] = this.caname; command[2] = this.servercertdn; command[3] = this.serverkeystorepasswd; command[4] = this.superadminpasswd; command[5] = "changeit"; command[6] = this.computername; Process setupadminweb = Runtime.getRuntime().exec(command); if(setupadminweb.waitFor() != 0){ System.out.print(text.getProperty("ERRORSETTINGUPADMINWEB")); System.exit(-1); } command = new String[5]; command[0] = "./ca.sh"; command[1] = "getrootcert"; command[2] = this.caname; command[3] = "tmp/rootca.der"; command[4] = "-der"; Process getrootcert = Runtime.getRuntime().exec(command); if(getrootcert.waitFor() != 0){ System.out.println(text.getProperty("ERRORSETTINGUPADMINWEB")); System.exit(-1); } } catch (Exception e) { System.out.println(text.getProperty("ERRORSETTINGUPADMINWEB") + e); System.exit(-1); } } } private void displayInstallingMessage(){ System.out.print(text.getProperty("THEINSTALLATIONWILLNOWSTART")); } public void displayEndMessage(){ System.out.print(text.getProperty("INSTALLATIONCOMPLETE")); System.out.print(text.getProperty("REMAININGSTEPS")); System.out.print(text.getProperty("GOTOURL")); System.out.print(text.getProperty("ANDYOUAREALLSET")); System.out.print(text.getProperty("INTERESTEDINSUPPORT")); } private String getAnswer(){ String returnval = ""; try { returnval= reader.readLine(); } catch (Exception e) {} return returnval; } private boolean answerInBoolean(String answer) { return answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("n") || answer.equalsIgnoreCase("yes") || answer.equalsIgnoreCase("no"); } private boolean getBooleanAnswer(String answer){ return answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("yes"); } private boolean answerInDigits(String answer){ return ! nondigit.matcher(answer).find(); } private boolean answerInDigitsAndDots(String answer){ return !nondigitordot.matcher(answer).find(); } private int getDigitAnswer(String answer){ return Integer.parseInt(answer); } private boolean answerLegalDN(String answer){ return !answer.trim().equals("") && LDAPDN.isValid(answer); } private boolean answerLegalName(String answer){ return !answer.trim().equals("") && !nonword.matcher(answer).find(); } private boolean answerLegalPolicyId(String answer){ if(answer.equalsIgnoreCase("NO")) return true; return !answer.trim().equals("") && !nondigitordot.matcher(answer).find(); } private String getPolicyId(String answer){ if(answer.equalsIgnoreCase("NO")) return "null"; return answer; } private boolean answerLegalKeySize(String answer){ if(!answerInDigits(answer)) return false; int keysize = getInt(answer); return keysize == 512 || keysize == 1024 || keysize == 2048 || keysize == 4096; } private boolean answerLegalValidity(String answer){ if(!answerInDigits(answer)) return false; int val = getInt(answer); return val > 0 && val < 35600; } private int getInt(String answer){ int returnval = -1; try{ returnval = Integer.parseInt(answer); }catch(Exception e){} return returnval; } private boolean answerLegalComputerName(String answer){ return !answer.trim().equals("") && !this.notcomputername.matcher(answer).find(); } private boolean answerLegalPassword(String answer){ int len = answer.length(); if(answer.indexOf(' ') != -1 || answer.indexOf('"') != -1 || answer.indexOf('\'') != -1) return false; return len > 1 && len < 14; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -