solr4.x的kerberos认证


    public static void loginSolr(String username,String password) {
        HttpClientUtil.setConfigurer(new PreemptiveBasicAuthConfigurer());
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(HttpClientUtil.PROP_BASIC_AUTH_USER, username);
        params.set(HttpClientUtil.PROP_BASIC_AUTH_PASS, password);
        PreemptiveBasicAuthConfigurer.setDefaultSolrParams(params);

        try {
            UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
            loginUser.checkTGTAndReloginFromKeytab();
            System.out.println("login success:" + username);
        } catch (IOException e) {
            System.out.println("login failed");
            throw  new RuntimeException(e);
        }

    }
``

你可能感兴趣的:(大数据)