Skip to content

Commit

Permalink
spotless fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
  • Loading branch information
gbbafna committed Aug 31, 2023
1 parent 3bc06ab commit 9a0b9ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

package org.opensearch.encryption;

import com.amazonaws.encryptionsdk.CryptoAlgorithm;
import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager;
import com.amazonaws.encryptionsdk.caching.LocalCryptoMaterialsCache;
import org.opensearch.common.crypto.CryptoHandler;
import org.opensearch.common.crypto.MasterKeyProvider;
import org.opensearch.common.unit.TimeValue;
Expand All @@ -20,6 +17,10 @@
import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;

import com.amazonaws.encryptionsdk.CryptoAlgorithm;
import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager;
import com.amazonaws.encryptionsdk.caching.LocalCryptoMaterialsCache;

public class CryptoManagerFactory {

private final int dataKeyCacheSize;
Expand Down Expand Up @@ -49,7 +50,7 @@ private String validateAndGetAlgorithmId(String algorithm) {
}
}

public CryptoManager<? , ?> getOrCreateCryptoManager(
public CryptoManager<?, ?> getOrCreateCryptoManager(
MasterKeyProvider keyProvider,
String keyProviderName,
String keyProviderType,
Expand All @@ -60,12 +61,12 @@ private String validateAndGetAlgorithmId(String algorithm) {
keyProviderName,
validateAndGetAlgorithmId(algorithm)
);
CryptoHandler<? , ?> cryptoHandler = createCryptoProvider(algorithm, materialsManager, keyProvider);
CryptoHandler<?, ?> cryptoHandler = createCryptoProvider(algorithm, materialsManager, keyProvider);
return createCryptoManager(cryptoHandler, keyProviderType, keyProviderName, onClose);
}

// package private for tests
CryptoHandler<? , ?> createCryptoProvider(
CryptoHandler<?, ?> createCryptoProvider(
String algorithm,
CachingCryptoMaterialsManager materialsManager,
MasterKeyProvider masterKeyProvider
Expand All @@ -89,7 +90,12 @@ CachingCryptoMaterialsManager createMaterialsManager(MasterKeyProvider masterKey
}

// package private for tests
<T, U> CryptoManager<?, ?> createCryptoManager(CryptoHandler<T, U> cryptoHandler, String keyProviderType, String keyProviderName, Runnable onClose) {
<T, U> CryptoManager<?, ?> createCryptoManager(
CryptoHandler<T, U> cryptoHandler,
String keyProviderType,
String keyProviderName,
Runnable onClose
) {
return new CryptoManagerImpl<T, U>(keyProviderName, keyProviderType) {
@Override
protected void closeInternal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

package org.opensearch.encryption;

import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager;
import org.junit.Before;
import org.opensearch.common.crypto.CryptoHandler;
import org.opensearch.common.crypto.MasterKeyProvider;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.test.OpenSearchTestCase;
import org.junit.Before;

import java.util.Collections;

import com.amazonaws.encryptionsdk.caching.CachingCryptoMaterialsManager;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -37,7 +38,7 @@ public void testGetOrCreateCryptoManager() {
MasterKeyProvider mockKeyProvider = mock(MasterKeyProvider.class);
when(mockKeyProvider.getEncryptionContext()).thenReturn(Collections.emptyMap());

CryptoManager<? , ?> cryptoManager = cryptoManagerFactory.getOrCreateCryptoManager(
CryptoManager<?, ?> cryptoManager = cryptoManagerFactory.getOrCreateCryptoManager(
mockKeyProvider,
"keyProviderName",
"keyProviderType",
Expand All @@ -52,7 +53,7 @@ public void testCreateCryptoProvider() {
MasterKeyProvider mockKeyProvider = mock(MasterKeyProvider.class);
when(mockKeyProvider.getEncryptionContext()).thenReturn(Collections.emptyMap());

CryptoHandler<? , ?> cryptoHandler = cryptoManagerFactory.createCryptoProvider(
CryptoHandler<?, ?> cryptoHandler = cryptoManagerFactory.createCryptoProvider(
"ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384",
mockMaterialsManager,
mockKeyProvider
Expand All @@ -75,8 +76,8 @@ public void testCreateMaterialsManager() {
}

public void testCreateCryptoManager() {
CryptoHandler<? , ?> mockCryptoHandler = mock(CryptoHandler.class);
CryptoManager<? , ?> cryptoManager = cryptoManagerFactory.createCryptoManager(
CryptoHandler<?, ?> mockCryptoHandler = mock(CryptoHandler.class);
CryptoManager<?, ?> cryptoManager = cryptoManagerFactory.createCryptoManager(
mockCryptoHandler,
"keyProviderName",
"keyProviderType",
Expand Down

0 comments on commit 9a0b9ea

Please sign in to comment.