private byte[] generateOtpHash(final String algorithm, final String passPhrase, final String seed, final int newSequenceNumber) throws NoSuchAlgorithmException, InvalidKeySpecException { PasswordFactory otpFactory = PasswordFactory.getInstance(algorithm, providers); OneTimePasswordAlgorithmSpec otpSpec = new OneTimePasswordAlgorithmSpec(algorithm, seed, newSequenceNumber); EncryptablePasswordSpec passwordSpec = new EncryptablePasswordSpec(passPhrase.toCharArray(), otpSpec); OneTimePassword otPassword = (OneTimePassword) otpFactory.generatePassword(passwordSpec); return otPassword.getHash(); } }
if (plainText) { // file contains clear passwords - needs to be digested AlgorithmParameterSpec spec = parameterSpec != null ? parameterSpec : new DigestPasswordAlgorithmSpec(accountEntry.getName(), loadedState.getRealmName()); passwordSpec = new EncryptablePasswordSpec(accountEntry.getPasswordRepresentation().toCharArray(), spec); } else { // already digested file - need to check realm name if (parameterSpec != null) { // when not null, type already checked in acquire support check
final ClearPasswordSpec spec = clearFactory.getKeySpec(clearFactory.translate(twoWayPassword), ClearPasswordSpec.class); if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(spec.getEncodedPassword(), generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(spec)); if (password != null) { if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(password, generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(new ClearPasswordSpec(password)));
private byte[] generateOtpHash(final String algorithm, final String passPhrase, final String seed, final int newSequenceNumber) throws NoSuchAlgorithmException, InvalidKeySpecException { PasswordFactory otpFactory = PasswordFactory.getInstance(algorithm, providers); OneTimePasswordAlgorithmSpec otpSpec = new OneTimePasswordAlgorithmSpec(algorithm, seed, newSequenceNumber); EncryptablePasswordSpec passwordSpec = new EncryptablePasswordSpec(passPhrase.toCharArray(), otpSpec); OneTimePassword otPassword = (OneTimePassword) otpFactory.generatePassword(passwordSpec); return otPassword.getHash(); } }
private byte[] generateOtpHash(final String algorithm, final String passPhrase, final String seed, final int newSequenceNumber) throws NoSuchAlgorithmException, InvalidKeySpecException { PasswordFactory otpFactory = PasswordFactory.getInstance(algorithm, providers); OneTimePasswordAlgorithmSpec otpSpec = new OneTimePasswordAlgorithmSpec(algorithm, seed, newSequenceNumber); EncryptablePasswordSpec passwordSpec = new EncryptablePasswordSpec(passPhrase.toCharArray(), otpSpec); OneTimePassword otPassword = (OneTimePassword) otpFactory.generatePassword(passwordSpec); return otPassword.getHash(); } }
private byte[] generateOtpHash(final String algorithm, final String passPhrase, final String seed, final int newSequenceNumber) throws NoSuchAlgorithmException, InvalidKeySpecException { PasswordFactory otpFactory = PasswordFactory.getInstance(algorithm, providers); OneTimePasswordAlgorithmSpec otpSpec = new OneTimePasswordAlgorithmSpec(algorithm, seed, newSequenceNumber); EncryptablePasswordSpec passwordSpec = new EncryptablePasswordSpec(passPhrase.toCharArray(), otpSpec); OneTimePassword otPassword = (OneTimePassword) otpFactory.generatePassword(passwordSpec); return otPassword.getHash(); } }
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password, algorithmParameterSpec);
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password, algorithmParameterSpec);
if (plainText) { AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), algorithmParameterSpec); } else { byte[] hashed = ByteIterator.ofBytes(password.getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain();
if (plainText) { AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), algorithmParameterSpec); } else { byte[] hashed = ByteIterator.ofBytes(password.getBytes(StandardCharsets.UTF_8)).asUtf8String().hexDecode().drain();
byte[] salt = Bcrypt.SALT.resolveModelAttribute(parentContext, passwordNode).asBytes(); int iterationCount = Bcrypt.ITERATION_COUNT.resolveModelAttribute(parentContext, passwordNode).asInt(); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), new IteratedSaltedPasswordAlgorithmSpec(iterationCount, salt)); algorithm = Bcrypt.ALGORITHM.resolveModelAttribute(parentContext, passwordNode).asString(); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), null); algorithm = SimpleDigest.ALGORITHM.resolveModelAttribute(parentContext, passwordNode).asString(); byte[] salt = SaltedSimpleDigest.SALT.resolveModelAttribute(parentContext, passwordNode).asBytes(); SaltedPasswordAlgorithmSpec spec = new SaltedPasswordAlgorithmSpec(salt); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), spec); algorithm = SaltedSimpleDigest.ALGORITHM.resolveModelAttribute(parentContext, passwordNode).asString(); byte[] salt = ScramDigest.SALT.resolveModelAttribute(parentContext, passwordNode).asBytes(); int iterationCount = ScramDigest.ITERATION_COUNT.resolveModelAttribute(parentContext, passwordNode).asInt(); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), new IteratedSaltedPasswordAlgorithmSpec(iterationCount, salt)); algorithm = ScramDigest.ALGORITHM.resolveModelAttribute(parentContext, passwordNode).asString(); algorithm = Digest.ALGORITHM.resolveModelAttribute(parentContext, passwordNode).asString(); DigestPasswordAlgorithmSpec dpas = new DigestPasswordAlgorithmSpec(principalName, realm); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), dpas); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), otpSpec);
try { final PasswordFactory instance = PasswordFactory.getInstance(DigestPassword.ALGORITHM_DIGEST_MD5); final Password pwd = instance.generatePassword(new EncryptablePasswordSpec(password, new DigestPasswordAlgorithmSpec(serverName, DOMAIN_SERVER_AUTH_REALM))); return credentialType.cast(new PasswordCredential(pwd)); } catch (Exception e) {
try { final PasswordFactory instance = PasswordFactory.getInstance(DigestPassword.ALGORITHM_DIGEST_MD5); final Password pwd = instance.generatePassword(new EncryptablePasswordSpec(password, new DigestPasswordAlgorithmSpec(serverName, DOMAIN_SERVER_AUTH_REALM))); return credentialType.cast(new PasswordCredential(pwd)); } catch (Exception e) {
final Password password = instance.generatePassword(new EncryptablePasswordSpec(server.getAuthKey().toCharArray(), new DigestPasswordAlgorithmSpec(userName, realm))); dhc.setCredential(new PasswordCredential(password)); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
final Password password = instance.generatePassword(new EncryptablePasswordSpec(server.getAuthKey().toCharArray(), new DigestPasswordAlgorithmSpec(userName, realm))); dhc.setCredential(new PasswordCredential(password)); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
if (plainText) { // file contains clear passwords - needs to be digested AlgorithmParameterSpec spec = parameterSpec != null ? parameterSpec : new DigestPasswordAlgorithmSpec(accountEntry.getName(), loadedState.getRealmName()); passwordSpec = new EncryptablePasswordSpec(accountEntry.getPasswordRepresentation().toCharArray(), spec); } else { // already digested file - need to check realm name if (parameterSpec != null) { // when not null, type already checked in acquire support check
if (plainText) { // file contains clear passwords - needs to be digested AlgorithmParameterSpec spec = parameterSpec != null ? parameterSpec : new DigestPasswordAlgorithmSpec(accountEntry.getName(), loadedState.getRealmName()); passwordSpec = new EncryptablePasswordSpec(accountEntry.getPasswordRepresentation().toCharArray(), spec); } else { // already digested file - need to check realm name if (parameterSpec != null) { // when not null, type already checked in acquire support check
if (plainText) { // file contains clear passwords - needs to be digested AlgorithmParameterSpec spec = parameterSpec != null ? parameterSpec : new DigestPasswordAlgorithmSpec(accountEntry.getName(), loadedState.getRealmName()); passwordSpec = new EncryptablePasswordSpec(accountEntry.getPasswordRepresentation().toCharArray(), spec); } else { // already digested file - need to check realm name if (parameterSpec != null) { // when not null, type already checked in acquire support check
final ClearPasswordSpec spec = clearFactory.getKeySpec(clearFactory.translate(twoWayPassword), ClearPasswordSpec.class); if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(spec.getEncodedPassword(), generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(spec)); if (password != null) { if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(password, generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(new ClearPasswordSpec(password)));
final ClearPasswordSpec spec = clearFactory.getKeySpec(clearFactory.translate(twoWayPassword), ClearPasswordSpec.class); if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(spec.getEncodedPassword(), generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(spec)); if (password != null) { if (matchParameters != null) { return passwordType.cast(passwordFactory.generatePassword(new EncryptablePasswordSpec(password, generateParameters))); } else { return passwordType.cast(passwordFactory.generatePassword(new ClearPasswordSpec(password)));