public static BaseUrl baseUrlFrom( final String url ) throws MalformedURLException { return baseUrlFrom( new URL( Check.notBlank( url, "URL" ) ) ); }
public String toUrl() { return getProtocol().name().toLowerCase() + "://" + getHost() + ":" + getPort() + getPath(); }
public static BaseUrl baseUrlFrom( final URL url ) { Check.notNull( url, URL.class ); final Protocol protocol = Protocol.valueOf( url.getProtocol().toUpperCase() ); final String host = url.getHost(); final int port = url.getPort() == -1 ? url.getDefaultPort() : url.getPort(); String fixedPath = url.getPath(); if ( !fixedPath.startsWith( "/" ) ) { fixedPath = "/" + fixedPath; } if ( !fixedPath.endsWith( "/" ) ) { fixedPath = fixedPath + "/"; } return new BaseUrl( protocol, host, port, fixedPath ); } }
final BaseUrl baseUrl = BaseUrl.baseUrlFrom(connection.getBaseUrl()); final UsernamePasswordAuthenticationInfo authenticationInfo; final Map<Protocol, ProxyInfo> proxyInfos = new HashMap<Protocol, ProxyInfo>(1); new ProxyInfo(baseUrl.getProtocol(), connection.getProxy().getHost(), connection.getProxy().getPort(), proxyAuthentication); proxyInfos.put(zProxy.getProxyProtocol(), zProxy); log("NexusClient created for Nexus instance on URL: " + baseUrl.toString());
protected NexusClient createNexusClient(final Parameters parameters) { final String nexusUrl = parameters.getNexusUrl(); try { final BaseUrl baseUrl = BaseUrl.baseUrlFrom(nexusUrl); final UsernamePasswordAuthenticationInfo authenticationInfo; final Map<Protocol, ProxyInfo> proxyInfos = new HashMap<Protocol, ProxyInfo>(1); new ProxyInfo(baseUrl.getProtocol(), proxy.getHost(), proxy.getPort(), proxyAuthentication); proxyInfos.put(zProxy.getProxyProtocol(), zProxy);
final ProxyInfo proxyInfo = connectionInfo.getProxyInfos().get( connectionInfo.getBaseUrl().getProtocol() ); if ( proxyInfo != null )
concat(remoteNexus.getConnectionInfo().getBaseUrl().toString(), "/content/repositories", stagingRepository.getRepositoryId());
request.setProxyProtocol(getNexusUrl().getProtocol().toString().toLowerCase()); request.setProxyHost(getConnectionInfo().getProxy().getHost()); request.setProxyPort(getConnectionInfo().getProxy().getPort());
concat(getNexusUrl().toString(), "/content/repositories", stagingRepositoryId);
/** * Creates a {@link NexusClient} for specified Nexus instance for anonymous user. * * @param nexus to create client for * @return created nexus client. Never null. */ protected NexusClient createNexusClientForAnonymous(final NexusBundle nexus) { return nexusClientFactory.createFor( baseUrlFrom(nexus.getUrl()) ); }
/** * 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 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); }