@Override
    public Map<String, List<Object>> getAttributes(final HttpServletRequest request) {
        val attributes = new HashMap<String, List<Object>>();
        val headers = Collections.list(request.getHeaderNames());
        headers.forEach(headerName -> headerPatterns.entrySet()
            .stream()
            .filter(entry -> RegexUtils.find(entry.getKey(), headerName))
            .filter(entry -> StringUtils.isNotBlank(request.getHeader(headerName)))
            .filter(entry -> RegexUtils.find(entry.getValue(), request.getHeader(headerName)))
            .forEach(entry -> {
                val headerNamePattern = RegexUtils.createPattern(entry.getKey(), Pattern.CASE_INSENSITIVE);
                val headerNameMatcher = headerNamePattern.matcher(headerName);
                val headerNameToUse = headerNameMatcher.find() && headerNameMatcher.groupCount() > 0
                    ? headerNameMatcher.group(1) : headerName;
                val headerValue = request.getHeader(headerName);
                val headerValuePattern = RegexUtils.createPattern(entry.getValue(), Pattern.CASE_INSENSITIVE);
                val headerValueMatcher = headerValuePattern.matcher(headerValue);
                val headerValueToUse = headerValueMatcher.find() && headerValueMatcher.groupCount() > 0
                    ? headerValueMatcher.group(1) : headerName;
                attributes.put(headerNameToUse, CollectionUtils.wrapList(headerValueToUse));
            }));
        return attributes;
    }
This is {@link DefaultRemoteRequestPrincipalAttributesExtractor}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-trusted/src/main/java/org/apereo/cas/adaptors/trusted/authentication/principal/DefaultRemoteRequestPrincipalAttributesExtractor.java