package com.lucidworks.hadoop.utils;

import org.apache.hadoop.conf.Configuration;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Security {
  public static final String LWW_JAAS_FILE = "lww.jaas.file";
  public static final String LWW_JAAS_APPNAME = "lww.jaas.appname";

  private static Logger log = LoggerFactory.getLogger(Security.class);

  public static void setSecurityConfig(Configuration job) {
    final String jaasFile = job.get(LWW_JAAS_FILE);
    if (jaasFile != null) {
      log.debug("Using kerberized Solr.");
      System.setProperty("java.security.auth.login.config", jaasFile);
      final String appname = job.get(LWW_JAAS_APPNAME, "Client");
      System.setProperty("solr.kerberos.jaas.appname", appname);
      HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
    }
  }
}

@@ -411,16 +411,298 @@
 ppname%22;
+%0A  public static final String LWW_KEYSTORE = %22lww.keystore%22;%0A  public static final String LWW_KEYSTOREPASSWORD = %22lww.keystore.password%22;%0A  public static final String LWW_TRUSTSTORE = %22lww.truststore%22;%0A  public static final String LWW_TRUSTSTOREPASSWORD = %22lww.truststore.password%22;
 %0A%0A  priv
@@ -767,16 +767,54 @@
 lass);%0A%0A
+  // Sets Security features if needed%0A
   public
@@ -1186,24 +1186,24 @@
 , appname);%0A
-
       HttpCl
@@ -1264,14 +1264,782 @@
 ;%0A    %7D%0A
+    final String keystore = job.get(LWW_KEYSTORE);%0A    if (keystore != null) %7B%0A      log.debug(%22Using keystore: %22 + keystore);%0A      System.setProperty(%22javax.net.ssl.keyStore%22, keystore);%0A    %7D%0A    final String keystorePassword = job.get(LWW_KEYSTOREPASSWORD);%0A    if (keystore != null) %7B%0A      System.setProperty(%22javax.net.ssl.keyStorePassword%22, keystorePassword);%0A    %7D%0A    final String truststore = job.get(LWW_TRUSTSTORE);%0A    if (keystore != null) %7B%0A      log.debug(%22Using truststore: %22 + truststore);%0A      System.setProperty(%22javax.net.ssl.trustStore%22, truststore);%0A    %7D%0A    final String truststorePassword = job.get(LWW_TRUSTSTOREPASSWORD);%0A    if (keystore != null) %7B%0A      System.setProperty(%22javax.net.ssl.trustStorePassword%22, truststorePassword);%0A    %7D%0A
   %7D%0A%7D%0A

Add ssl support.