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;
}
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;
}
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;
}
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);
}
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();
}
Aggregations