Skip to content

Commit

Permalink
Rename getter/setter to match config name
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Oct 29, 2024
1 parent 62f274b commit b69d220
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class SpoolingConfig
{
private Optional<SecretKey> sharedEncryptionKey = Optional.empty();
private Optional<SecretKey> sharedSecretKey = Optional.empty();
private SegmentRetrievalMode retrievalMode = SegmentRetrievalMode.STORAGE;
private Optional<Duration> storageRedirectTtl = Optional.empty();

Expand All @@ -43,17 +43,17 @@ public class SpoolingConfig
private DataSize initialSegmentSize = DataSize.of(8, MEGABYTE);
private DataSize maximumSegmentSize = DataSize.of(16, MEGABYTE);

public Optional<SecretKey> getSharedEncryptionKey()
public Optional<SecretKey> getSharedSecretKey()
{
return sharedEncryptionKey;
return sharedSecretKey;
}

@ConfigDescription("256 bit, base64-encoded secret key used to secure segment identifiers")
@Config("protocol.spooling.shared-secret-key")
@ConfigSecuritySensitive
public SpoolingConfig setSharedEncryptionKey(String sharedEncryptionKey)
public SpoolingConfig setSharedSecretKey(String sharedEncryptionKey)
{
this.sharedEncryptionKey = Optional.ofNullable(sharedEncryptionKey)
this.sharedSecretKey = Optional.ofNullable(sharedEncryptionKey)
.map(value -> new SecretKeySpec(getDecoder().decode(value), "AES"));
return this;
}
Expand Down Expand Up @@ -152,15 +152,15 @@ public SpoolingConfig setMaximumInlinedSize(DataSize maximumInlinedSize)
@AssertTrue(message = "protocol.spooling.shared-secret-key must be 256 bits long")
public boolean isSharedEncryptionKeyAes256()
{
return sharedEncryptionKey
return sharedSecretKey
.map(Ciphers::is256BitSecretKeySpec)
.orElse(true);
}

@AssertTrue(message = "protocol.spooling.shared-secret-key must be set")
public boolean isSharedEncryptionKeySet()
{
return sharedEncryptionKey.isPresent();
return sharedSecretKey.isPresent();
}

@AssertTrue(message = "protocol.spooling.coordinator-storage-redirect-ttl can be set when protocol.spooling.retrieval-mode is COORDINATOR_STORAGE_REDIRECT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public SpoolingManagerBridge(SpoolingConfig spoolingConfig, SpoolingManagerRegis
this.registry = requireNonNull(registry, "registry is null");
requireNonNull(spoolingConfig, "spoolingConfig is null");
this.retrievalMode = spoolingConfig.getRetrievalMode();
this.secretKey = spoolingConfig.getSharedEncryptionKey()
this.secretKey = spoolingConfig.getSharedSecretKey()
.orElseThrow(() -> new IllegalArgumentException("protocol.spooling.shared-secret-key is not set"));
this.maxDirectPassThroughTtl = fromDuration(spoolingConfig.getStorageRedirectTtl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestSpoolingConfig
public void testDefaults()
{
assertRecordedDefaults(recordDefaults(SpoolingConfig.class)
.setSharedEncryptionKey(null)
.setSharedSecretKey(null)
.setRetrievalMode(STORAGE)
.setStorageRedirectTtl(Optional.empty())
.setInitialSegmentSize(DataSize.of(8, MEGABYTE))
Expand Down Expand Up @@ -66,7 +66,7 @@ public void testExplicitPropertyMappings()
SpoolingConfig expected = new SpoolingConfig()
.setRetrievalMode(COORDINATOR_STORAGE_REDIRECT)
.setStorageRedirectTtl(Optional.of(Duration.valueOf("60s")))
.setSharedEncryptionKey(randomAesEncryptionKey)
.setSharedSecretKey(randomAesEncryptionKey)
.setInitialSegmentSize(DataSize.of(1, KILOBYTE))
.setMaximumSegmentSize(DataSize.of(8, KILOBYTE))
.setMaximumInlinedRows(1024)
Expand Down

0 comments on commit b69d220

Please sign in to comment.