Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -120,6 +121,7 @@ public class RestLookupService extends AbstractControllerService implements Reco
.required(false)
.identifiesControllerService(SSLContextService.class)
.build();

public static final PropertyDescriptor PROP_BASIC_AUTH_USERNAME = new PropertyDescriptor.Builder()
.name("rest-lookup-basic-auth-username")
.displayName("Basic Authentication Username")
Expand All @@ -138,6 +140,7 @@ public class RestLookupService extends AbstractControllerService implements Reco
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.createRegexMatchingValidator(Pattern.compile("^[\\x20-\\x7e\\x80-\\xff]+$")))
.build();

public static final PropertyDescriptor PROP_DIGEST_AUTH = new PropertyDescriptor.Builder()
.name("rest-lookup-digest-auth")
.displayName("Use Digest Authentication")
Expand All @@ -148,6 +151,24 @@ public class RestLookupService extends AbstractControllerService implements Reco
.allowableValues("true", "false")
.build();

public static final PropertyDescriptor PROP_CONNECT_TIMEOUT = new PropertyDescriptor.Builder()
.name("rest-lookup-connection-timeout")
.displayName("Connection Timeout")
.description("Max wait time for connection to remote service.")
.required(true)
.defaultValue("5 secs")
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.build();

public static final PropertyDescriptor PROP_READ_TIMEOUT = new PropertyDescriptor.Builder()
.name("rest-lookup-read-timeout")
.displayName("Read Timeout")
.description("Max wait time for response from remote service.")
.required(true)
.defaultValue("15 secs")
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.build();

private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH, ProxySpec.SOCKS};
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE
= ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS);
Expand All @@ -170,7 +191,9 @@ public class RestLookupService extends AbstractControllerService implements Reco
PROXY_CONFIGURATION_SERVICE,
PROP_BASIC_AUTH_USERNAME,
PROP_BASIC_AUTH_PASSWORD,
PROP_DIGEST_AUTH
PROP_DIGEST_AUTH,
PROP_CONNECT_TIMEOUT,
PROP_READ_TIMEOUT
));
KEYS = Collections.emptySet();
}
Expand Down Expand Up @@ -199,6 +222,10 @@ public void onEnabled(final ConfigurationContext context) {

setAuthenticator(builder, context);

// Set timeouts
builder.connectTimeout((context.getProperty(PROP_CONNECT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()), TimeUnit.MILLISECONDS);
builder.readTimeout(context.getProperty(PROP_READ_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(), TimeUnit.MILLISECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this change?


if (proxyConfigurationService != null) {
setProxy(builder);
}
Expand Down