public SlingClientConfig build()

in src/main/java/org/apache/sling/testing/clients/SlingClientConfig.java [211:249]


        public SlingClientConfig build() throws ClientException {
            if (!this.url.isAbsolute()) {
                throw new TestingSetupException("Url must be absolute: " + url);
            }

            HttpHost targetHost = URIUtils.extractHost(this.url);
            if (targetHost == null) {
                throw new TestingSetupException("Failed to extract hostname from url " + url);
            }

            // Create default CredentialsProvider if not set
            if (credsProvider == null) {
                credsProvider = new BasicCredentialsProvider();
                // Empty user "" is a valid user for basic authentication
                if (this.user != null) {
                    credsProvider.setCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()),
                            new UsernamePasswordCredentials(this.user, this.password));
                }
            }

            // Create default AuthCache for basic if not set
            if (authCache == null) {
                BasicScheme basicScheme = new BasicScheme();
                authCache = new BasicAuthCache();
                authCache.put(targetHost, basicScheme);
            }

            // if preemptive auth is disabled, force auth cache to be null
            if (!this.preemptiveAuth) {
                authCache = null;
            }

            // Create default CookieStore if not set
            if (cookieStore == null) {
                cookieStore = new BasicCookieStore();
            }

            return new SlingClientConfig(url, user, password, cookieStore, credsProvider, authCache);
        }