static void activateHttpAndHttpsProxies(Settings settings, SettingsDecrypter decrypter)
      throws MojoExecutionException {
    List<Proxy> proxies = new ArrayList<>(2);
    for (String protocol : ImmutableList.of("http", "https")) {
      if (areProxyPropertiesSet(protocol)) {
        continue;
      }
      settings.getProxies().stream()
          .filter(Proxy::isActive)
          .filter(proxy -> protocol.equals(proxy.getProtocol()))
          .findFirst()
          .ifPresent(proxies::add);
    }

    if (proxies.isEmpty()) {
      return;
    }

    SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest().setProxies(proxies);
    SettingsDecryptionResult result = decrypter.decrypt(request);

    for (SettingsProblem problem : result.getProblems()) {
      if (problem.getSeverity() == SettingsProblem.Severity.ERROR
          || problem.getSeverity() == SettingsProblem.Severity.FATAL) {
        throw new MojoExecutionException(
            "Unable to decrypt proxy info from settings.xml: " + problem);
      }
    }

    result.getProxies().forEach(MavenSettingsProxyProvider::setProxyProperties);
  }
@Test
  public void testActivateHttpAndHttpsProxies_firstActiveHttpsProxy()
      throws MojoExecutionException {
    MavenSettingsProxyProvider.activateHttpAndHttpsProxies(
        httpsOnlyProxySettings, settingsDecrypter);

    Assert.assertEquals("proxy2.example.com", System.getProperty("https.proxyHost"));
    Assert.assertNull(System.getProperty("http.proxyHost"));
  }