protected Map<String, List<Object>> authorizeReleaseOfAllowedAttributes(final RegisteredServiceAttributeReleasePolicyContext context,
                                                                            final Map<String, List<Object>> attrs) {
        val publicKey = context.getRegisteredService().getPublicKey();
        if (publicKey == null) {
            LOGGER.error("No public key is defined for service [{}]. No attributes will be released", context.getRegisteredService());
            return new HashMap<>();
        }
        LOGGER.debug("Using service [{}] public key [{}] to initialize the cipher", context.getRegisteredService().getServiceId(), publicKey);
        val cipher = publicKey.toCipher();
        if (cipher == null) {
            LOGGER.error("Unable to initialize cipher given the public key algorithm [{}]", publicKey.getAlgorithm());
            return new HashMap<>();
        }
        val resolvedAttributes = new TreeMap<String, List<Object>>(String.CASE_INSENSITIVE_ORDER);
        resolvedAttributes.putAll(attrs);
        val attributesToRelease = new HashMap<String, List<Object>>();
        getAllowedAttributes()
            .stream()
            .filter(resolvedAttributes::containsKey)
            .forEach(attr -> {
                LOGGER.debug("Found attribute [{}] in the list of allowed attributes. Encoding...", attr);
                val encodedValues = resolvedAttributes.get(attr)
                    .stream()
                    .map(Unchecked.function(value -> {
                        LOGGER.trace("Encrypting attribute [{}] with value [{}]", attr, value);
                        val result = EncodingUtils.encodeBase64(cipher.doFinal(value.toString().getBytes(StandardCharsets.UTF_8)));
                        LOGGER.trace("Encrypted attribute [{}] with value [{}]", attr, result);
                        return result;
                    }))
                    .collect(Collectors.<Object>toList());
                attributesToRelease.put(attr, encodedValues);
            });
        return attributesToRelease;
    }
Authorize release of allowed attributes map.

@param context the context
@param attrs   the attributes
@return the map
core/cas-server-core-authentication-attributes/src/main/java/org/apereo/cas/services/ReturnEncryptedAttributeReleasePolicy.java