Search in sources :

Example 1 with AuthenticationBuilder

use of org.eclipse.aether.util.repository.AuthenticationBuilder in project fabric8 by jboss-fuse.

the class AetherBasedResolver method getAuthentication.

private Authentication getAuthentication(String repoId) {
    Server server = m_settings.getServer(repoId);
    if (server != null && server.getUsername() != null) {
        AuthenticationBuilder authBuilder = new AuthenticationBuilder();
        authBuilder.addUsername(server.getUsername()).addPassword(server.getPassword());
        return authBuilder.build();
    }
    return null;
}
Also used : AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) Server(org.apache.maven.settings.Server)

Example 2 with AuthenticationBuilder

use of org.eclipse.aether.util.repository.AuthenticationBuilder in project gate-core by GateNLP.

the class Utils method getRepositoryList.

public static List<RemoteRepository> getRepositoryList() throws SettingsBuildingException {
    List<RemoteRepository> repos = new ArrayList<RemoteRepository>();
    RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
    // Without this we wouldn't be able to find SNAPSHOT builds of plugins we
    // haven't built and installed locally ourselves
    RemoteRepository gateRepo = new RemoteRepository.Builder("gate", "default", "http://repo.gate.ac.uk/content/groups/public/").build();
    // Add all repos from settings.xml
    // http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
    Settings effectiveSettings = loadMavenSettings();
    org.apache.maven.settings.Proxy proxy = effectiveSettings.getActiveProxy();
    DefaultProxySelector selector = null;
    if (proxy != null) {
        selector = new DefaultProxySelector();
        selector.add(new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build()), proxy.getNonProxyHosts());
    }
    Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
    for (String profileName : effectiveSettings.getActiveProfiles()) {
        Profile profile = profilesMap.get(profileName);
        List<Repository> repositories = profile.getRepositories();
        for (Repository repo : repositories) {
            RemoteRepository remoteRepo = new RemoteRepository.Builder(repo.getId(), "default", repo.getUrl()).build();
            if (selector != null) {
                remoteRepo = new RemoteRepository.Builder(remoteRepo).setProxy(selector.getProxy(remoteRepo)).build();
            }
            repos.add(remoteRepo);
        }
    }
    repos.add(central);
    repos.add(gateRepo);
    return repos;
}
Also used : AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Profile(org.apache.maven.settings.Profile) Proxy(org.eclipse.aether.repository.Proxy) Repository(org.apache.maven.settings.Repository) LocalRepository(org.eclipse.aether.repository.LocalRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Settings(org.apache.maven.settings.Settings)

Example 3 with AuthenticationBuilder

use of org.eclipse.aether.util.repository.AuthenticationBuilder in project spring-cloud-function by spring-cloud.

the class MavenSettings method createProxySelector.

private ProxySelector createProxySelector(SettingsDecryptionResult decryptedSettings) {
    DefaultProxySelector selector = new DefaultProxySelector();
    for (Proxy proxy : decryptedSettings.getProxies()) {
        Authentication authentication = new AuthenticationBuilder().addUsername(proxy.getUsername()).addPassword(proxy.getPassword()).build();
        selector.add(new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts());
    }
    return selector;
}
Also used : Proxy(org.apache.maven.settings.Proxy) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) DefaultProxySelector(org.eclipse.aether.util.repository.DefaultProxySelector) Authentication(org.eclipse.aether.repository.Authentication)

Example 4 with AuthenticationBuilder

use of org.eclipse.aether.util.repository.AuthenticationBuilder in project spring-cloud-function by spring-cloud.

the class MavenSettings method createAuthenticationSelector.

private AuthenticationSelector createAuthenticationSelector(SettingsDecryptionResult decryptedSettings) {
    DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector();
    for (Server server : decryptedSettings.getServers()) {
        AuthenticationBuilder auth = new AuthenticationBuilder();
        auth.addUsername(server.getUsername()).addPassword(server.getPassword());
        auth.addPrivateKey(server.getPrivateKey(), server.getPassphrase());
        selector.add(server.getId(), auth.build());
    }
    return new ConservativeAuthenticationSelector(selector);
}
Also used : AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) Server(org.apache.maven.settings.Server) DefaultAuthenticationSelector(org.eclipse.aether.util.repository.DefaultAuthenticationSelector) ConservativeAuthenticationSelector(org.eclipse.aether.util.repository.ConservativeAuthenticationSelector)

Example 5 with AuthenticationBuilder

use of org.eclipse.aether.util.repository.AuthenticationBuilder in project buck by facebook.

the class AetherUtil method toRemoteRepository.

public static RemoteRepository toRemoteRepository(String repoUrl, Optional<String> username, Optional<String> password) {
    RemoteRepository.Builder repo = new RemoteRepository.Builder(null, "default", repoUrl).setPolicy(new RepositoryPolicy(true, null, CHECKSUM_POLICY_FAIL));
    if (username.isPresent() && password.isPresent()) {
        Authentication authentication = new AuthenticationBuilder().addUsername(username.get()).addPassword(password.get()).build();
        repo.setAuthentication(authentication);
    }
    return repo.build();
}
Also used : AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) Authentication(org.eclipse.aether.repository.Authentication) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Aggregations

AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)14 Authentication (org.eclipse.aether.repository.Authentication)7 Proxy (org.eclipse.aether.repository.Proxy)7 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)5 File (java.io.File)3 RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Server (org.apache.maven.settings.Server)2 DefaultProxySelector (org.eclipse.aether.util.repository.DefaultProxySelector)2 FixedIndexedRepo (aQute.bnd.deployer.repository.FixedIndexedRepo)1 Command (com.github.rvesse.airline.annotations.Command)1 Option (com.github.rvesse.airline.annotations.Option)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 Inject (com.google.inject.Inject)1 SuppressForbidden (io.netty.util.SuppressForbidden)1