Skip to content

Commit e506830

Browse files
committed
remove logging, redundant code
1 parent 21a2c0c commit e506830

File tree

7 files changed

+0
-28
lines changed

7 files changed

+0
-28
lines changed

src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public static void LowLevelMultipartUpload() throws IOException {
8585

8686
// Process and Upload each part
8787
while ((bytesRead = inputStream.read(partData, 0, partData.length)) != -1) {
88-
System.out.println("part no: " + partsSent);
8988
outputStream.write(partData, 0, bytesRead);
9089
if (bytesSent < PART_SIZE) {
9190
bytesSent += bytesRead;
@@ -104,7 +103,6 @@ public static void LowLevelMultipartUpload() throws IOException {
104103
final InputStream partInputStream = new ByteArrayInputStream(outputStream.toByteArray());
105104

106105
// Upload all the different parts of the object
107-
System.out.println("uploading part no: " + uploadPartRequest.partNumber());
108106
UploadPartResponse uploadPartResult = v3Client.uploadPart(uploadPartRequest,
109107
RequestBody.fromInputStream(partInputStream, partInputStream.available()));
110108

@@ -133,7 +131,6 @@ public static void LowLevelMultipartUpload() throws IOException {
133131

134132
// Upload the last part multipart upload to invoke `cipher.doFinal()`
135133
final InputStream partInputStream = new ByteArrayInputStream(outputStream.toByteArray());
136-
System.out.println("uploading FINAL part no: " + uploadPartRequest.partNumber());
137134
UploadPartResponse uploadPartResult = v3Client.uploadPart(uploadPartRequest,
138135
RequestBody.fromInputStream(partInputStream, partInputStream.available()));
139136

@@ -144,15 +141,13 @@ public static void LowLevelMultipartUpload() throws IOException {
144141

145142
// Finally call completeMultipartUpload operation to tell S3 to merge all uploaded
146143
// parts and finish the multipart operation.
147-
System.out.println("completing MPU");
148144
v3Client.completeMultipartUpload(builder -> builder
149145
.bucket(BUCKET)
150146
.key(objectKey)
151147
.uploadId(initiateResult.uploadId())
152148
.multipartUpload(partBuilder -> partBuilder.parts(partETags)));
153149

154150
// Call getObject to retrieve and decrypt the object from S3
155-
System.out.println("GetObject follows");
156151
ResponseInputStream<GetObjectResponse> output = v3Client.getObject(builder -> builder
157152
.bucket(BUCKET)
158153
.key(objectKey));

src/main/java/software/amazon/encryption/s3/internal/CipherProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public CipherProvider(final CryptographicMaterialsManager cmm) {
3030
* @return a Cipher object, initialized and ready to use
3131
*/
3232
public static Cipher createAndInitCipher(final CryptographicMaterials materials, byte[] iv) {
33-
System.out.println("creating a cipher.");
3433
// Validate that the IV has been populated. There is a small chance
3534
// that an IV containing only 0s is (validly) randomly generated,
3635
// but the tradeoff is worth the protection, and an IV of 0s is
@@ -42,7 +41,6 @@ public static Cipher createAndInitCipher(final CryptographicMaterials materials,
4241
Cipher cipher = CryptoFactory.createCipher(materials.algorithmSuite().cipherName(), materials.cryptoProvider());
4342
switch (materials.algorithmSuite()) {
4443
case ALG_AES_256_GCM_IV12_TAG16_NO_KDF:
45-
System.out.println("initting a GCM cipher");
4644
cipher.init(materials.cipherMode().opMode(), materials.dataKey(), new GCMParameterSpec(materials.algorithmSuite().cipherTagLengthBits(), iv));
4745
break;
4846
case ALG_AES_256_CTR_IV16_TAG16_NO_KDF:

src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class CipherSubscriber implements Subscriber<ByteBuffer> {
2525
private byte[] outputBuffer;
2626

2727
CipherSubscriber(Subscriber<? super ByteBuffer> wrappedSubscriber, Long contentLength, CryptographicMaterials materials, byte[] iv, boolean isLastPart) {
28-
System.out.println("Initializing CipherSubscriber. It is " + (isLastPart ? "infact" : "NOT") + " the last part!");
2928
this.wrappedSubscriber = wrappedSubscriber;
3029
this.contentLength = contentLength;
3130
this.materials = materials;
@@ -102,7 +101,6 @@ public void onComplete() {
102101
return;
103102
}
104103
try {
105-
System.out.println("Doing final!");
106104
outputBuffer = cipher.doFinal();
107105
// Send the final bytes to the wrapped subscriber
108106
wrappedSubscriber.onNext(ByteBuffer.wrap(outputBuffer));

src/main/java/software/amazon/encryption/s3/internal/GetEncryptedObjectPipeline.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,10 @@ public void onStream(SdkPublisher<ByteBuffer> ciphertextPublisher) {
138138
long[] desiredRange = RangedGetUtils.getRange(materials.getContentRange());
139139
long[] cryptoRange = RangedGetUtils.getCryptoRange(materials.getContentRange());
140140
AlgorithmSuite algorithmSuite = materials.algorithmSuite();
141-
// SecretKey contentKey = materials.dataKey();
142-
// final int tagLength = algorithmSuite.cipherTagLengthBits();
143141
byte[] iv = contentMetadata.contentIv();
144142
if (algorithmSuite == AlgorithmSuite.ALG_AES_256_CTR_IV16_TAG16_NO_KDF) {
145143
iv = AesCtrUtils.adjustIV(iv, cryptoRange[0]);
146144
}
147-
// final Cipher cipher = CryptoFactory.createCipher(algorithmSuite.cipherName(), materials.cryptoProvider());
148-
switch (algorithmSuite) {
149-
case ALG_AES_256_GCM_IV12_TAG16_NO_KDF:
150-
System.out.println("initting a GCM cipher for decrypt...");
151-
// cipher.init(Cipher.DECRYPT_MODE, contentKey, new GCMParameterSpec(tagLength, iv));
152-
break;
153-
case ALG_AES_256_CTR_IV16_TAG16_NO_KDF:
154-
case ALG_AES_256_CBC_IV16_NO_KDF:
155-
// cipher.init(Cipher.DECRYPT_MODE, contentKey, new IvParameterSpec(iv));
156-
break;
157-
default:
158-
throw new S3EncryptionClientException("Unknown algorithm: " + algorithmSuite.cipherName());
159-
}
160145

161146
if (algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CBC_IV16_NO_KDF)
162147
|| algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CTR_IV16_TAG16_NO_KDF)

src/main/java/software/amazon/encryption/s3/internal/MultipartUploadMaterials.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ private MultipartUploadMaterials(Builder builder) {
4343
this._cryptoProvider = builder._cryptoProvider;
4444
this._plaintextLength = builder._plaintextLength;
4545
this._cipher = builder._cipher;
46-
System.out.println("initializing upload materials");
4746
}
4847

4948
static public Builder builder() {
@@ -74,7 +73,6 @@ public final void setHasFinalPartBeenSeen(boolean hasFinalPartBeenSeen) {
7473
*/
7574
@Override
7675
public Cipher getCipher(byte[] iv) {
77-
System.out.println("returning cipher");
7876
if (!Arrays.equals(iv, _cipher.getIV())) {
7977
throw new S3EncryptionClientException("IVs in MultipartUploadMaterials do not match!");
8078
}

src/main/java/software/amazon/encryption/s3/materials/AesKeyring.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ public byte[] decryptDataKey(DecryptionMaterials materials, byte[] encryptedData
138138

139139
GCMParameterSpec gcmParameterSpec = new GCMParameterSpec(TAG_LENGTH_BITS, iv);
140140
final Cipher cipher = CryptoFactory.createCipher(CIPHER_ALGORITHM, materials.cryptoProvider());
141-
System.out.println("aes keyring cipher - shouldn't happen..");
142141
cipher.init(Cipher.DECRYPT_MODE, _wrappingKey, gcmParameterSpec);
143142

144143
final byte[] aADBytes = AlgorithmSuite.ALG_AES_256_GCM_IV12_TAG16_NO_KDF.cipherName().getBytes(StandardCharsets.UTF_8);

src/main/java/software/amazon/encryption/s3/materials/RsaKeyring.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public byte[] encryptDataKey(SecureRandom secureRandom,
132132
@Override
133133
public byte[] decryptDataKey(DecryptionMaterials materials, byte[] encryptedDataKey) throws GeneralSecurityException {
134134
final Cipher cipher = CryptoFactory.createCipher(CIPHER_ALGORITHM, materials.cryptoProvider());
135-
System.out.println("rsa keyring cipher - shouldn't happen..");
136135
cipher.init(Cipher.UNWRAP_MODE, _partialRsaKeyPair.getPrivateKey(), OAEP_PARAMETER_SPEC);
137136

138137
String dataKeyAlgorithm = materials.algorithmSuite().dataKeyAlgorithm();

0 commit comments

Comments
 (0)