private Map<String, Object> prepareSamlAttributes(final Map<String, Object> model, final Service service,
                                                      final Map<String, List<Object>> authnAttributes,
                                                      final Map<String, List<Object>> principalAttributes) {
        val registeredService = servicesManager.findServiceBy(service);
        LOGGER.debug("Retrieved authentication attributes [{}] from the model", authnAttributes);

        val attributesToReturn = new HashMap<String, Object>();
        attributesToReturn.putAll(principalAttributes);
        attributesToReturn.putAll(authnAttributes);

        LOGGER.debug("Beginning to encode attributes [{}] for service [{}]", attributesToReturn, registeredService.getServiceId());
        val finalAttributes = protocolAttributeEncoder.encodeAttributes(model, attributesToReturn, registeredService, service);
        LOGGER.debug("Final collection of attributes are [{}]", finalAttributes);

        return finalAttributes;
    }
Encode saml response.

@param samlResponse the saml response
@param request      the request
@param response     the response
@throws Exception the exception
support/cas-server-support-saml/src/main/java/org/apereo/cas/support/saml/authentication/SamlResponseBuilder.java