private static Authentication toAuthentication( org.apache.maven.artifact.repository.Authentication auth ) { Authentication result = null; if ( auth != null ) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername( auth.getUsername() ).addPassword( auth.getPassword() ); authBuilder.addPrivateKey( auth.getPrivateKey(), auth.getPassphrase() ); result = authBuilder.build(); } return result; }
private static Authentication toAuthentication(org.apache.maven.artifact.repository.Authentication auth) { Authentication result = null; if (auth != null) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername(auth.getUsername()).addPassword(auth.getPassword()); authBuilder.addPrivateKey(auth.getPrivateKey(), auth.getPassphrase()); result = authBuilder.build(); } return result; }
private static Authentication toAuthentication(org.apache.maven.artifact.repository.Authentication auth) { Authentication result = null; if (auth != null) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername(auth.getUsername()).addPassword(auth.getPassword()); authBuilder.addPrivateKey(auth.getPrivateKey(), auth.getPassphrase()); result = authBuilder.build(); } return result; }
/** * Builds a RemoteRepository for resolving artifacts. * * @param altRepository the repository identifier or alt-syntax specification * @return the resolve remote repository * @throws MojoExecutionException if the provided repository specification defines an invalid repository layout * @throws MojoFailureException if the provided repository specification is invalid */ RemoteRepository getRepository(final String altRepository) throws MojoExecutionException, MojoFailureException { if (getLog().isDebugEnabled()) { getLog().debug("Creating remote Aether repository (to resolve remote artifacts) for: " + altRepository); } // Get an appropriate injected ArtifactRepository. (This resolves authentication in the 'normal' manner from Maven) ArtifactRepository remoteArtifactRepo = getDeploymentRepository(altRepository); if (getLog().isDebugEnabled()) { getLog().debug("Resolved maven deployment repository. Transcribing to Aether Repository..."); } RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(remoteArtifactRepo.getId(), remoteArtifactRepo.getLayout().getId(), remoteArtifactRepo.getUrl()); // Add authentication. if (remoteArtifactRepo.getAuthentication() != null) { if (getLog().isDebugEnabled()) { getLog().debug("Maven deployment repsoitory has Authentication. Transcribing to Aether Authentication..."); } remoteRepoBuilder.setAuthentication(new AuthenticationBuilder().addUsername(remoteArtifactRepo.getAuthentication().getUsername()) .addPassword(remoteArtifactRepo.getAuthentication().getPassword()) .addPrivateKey(remoteArtifactRepo.getAuthentication().getPrivateKey(), remoteArtifactRepo.getAuthentication().getPassphrase()) .build()); } return remoteRepoBuilder.build(); }
private org.apache.maven.repository.Proxy proxy(MavenSettings settings, RepositorySystemSession session, RemoteRepository remote, ProxySelector proxy) { Proxy config = proxy.getProxy(remote); if (config == null) { return null; } org.apache.maven.repository.Proxy result = new org.apache.maven.repository.Proxy(); result.setHost(config.getHost()); if (config.getAuthentication() != null) { org.apache.maven.artifact.repository.Authentication auth = authentication( settings, session, new RemoteRepository.Builder(remote) .setAuthentication(config.getAuthentication()).build(), config.getAuthentication()); result.setUserName(auth.getUsername()); result.setPassword(auth.getPassword() != null ? auth.getPassword() : auth.getPassphrase()); } result.setProtocol(config.getType()); result.setPort(config.getPort()); return result; }