use of org.sonatype.aether.repository.Authentication in project sonatype-aether by sonatype.
the class AuthGetTest method before.
@Before
@Override
public void before() throws Exception {
super.before();
repository().setAuthentication(new Authentication("user", "password"));
}
use of org.sonatype.aether.repository.Authentication in project sonatype-aether by sonatype.
the class AuthWithNonAsciiCredentialsGetTest method before.
@Before
@Override
public void before() throws Exception {
super.before();
repository().setAuthentication(new Authentication("user-non-ascii", "\u00E4\u00DF"));
}
use of org.sonatype.aether.repository.Authentication in project sonatype-aether by sonatype.
the class DefaultRepositorySystemSessionTest method testDefaultAuthenticationSelectorUsesExistingAuth.
@Test
public void testDefaultAuthenticationSelectorUsesExistingAuth() {
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
RemoteRepository repo = new RemoteRepository("id", "default", "void");
assertSame(null, session.getAuthenticationSelector().getAuthentication(repo));
repo.setAuthentication(new Authentication("user", "pass"));
assertSame(repo.getAuthentication(), session.getAuthenticationSelector().getAuthentication(repo));
}
use of org.sonatype.aether.repository.Authentication in project zeppelin by apache.
the class SparkDependencyContext method fetchArtifactWithDep.
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(SparkDependencyResolver.inferScalaVersion(dep.getGroupArtifactVersion()));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(SparkDependencyResolver.inferScalaVersion(dep.getExclusions()));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (RemoteRepository repo : additionalRepos) {
collectRequest.addRepository(repo);
}
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
Authentication auth = repo.getAuthentication();
if (auth != null) {
rr.setAuthentication(auth);
}
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.repository.Authentication in project build-info by JFrogDev.
the class ArtifactorySonatypeResolversHelper method getResolutionRepositories.
/**
* Create a list containing one release and one snapshot resolution repositories, according to the configuration in the Artifactory plugin.
* The list is used to override Maven's default or configured repositories, so that the build dependencies are resolved from Artifactory.
* The list is saved and reused for further invokations to this method.
* @param session
* @return
*/
public List<RemoteRepository> getResolutionRepositories(RepositorySystemSession session) {
if (resolutionRepositories == null) {
Properties allMavenProps = new Properties();
allMavenProps.putAll(session.getSystemProperties());
allMavenProps.putAll(session.getUserProperties());
resolutionHelper.init(allMavenProps);
String releaseRepoUrl = resolutionHelper.getRepoReleaseUrl();
String snapshotRepoUrl = resolutionHelper.getRepoSnapshotUrl();
Authentication authentication = null;
if (StringUtils.isNotBlank(resolutionHelper.getRepoUsername())) {
authentication = new Authentication(resolutionHelper.getRepoUsername(), resolutionHelper.getRepoPassword());
}
Proxy proxy = null;
if (StringUtils.isNotBlank(resolutionHelper.getProxyHost())) {
proxy = new Proxy(null, resolutionHelper.getProxyHost(), resolutionHelper.getProxyPort(), new Authentication(resolutionHelper.getProxyUsername(), resolutionHelper.getProxyPassword()));
}
if (StringUtils.isNotBlank(snapshotRepoUrl)) {
logger.debug("Enforcing snapshot repository for resolution: " + snapshotRepoUrl);
RepositoryPolicy releasePolicy = new RepositoryPolicy(false, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
RepositoryPolicy snapshotPolicy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
snapshotRepository = new RemoteRepository("artifactory-snapshot", "default", snapshotRepoUrl);
if (authentication != null) {
logger.debug("Enforcing repository authentication: " + authentication + " for snapshot resolution repository");
snapshotRepository.setAuthentication(authentication);
}
if (proxy != null) {
logger.debug("Enforcing proxy: " + proxy + " for snapshot resolution repository");
snapshotRepository.setProxy(proxy);
}
snapshotRepository.setPolicy(false, releasePolicy);
snapshotRepository.setPolicy(true, snapshotPolicy);
}
if (StringUtils.isNotBlank(releaseRepoUrl)) {
logger.debug("Enforcing release repository for resolution: " + releaseRepoUrl);
boolean snapshotPolicyEnabled = snapshotRepository == null;
String repositoryId = snapshotPolicyEnabled ? "artifactory-release-snapshot" : "artifactory-release";
RepositoryPolicy releasePolicy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
RepositoryPolicy snapshotPolicy = new RepositoryPolicy(snapshotPolicyEnabled, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
releaseRepository = new RemoteRepository(repositoryId, "default", releaseRepoUrl);
if (authentication != null) {
logger.debug("Enforcing repository authentication: " + authentication + " for release resolution repository");
releaseRepository.setAuthentication(authentication);
}
if (proxy != null) {
logger.debug("Enforcing proxy: " + proxy + " for release resolution repository");
releaseRepository.setProxy(proxy);
}
releaseRepository.setPolicy(false, releasePolicy);
releaseRepository.setPolicy(true, snapshotPolicy);
}
List<RemoteRepository> tempRepositories = Lists.newArrayList();
if (releaseRepository != null) {
tempRepositories.add(releaseRepository);
}
if (snapshotRepository != null) {
tempRepositories.add(snapshotRepository);
}
resolutionRepositories = tempRepositories;
}
return resolutionRepositories;
}
Aggregations