private Proxy getProxy(RepositorySystemSession session, ArtifactRepository repository) { if (session != null) { ProxySelector selector = session.getProxySelector(); if (selector != null) { RemoteRepository repo = RepositoryUtils.toRepo(repository); org.eclipse.aether.repository.Proxy proxy = selector.getProxy(repo); if (proxy != null) { Proxy p = new Proxy(); p.setHost(proxy.getHost()); p.setProtocol(proxy.getType()); p.setPort(proxy.getPort()); if (proxy.getAuthentication() != null) { repo = new RemoteRepository.Builder(repo).setProxy(proxy).build(); AuthenticationContext authCtx = AuthenticationContext.forProxy(session, repo); p.setUserName(authCtx.get(AuthenticationContext.USERNAME)); p.setPassword(authCtx.get(AuthenticationContext.PASSWORD)); p.setNtlmDomain(authCtx.get(AuthenticationContext.NTLM_DOMAIN)); p.setNtlmHost(authCtx.get(AuthenticationContext.NTLM_WORKSTATION)); authCtx.close(); } return p; } } } return null; }
private Mirror getMirror(RepositorySystemSession session, ArtifactRepository repository) { if (session != null) { org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if (selector != null) { RemoteRepository repo = selector.getMirror(RepositoryUtils.toRepo(repository)); if (repo != null) { Mirror mirror = new Mirror(); mirror.setId(repo.getId()); mirror.setUrl(repo.getUrl()); mirror.setLayout(repo.getContentType()); return mirror; } } } return null; }
private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository) { if (session != null) { AuthenticationSelector selector = session.getAuthenticationSelector(); if (selector != null) { RemoteRepository repo = RepositoryUtils.toRepo(repository); org.eclipse.aether.repository.Authentication auth = selector.getAuthentication(repo); if (auth != null) { repo = new RemoteRepository.Builder(repo).setAuthentication(auth).build(); AuthenticationContext authCtx = AuthenticationContext.forRepository(session, repo); Authentication result = new Authentication( authCtx.get(AuthenticationContext.USERNAME), authCtx.get(AuthenticationContext.PASSWORD)); result.setPrivateKey(authCtx.get(AuthenticationContext.PRIVATE_KEY_PATH)); result.setPassphrase(authCtx.get(AuthenticationContext.PRIVATE_KEY_PASSPHRASE)); authCtx.close(); return result; } } } return null; }