passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); 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 DigestPasswordAlgorithmSpec spec = (DigestPasswordAlgorithmSpec) parameterSpec; if (! loadedState.getRealmName().equals(spec.getRealm()) || ! accountEntry.getName().equals(spec.getUsername())) { if (log.isTraceEnabled()) { log.tracef("PropertiesRealm: Unable to obtain credential for username [%s] (available [%s]) and realm [%s] (available [%s])", spec.getUsername(), accountEntry.getName(), spec.getRealm(), loadedState.getRealmName());
DigestPasswordImpl(final String algorithm, final char[] password, final DigestPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.algorithm = algorithm; this.username = spec.getUsername(); this.realm = spec.getRealm(); try { this.digest = userRealmPasswordDigest(getMessageDigest(algorithm), spec.getUsername(), spec.getRealm(), password); } catch (NoSuchAlgorithmException e) { throw log.invalidKeySpecNoSuchMessageDigestAlgorithm(algorithm); } }
default DigestPasswordAlgorithmSpec getParameterSpec() { return new DigestPasswordAlgorithmSpec(getUsername(), getRealm()); }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { ArrayList<Callback> list = new ArrayList<>(Arrays.asList(callbacks)); Iterator<Callback> it = list.iterator(); CredentialCallback cb = null; while (it.hasNext()) { Callback callback = it.next(); if (callback instanceof AvailableRealmsCallback) { ((AvailableRealmsCallback) callback).setRealmNames(realmList); it.remove(); } else if (callback instanceof CredentialCallback) { cb = (CredentialCallback) callback; } } // If the only callback was AvailableRealmsCallback, we must not pass it to the AuthorizingCallbackHandler if (!list.isEmpty()) { if (cb != null && cb.getAlgorithm().equals(ALGORITHM_DIGEST_MD5)) { // It's necessary to add the NameCallback with the CredentialCallback, otherwise a UserNotFoundException is thrown DigestPasswordAlgorithmSpec spec = (DigestPasswordAlgorithmSpec) cb.getParameterSpec(); list.add(new NameCallback("User", spec.getUsername())); callbacks = list.toArray(new Callback[list.size()]); } delegate.handle(callbacks); } }
protected void engineEncode(final ASN1Encoder encoder, final DigestPasswordAlgorithmSpec parameterSpec) { encoder.startSequence(); encoder.encodeOctetString(parameterSpec.getUsername()); encoder.encodeOctetString(parameterSpec.getRealm()); encoder.endSequence(); }
protected DigestPasswordAlgorithmSpec engineDecode(final ASN1Decoder decoder) { decoder.startSequence(); final String username = decoder.decodeOctetStringAsString(); final String realm = decoder.decodeOctetStringAsString(); decoder.endSequence(); return new DigestPasswordAlgorithmSpec(username, realm); } }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { // We have to provide the available realms via this callback // Ideally we would utilise org.wildfly.security.sasl.util.AvailableRealmsSaslServerFactory, however as we can't // pass the SaslServerFactory impl to JGroups we must do it here instead. ArrayList<Callback> list = new ArrayList<>(Arrays.asList(callbacks)); Iterator<Callback> it = list.iterator(); CredentialCallback cb = null; while (it.hasNext()) { Callback callback = it.next(); if (callback instanceof AvailableRealmsCallback) { ((AvailableRealmsCallback) callback).setRealmNames(realmList); it.remove(); } else if (callback instanceof CredentialCallback) { cb = (CredentialCallback) callback; } } // If the only callback was AvailableRealmsCallback, we must not pass it to the AuthorizingCallbackHandler if (!list.isEmpty()) { if (cb != null && cb.getAlgorithm().equals(ALGORITHM_DIGEST_MD5)) { // It's necessary to add the NameCallback with the CredentialCallback, otherwise a UserNotFoundException is thrown DigestPasswordAlgorithmSpec spec = (DigestPasswordAlgorithmSpec) cb.getParameterSpec(); list.add(new NameCallback("User", spec.getUsername())); callbacks = list.toArray(new Callback[list.size()]); } getMechCallbackHandler().handle(callbacks); } }
if (! Objects.equals(digestSpec.getRealm(), realm) || ! Objects.equals(digestSpec.getUsername(), principal.getName())) { return null; } else { passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password, algorithmParameterSpec);
DigestPasswordImpl(final String algorithm, final char[] password, final DigestPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.algorithm = algorithm; this.username = spec.getUsername(); this.realm = spec.getRealm(); try { this.digest = userRealmPasswordDigest(getMessageDigest(algorithm), spec.getUsername(), spec.getRealm(), password); } catch (NoSuchAlgorithmException e) { throw log.invalidKeySpecNoSuchMessageDigestAlgorithm(algorithm); } }
new DigestPasswordAlgorithmSpec(username, realm) : null;
if (! Objects.equals(digestSpec.getRealm(), realm) || ! Objects.equals(digestSpec.getUsername(), principal.getName())) { return null; } else { passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password, algorithmParameterSpec);
DigestPasswordImpl(final String algorithm, final char[] password, final DigestPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.algorithm = algorithm; this.username = spec.getUsername(); this.realm = spec.getRealm(); try { this.digest = userRealmPasswordDigest(getMessageDigest(algorithm), spec.getUsername(), spec.getRealm(), password); } catch (NoSuchAlgorithmException e) { throw log.invalidKeySpecNoSuchMessageDigestAlgorithm(algorithm); } }
default DigestPasswordAlgorithmSpec getParameterSpec() { return new DigestPasswordAlgorithmSpec(getUsername(), getRealm()); }
if (! Objects.equals(digestSpec.getRealm(), realm) || ! Objects.equals(digestSpec.getUsername(), principal.getName())) { return null; passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); if (plainText) { AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), algorithmParameterSpec); } else {
DigestPasswordImpl(final String algorithm, final char[] password, final DigestPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.algorithm = algorithm; this.username = spec.getUsername(); this.realm = spec.getRealm(); try { this.digest = userRealmPasswordDigest(getMessageDigest(algorithm), spec.getUsername(), spec.getRealm(), password); } catch (NoSuchAlgorithmException e) { throw log.invalidKeySpecNoSuchMessageDigestAlgorithm(algorithm); } }
default DigestPasswordAlgorithmSpec getParameterSpec() { return new DigestPasswordAlgorithmSpec(getUsername(), getRealm()); }
if (! Objects.equals(digestSpec.getRealm(), realm) || ! Objects.equals(digestSpec.getUsername(), principal.getName())) { return null; passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); if (plainText) { AlgorithmParameterSpec algorithmParameterSpec = new DigestPasswordAlgorithmSpec(principal.getName(), realm); passwordSpec = new EncryptablePasswordSpec(password.toCharArray(), algorithmParameterSpec); } else {
protected void engineEncode(final ASN1Encoder encoder, final DigestPasswordAlgorithmSpec parameterSpec) { encoder.startSequence(); encoder.encodeOctetString(parameterSpec.getUsername()); encoder.encodeOctetString(parameterSpec.getRealm()); encoder.endSequence(); }
default DigestPasswordAlgorithmSpec getParameterSpec() { return new DigestPasswordAlgorithmSpec(getUsername(), getRealm()); }
passwordFactory = getPasswordFactory(ALGORITHM_DIGEST_MD5); 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 DigestPasswordAlgorithmSpec spec = (DigestPasswordAlgorithmSpec) parameterSpec; if (! loadedState.getRealmName().equals(spec.getRealm()) || ! accountEntry.getName().equals(spec.getUsername())) { if (log.isTraceEnabled()) { log.tracef("PropertiesRealm: Unable to obtain credential for username [%s] (available [%s]) and realm [%s] (available [%s])", spec.getUsername(), accountEntry.getName(), spec.getRealm(), loadedState.getRealmName());