@Override protected Object execute0() throws Exception { ParamUtil.requireRange("k", quorum, 1, 10); char[] password; if (quorum == 1) { password = readPassword("Password"); } else { char[][] parts = new char[quorum][]; for (int i = 0; i < quorum; i++) { parts[i] = readPassword("Password " + (i + 1) + "/" + quorum); } password = StringUtil.merge(parts); } String passwordHint = OBFPasswordService.obfuscate(new String(password)); if (outFile != null) { saveVerbose("saved the obfuscated password to file", new File(outFile), passwordHint.getBytes()); } else { println("the obfuscated password is: '" + passwordHint + "'"); } return null; }
parts[i] = readPassword("Master password (part " + (i + 1) + "/" + mquorum + ")"); masterPassword = StringUtil.merge(parts);
parts[i] = readPassword("Password (part " + (i + 1) + "/" + quorum + ")"); password = StringUtil.merge(parts);
@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"); }