0

我正在尝试将我的 HttpClient 4.x 代码移植到 5.x

Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
            .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true)).build();

但是在 5.x 中不再有 AuthSchemeProvider,并且 SPNegoSchemeFactory 有一个不同的构造函数:-/

4

1 回答 1

0

这样的事情有什么问题?

final Registry<AuthSchemeFactory> schemeFactoryRegistry = RegistryBuilder.<AuthSchemeFactory>create()
        .register(StandardAuthScheme.BASIC, BasicSchemeFactory.INSTANCE)
        .register(StandardAuthScheme.DIGEST, DigestSchemeFactory.INSTANCE)
        .register(StandardAuthScheme.NTLM, NTLMSchemeFactory.INSTANCE)
        .register(StandardAuthScheme.SPNEGO, new SPNegoSchemeFactory(
                KerberosConfig.custom()
                        .setStripPort(KerberosConfig.Option.DEFAULT)
                        .setUseCanonicalHostname(KerberosConfig.Option.DEFAULT)
                        .build(),
                SystemDefaultDnsResolver.INSTANCE))
        .register(StandardAuthScheme.KERBEROS, KerberosSchemeFactory.DEFAULT)
        .build();
于 2020-06-08T10:01:39.277 回答