protected void encryptAndEncodeAndPutIntoAttributesMap(final Map<String, Object> resultingAttributes,
                                                           final Map<String, String> cachedAttributesToEncode,
                                                           final String cachedAttributeName,
                                                           final RegisteredServiceCipherExecutor cipher,
                                                           final RegisteredService registeredService) {
        val cachedAttributeValue = cachedAttributesToEncode.remove(cachedAttributeName);
        val encodedValue = StringUtils.isNotBlank(cachedAttributeValue)
            ? cipher.encode(cachedAttributeValue, Optional.of(registeredService))
            : cachedAttributeValue;
        if (StringUtils.isNotBlank(encodedValue)) {
            resultingAttributes.put(cachedAttributeName, encodedValue);
        }
    }
The default implementation of the attribute
encoder that will use a per-service key-pair
to encrypt the credential password and PGT
when available. All other attributes remain in
place.

@author Misagh Moayyed
@since 4.1
core/cas-server-core-services-authentication/src/main/java/org/apereo/cas/authentication/support/DefaultCasProtocolAttributeEncoder.java