public List<VirtualRepository> getVirtualRepositoryKeys() {
   Credentials resolvingCredentials = getResolvingCredentials();
   try {
     ArtifactoryBuildInfoClient client =
         createArtifactoryClient(
             resolvingCredentials.getUsername(), resolvingCredentials.getPassword());
     List<String> keys = client.getVirtualRepositoryKeys();
     virtualRepositories =
         Lists.newArrayList(
             Lists.transform(
                 keys,
                 new Function<String, VirtualRepository>() {
                   public VirtualRepository apply(String from) {
                     return new VirtualRepository(from, from);
                   }
                 }));
   } catch (IOException e) {
     log.log(Level.WARNING, "Failed to obtain list of virtual repositories: " + e.getMessage());
     return Lists.newArrayList();
   }
   virtualRepositories.add(
       0,
       new VirtualRepository(
           "-- To use Artifactory for resolution select a virtual repository --", ""));
   return virtualRepositories;
 }
 public List<String> getRepositoryKeys() {
   Credentials resolvingCredentials = getResolvingCredentials();
   try {
     ArtifactoryBuildInfoClient client =
         createArtifactoryClient(
             resolvingCredentials.getUsername(), resolvingCredentials.getPassword());
     repositories = client.getLocalRepositoriesKeys();
   } catch (IOException e) {
     log.log(Level.WARNING, "Failed to obtain list of local repositories: " + e.getMessage());
     return Lists.newArrayList();
   }
   return repositories;
 }
  public ArtifactoryBuildInfoClient createArtifactoryClient(String userName, String password) {
    ArtifactoryBuildInfoClient client =
        new ArtifactoryBuildInfoClient(url, userName, password, new NullLog());
    client.setConnectionTimeout(timeout);

    ProxyConfiguration proxyConfiguration = Hudson.getInstance().proxy;
    if (!bypassProxy && proxyConfiguration != null) {
      client.setProxyConfiguration(
          proxyConfiguration.name,
          proxyConfiguration.port,
          proxyConfiguration.getUserName(),
          proxyConfiguration.getPassword());
    }

    return client;
  }
 private void testConnection() {
   ArtifactoryBuildInfoClient testClient;
   if (StringUtils.isNotBlank(username)) {
     testClient =
         new ArtifactoryBuildInfoClient(url, username, password, new BambooBuildInfoLog(log));
   } else {
     testClient = new ArtifactoryBuildInfoClient(url, new BambooBuildInfoLog(log));
   }
   testClient.setConnectionTimeout(timeout);
   try {
     testClient.verifyCompatibleArtifactoryVersion();
     addActionMessage("Connection successful!");
   } catch (VersionException ve) {
     handleConnectionException(ve);
   } catch (IllegalArgumentException iae) {
     handleConnectionException(iae);
   }
 }
 public void deploy() throws IOException {
   String url = configurator.getArtifactoryServer().getUrl() + "/api/build";
   listener.getLogger().println("Deploying build info to: " + url);
   client.sendBuildInfo(buildInfo);
 }