/** * Extract password value from passed value (if instance of GuardedString or GuardedByteArray). * * @param pwd received from the underlying connector * @return password value */ public static String getPassword(final Object pwd) { final StringBuilder result = new StringBuilder(); if (pwd instanceof GuardedString) { result.append(SecurityUtil.decrypt((GuardedString) pwd)); } else if (pwd instanceof GuardedByteArray) { result.append(SecurityUtil.decrypt((GuardedByteArray) pwd)); } else if (pwd instanceof String) { result.append((String) pwd); } else { result.append(pwd.toString()); } return result.toString(); }
EncryptorFactory.getInstance().getDefaultEncryptor().encrypt(SecurityUtil.decrypt(source).getBytes()); jgen.writeStringField("encryptedBytes", Base64.getEncoder().encodeToString(encryptedBytes));
EncryptorFactory.getInstance().getDefaultEncryptor().encrypt(SecurityUtil.decrypt(source).getBytes()); jgen.writeStringField("encryptedBytes", Base64.getEncoder().encodeToString(encryptedBytes));