-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Description
I want to create a KerberosRestTemplate extension with userPrincipal, password, and loginOptions parameters. I also want to configure the timeout. Currently, this requires copying classes and methods, as they are private static. This means that you have to copy the entire class code
But I want it to be
import java.util.Map;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.core5.util.Timeout;
import org.springframework.security.kerberos.client.KerberosRestTemplate;
public class CustomKerberosRestTemplate extends KerberosRestTemplate {
public CustomKerberosRestTemplate(
String userPrincipal,
String password,
Map<String, Object> loginOptions
) {
super(null, userPrincipal, password, loginOptions);
}
@Override
protected void customizeHttpClient(HttpClientBuilder builder) {
PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
.setDefaultConnectionConfig(ConnectionConfig.custom()
.setSocketTimeout(Timeout.ofSeconds(10))
.setConnectTimeout(Timeout.ofSeconds(10))
.build())
.build();
builder.setConnectionManager(connectionManager);
}
}
Metadata
Metadata
Assignees
Labels
No labels