public void configure(DefaultHttpClient httpClient, SolrParams config) {
    super.configure(httpClient, config);

    // Begin change for SDC-2962
    // Instead of checking existence of JAAS file, do the following if solr kerberos is enabled
    //if (System.getProperty(LOGIN_CONFIG_PROP) != null) {
      //String configValue = System.getProperty(LOGIN_CONFIG_PROP);

      //if (configValue != null) {
       // logger.info("Setting up SPNego auth with config: " + configValue);
        final String useSubjectCredsProp = "javax.security.auth.useSubjectCredsOnly";
        String useSubjectCredsVal = System.getProperty(useSubjectCredsProp);

        // "javax.security.auth.useSubjectCredsOnly" should be false so that the underlying
        // authentication mechanism can load the credentials from the JAAS configuration.
        if (useSubjectCredsVal == null) {
          System.setProperty(useSubjectCredsProp, "false");
        }
        else if (!useSubjectCredsVal.toLowerCase(Locale.ROOT).equals("false")) {
          // Don't overwrite the prop value if it's already been written to something else,
          // but log because it is likely the Credentials won't be loaded correctly.
          logger.warn("System Property: " + useSubjectCredsProp + " set to: " + useSubjectCredsVal
              + " not false.  SPNego authentication may not be successful.");
        }

        // Change for SDC-2962
        //javax.security.auth.login.Configuration.setConfiguration(jaasConfig);
        //Enable only SPNEGO authentication scheme.
        AuthSchemeRegistry registry = new AuthSchemeRegistry();
        registry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false));
        httpClient.setAuthSchemes(registry);
        // Get the credentials from the JAAS configuration rather than here
        Credentials useJaasCreds = new Credentials() {
          public String getPassword() {
            return null;
          }
          public Principal getUserPrincipal() {
            return null;
          }
        };

        SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory();
        httpClient.getCookieSpecs().register(cookieFactory.POLICY_NAME, cookieFactory);
        httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, cookieFactory.POLICY_NAME);

        httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, useJaasCreds);

        httpClient.addRequestInterceptor(bufferedEntityInterceptor);
      //} else {
        //httpClient.getCredentialsProvider().clear();
      //}
   // }
  }
public void configure(DefaultHttpClient httpClient, SolrParams config) {
    super.configure(httpClient, config);

    
    
    
      

      
       
        final String useSubjectCredsProp = "javax.security.auth.useSubjectCredsOnly";
        String useSubjectCredsVal = System.getProperty(useSubjectCredsProp);

        
        
        if (useSubjectCredsVal == null) {
          System.setProperty(useSubjectCredsProp, "false");
        }
        else if (!useSubjectCredsVal.toLowerCase(Locale.ROOT).equals("false")) {
          
          
          logger.warn("System Property: " + useSubjectCredsProp + " set to: " + useSubjectCredsVal
              + " not false.  SPNego authentication may not be successful.");
        }

        
        
        
        AuthSchemeRegistry registry = new AuthSchemeRegistry();
        registry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false));
        httpClient.setAuthSchemes(registry);
        
        Credentials useJaasCreds = new Credentials() {
          public String getPassword() {
            return null;
          }
          public Principal getUserPrincipal() {
            return null;
          }
        };

        SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory();
        httpClient.getCookieSpecs().register(cookieFactory.POLICY_NAME, cookieFactory);
        httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, cookieFactory.POLICY_NAME);

        httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, useJaasCreds);

        httpClient.addRequestInterceptor(bufferedEntityInterceptor);
      
        
      
   
  }
public void configure ( DefaultHttpClient httpClient , SolrParams config ) { super . configure ( httpClient , config ) ; // Begin change for SDC-2962 // Instead of checking existence of JAAS file, do the following if solr kerberos is enabled //if (System.getProperty(LOGIN_CONFIG_PROP) != null) { //String configValue = System.getProperty(LOGIN_CONFIG_PROP); //if (configValue != null) { // logger.info("Setting up SPNego auth with config: " + configValue); final String useSubjectCredsProp = "javax.security.auth.useSubjectCredsOnly" ; String useSubjectCredsVal = System . getProperty ( useSubjectCredsProp ) ; // "javax.security.auth.useSubjectCredsOnly" should be false so that the underlying // authentication mechanism can load the credentials from the JAAS configuration. if ( useSubjectCredsVal == null ) { System . setProperty ( useSubjectCredsProp , "false" ) ; } else if ( ! useSubjectCredsVal . toLowerCase ( Locale . ROOT ) . equals ( "false" ) ) { // Don't overwrite the prop value if it's already been written to something else, // but log because it is likely the Credentials won't be loaded correctly. logger . warn ( "System Property: " + useSubjectCredsProp + " set to: " + useSubjectCredsVal + " not false.  SPNego authentication may not be successful." ) ; } // Change for SDC-2962 //javax.security.auth.login.Configuration.setConfiguration(jaasConfig); //Enable only SPNEGO authentication scheme. AuthSchemeRegistry registry = new AuthSchemeRegistry ( ) ; registry . register ( AuthSchemes . SPNEGO , new SPNegoSchemeFactory ( true , false ) ) ; httpClient . setAuthSchemes ( registry ) ; // Get the credentials from the JAAS configuration rather than here Credentials useJaasCreds = new Credentials ( ) { public String getPassword ( ) { return null ; } public Principal getUserPrincipal ( ) { return null ; } } ; SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory ( ) ; httpClient . getCookieSpecs ( ) . register ( cookieFactory . POLICY_NAME , cookieFactory ) ; httpClient . getParams ( ) . setParameter ( ClientPNames . COOKIE_POLICY , cookieFactory . POLICY_NAME ) ; httpClient . getCredentialsProvider ( ) . setCredentials ( AuthScope . ANY , useJaasCreds ) ; httpClient . addRequestInterceptor ( bufferedEntityInterceptor ) ; //} else { //httpClient.getCredentialsProvider().clear(); //} // } }
private static final Configuration jaasConfig = new org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer.SolrJaasConfiguration();
private static final Configuration jaasConfig = new org . apache . solr . client . solrj . impl . Krb5HttpClientConfigurer . SolrJaasConfiguration () ;