提问者:小点点

Apache HttpComponents HttpClient 5.0-KerberosSPNEGO客户端


我正在尝试移植我的HttpClient 4。x代码为5。x

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

但是在5。x不再有AuthSchemeProvider,SPNegoSchemeFactory具有不同的构造函数:-/


共1个答案

匿名用户

这样的事情怎么了?

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