software.amazon.awssdk.services.kinesis.model.EncryptionType Java Examples
The following examples show how to use
software.amazon.awssdk.services.kinesis.model.EncryptionType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsKinesisScannerTest.java From clouditor with Apache License 2.0 | 5 votes |
@BeforeAll static void setUpOnce() throws IOException { discoverAssets( KinesisClient.class, AwsKinesisScanner::new, api -> { when(api.listStreams()) .thenReturn( ListStreamsResponse.builder() .streamNames("stream-encrypted", "stream-not-encrypted") .build()); when(api.describeStream( DescribeStreamRequest.builder().streamName("stream-encrypted").build())) .thenReturn( DescribeStreamResponse.builder() .streamDescription( StreamDescription.builder() .streamARN("arn:aws:kinesis:us-east-1:111122223333:encrypted") .encryptionType(EncryptionType.KMS) .build()) .build()); when(api.describeStream( DescribeStreamRequest.builder().streamName("stream-not-encrypted").build())) .thenReturn( DescribeStreamResponse.builder() .streamDescription( StreamDescription.builder() .streamARN("arn:aws:kinesis:us-east-1:111122223333:unencrypted") .encryptionType(EncryptionType.NONE) .build()) .build()); }); }
Example #2
Source File: KinesisRecord.java From pulsar with Apache License 2.0 | 5 votes |
public KinesisRecord(KinesisClientRecord record) { this.key = Optional.of(record.partitionKey()); // encryption type can (annoyingly) be null, so we default to NONE EncryptionType encType = EncryptionType.NONE; if (record.encryptionType() != null) { encType = record.encryptionType(); } setProperty(ARRIVAL_TIMESTAMP, record.approximateArrivalTimestamp().toString()); setProperty(ENCRYPTION_TYPE, encType.toString()); setProperty(PARTITION_KEY, record.partitionKey()); setProperty(SEQUENCE_NUMBER, record.sequenceNumber()); if (encType == EncryptionType.NONE) { String s = null; try { s = decoder.decode(record.data()).toString(); } catch (CharacterCodingException e) { // Ignore } this.value = (s != null) ? s.getBytes() : null; } else if (encType == EncryptionType.KMS) { // use the raw encrypted value, let them handle it downstream // TODO: support decoding KMS data here... should be fairly simple this.value = record.data().array(); } else { // Who knows? this.value = null; } }