use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.
the class AzureVaultKeyGenerator method generate.
@Override
public AzureVaultKeyPair generate(String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) {
final KeyPair keys = this.nacl.generateNewKeys();
final StringBuilder publicId = new StringBuilder();
final StringBuilder privateId = new StringBuilder();
if (filename != null) {
final Path path = Paths.get(filename);
final String keyVaultId = path.getFileName().toString();
if (!keyVaultId.matches("^[0-9a-zA-Z\\-]*$")) {
throw new UnsupportedCharsetException("Generated key ID for Azure Key Vault can contain only 0-9, a-z, A-Z and - characters");
}
publicId.append(keyVaultId);
privateId.append(keyVaultId);
}
publicId.append("Pub");
privateId.append("Key");
saveKeyInVault(publicId.toString(), keys.getPublicKey());
saveKeyInVault(privateId.toString(), keys.getPrivateKey());
return new AzureVaultKeyPair(publicId.toString(), privateId.toString(), null, null);
}
use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.
the class ValidationTest method azureKeyPairIdsDisallowedCharactersCreateViolation.
@Test
public void azureKeyPairIdsDisallowedCharactersCreateViolation() {
String keyVaultId = "invalid_@!£$%^~^&_id";
AzureVaultKeyPair keyPair = new AzureVaultKeyPair(keyVaultId, keyVaultId, null, null);
Set<ConstraintViolation<AzureVaultKeyPair>> violations = validator.validate(keyPair);
assertThat(violations).hasSize(2);
assertThat(violations).extracting("messageTemplate").containsExactly("Azure Key Vault key IDs can only contain alphanumeric characters and dashes (-)", "Azure Key Vault key IDs can only contain alphanumeric characters and dashes (-)");
}
use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.
the class ValidationTest method azureKeyPairKeyVersionMustBe32CharsLong.
@Test
public void azureKeyPairKeyVersionMustBe32CharsLong() {
String is32Chars = "12345678901234567890123456789012";
AzureVaultKeyPair keyPair = new AzureVaultKeyPair("id", "id", is32Chars, is32Chars);
Set<ConstraintViolation<AzureVaultKeyPair>> violations = validator.validate(keyPair);
assertThat(violations).hasSize(0);
}
use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.
the class ValidationTest method azureKeyPairKeyVersionLongerThan32CharsCreatesViolation.
@Test
public void azureKeyPairKeyVersionLongerThan32CharsCreatesViolation() {
String is33Chars = "123456789012345678901234567890123";
AzureVaultKeyPair keyPair = new AzureVaultKeyPair("id", "id", is33Chars, is33Chars);
Set<ConstraintViolation<AzureVaultKeyPair>> violations = validator.validate(keyPair);
assertThat(violations).hasSize(2);
assertThat(violations).extracting("messageTemplate").containsExactly("length must be 32 characters", "length must be 32 characters");
}
use of com.quorum.tessera.config.keypairs.AzureVaultKeyPair in project tessera by ConsenSys.
the class ValidationTest method azureKeyPairIdsAllowedCharacterSetIsAlphanumericAndDash.
@Test
public void azureKeyPairIdsAllowedCharacterSetIsAlphanumericAndDash() {
String keyVaultId = "0123456789-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
AzureVaultKeyPair keyPair = new AzureVaultKeyPair(keyVaultId, keyVaultId, null, null);
Set<ConstraintViolation<AzureVaultKeyPair>> violations = validator.validate(keyPair);
assertThat(violations).hasSize(0);
}
Aggregations