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