Search in sources :

Example 1 with AuthenticationSelector

use of org.sonatype.aether.repository.AuthenticationSelector in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManager method aggregateRepositories.

public List<RemoteRepository> aggregateRepositories(RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw) {
    if (recessiveRepositories.isEmpty()) {
        return dominantRepositories;
    }
    MirrorSelector mirrorSelector = session.getMirrorSelector();
    AuthenticationSelector authSelector = session.getAuthenticationSelector();
    ProxySelector proxySelector = session.getProxySelector();
    List<RemoteRepository> result = new ArrayList<RemoteRepository>(dominantRepositories);
    next: for (RemoteRepository recessiveRepository : recessiveRepositories) {
        RemoteRepository repository = recessiveRepository;
        if (recessiveIsRaw) {
            RemoteRepository mirrorRepository = mirrorSelector.getMirror(recessiveRepository);
            if (mirrorRepository == null) {
                repository = recessiveRepository;
            } else {
                logger.debug("Using mirror " + mirrorRepository.getId() + " (" + mirrorRepository.getUrl() + ") for " + recessiveRepository.getId() + " (" + recessiveRepository.getUrl() + ").");
                repository = mirrorRepository;
            }
        }
        String key = getKey(repository);
        for (ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) {
            RemoteRepository dominantRepository = it.next();
            if (key.equals(getKey(dominantRepository))) {
                if (!dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty()) {
                    RemoteRepository mergedRepository = mergeMirrors(session, dominantRepository, repository);
                    if (mergedRepository != dominantRepository) {
                        it.set(mergedRepository);
                    }
                }
                continue next;
            }
        }
        if (recessiveIsRaw) {
            Authentication auth = authSelector.getAuthentication(repository);
            if (auth != null) {
                repository.setAuthentication(auth);
            }
            Proxy proxy = proxySelector.getProxy(repository);
            if (proxy != null) {
                repository.setProxy(proxy);
            }
        }
        result.add(repository);
    }
    return result;
}
Also used : ProxySelector(org.sonatype.aether.repository.ProxySelector) Proxy(org.sonatype.aether.repository.Proxy) AuthenticationSelector(org.sonatype.aether.repository.AuthenticationSelector) MirrorSelector(org.sonatype.aether.repository.MirrorSelector) Authentication(org.sonatype.aether.repository.Authentication) ArrayList(java.util.ArrayList) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) ListIterator(java.util.ListIterator)

Aggregations

ArrayList (java.util.ArrayList)1 ListIterator (java.util.ListIterator)1 Authentication (org.sonatype.aether.repository.Authentication)1 AuthenticationSelector (org.sonatype.aether.repository.AuthenticationSelector)1 MirrorSelector (org.sonatype.aether.repository.MirrorSelector)1 Proxy (org.sonatype.aether.repository.Proxy)1 ProxySelector (org.sonatype.aether.repository.ProxySelector)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1