public static Optional<JksOptions> buildJksKeyStoreOptions(
      final Map<String, String> props,
      final Optional<String> alias
  ) {
    final String location = getKeyStoreLocation(props);
    final String keyStorePassword = getKeyStorePassword(props);
    final String keyPassword = getKeyPassword(props);

    if (!Strings.isNullOrEmpty(location)) {
      final JksOptions jksOptions;

      if (alias.isPresent() && !alias.get().isEmpty()) {
        jksOptions = buildJksOptions(
            loadJksKeyStore(location, keyStorePassword, keyPassword, alias.get()),
            keyStorePassword
        );
      } else {
        jksOptions = buildJksOptions(location, keyStorePassword);
      }

      return Optional.of(jksOptions);
    }

    return Optional.empty();
  }
@Test
  public void shouldBuildKeyStoreJksOptionsWithKeyPasswordWhenAliasIsPassed() {
    // When
    final Optional<JksOptions> jksOptions = VertxSslOptionsFactory.buildJksKeyStoreOptions(
        ImmutableMap.of(
            SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG,
            SERVER_KEY_STORE.keyStoreProps().get(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG),
            SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG,
            SERVER_KEY_STORE.keyStoreProps().get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG),
            SslConfigs.SSL_KEY_PASSWORD_CONFIG,
            SERVER_KEY_STORE.keyStoreProps().get(SslConfigs.SSL_KEY_PASSWORD_CONFIG)
        ),
        Optional.of("localhost")
    );

    // Then
    assertThat(jksOptions.get().getValue(), not(nullValue()));
    assertThat(jksOptions.get().getPassword(),
        is(SERVER_KEY_STORE.keyStoreProps().get(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG)));

    // When a key password is set, the Vert.x options are built without a keyStore location
    assertThat(jksOptions.get().getPath(), is(nullValue()));
  }