@Test(expected = NullPointerException.class) public void nullFilenameThrowsException() { KeyVaultOptions keyVaultOptions = mock(KeyVaultOptions.class); when(keyVaultOptions.getSecretEngineName()).thenReturn("secretEngine"); hashicorpVaultKeyGenerator.generate(null, null, keyVaultOptions); }
@Override public HashicorpVaultKeyPair generate( String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) { Objects.requireNonNull(filename); Objects.requireNonNull( keyVaultOptions, "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); Objects.requireNonNull( keyVaultOptions.getSecretEngineName(), "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); final KeyPair keys = this.nacl.generateNewKeys(); String pubId = "publicKey"; String privId = "privateKey"; Map<String, Object> keyPairData = new HashMap<>(); keyPairData.put(pubId, keys.getPublicKey().encodeToBase64()); keyPairData.put(privId, keys.getPrivateKey().encodeToBase64()); keyVaultService.setSecret( new HashicorpSetSecretData(keyVaultOptions.getSecretEngineName(), filename, keyPairData)); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(pubId), keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(privId), keyVaultOptions.getSecretEngineName(), filename, privId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, privId); return new HashicorpVaultKeyPair(pubId, privId, keyVaultOptions.getSecretEngineName(), filename, null); }
HashicorpVaultKeyGenerator implements KeyGenerator { @Override public HashicorpVaultKeyPair generate( String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) { Objects.requireNonNull(filename); Objects.requireNonNull( keyVaultOptions, "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); Objects.requireNonNull( keyVaultOptions.getSecretEngineName(), "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); final KeyPair keys = this.nacl.generateNewKeys(); String pubId = "publicKey"; String privId = "privateKey"; Map<String, Object> keyPairData = new HashMap<>(); keyPairData.put(pubId, keys.getPublicKey().encodeToBase64()); keyPairData.put(privId, keys.getPrivateKey().encodeToBase64()); keyVaultService.setSecret( new HashicorpSetSecretData(keyVaultOptions.getSecretEngineName(), filename, keyPairData)); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(pubId), keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(privId), keyVaultOptions.getSecretEngineName(), filename, privId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, privId); return new HashicorpVaultKeyPair(pubId, privId, keyVaultOptions.getSecretEngineName(), filename, null); } }
HashicorpVaultKeyGenerator implements KeyGenerator { @Override public HashicorpVaultKeyPair generate( String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) { Objects.requireNonNull(filename); Objects.requireNonNull( keyVaultOptions, "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); Objects.requireNonNull( keyVaultOptions.getSecretEngineName(), "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); final KeyPair keys = this.nacl.generateNewKeys(); String pubId = "publicKey"; String privId = "privateKey"; Map<String, Object> keyPairData = new HashMap<>(); keyPairData.put(pubId, keys.getPublicKey().encodeToBase64()); keyPairData.put(privId, keys.getPrivateKey().encodeToBase64()); keyVaultService.setSecret( new HashicorpSetSecretData(keyVaultOptions.getSecretEngineName(), filename, keyPairData)); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(pubId), keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(privId), keyVaultOptions.getSecretEngineName(), filename, privId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, privId); return new HashicorpVaultKeyPair(pubId, privId, keyVaultOptions.getSecretEngineName(), filename, null); } HashicorpVaultKeyGenerator(
            final Encryptor nacl, KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> keyVaultService); }
HashicorpVaultKeyGenerator implements KeyGenerator { @Override public HashicorpVaultKeyPair generate( String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) { Objects.requireNonNull(filename); Objects.requireNonNull( keyVaultOptions, "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); Objects.requireNonNull( keyVaultOptions.getSecretEngineName(), "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); final KeyPair keys = this.nacl.generateNewKeys(); String pubId = "publicKey"; String privId = "privateKey"; Map<String, Object> keyPairData = new HashMap<>(); keyPairData.put(pubId, keys.getPublicKey().encodeToBase64()); keyPairData.put(privId, keys.getPrivateKey().encodeToBase64()); keyVaultService.setSecret( new HashicorpSetSecretData(keyVaultOptions.getSecretEngineName(), filename, keyPairData)); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(pubId), keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(privId), keyVaultOptions.getSecretEngineName(), filename, privId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, privId); return new HashicorpVaultKeyPair(pubId, privId, keyVaultOptions.getSecretEngineName(), filename, null); } HashicorpVaultKeyGenerator(
            final Encryptor nacl, KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> keyVaultService); @Override HashicorpVaultKeyPair generate(
            String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions); }
HashicorpVaultKeyGenerator implements KeyGenerator { @Override public HashicorpVaultKeyPair generate( String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions) { Objects.requireNonNull(filename); Objects.requireNonNull( keyVaultOptions, "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); Objects.requireNonNull( keyVaultOptions.getSecretEngineName(), "-keygenvaultsecretengine must be provided if using the Hashicorp vault type"); final KeyPair keys = this.nacl.generateNewKeys(); String pubId = "publicKey"; String privId = "privateKey"; Map<String, Object> keyPairData = new HashMap<>(); keyPairData.put(pubId, keys.getPublicKey().encodeToBase64()); keyPairData.put(privId, keys.getPrivateKey().encodeToBase64()); keyVaultService.setSecret( new HashicorpSetSecretData(keyVaultOptions.getSecretEngineName(), filename, keyPairData)); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(pubId), keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, pubId); LOGGER.debug( "Key {} saved to vault secret engine {} with name {} and id {}", keyPairData.get(privId), keyVaultOptions.getSecretEngineName(), filename, privId); LOGGER.info( "Key saved to vault secret engine {} with name {} and id {}", keyVaultOptions.getSecretEngineName(), filename, privId); return new HashicorpVaultKeyPair(pubId, privId, keyVaultOptions.getSecretEngineName(), filename, null); } HashicorpVaultKeyGenerator(
            final Encryptor nacl, KeyVaultService<HashicorpSetSecretData, HashicorpGetSecretData> keyVaultService); @Override HashicorpVaultKeyPair generate(
            String filename, ArgonOptions encryptionOptions, KeyVaultOptions keyVaultOptions);  }