@Override public final NexusClient createFor( final BaseUrl baseUrl, final AuthenticationInfo authenticationInfo ) { final ConnectionInfo connectionInfo = new ConnectionInfo( baseUrl, authenticationInfo, null ); return createFor( connectionInfo ); }
public String resolvePath( final String path ) { // we need more logic here, but for now will do it ;) return getConnectionInfo().getBaseUrl() + path; }
@Override public String toString() { final StringBuilder sb = new StringBuilder( "(" ); sb.append( "url=" ).append( getBaseUrl() ); if ( getAuthenticationInfo() != null ) { sb.append( ",authc=" ).append( getAuthenticationInfo() ); } if ( !getProxyInfos().isEmpty() ) { sb.append( ",proxy=" ).append( getProxyInfos() ); } sb.append( ")" ); return sb.toString(); } }
final ValidationLevel sslCertificateHostnameValidationLevel = parameters .isSslAllowAll() ? ValidationLevel.NONE : ValidationLevel.LAX; final ConnectionInfo connectionInfo = new ConnectionInfo(baseUrl, authenticationInfo, proxyInfos, sslCertificateValidationLevel, sslCertificateHostnameValidationLevel); final NexusClient nexusClient = new JerseyNexusClientFactory( final NexusStatus nexusStatus = nexusClient.getNexusStatus(); log.info(" * Connected to Nexus at {}, is version {} and edition \"{}\"", connectionInfo.getBaseUrl(), nexusStatus.getVersion(), nexusStatus.getEditionLong()); return nexusClient;
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 BaseUrl getNexusUrl() { return getNexusClient().getConnectionInfo().getBaseUrl(); }
protected void applyProxyIfAny( final ConnectionInfo connectionInfo, ApacheHttpClient4Config config ) if ( connectionInfo.getProxyInfos().size() > 0 ) final ProxyInfo proxyInfo = connectionInfo.getProxyInfos().get( connectionInfo.getBaseUrl().getProtocol() ); if ( proxyInfo != null ) (UsernamePasswordAuthenticationInfo) connectionInfo.getAuthenticationInfo(); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_USERNAME, upinfo.getUsername() ); 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); }
c -> { NodeInfo nodeInfo = new NodeInfo(); nodeInfo.baseUrl = c.getConnectionInfo().getBaseUrl(); nodeInfo.repositories = c.getSubsystem(Repositories.class); return nodeInfo;
new org.sonatype.nexus.client.rest.ConnectionInfo(baseUrl, authenticationInfo, proxyInfos);
throw new IllegalArgumentException( // same ex, but "translated" to be more meaningful String.format("Nexus instance at base URL %s does not support staging v2; reported status: %s, reason: %s", nexusClient.getConnectionInfo().getBaseUrl(), nexusClient.getNexusStatus(), e.getMessage()),
concat(remoteNexus.getConnectionInfo().getBaseUrl().toString(), "/content/repositories", stagingRepository.getRepositoryId());
throw new BuildException( String.format("Nexus instance at base URL %s does not support staging v2; reported status: %s, reason:%s", nexusClient.getConnectionInfo().getBaseUrl(), nexusClient.getNexusStatus(), e.getMessage()),