@Override
    public void populateAttributes(final AuthenticationBuilder builder, final AuthenticationTransaction transaction) {
        transaction.getPrimaryCredential().ifPresent(credential -> {
            LOGGER.debug("Processing request to capture the credential for [{}]", credential.getId());
            val upc = (UsernamePasswordCredential) credential;
            val psw = this.cipherExecutor == null ? upc.toPassword() : this.cipherExecutor.encode(upc.toPassword(), ArrayUtils.EMPTY_OBJECT_ARRAY);
            builder.addAttribute(UsernamePasswordCredential.AUTHENTICATION_ATTRIBUTE_PASSWORD, psw);
            LOGGER.debug("Credential is added as the authentication attribute [{}] to the authentication",
                UsernamePasswordCredential.AUTHENTICATION_ATTRIBUTE_PASSWORD);
        });
    }
We utilize the {@link AuthenticationMetaDataPopulator} to retrieve and store
the password as an authentication attribute under the key
{@link UsernamePasswordCredential#AUTHENTICATION_ATTRIBUTE_PASSWORD}.

@author Misagh Moayyed
@since 4.1
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/metadata/CacheCredentialsMetaDataPopulator.java