Skip to content

KerberosRestTemplate does not scale well #321

Description

@Marat-Tim

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);
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions