spring-projects / spring-projects/spring-security-kerberos

KerberosRestTemplate does not scale well

Open
#321 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
199
Forks
222
PR merge metrics
No merged PRs in 30d

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating KerberosRestTemplate and reviewing the private static methods that currently force users to copy the class. Define an extension point for customizing the HttpClientBuilder and support the requested constructor parameters and timeout configuration. Done means a subclass can provide these options without copying the implementation, with coverage for the new behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.