@Override public char[] resolvePassword(String passwordHint) throws PasswordResolverException { return OBFPasswordService.deobfuscate(passwordHint).toCharArray(); }
@Override public String protectPassword(char[] password) throws PasswordResolverException { return OBFPasswordService.obfuscate(new String(password)); }
public static String deobfuscate(String str) { Args.notNull(str, "str"); if (startsWithIgnoreCase(str, OBFUSCATE)) { str = str.substring(4); } byte[] bytes = new byte[str.length() / 2]; int idx = 0; for (int i = 0; i < str.length(); i += 4) { if (str.charAt(i) == 'U') { i++; String sx = str.substring(i, i + 4); int i0 = Integer.parseInt(sx, 36); byte bx = (byte) (i0 >> 8); bytes[idx++] = bx; } else { String sx = str.substring(i, i + 4); int i0 = Integer.parseInt(sx, 36); int i1 = (i0 / 256); int i2 = (i0 % 256); byte bx = (byte) ((i1 + i2 - 254) / 2); bytes[idx++] = bx; } } // end for return new String(bytes, 0, idx, StandardCharsets.UTF_8); }
@Override public void init(String conf) throws PasswordResolverException { Args.notBlank(conf, "conf"); this.password = OBFPasswordService.deobfuscate(conf).toCharArray(); }
@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; }
@Override protected Object execute0() throws Exception { if (!(passwordHint == null ^ passwordFile == null)) { throw new IllegalCmdParamException( "exactly one of password and password-file must be specified"); } if (passwordHint == null) { passwordHint = new String(IoUtil.read(passwordFile)); } if (!StringUtil.startsWithIgnoreCase(passwordHint, "OBF:")) { throw new IllegalCmdParamException("encrypted password '" + passwordHint + "' does not start with OBF:"); } String password = OBFPasswordService.deobfuscate(passwordHint); if (outFile != null) { saveVerbose("saved the password to file", new File(outFile), new String(password).getBytes()); } else { println("the password is: '" + new String(password) + "'"); } return null; }
return OBFPasswordService.deobfuscate(passwordHint).toCharArray(); } else { return passwordHint.toCharArray();
String str = new String(IoUtil.read(masterPasswordFile)); if (str.startsWith("OBF:") || str.startsWith("obf:")) { str = OBFPasswordService.deobfuscate(str);
String str = new String(IoUtil.read(masterPasswordFile)); if (str.startsWith("OBF:") || str.startsWith("obf:")) { str = OBFPasswordService.deobfuscate(str);