public static SamlIdPMetadataDocument putSamlIdPMetadataIntoBucket(final S3Client s3Client,
                                                                       final SamlIdPMetadataDocument doc,
                                                                       final String bucketNameToUse) throws Throwable {
        val metadataObject = CollectionUtils.<String, String>wrap(
            "signingCertificate", StringUtils.defaultString(doc.getSigningCertificate()),
            "signingKey", StringUtils.defaultString(doc.getSigningKey()),
            "encryptionCertificate", StringUtils.defaultString(doc.getEncryptionCertificate()),
            "encryptionKey", StringUtils.defaultString(doc.getEncryptionKey()),
            "metadata", doc.getMetadata()
        );
        metadataObject.entrySet().removeIf(entry -> StringUtils.isBlank(entry.getValue()));

        val request = PutObjectRequest.builder()
            .key(String.valueOf(doc.getId()))
            .bucket(bucketNameToUse)
            .contentType(MediaType.APPLICATION_JSON_VALUE)
            .build();

        val requestBody = RequestBody.fromString(MAPPER.writeValueAsString(metadataObject));
        s3Client.putObject(request, requestBody);
        return doc;
    }
Put saml id p metadata into bucket.

@param s3Client        the s 3 client
@param doc             the doc
@param bucketNameToUse the bucket name to use
@return the saml id p metadata document
@throws Throwable the throwable
support/cas-server-support-saml-idp-metadata-aws-s3/src/main/java/org/apereo/cas/support/saml/idp/metadata/AmazonS3SamlIdPMetadataUtils.java