public InputStream getInputStream() throws CoreException {
    if (filePath != null) {
      File file = new File(filePath);
      if (file.isFile()) {
        IMaven maven = MavenPlugin.getDefault().getMaven();
        Settings settings = maven.buildSettings(null, filePath);

        List<Server> servers = settings.getServers();
        if (servers != null) {
          for (Server server : servers) {
            server.setUsername(obfuscate(server.getUsername()));
            server.setPassword(obfuscate(server.getPassword()));
            server.setPassphrase(obfuscate(server.getPassphrase()));
          }
        }

        List<Proxy> proxies = settings.getProxies();
        if (proxies != null) {
          for (Proxy proxy : proxies) {
            proxy.setUsername(obfuscate(proxy.getUsername()));
            proxy.setPassword(obfuscate(proxy.getPassword()));
          }
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 4);
        maven.writeSettings(settings, baos);
        return new ByteArrayInputStream(baos.toByteArray());
      }
    }
    return null;
  }
  /**
   * Gets proxy selector
   *
   * @return the selector
   */
  public ProxySelector proxySelector() {
    DefaultProxySelector dps = new DefaultProxySelector();

    for (Proxy proxy : settings.getProxies()) {
      dps.add(MavenConverter.asProxy(proxy), proxy.getNonProxyHosts());
    }

    return dps;
  }
  public void update(Settings settings, File settingsFile) throws ManipulationException {
    try {
      Settings defaultSettings = new Settings();

      if (settingsFile.exists()) {
        DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
        settingsRequest.setGlobalSettingsFile(settingsFile);
        defaultSettings = settingsBuilder.build(settingsRequest).getEffectiveSettings();
      }

      for (Profile profile : settings.getProfiles()) {
        Iterator<Profile> i = defaultSettings.getProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().getId().equals(profile.getId())) {
            i.remove();
          }
        }
        defaultSettings.addProfile(profile);
      }
      for (String activeProfile : settings.getActiveProfiles()) {
        Iterator<String> i = defaultSettings.getActiveProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().equals(activeProfile)) {
            i.remove();
          }
        }
        defaultSettings.addActiveProfile(activeProfile);
      }
      for (Mirror mirror : settings.getMirrors()) {
        defaultSettings.addMirror(mirror);
      }
      for (Proxy proxy : settings.getProxies()) {
        defaultSettings.addProxy(proxy);
      }
      for (Server server : settings.getServers()) {
        defaultSettings.addServer(server);
      }
      for (String pluginGroup : settings.getPluginGroups()) {
        defaultSettings.addPluginGroup(pluginGroup);
      }
      if (settings.getLocalRepository() != null) {
        defaultSettings.setLocalRepository(settings.getLocalRepository());
      }

      write(defaultSettings, settingsFile);
    } catch (SettingsBuildingException e) {
      throw new ManipulationException(
          "Failed to build existing settings.xml for repo removal backup.",
          e,
          settingsFile,
          e.getMessage());
    }
  }
  private ProxySelector getProxySelector() {
    DefaultProxySelector selector = new DefaultProxySelector();

    for (Proxy proxy : proxies) {
      selector.add(ConverterUtils.toProxy(proxy), proxy.getNonProxyHosts());
    }

    Settings settings = getSettings();
    for (org.apache.maven.settings.Proxy proxy : settings.getProxies()) {
      org.sonatype.aether.repository.Authentication auth = null;
      if (proxy.getUsername() != null || proxy.getPassword() != null) {
        auth =
            new org.sonatype.aether.repository.Authentication(
                proxy.getUsername(), proxy.getPassword());
      }
      selector.add(
          new org.sonatype.aether.repository.Proxy(
              proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth),
          proxy.getNonProxyHosts());
    }

    return selector;
  }