public static SamlIdPMetadataDocument readMetadataDocumentFromBucket(final ResponseInputStream<GetObjectResponse> object,
                                                                         final String bucketToUse) throws Exception {
        val metadataObject = MAPPER.readValue(IOUtils.toString(object, StandardCharsets.UTF_8), new TypeReference<Map<String, String>>() {
        });
        val metadataDocument = new SamlIdPMetadataDocument();
        metadataDocument.setMetadata(metadataObject.get("metadata"));
        LOGGER.debug("Located S3 object metadata [{}] from bucket [{}]", metadataObject, bucketToUse);
        metadataDocument.setEncryptionCertificate(metadataObject.get("encryptionCertificate"));
        metadataDocument.setSigningCertificate(metadataObject.get("signingCertificate"));
        metadataDocument.setEncryptionKey(metadataObject.get("encryptionKey"));
        metadataDocument.setSigningKey(metadataObject.get("signingKey"));
        metadataDocument.setAppliesTo(bucketToUse);
        return metadataDocument;
    }
Read metadata document from bucket.

@param object      the object
@param bucketToUse the bucket to use
@return the saml id p metadata document
@throws Exception the exception
support/cas-server-support-saml-idp-metadata-aws-s3/src/main/java/org/apereo/cas/support/saml/idp/metadata/AmazonS3SamlIdPMetadataUtils.java