@Audit(action = AuditableActions.SAML2_METADATA_RESOLUTION,
        actionResolverName = AuditActionResolvers.SAML2_METADATA_RESOLUTION_ACTION_RESOLVER,
        resourceResolverName = AuditResourceResolvers.SAML2_METADATA_RESOLUTION_RESOURCE_RESOLVER)
    @Override
    public Collection<? extends MetadataResolver> resolve(final SamlRegisteredService service,
                                                          final CriteriaSet criteriaSet) {

        LOGGER.debug("Locating S3 object(s) from bucket [{}]...", bucketName);
        if (s3Client.listBuckets(ListBucketsRequest.builder().build())
            .buckets().stream().noneMatch(b -> b.name().equalsIgnoreCase(bucketName))) {
            LOGGER.debug("S3 bucket [{}] does not exist", bucketName);
            return new ArrayList<>();
        }

        val result = s3Client.listObjectsV2(ListObjectsV2Request.builder().bucket(bucketName).build());
        val objects = result.contents();
        LOGGER.debug("Located [{}] S3 object(s) from bucket [{}]", objects.size(), bucketName);

        return objects.stream()
            .map(obj -> {
                val objectKey = obj.key();
                LOGGER.debug("Fetching object [{}] from bucket [{}]", objectKey, bucketName);

                try (val is = s3Client.getObject(GetObjectRequest.builder().key(objectKey).bucket(bucketName).build())) {
                    val document = new SamlMetadataDocument();
                    document.setId(System.nanoTime());
                    document.setName(objectKey);
                    val objectMetadata = is.response().metadata();
                    if (objectMetadata != null) {
                        document.setSignature(objectMetadata.get("signature"));
                        if (StringUtils.isNotBlank(document.getSignature())) {
                            LOGGER.debug("Found metadata signature as part of object metadata for [{}] from bucket [{}]", objectKey, bucketName);
                        }
                    }
                    document.setValue(IOUtils.toString(is, StandardCharsets.UTF_8));
                    return buildMetadataResolverFrom(service, document);
                } catch (final Exception e) {
                    LoggingUtils.error(LOGGER, e);
                }
                return null;
            })
            .filter(Objects::nonNull)
            .collect(Collectors.toList());
    }
This is {@link AmazonS3SamlRegisteredServiceMetadataResolver}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp-metadata-aws-s3/src/main/java/org/apereo/cas/support/saml/metadata/resolver/AmazonS3SamlRegisteredServiceMetadataResolver.java