protected void login() {
   ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
   try {
     Thread.currentThread().setContextClassLoader(configHolder.getClassLoader());
     String userName = configHolder.getUserName();
     if (userName == null) {
       throw new HadoopException(
           "Unable to find login username for hadoop environment, [" + dataSource + "]");
     }
     String keyTabFile = configHolder.getKeyTabFile();
     if (keyTabFile != null) {
       if (UserGroupInformation.isSecurityEnabled()) {
         loginSubject = SecureClientLogin.loginUserFromKeytab(userName, keyTabFile);
       } else {
         loginSubject = SecureClientLogin.login(userName);
       }
     } else {
       String password = configHolder.getPassword();
       if (UserGroupInformation.isSecurityEnabled()) {
         loginSubject = SecureClientLogin.loginUserWithPassword(userName, password);
       } else {
         loginSubject = SecureClientLogin.login(userName);
       }
     }
   } catch (IOException ioe) {
     throw new HadoopException("Unable to login to Hadoop environment [" + dataSource + "]", ioe);
   } finally {
     Thread.currentThread().setContextClassLoader(prevCl);
   }
 }
  protected void login() {
    ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
    String errMsg =
        " You can still save the repository and start creating "
            + "policies, but you would not be able to use autocomplete for "
            + "resource names. Check xa_portal.log for more info.";
    try {
      // Thread.currentThread().setContextClassLoader(configHolder.getClassLoader());
      String userName = configHolder.getUserName();
      if (userName == null) {
        String msgDesc =
            "Unable to find login username for hadoop environment, [" + serviceName + "]";
        HadoopException hdpException = new HadoopException(msgDesc);
        hdpException.generateResponseDataMap(false, msgDesc + errMsg, msgDesc + errMsg, null, null);

        throw hdpException;
      }
      String keyTabFile = configHolder.getKeyTabFile();
      if (keyTabFile != null) {
        if (configHolder.isKerberosAuthentication()) {
          LOG.info("Init Login: security enabled, using username/keytab");
          loginSubject = SecureClientLogin.loginUserFromKeytab(userName, keyTabFile);
        } else {
          LOG.info("Init Login: using username");
          loginSubject = SecureClientLogin.login(userName);
        }
      } else {
        String password = configHolder.getPassword();
        if (configHolder.isKerberosAuthentication()) {
          LOG.info("Init Login: using username/password");
          loginSubject = SecureClientLogin.loginUserWithPassword(userName, password);
        } else {
          LOG.info("Init Login: security not enabled, using username");
          loginSubject = SecureClientLogin.login(userName);
        }
      }
    } catch (IOException ioe) {
      String msgDesc = "Unable to login to Hadoop environment [" + serviceName + "]";

      HadoopException hdpException = new HadoopException(msgDesc, ioe);
      hdpException.generateResponseDataMap(
          false, getMessage(ioe) + errMsg, msgDesc + errMsg, null, null);
      throw hdpException;
    } catch (SecurityException se) {
      String msgDesc = "Unable to login to Hadoop environment [" + serviceName + "]";
      HadoopException hdpException = new HadoopException(msgDesc, se);
      hdpException.generateResponseDataMap(
          false, getMessage(se) + errMsg, msgDesc + errMsg, null, null);
      throw hdpException;
    } finally {
      Thread.currentThread().setContextClassLoader(prevCl);
    }
  }