Search in sources :

Example 1 with DefaultBasicAuthentication

use of org.gradle.internal.authentication.DefaultBasicAuthentication in project gradle by gradle.

the class DefaultHttpBuildCacheServiceFactory method createBuildCacheService.

@Override
public BuildCacheService createBuildCacheService(HttpBuildCache configuration) {
    URI url = configuration.getUrl();
    if (url == null) {
        throw new IllegalStateException("HTTP build cache has no URL configured");
    }
    Collection<Authentication> authentications = Collections.emptyList();
    if (configuration.getCredentials().getUsername() != null && configuration.getCredentials().getPassword() != null) {
        try {
            url = new URI(url.getScheme(), null, url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getFragment());
        } catch (URISyntaxException e) {
            throw new GradleException("Error constructing URL for http build cache", e);
        }
        DefaultBasicAuthentication basicAuthentication = new DefaultBasicAuthentication("basic");
        basicAuthentication.setCredentials(configuration.getCredentials());
        authentications = Collections.<Authentication>singleton(basicAuthentication);
    }
    HttpClientHelper httpClientHelper = new HttpClientHelper(new DefaultHttpSettings(authentications, sslContextFactory));
    return new HttpBuildCacheService(httpClientHelper, url);
}
Also used : HttpClientHelper(org.gradle.internal.resource.transport.http.HttpClientHelper) Authentication(org.gradle.authentication.Authentication) DefaultBasicAuthentication(org.gradle.internal.authentication.DefaultBasicAuthentication) GradleException(org.gradle.api.GradleException) DefaultBasicAuthentication(org.gradle.internal.authentication.DefaultBasicAuthentication) URISyntaxException(java.net.URISyntaxException) DefaultHttpSettings(org.gradle.internal.resource.transport.http.DefaultHttpSettings) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 GradleException (org.gradle.api.GradleException)1 Authentication (org.gradle.authentication.Authentication)1 DefaultBasicAuthentication (org.gradle.internal.authentication.DefaultBasicAuthentication)1 DefaultHttpSettings (org.gradle.internal.resource.transport.http.DefaultHttpSettings)1 HttpClientHelper (org.gradle.internal.resource.transport.http.HttpClientHelper)1