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; }
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();
/** * Gets the authentication data for the specified key. * * @param <T> The data type of the authentication data. * @param key The key whose authentication data should be retrieved, must not be {@code null}. * @param type The expected type of the authentication data, must not be {@code null}. * @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type. */ public <T> T get( String key, Class<T> type ) { return get( key, null, type ); }
AuthenticationContext proxyAuthenticationContext = AuthenticationContext.forProxy(session, repository); if (proxyAuthenticationContext != null) { try { String username = proxyAuthenticationContext.get(AuthenticationContext.USERNAME); String password = proxyAuthenticationContext.get(AuthenticationContext.PASSWORD); proxy.setAuthentication(new AetherClientAuthentication(username, password)); } finally { AuthenticationContext.close(proxyAuthenticationContext); AuthenticationContext repoAuthenticationContext = AuthenticationContext.forRepository(session, repository); if (repoAuthenticationContext != null) { try { String username = repoAuthenticationContext.get(AuthenticationContext.USERNAME); String password = repoAuthenticationContext.get(AuthenticationContext.PASSWORD); AetherClientAuthentication authentication = new AetherClientAuthentication(username, password); config.setAuthentication(authentication); } finally { AuthenticationContext.close(repoAuthenticationContext);
private org.apache.maven.artifact.repository.Authentication authentication( MavenSettings settings, RepositorySystemSession session, RemoteRepository remote, Authentication authentication) { AuthenticationContext context = AuthenticationContext.forRepository(session, remote); if (context == null) { return null; } authentication.fill(context, "username", Collections.<String, String>emptyMap()); authentication.fill(context, "password", Collections.<String, String>emptyMap()); authentication.fill(context, "passphrase", Collections.<String, String>emptyMap()); authentication.fill(context, "privateKey", Collections.<String, String>emptyMap()); org.apache.maven.artifact.repository.Authentication maven = new org.apache.maven.artifact.repository.Authentication( context.get("username"), context.get("password")); if (context.get("passphrase") != null) { maven.setPassphrase(context.get("passphrase")); } if (context.get("privateKey") != null) { maven.setPrivateKey(context.get("privateKey")); } return maven; }
repoAuthContext = AuthenticationContext.forRepository( session, repository ); proxyAuthContext = AuthenticationContext.forProxy( session, repository );
/** * Closes the specified authentication context. This is a convenience method doing a {@code null} check before * calling {@link #close()} on the given context. * * @param context The authentication context to close, may be {@code null}. */ public static void close( AuthenticationContext context ) { if ( context != null ) { context.close(); } }
public void fill( AuthenticationContext context, String key, Map<String, String> data ) Proxy proxy = context.getProxy(); if ( proxy == null ) try url = new URL( context.getRepository().getUrl() ); if ( auth != null ) context.put( AuthenticationContext.USERNAME, auth.getUserName() ); context.put( AuthenticationContext.PASSWORD, auth.getPassword() ); context.put( AuthenticationContext.USERNAME, System.getProperty( "http.proxyUser" ) ); context.put( AuthenticationContext.PASSWORD, System.getProperty( "http.proxyPassword" ) );
private static AuthenticationContext newInstance( RepositorySystemSession session, RemoteRepository repository, Proxy proxy, Authentication auth ) { if ( auth == null ) { return null; } return new AuthenticationContext( session, repository, proxy, auth ); }
/** * Gets the authentication data for the specified key. * * @param key The key whose authentication data should be retrieved, must not be {@code null}. * @return The requested authentication data or {@code null} if none. */ public String get( String key ) { return get( key, null, String.class ); }
repoAuthContext = AuthenticationContext.forRepository( session, repository ); proxyAuthContext = AuthenticationContext.forProxy( session, repository );
/** * Closes the specified authentication context. This is a convenience method doing a {@code null} check before * calling {@link #close()} on the given context. * * @param context The authentication context to close, may be {@code null}. */ public static void close( AuthenticationContext context ) { if ( context != null ) { context.close(); } }
public void fill( AuthenticationContext context, String key, Map<String, String> data ) Proxy proxy = context.getProxy(); if ( proxy == null ) try url = new URL( context.getRepository().getUrl() ); if ( auth != null ) context.put( AuthenticationContext.USERNAME, auth.getUserName() ); context.put( AuthenticationContext.PASSWORD, auth.getPassword() ); context.put( AuthenticationContext.USERNAME, System.getProperty( "http.proxyUser" ) ); context.put( AuthenticationContext.PASSWORD, System.getProperty( "http.proxyPassword" ) );
public void fill( AuthenticationContext context, String key, Map<String, String> data ) { context.put( this.key, value ); }
private static AuthenticationContext newInstance( RepositorySystemSession session, RemoteRepository repository, Proxy proxy, Authentication auth ) { if ( auth == null ) { return null; } return new AuthenticationContext( session, repository, proxy, auth ); }
@Override public String getPassphrase() { return authContext.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ); } };
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; }
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();
repoAuthContext = AuthenticationContext.forRepository( session, repository ); proxyAuthContext = AuthenticationContext.forProxy( session, repository );