/** * Creates a {@link NexusClient} for specified Nexus instance, user and password. * * @param nexus to create client for * @param userName user * @param password password * @return created nexus client. Never null. */ protected NexusClient createNexusClient(final NexusBundle nexus, final String userName, final String password) { return nexusClientFactory.createFor( baseUrlFrom(checkNotNull(nexus).getUrl()), new UsernamePasswordAuthenticationInfo(checkNotNull(userName), checkNotNull(password)) ); }
protected void applyAuthenticationIfAny( final ConnectionInfo connectionInfo, ApacheHttpClient4Config config ) { if ( connectionInfo.getAuthenticationInfo() != null ) { if ( connectionInfo.getAuthenticationInfo() instanceof UsernamePasswordAuthenticationInfo ) { final UsernamePasswordAuthenticationInfo upinfo = (UsernamePasswordAuthenticationInfo) connectionInfo.getAuthenticationInfo(); final CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider(); credentialsProvider.setCredentials( AuthScope.ANY, new UsernamePasswordCredentials( upinfo.getUsername(), upinfo.getPassword() ) ); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider ); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION, true ); } else { throw new IllegalArgumentException( Template.of( "AuthenticationInfo of type %s is not supported!", connectionInfo.getAuthenticationInfo().getClass().getName() ).toString() ); } } }
protected NexusClient getNexusClientForBaseUrl(final String baseUrlString, final SubsystemFactory<?, JerseyNexusClient>... subsystemFactories) { if (baseUrlString == null) { throw new IllegalStateException(); } BaseUrl baseUrl; try { baseUrl = BaseUrl.baseUrlFrom(sanitizeBaseurl(baseUrlString)); } catch (MalformedURLException e) { throw new RuntimeException(e); } AuthenticationInfo authenticationInfo = new UsernamePasswordAuthenticationInfo(nexus.getUsername(), nexus.getPassword()); ConnectionInfo connectionInfo = new ConnectionInfo(baseUrl, authenticationInfo, null /* proxyInfos */); return new JerseyNexusClientFactory(subsystemFactories).createFor(connectionInfo); }
(UsernamePasswordAuthenticationInfo) connectionInfo.getAuthenticationInfo(); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_USERNAME, upinfo.getUsername() ); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_PASSWORD, upinfo.getPassword() );
log.info(" + Using server credentials \"{}\" from Maven settings.", server.getId()); authenticationInfo = new UsernamePasswordAuthenticationInfo(server.getUsername(), server.getPassword()); if (proxy.getUsername() != null) { proxyAuthentication = new UsernamePasswordAuthenticationInfo(proxy.getUsername(), proxy.getPassword());
new UsernamePasswordAuthenticationInfo(connection.getAuthentication().getUsername(), connection.getAuthentication().getPassword()); if (connection.getProxy().getAuthentication() != null) { proxyAuthentication = new UsernamePasswordAuthenticationInfo( connection.getProxy().getAuthentication().getUsername(), connection.getProxy().getAuthentication().getPassword());