Search in sources :

Example 1 with Authentication

use of org.eclipse.aether.repository.Authentication in project spring-boot by spring-projects.

the class SettingsXmlRepositorySystemSessionAutoConfigurationTests method assertAuthenticationSelectorConfiguration.

private void assertAuthenticationSelectorConfiguration(DefaultRepositorySystemSession session, RemoteRepository repository) {
    Authentication authentication = session.getAuthenticationSelector().getAuthentication(repository);
    repository = new RemoteRepository.Builder(repository).setAuthentication(authentication).build();
    AuthenticationContext authenticationContext = AuthenticationContext.forRepository(session, repository);
    assertThat(authenticationContext.get(AuthenticationContext.USERNAME)).isEqualTo("tester");
    assertThat(authenticationContext.get(AuthenticationContext.PASSWORD)).isEqualTo("secret");
}
Also used : AuthenticationContext(org.eclipse.aether.repository.AuthenticationContext) Authentication(org.eclipse.aether.repository.Authentication) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 2 with Authentication

use of org.eclipse.aether.repository.Authentication 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)

Example 3 with Authentication

use of org.eclipse.aether.repository.Authentication in project spring-boot by spring-projects.

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)

Aggregations

Authentication (org.eclipse.aether.repository.Authentication)3 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)2 AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)2 Proxy (org.apache.maven.settings.Proxy)1 AuthenticationContext (org.eclipse.aether.repository.AuthenticationContext)1 RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)1 DefaultProxySelector (org.eclipse.aether.util.repository.DefaultProxySelector)1