docs: @SneakyThrows
      public static SamlRegisteredService newSamlServiceProviderService(final AbstractSamlSPProperties sp,
                                                                        final SamlRegisteredServiceCachingMetadataResolver resolver) {
          if (StringUtils.isBlank(sp.getMetadata())) {
              LOGGER.debug("Skipped registration of [{}] since no metadata location is found", sp.getName());
              return null;
          }
  
          val service = new SamlRegisteredService();
          service.setName(sp.getName());
          service.setDescription(sp.getDescription());
          service.setEvaluationOrder(Ordered.HIGHEST_PRECEDENCE);
          service.setMetadataLocation(sp.getMetadata());
          val attributesToRelease = new ArrayList<String>(sp.getAttributes());
          if (StringUtils.isNotBlank(sp.getNameIdAttribute())) {
              attributesToRelease.add(sp.getNameIdAttribute());
              service.setUsernameAttributeProvider(new PrincipalAttributeRegisteredServiceUsernameProvider(sp.getNameIdAttribute()));
          }
          if (StringUtils.isNotBlank(sp.getNameIdFormat())) {
              service.setRequiredNameIdFormat(sp.getNameIdFormat());
          }
  
          val attributes = CoreAuthenticationUtils.transformPrincipalAttributesListIntoMultiMap(attributesToRelease);
          val policy = new ChainingAttributeReleasePolicy();
          policy.addPolicy(new ReturnMappedAttributeReleasePolicy(CollectionUtils.wrap(attributes)));
          service.setAttributeReleasePolicy(policy);
  
          service.setMetadataCriteriaRoles(SPSSODescriptor.DEFAULT_ELEMENT_NAME.getLocalPart());
          service.setMetadataCriteriaRemoveEmptyEntitiesDescriptors(true);
          service.setMetadataCriteriaRemoveRolelessEntityDescriptors(true);
  
          if (StringUtils.isNotBlank(sp.getSignatureLocation())) {
              service.setMetadataSignatureLocation(sp.getSignatureLocation());
          }
  
          val entityIDList = determineEntityIdList(sp, resolver, service);
  
          if (entityIDList.isEmpty()) {
              LOGGER.warn("Skipped registration of [{}] since no metadata entity ids could be found", sp.getName());
              return null;
          }
          val entityIds = org.springframework.util.StringUtils.collectionToDelimitedString(entityIDList, "|");
          service.setMetadataCriteriaDirection(PredicateFilter.Direction.INCLUDE.name());
          service.setMetadataCriteriaPattern(entityIds);
  
          LOGGER.debug("Registering saml service [{}] by entity id [{}]", sp.getName(), entityIds);
          service.setServiceId(entityIds);
  
          service.setSignAssertions(sp.isSignAssertions());
          service.setSignResponses(sp.isSignResponses());
  
          return service;
      }