private Principal resolvePrincipalForAttributeQuery(final Authentication authentication,
                                                        final RegisteredService registeredService) throws Throwable {
        val repositories = new HashSet<String>();
        if (registeredService != null) {
            repositories.addAll(registeredService.getAttributeReleasePolicy()
                .getPrincipalAttributesRepository().getAttributeRepositoryIds());
        }

        val principal = authentication.getPrincipal();
        val attributes = PrincipalAttributeRepositoryFetcher.builder()
            .attributeRepository(getConfigurationContext().getAttributeRepository())
            .principalId(principal.getId())
            .activeAttributeRepositoryIdentifiers(repositories)
            .currentPrincipal(principal)
            .build()
            .retrieve();
        LOGGER.debug("Attributes retrieved from attribute repositories are [{}]", attributes);
        return PrincipalFactoryUtils.newPrincipalFactory().createPrincipal(principal.getId(), attributes);
    }
Handle post request.

@param response the response
@param request  the request
@throws Exception the exception
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/query/SamlIdPSaml2AttributeQueryProfileHandlerController.java