protected Map<String, List<Object>> getPrincipalAttributesFromReleasePolicy(
        final RegisteredServiceUsernameProviderContext context) throws Throwable {
        if (context.getRegisteredService() != null && context.getRegisteredService().getAccessStrategy()
            .isServiceAccessAllowed(context.getRegisteredService(), context.getService())) {
            LOGGER.debug("Located service [{}] in the registry. Attempting to resolve attributes for [{}]",
                context.getRegisteredService(), context.getPrincipal().getId());
            if (context.getRegisteredService().getAttributeReleasePolicy() == null) {
                LOGGER.debug("No attribute release policy is defined for [{}]. Returning default principal attributes", context.getService().getId());
                return context.getPrincipal().getAttributes();
            }
            val releasePolicyContext = RegisteredServiceAttributeReleasePolicyContext.builder()
                .registeredService(context.getRegisteredService())
                .service(context.getService())
                .principal(context.getPrincipal())
                .applicationContext(context.getApplicationContext())
                .build();
            return context.getRegisteredService().getAttributeReleasePolicy().getAttributes(releasePolicyContext);
        }
        LOGGER.debug("Could not locate service [{}] in the registry.", context.getService().getId());
        throw UnauthorizedServiceException.denied("Rejected: %s".formatted(context.getService().getId()));
    }
Determines the username for this registered service based on a principal attribute.
If the attribute is not found, default principal id is returned.

@author Misagh Moayyed
@since 4.1.0
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/PrincipalAttributeRegisteredServiceUsernameProvider.java