From 75f9881c4b4e4c455161e3d8be597d79c159aa2d Mon Sep 17 00:00:00 2001 From: Gaurav Bafna Date: Tue, 29 Aug 2023 16:29:00 +0530 Subject: [PATCH] renaming provider to handler --- ...CryptoProvider.java => CryptoHandler.java} | 2 +- .../opensearch/encryption/CryptoManager.java | 4 +-- .../encryption/CryptoManagerFactory.java | 20 +++++------ ...oProvider.java => FrameCryptoHandler.java} | 6 ++-- .../encryption/CryptoManagerFactoryTests.java | 10 +++--- .../encryption/frame/CryptoTests.java | 16 ++++----- ...syncMultiStreamEncryptedBlobContainer.java | 34 +++++++++---------- .../blobstore/EncryptedBlobContainer.java | 26 +++++++------- .../blobstore/EncryptedBlobMetadata.java | 12 +++---- .../RepositoriesServiceTests.java | 12 +++---- 10 files changed, 71 insertions(+), 71 deletions(-) rename libs/common/src/main/java/org/opensearch/common/crypto/{CryptoProvider.java => CryptoHandler.java} (99%) rename libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/{FrameCryptoProvider.java => FrameCryptoHandler.java} (98%) diff --git a/libs/common/src/main/java/org/opensearch/common/crypto/CryptoProvider.java b/libs/common/src/main/java/org/opensearch/common/crypto/CryptoHandler.java similarity index 99% rename from libs/common/src/main/java/org/opensearch/common/crypto/CryptoProvider.java rename to libs/common/src/main/java/org/opensearch/common/crypto/CryptoHandler.java index 1924203031d2f..03491612c58f6 100644 --- a/libs/common/src/main/java/org/opensearch/common/crypto/CryptoProvider.java +++ b/libs/common/src/main/java/org/opensearch/common/crypto/CryptoHandler.java @@ -20,7 +20,7 @@ * T - Encryption Metadata * U - Parsed Encryption Metadata */ -public interface CryptoProvider { +public interface CryptoHandler { /** * To initialise or create a new crypto metadata to be used in encryption. This is needed to set the context before diff --git a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManager.java b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManager.java index 8c35a333d4723..8e1fc8570d552 100644 --- a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManager.java +++ b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManager.java @@ -8,7 +8,7 @@ package org.opensearch.encryption; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.util.concurrent.RefCounted; /** @@ -29,5 +29,5 @@ public interface CryptoManager extends RefCounted { /** * @return Crypto provider for encrypting or decrypting raw content. */ - CryptoProvider getCryptoProvider(); + CryptoHandler getCryptoProvider(); } diff --git a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManagerFactory.java b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManagerFactory.java index f19e315c17f14..bd54f22628d89 100644 --- a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManagerFactory.java +++ b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/CryptoManagerFactory.java @@ -11,11 +11,11 @@ import com.amazonaws.encryptionsdk.CryptoAlgorithm; import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager; import com.amazonaws.encryptionsdk.caching.LocalCryptoMaterialsCache; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.crypto.MasterKeyProvider; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.AbstractRefCounted; -import org.opensearch.encryption.frame.FrameCryptoProvider; +import org.opensearch.encryption.frame.FrameCryptoHandler; import org.opensearch.encryption.frame.core.AwsCrypto; import org.opensearch.encryption.keyprovider.CryptoMasterKey; @@ -61,24 +61,24 @@ private String validateAndGetAlgorithmId(String algorithm) { keyProviderName, validateAndGetAlgorithmId(algorithm) ); - CryptoProvider cryptoProvider = createCryptoProvider(algorithm, materialsManager, keyProvider); - return createCryptoManager(cryptoProvider, keyProviderType, keyProviderName, onClose); + CryptoHandler cryptoHandler = createCryptoProvider(algorithm, materialsManager, keyProvider); + return createCryptoManager(cryptoHandler, keyProviderType, keyProviderName, onClose); } // package private for tests - CryptoProvider createCryptoProvider( + CryptoHandler createCryptoProvider( String algorithm, CachingCryptoMaterialsManager materialsManager, MasterKeyProvider masterKeyProvider ) { switch (algorithm) { case "ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY": - return new FrameCryptoProvider( + return new FrameCryptoHandler( new AwsCrypto(materialsManager, CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY), masterKeyProvider.getEncryptionContext() ); case "ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384": - return new FrameCryptoProvider( + return new FrameCryptoHandler( new AwsCrypto(materialsManager, CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384), masterKeyProvider.getEncryptionContext() ); @@ -103,7 +103,7 @@ CachingCryptoMaterialsManager createMaterialsManager(MasterKeyProvider masterKey } // package private for tests - CryptoManager createCryptoManager(CryptoProvider cryptoProvider, String keyProviderType, String keyProviderName, Runnable onClose) { + CryptoManager createCryptoManager(CryptoHandler cryptoHandler, String keyProviderType, String keyProviderName, Runnable onClose) { return new CryptoManagerImpl(keyProviderName, keyProviderType) { @Override protected void closeInternal() { @@ -121,8 +121,8 @@ public String name() { } @Override - public CryptoProvider getCryptoProvider() { - return cryptoProvider; + public CryptoHandler getCryptoProvider() { + return cryptoHandler; } }; } diff --git a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoProvider.java b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoHandler.java similarity index 98% rename from libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoProvider.java rename to libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoHandler.java index e01c6621cdbff..136ea3f04eb9b 100644 --- a/libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoProvider.java +++ b/libs/encryption-sdk/src/main/java/org/opensearch/encryption/frame/FrameCryptoHandler.java @@ -9,7 +9,7 @@ package org.opensearch.encryption.frame; import com.amazonaws.encryptionsdk.ParsedCiphertext; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.crypto.DecryptedRangedStreamProvider; import org.opensearch.common.crypto.EncryptedHeaderContentSupplier; import org.opensearch.encryption.frame.core.AwsCrypto; @@ -20,14 +20,14 @@ import java.io.InputStream; import java.util.Map; -public class FrameCryptoProvider implements CryptoProvider { +public class FrameCryptoHandler implements CryptoHandler { private final AwsCrypto awsCrypto; private final Map encryptionContext; // package private for tests private final int FRAME_SIZE = 8 * 1024; - public FrameCryptoProvider(AwsCrypto awsCrypto, Map encryptionContext) { + public FrameCryptoHandler(AwsCrypto awsCrypto, Map encryptionContext) { this.awsCrypto = awsCrypto; this.encryptionContext = encryptionContext; } diff --git a/libs/encryption-sdk/src/test/java/org/opensearch/encryption/CryptoManagerFactoryTests.java b/libs/encryption-sdk/src/test/java/org/opensearch/encryption/CryptoManagerFactoryTests.java index 9f4fe1ebb2ef9..a2b29619a71b0 100644 --- a/libs/encryption-sdk/src/test/java/org/opensearch/encryption/CryptoManagerFactoryTests.java +++ b/libs/encryption-sdk/src/test/java/org/opensearch/encryption/CryptoManagerFactoryTests.java @@ -10,7 +10,7 @@ import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager; import org.junit.Before; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.crypto.MasterKeyProvider; import org.opensearch.common.unit.TimeValue; import org.opensearch.test.OpenSearchTestCase; @@ -48,13 +48,13 @@ public void testCreateCryptoProvider() { MasterKeyProvider mockKeyProvider = mock(MasterKeyProvider.class); when(mockKeyProvider.getEncryptionContext()).thenReturn(Collections.emptyMap()); - CryptoProvider cryptoProvider = cryptoManagerFactory.createCryptoProvider( + CryptoHandler cryptoHandler = cryptoManagerFactory.createCryptoProvider( "ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY", mockMaterialsManager, mockKeyProvider ); - assertNotNull(cryptoProvider); + assertNotNull(cryptoHandler); } public void testCreateMaterialsManager() { @@ -71,9 +71,9 @@ public void testCreateMaterialsManager() { } public void testCreateCryptoManager() { - CryptoProvider mockCryptoProvider = mock(CryptoProvider.class); + CryptoHandler mockCryptoHandler = mock(CryptoHandler.class); CryptoManager cryptoManager = cryptoManagerFactory.createCryptoManager( - mockCryptoProvider, + mockCryptoHandler, "keyProviderName", "keyProviderType", null diff --git a/libs/encryption-sdk/src/test/java/org/opensearch/encryption/frame/CryptoTests.java b/libs/encryption-sdk/src/test/java/org/opensearch/encryption/frame/CryptoTests.java index 78199047ab9c7..146cf187bf2a1 100644 --- a/libs/encryption-sdk/src/test/java/org/opensearch/encryption/frame/CryptoTests.java +++ b/libs/encryption-sdk/src/test/java/org/opensearch/encryption/frame/CryptoTests.java @@ -45,14 +45,14 @@ public class CryptoTests extends OpenSearchTestCase { - private static FrameCryptoProvider frameCryptoProvider; + private static FrameCryptoHandler frameCryptoProvider; - private static FrameCryptoProvider frameCryptoProviderTrailingAlgo; + private static FrameCryptoHandler frameCryptoProviderTrailingAlgo; - static class CustomFrameCryptoProviderTest extends FrameCryptoProvider { + static class CustomFrameCryptoHandlerTest extends FrameCryptoHandler { private final int frameSize; - CustomFrameCryptoProviderTest(AwsCrypto awsCrypto, HashMap config, int frameSize) { + CustomFrameCryptoHandlerTest(AwsCrypto awsCrypto, HashMap config, int frameSize) { super(awsCrypto, config); this.frameSize = frameSize; } @@ -65,12 +65,12 @@ public int getFrameSize() { @Before public void setupResources() { - frameCryptoProvider = new CustomFrameCryptoProviderTest( + frameCryptoProvider = new CustomFrameCryptoHandlerTest( createAwsCrypto(CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY), new HashMap<>(), 100 ); - frameCryptoProviderTrailingAlgo = new CustomFrameCryptoProviderTest( + frameCryptoProviderTrailingAlgo = new CustomFrameCryptoHandlerTest( createAwsCrypto(CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384), new HashMap<>(), 100 @@ -99,7 +99,7 @@ private EncryptedStore verifyAndGetEncryptedContent() throws IOException, URISyn return verifyAndGetEncryptedContent(false, frameCryptoProvider); } - private EncryptedStore verifyAndGetEncryptedContent(boolean truncateRemainderPart, FrameCryptoProvider frameCryptoProvider) + private EncryptedStore verifyAndGetEncryptedContent(boolean truncateRemainderPart, FrameCryptoHandler frameCryptoProvider) throws IOException, URISyntaxException { String path = CryptoTests.class.getResource("/raw_content_for_crypto_test").toURI().getPath(); File file = new File(path); @@ -141,7 +141,7 @@ public void testEncryptedDecryptedLengthEstimations() { for (int i = 0; i < 100; i++) { // Raw content size cannot be max value as encrypted size will overflow for the same. long n = randomLongBetween(0, Long.MAX_VALUE / 2); - FrameCryptoProvider frameCryptoProvider = new CustomFrameCryptoProviderTest( + FrameCryptoHandler frameCryptoProvider = new CustomFrameCryptoHandlerTest( createAwsCrypto(CryptoAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY), new HashMap<>(), randomIntBetween(10, 10240) diff --git a/server/src/main/java/org/opensearch/common/blobstore/AsyncMultiStreamEncryptedBlobContainer.java b/server/src/main/java/org/opensearch/common/blobstore/AsyncMultiStreamEncryptedBlobContainer.java index 53f6ef6defccb..6754b7bfb01cd 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/AsyncMultiStreamEncryptedBlobContainer.java +++ b/server/src/main/java/org/opensearch/common/blobstore/AsyncMultiStreamEncryptedBlobContainer.java @@ -10,7 +10,7 @@ import org.opensearch.common.StreamContext; import org.opensearch.common.blobstore.stream.write.WriteContext; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.io.InputStreamContainer; import org.opensearch.core.action.ActionListener; @@ -25,17 +25,17 @@ public class AsyncMultiStreamEncryptedBlobContainer extends EncryptedBlobContainer implements AsyncMultiStreamBlobContainer { private final AsyncMultiStreamBlobContainer blobContainer; - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; - public AsyncMultiStreamEncryptedBlobContainer(AsyncMultiStreamBlobContainer blobContainer, CryptoProvider cryptoProvider) { - super(blobContainer, cryptoProvider); + public AsyncMultiStreamEncryptedBlobContainer(AsyncMultiStreamBlobContainer blobContainer, CryptoHandler cryptoHandler) { + super(blobContainer, cryptoHandler); this.blobContainer = blobContainer; - this.cryptoProvider = cryptoProvider; + this.cryptoHandler = cryptoHandler; } @Override public void asyncBlobUpload(WriteContext writeContext, ActionListener completionListener) throws IOException { - EncryptedWriteContext encryptedWriteContext = new EncryptedWriteContext(writeContext, cryptoProvider); + EncryptedWriteContext encryptedWriteContext = new EncryptedWriteContext(writeContext, cryptoHandler); blobContainer.asyncBlobUpload(encryptedWriteContext, completionListener); } @@ -47,23 +47,23 @@ public boolean remoteIntegrityCheckSupported() { static class EncryptedWriteContext extends WriteContext { private final Object encryptionMetadata; - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; private final long fileSize; /** * Construct a new encrypted WriteContext object */ - public EncryptedWriteContext(WriteContext writeContext, CryptoProvider cryptoProvider) { + public EncryptedWriteContext(WriteContext writeContext, CryptoHandler cryptoHandler) { super(writeContext); - this.cryptoProvider = cryptoProvider; - this.encryptionMetadata = this.cryptoProvider.initEncryptionMetadata(); - this.fileSize = this.cryptoProvider.estimateEncryptedLengthOfEntireContent(encryptionMetadata, writeContext.getFileSize()); + this.cryptoHandler = cryptoHandler; + this.encryptionMetadata = this.cryptoHandler.initEncryptionMetadata(); + this.fileSize = this.cryptoHandler.estimateEncryptedLengthOfEntireContent(encryptionMetadata, writeContext.getFileSize()); } public StreamContext getStreamProvider(long partSize) { - long adjustedPartSize = cryptoProvider.adjustContentSizeForPartialEncryption(encryptionMetadata, partSize); + long adjustedPartSize = cryptoHandler.adjustContentSizeForPartialEncryption(encryptionMetadata, partSize); StreamContext streamContext = super.getStreamProvider(adjustedPartSize); - return new EncryptedStreamContext(streamContext, cryptoProvider, encryptionMetadata); + return new EncryptedStreamContext(streamContext, cryptoHandler, encryptionMetadata); } /** @@ -76,22 +76,22 @@ public long getFileSize() { static class EncryptedStreamContext extends StreamContext { - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; private final Object encryptionMetadata; /** * Construct a new encrypted StreamContext object */ - public EncryptedStreamContext(StreamContext streamContext, CryptoProvider cryptoProvider, Object encryptionMetadata) { + public EncryptedStreamContext(StreamContext streamContext, CryptoHandler cryptoHandler, Object encryptionMetadata) { super(streamContext); - this.cryptoProvider = cryptoProvider; + this.cryptoHandler = cryptoHandler; this.encryptionMetadata = encryptionMetadata; } @Override public InputStreamContainer provideStream(int partNumber) throws IOException { InputStreamContainer inputStreamContainer = super.provideStream(partNumber); - return cryptoProvider.createEncryptingStreamOfPart(encryptionMetadata, inputStreamContainer, getNumberOfParts(), partNumber); + return cryptoHandler.createEncryptingStreamOfPart(encryptionMetadata, inputStreamContainer, getNumberOfParts(), partNumber); } } diff --git a/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobContainer.java b/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobContainer.java index 3c2c717e6b1ea..451f33bc14c51 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobContainer.java +++ b/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobContainer.java @@ -9,7 +9,7 @@ package org.opensearch.common.blobstore; import org.opensearch.common.CheckedBiConsumer; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.crypto.DecryptedRangedStreamProvider; import org.opensearch.common.crypto.EncryptedHeaderContentSupplier; import org.opensearch.common.io.InputStreamContainer; @@ -27,11 +27,11 @@ public class EncryptedBlobContainer implements BlobContainer { private final BlobContainer blobContainer; - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; - public EncryptedBlobContainer(BlobContainer blobContainer, CryptoProvider cryptoProvider) { + public EncryptedBlobContainer(BlobContainer blobContainer, CryptoHandler cryptoHandler) { this.blobContainer = blobContainer; - this.cryptoProvider = cryptoProvider; + this.cryptoHandler = cryptoHandler; } @Override @@ -47,7 +47,7 @@ public boolean blobExists(String blobName) throws IOException { @Override public InputStream readBlob(String blobName) throws IOException { InputStream inputStream = blobContainer.readBlob(blobName); - return cryptoProvider.createDecryptingStream(inputStream); + return cryptoHandler.createDecryptingStream(inputStream); } private EncryptedHeaderContentSupplier getEncryptedHeaderContentSupplier(String blobName) { @@ -64,8 +64,8 @@ private EncryptedHeaderContentSupplier getEncryptedHeaderContentSupplier(String @Override public InputStream readBlob(String blobName, long position, long length) throws IOException { - Object encryptionMetadata = cryptoProvider.loadEncryptionMetadata(getEncryptedHeaderContentSupplier(blobName)); - DecryptedRangedStreamProvider decryptedStreamProvider = cryptoProvider.createDecryptingStreamOfRange( + Object encryptionMetadata = cryptoHandler.loadEncryptionMetadata(getEncryptedHeaderContentSupplier(blobName)); + DecryptedRangedStreamProvider decryptedStreamProvider = cryptoHandler.createDecryptingStreamOfRange( encryptionMetadata, position, position + length - 1 @@ -83,10 +83,10 @@ public long readBlobPreferredLength() { private void executeWrite(InputStream inputStream, long blobSize, CheckedBiConsumer writeConsumer) throws IOException { - Object cryptoContext = cryptoProvider.initEncryptionMetadata(); + Object cryptoContext = cryptoHandler.initEncryptionMetadata(); InputStreamContainer streamContainer = new InputStreamContainer(inputStream, blobSize, 0); - InputStreamContainer encryptedStream = cryptoProvider.createEncryptingStream(cryptoContext, streamContainer); - long cryptoLength = cryptoProvider.estimateEncryptedLengthOfEntireContent(cryptoContext, blobSize); + InputStreamContainer encryptedStream = cryptoHandler.createEncryptingStream(cryptoContext, streamContainer); + long cryptoLength = cryptoHandler.estimateEncryptedLengthOfEntireContent(cryptoContext, blobSize); writeConsumer.accept(encryptedStream.getInputStream(), cryptoLength); } @@ -135,7 +135,7 @@ public Map children() throws IOException { if (children != null) { return children.entrySet() .stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> new EncryptedBlobContainer(entry.getValue(), cryptoProvider))); + .collect(Collectors.toMap(Map.Entry::getKey, entry -> new EncryptedBlobContainer(entry.getValue(), cryptoHandler))); } else { return null; } @@ -157,7 +157,7 @@ private Map convertToEncryptedMetadataMap(Map new EncryptedBlobMetadata(entry.getValue(), cryptoProvider, getEncryptedHeaderContentSupplier(entry.getKey())) + entry -> new EncryptedBlobMetadata(entry.getValue(), cryptoHandler, getEncryptedHeaderContentSupplier(entry.getKey())) ) ); @@ -178,7 +178,7 @@ public void listBlobsByPrefixInSortedOrder( .map( blobMetadata -> new EncryptedBlobMetadata( blobMetadata, - cryptoProvider, + cryptoHandler, getEncryptedHeaderContentSupplier(blobMetadata.name()) ) ) diff --git a/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobMetadata.java b/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobMetadata.java index 315a96f1591bb..9002691937941 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobMetadata.java +++ b/server/src/main/java/org/opensearch/common/blobstore/EncryptedBlobMetadata.java @@ -8,7 +8,7 @@ package org.opensearch.common.blobstore; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.common.crypto.EncryptedHeaderContentSupplier; import java.io.IOException; @@ -19,16 +19,16 @@ public class EncryptedBlobMetadata implements BlobMetadata { private final EncryptedHeaderContentSupplier encryptedHeaderContentSupplier; private final BlobMetadata delegate; - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; public EncryptedBlobMetadata( BlobMetadata delegate, - CryptoProvider cryptoProvider, + CryptoHandler cryptoHandler, EncryptedHeaderContentSupplier encryptedHeaderContentSupplier ) { this.encryptedHeaderContentSupplier = encryptedHeaderContentSupplier; this.delegate = delegate; - this.cryptoProvider = cryptoProvider; + this.cryptoHandler = cryptoHandler; } @Override @@ -40,10 +40,10 @@ public String name() { public long length() { Object cryptoContext; try { - cryptoContext = cryptoProvider.loadEncryptionMetadata(encryptedHeaderContentSupplier); + cryptoContext = cryptoHandler.loadEncryptionMetadata(encryptedHeaderContentSupplier); } catch (IOException ex) { throw new RuntimeException(ex); } - return cryptoProvider.estimateDecryptedLength(cryptoContext, delegate.length()); + return cryptoHandler.estimateDecryptedLength(cryptoContext, delegate.length()); } } diff --git a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java index 866ed1b0f7c3b..099f8fe8b0ade 100644 --- a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java +++ b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java @@ -34,7 +34,7 @@ import org.apache.lucene.index.IndexCommit; import org.opensearch.Version; -import org.opensearch.common.crypto.CryptoProvider; +import org.opensearch.common.crypto.CryptoHandler; import org.opensearch.core.action.ActionListener; import org.opensearch.action.admin.cluster.crypto.CryptoSettings; import org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequest; @@ -529,7 +529,7 @@ private void assertThrowsOnRegister(String repoName) { expectThrows(RepositoryException.class, () -> repositoriesService.registerRepository(request, null)); } - private static class TestCryptoProvider implements CryptoProvider { + private static class TestCryptoHandler implements CryptoHandler { @Override public Object initEncryptionMetadata() { @@ -590,12 +590,12 @@ private static abstract class TestCryptoManager implements CryptoManager { private final String name; private final AtomicInteger ref; - private final CryptoProvider cryptoProvider; + private final CryptoHandler cryptoHandler; public TestCryptoManager(Settings settings, String keyProviderName) { this.name = keyProviderName; this.ref = new AtomicInteger(1); - this.cryptoProvider = new TestCryptoProvider(); + this.cryptoHandler = new TestCryptoHandler(); } @Override @@ -624,8 +624,8 @@ public String name() { return name; } - public CryptoProvider getCryptoProvider() { - return cryptoProvider; + public CryptoHandler getCryptoProvider() { + return cryptoHandler; } }