use of org.gradle.internal.verifier.HttpRedirectVerifier in project gradle by gradle.
the class DefaultHttpBuildCacheServiceFactory method createBuildCacheService.
@Override
public BuildCacheService createBuildCacheService(HttpBuildCache configuration, Describer describer) {
URI url = configuration.getUrl();
if (url == null) {
throw new IllegalStateException("HTTP build cache has no URL configured");
}
URI noUserInfoUrl = stripUserInfo(url);
HttpBuildCacheCredentials credentials = configuration.getCredentials();
if (!credentialsPresent(credentials) && url.getUserInfo() != null) {
credentials = extractCredentialsFromUserInfo(url);
}
Collection<Authentication> authentications = Collections.emptyList();
if (credentialsPresent(credentials)) {
DefaultBasicAuthentication basicAuthentication = new DefaultBasicAuthentication("basic");
basicAuthentication.setCredentials(credentials);
basicAuthentication.addHost(url.getHost(), url.getPort());
authentications = Collections.<Authentication>singleton(basicAuthentication);
}
boolean authenticated = !authentications.isEmpty();
boolean allowUntrustedServer = configuration.isAllowUntrustedServer();
boolean allowInsecureProtocol = configuration.isAllowInsecureProtocol();
boolean useExpectContinue = configuration.isUseExpectContinue();
HttpRedirectVerifier redirectVerifier = createRedirectVerifier(noUserInfoUrl, allowInsecureProtocol);
DefaultHttpSettings.Builder builder = DefaultHttpSettings.builder().withAuthenticationSettings(authentications).maxRedirects(MAX_REDIRECTS).withRedirectMethodHandlingStrategy(HttpSettings.RedirectMethodHandlingStrategy.ALLOW_FOLLOW_FOR_MUTATIONS).withRedirectVerifier(redirectVerifier);
if (allowUntrustedServer) {
builder.allowUntrustedConnections();
} else {
builder.withSslContextFactory(sslContextFactory);
}
HttpClientHelper httpClientHelper = httpClientHelperFactory.create(builder.build());
describer.type("HTTP").config("url", noUserInfoUrl.toASCIIString()).config("authenticated", Boolean.toString(authenticated)).config("allowUntrustedServer", Boolean.toString(allowUntrustedServer)).config("allowInsecureProtocol", Boolean.toString(allowInsecureProtocol)).config("useExpectContinue", Boolean.toString(useExpectContinue));
return new HttpBuildCacheService(httpClientHelper, noUserInfoUrl, requestCustomizer, useExpectContinue);
}
use of org.gradle.internal.verifier.HttpRedirectVerifier in project gradle by gradle.
the class DefaultObjectConfigurationAction method applyScript.
private void applyScript(Object script) {
URI scriptUri = resolver.resolveUri(script);
TextResource resource;
if (script instanceof TextResource) {
resource = (TextResource) script;
} else {
HttpRedirectVerifier redirectVerifier = createHttpRedirectVerifier(scriptUri);
resource = textUriFileResourceLoaderFactory.create(redirectVerifier).loadUri("script", scriptUri);
}
ScriptSource scriptSource = new TextResourceScriptSource(resource);
ClassLoaderScope classLoaderScopeChild = classLoaderScope.createChild("script-" + scriptUri.toString());
ScriptHandler scriptHandler = scriptHandlerFactory.create(scriptSource, classLoaderScopeChild);
ScriptPlugin configurer = configurerFactory.create(scriptSource, scriptHandler, classLoaderScopeChild, classLoaderScope, false);
for (Object target : targets) {
configurer.apply(target);
}
}
use of org.gradle.internal.verifier.HttpRedirectVerifier in project gradle by gradle.
the class DefaultTextResourceFactory method fromUri.
private TextResource fromUri(Object uri, boolean allowInsecureProtocol) {
URI rootUri = fileOperations.uri(uri);
HttpRedirectVerifier redirectVerifier = HttpRedirectVerifierFactory.create(rootUri, allowInsecureProtocol, () -> throwExceptionDueToInsecureProtocol(rootUri), redirect -> throwExceptionDueToInsecureRedirect(uri, redirect));
return apiTextResourcesAdapterFactory.create(rootUri, redirectVerifier);
}
Aggregations