Skip to content

Commit 575627e

Browse files
author
Anirav Kareddy
committed
added _reEncryptInstructionFile boolean field to builder in AES + RSA keyrings
1 parent 1e2553a commit 575627e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public MaterialsDescription getMaterialsDescription() {
183183

184184
public static class Builder extends S3Keyring.Builder<AesKeyring, Builder> {
185185
private SecretKey _wrappingKey;
186+
private boolean _reEncryptInstructionFile = false;
186187

187188
private Builder() {
188189
super();
@@ -203,8 +204,16 @@ public Builder wrappingKey(final SecretKey wrappingKey) {
203204
_wrappingKey = wrappingKey;
204205
return builder();
205206
}
207+
public Builder reEncryptInstructionFile(boolean reEncryptInstructionFile) {
208+
_reEncryptInstructionFile = reEncryptInstructionFile;
209+
return builder();
210+
211+
}
206212

207213
public AesKeyring build() {
214+
if (_reEncryptInstructionFile && _materialsDescription == null) {
215+
throw new S3EncryptionClientException("Materials description must be provided for re-encrypt instruction file!");
216+
}
208217
return new AesKeyring(this);
209218
}
210219
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public MaterialsDescription getMaterialsDescription() {
203203

204204
public static class Builder extends S3Keyring.Builder<S3Keyring, Builder> {
205205
private PartialRsaKeyPair _partialRsaKeyPair;
206+
private boolean _reEncryptInstructionFile = false;
206207

207208
private Builder() {
208209
super();
@@ -217,10 +218,18 @@ public Builder wrappingKeyPair(final PartialRsaKeyPair partialRsaKeyPair) {
217218
_partialRsaKeyPair = partialRsaKeyPair;
218219
return builder();
219220
}
221+
public Builder reEncryptInstructionFile(final boolean reEncryptInstructionFile) {
222+
_reEncryptInstructionFile = reEncryptInstructionFile;
223+
return builder();
224+
}
220225

221226
public RsaKeyring build() {
227+
if (_reEncryptInstructionFile && _materialsDescription == null) {
228+
throw new S3EncryptionClientException("Materials description must be provided for re-encrypt instruction file!");
229+
}
222230
return new RsaKeyring(this);
223231
}
224-
}
232+
233+
}
225234

226235
}

0 commit comments

Comments
 (0)