use of com.amazon.dataprepper.plugins.prepper.peerforwarder.certificate.model.Certificate in project data-prepper by opensearch-project.
the class S3CertificateProvider method getCertificate.
public Certificate getCertificate() {
try {
final URI certificateFileUri = new URI(certificateFilePath);
final String certificate = getObjectWithKey(certificateFileUri.getHost(), certificateFileUri.getPath().substring(1));
return new Certificate(certificate);
} catch (URISyntaxException ex) {
LOG.error("Error encountered while parsing the certificate's Amazon S3 URI.", ex);
throw new RuntimeException(ex);
}
}
use of com.amazon.dataprepper.plugins.prepper.peerforwarder.certificate.model.Certificate in project data-prepper by opensearch-project.
the class FileCertificateProviderTest method getCertificateValidPathSuccess.
@Test
public void getCertificateValidPathSuccess() throws IOException {
final String certificateFilePath = FileCertificateProviderTest.class.getClassLoader().getResource("test-crt.crt").getPath();
fileCertificateProvider = new FileCertificateProvider(certificateFilePath);
final Certificate certificate = fileCertificateProvider.getCertificate();
final Path certFilePath = new File(certificateFilePath).toPath();
final String certAsString = Files.readString(certFilePath);
assertThat(certificate.getCertificate(), is(certAsString));
}
use of com.amazon.dataprepper.plugins.prepper.peerforwarder.certificate.model.Certificate in project data-prepper by opensearch-project.
the class S3CertificateProviderTest method getCertificateValidKeyPathSuccess.
@Test
public void getCertificateValidKeyPathSuccess() {
final String certificateContent = UUID.randomUUID().toString();
final String bucketName = UUID.randomUUID().toString();
final String certificatePath = UUID.randomUUID().toString();
final String s3SslKeyCertChainFile = String.format("s3://%s/%s", bucketName, certificatePath);
final InputStream certObjectStream = IOUtils.toInputStream(certificateContent, StandardCharsets.UTF_8);
final ResponseInputStream certResponseInputStream = new ResponseInputStream<>(GetObjectResponse.builder().build(), AbortableInputStream.create(certObjectStream));
final GetObjectRequest certRequest = GetObjectRequest.builder().bucket(bucketName).key(certificatePath).build();
when(s3Client.getObject(certRequest)).thenReturn(certResponseInputStream);
s3CertificateProvider = new S3CertificateProvider(s3Client, s3SslKeyCertChainFile);
final Certificate certificate = s3CertificateProvider.getCertificate();
assertThat(certificate.getCertificate(), is(certificateContent));
}
Aggregations