use of com.quorum.tessera.encryption.Encryptor in project tessera by ConsenSys.
the class AzureVaultKeyGeneratorTest method setUp.
@Before
public void setUp() {
this.encryptor = mock(Encryptor.class);
this.keyVaultService = mock(KeyVaultService.class);
final KeyPair keyPair = new KeyPair(pub, priv);
when(encryptor.generateNewKeys()).thenReturn(keyPair);
azureVaultKeyGenerator = new AzureVaultKeyGenerator(encryptor, keyVaultService);
}
use of com.quorum.tessera.encryption.Encryptor in project tessera by ConsenSys.
the class HashicorpVaultKeyGeneratorTest method setUp.
@Before
public void setUp() {
this.encryptor = mock(Encryptor.class);
this.keyVaultService = mock(KeyVaultService.class);
final KeyPair keyPair = new KeyPair(pub, priv);
when(encryptor.generateNewKeys()).thenReturn(keyPair);
this.hashicorpVaultKeyGenerator = new HashicorpVaultKeyGenerator(encryptor, keyVaultService);
}
use of com.quorum.tessera.encryption.Encryptor in project tessera by ConsenSys.
the class EllipticalCurveEncryptorFactoryTest method createInstance.
@Test
public void createInstance() {
final Encryptor result = encryptorFactory.create();
assertThat(encryptorFactory.getType()).isEqualTo("EC");
assertThat(result).isNotNull().isExactlyInstanceOf(EllipticalCurveEncryptor.class);
}
use of com.quorum.tessera.encryption.Encryptor in project tessera by ConsenSys.
the class DefaultKeyGeneratorFactory method create.
@Override
public KeyGenerator create(KeyVaultConfig keyVaultConfig, EncryptorConfig encryptorConfig) {
Objects.requireNonNull(encryptorConfig, "No encryptor config defined. ");
final EncryptorFactory encryptorFactory = EncryptorFactory.newFactory(encryptorConfig.getType().name());
final Encryptor encryptor = encryptorFactory.create(encryptorConfig.getProperties());
if (keyVaultConfig != null) {
final KeyVaultServiceFactory keyVaultServiceFactory = KeyVaultServiceFactory.getInstance(keyVaultConfig.getKeyVaultType());
final Config config = new Config();
final KeyConfiguration keyConfiguration = new KeyConfiguration();
if (keyVaultConfig.getKeyVaultType().equals(KeyVaultType.AZURE)) {
keyConfiguration.addKeyVaultConfig(keyVaultConfig);
config.setKeys(keyConfiguration);
final KeyVaultService keyVaultService = keyVaultServiceFactory.create(config, new EnvironmentVariableProvider());
return new AzureVaultKeyGenerator(encryptor, keyVaultService);
} else if (keyVaultConfig.getKeyVaultType().equals(KeyVaultType.AWS)) {
if (!(keyVaultConfig instanceof DefaultKeyVaultConfig)) {
throw new IllegalArgumentException("AWS key vault config not instance of DefaultKeyVaultConfig");
}
keyConfiguration.addKeyVaultConfig(keyVaultConfig);
config.setKeys(keyConfiguration);
final KeyVaultService keyVaultService = keyVaultServiceFactory.create(config, new EnvironmentVariableProvider());
return new AWSSecretManagerKeyGenerator(encryptor, keyVaultService);
} else {
keyConfiguration.addKeyVaultConfig(keyVaultConfig);
config.setKeys(keyConfiguration);
final KeyVaultService keyVaultService = keyVaultServiceFactory.create(config, new EnvironmentVariableProvider());
return new HashicorpVaultKeyGenerator(encryptor, keyVaultService);
}
}
KeyEncryptor keyEncyptor = KeyEncryptorFactory.newFactory().create(encryptorConfig);
return new FileKeyGenerator(encryptor, keyEncyptor, PasswordReaderFactory.create());
}
use of com.quorum.tessera.encryption.Encryptor in project tessera by ConsenSys.
the class JnaclFactoryTest method createInstance.
@Test
public void createInstance() {
final Encryptor result = jnaclFactory.create();
assertThat(jnaclFactory.getType()).isEqualTo("NACL");
assertThat(result).isNotNull().isExactlyInstanceOf(Jnacl.class);
}
Aggregations