我可以通过使用keytab来验证使用kerberized的solr。但是无法使用solrj在Java客户端中直接使用简单的用户名和密码进行身份验证。
我尝试使用SolrHttpClientBuilder.CredentialsProviderProvider。但这是行不通的。有什么方法可以像基本身份验证那样使用直接的用户名和密码进行身份验证。
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("xczc", "zxczx#123");
AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, null);
provider.setCredentials(scope, credentials);
Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.KERBEROS, new KerberosSchemeFactory(true)).build();
CloseableHttpClient httpclient1 = HttpClients.custom().setDefaultAuthSchemeRegistry(authSchemeRegistry)
.setDefaultCredentialsProvider(provider).build();
SolrClient client = solrClientBuilder.withHttpClient(httpclient1).build();