protected char[] readPassword(String prompt) throws IOException { String tmpPrompt = (prompt == null) ? "Password:" : prompt.trim(); if (!tmpPrompt.endsWith(":")) { tmpPrompt += ":"; } String passwordUi = System.getProperty("org.xipki.console.passwordui"); return "gui".equalsIgnoreCase(passwordUi) ? SecurePasswordInputPanel.readPassword(tmpPrompt) : readLine(tmpPrompt, '*').toCharArray(); }
protected char[] readPassword(String prompt) throws IOException { String tmpPrompt = (prompt == null) ? "Password:" : prompt.trim(); if (!tmpPrompt.endsWith(":")) { tmpPrompt += ":"; } String passwordUi = System.getProperty("org.xipki.console.passwordui"); return "gui".equalsIgnoreCase(passwordUi) ? SecurePasswordInputPanel.readPassword(tmpPrompt) : readLine(tmpPrompt, '*').toCharArray(); }
protected char[] readPassword(final String prompt) throws IOException { String tmpPrompt = (prompt == null) ? "Password:" : prompt.trim(); if (!tmpPrompt.endsWith(":")) { tmpPrompt += ":"; } String passwordUi = System.getProperty("org.xipki.console.passwordui"); return "gui".equalsIgnoreCase(passwordUi) ? SecurePasswordInputPanel.readPassword(tmpPrompt) : readLine(tmpPrompt, '*').toCharArray(); }
@Override public char[] getPassword(String prompt, String testToken) throws PasswordResolverException { String tmpPrompt = prompt; if (StringUtil.isBlank(tmpPrompt)) { tmpPrompt = "Password required"; } for (int i = 0; i < tries; i++) { char[] password; if (quorum == 1) { password = SecurePasswordInputPanel.readPassword(tmpPrompt); if (password == null) { throw new PasswordResolverException("user has cancelled"); } } else { char[][] passwordParts = new char[quorum][]; for (int j = 0; j < quorum; j++) { String promptPart = tmpPrompt + " (part " + (j + 1) + "/" + quorum + ")"; passwordParts[j] = SecurePasswordInputPanel.readPassword(promptPart); if (passwordParts[j] == null) { throw new PasswordResolverException("user has cancelled"); } } password = StringUtil.merge(passwordParts); } if (isPasswordValid(password, testToken)) { return password; } } throw new PasswordResolverException("Could not get the password after " + tries + " tries"); }