You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by lm...@apache.org on 2017/02/04 20:04:59 UTC

[1/3] knox git commit: checkpoint

Repository: knox
Updated Branches:
  refs/heads/knoxinit d6fda9c8d -> 54281ba58


checkpoint


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/b5bf07d7
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/b5bf07d7
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/b5bf07d7

Branch: refs/heads/knoxinit
Commit: b5bf07d7d8ebee2861054a516d21c32912cd7f82
Parents: d6fda9c
Author: Larry McCay <lm...@hortonworks.com>
Authored: Sun Jan 29 08:49:34 2017 -0500
Committer: Larry McCay <lm...@hortonworks.com>
Committed: Sun Jan 29 08:49:34 2017 -0500

----------------------------------------------------------------------
 gateway-shell/pom.xml                           |   4 +
 .../org/apache/hadoop/gateway/shell/Hadoop.java | 110 ++-------
 .../org/apache/hadoop/gateway/shell/KnoxSh.java | 246 +++++++++++++++++++
 pom.xml                                         |   5 +
 4 files changed, 274 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/b5bf07d7/gateway-shell/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-shell/pom.xml b/gateway-shell/pom.xml
index a6f1ea2..f17cfd8 100644
--- a/gateway-shell/pom.xml
+++ b/gateway-shell/pom.xml
@@ -65,6 +65,10 @@
             <artifactId>httpclient</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+        </dependency>
+        <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/knox/blob/b5bf07d7/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
index b2e186f..6bb6ba2 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
@@ -91,7 +91,7 @@ public class Hadoop implements Closeable {
   public void setHeaders(Map<String, String> headers) {
     this.headers = headers;
   }
-
+  
   public static Hadoop login( String url, String username, String password ) throws URISyntaxException {
     return new Hadoop(ClientContext.with(username, password, url));
   }
@@ -101,29 +101,11 @@ public class Hadoop implements Closeable {
             .connection().secure(false).end());
   }
 
-<<<<<<< Updated upstream
   public Hadoop( ClientContext clientContext) throws HadoopException, URISyntaxException {
-=======
-  public static Hadoop login(String url, Map<String, String> headers) throws URISyntaxException {
-    return new Hadoop( url, headers, true );
-  }
-
-  private Hadoop( String url, Map<String, String> headers ) throws HadoopException, URISyntaxException {
-    this(url, null, null, false);
-    this.headers = headers;
-  }
-
-  private Hadoop( String url, String username, String password ) throws HadoopException, URISyntaxException {
-    this(url, username, password, false);
-  }
-
-  private Hadoop( String url, String username, String password, boolean secure ) throws HadoopException, URISyntaxException {
->>>>>>> Stashed changes
     this.executor = Executors.newCachedThreadPool();
     this.base = clientContext.url();
 
     try {
-<<<<<<< Updated upstream
       client = createClient(clientContext);
     } catch (GeneralSecurityException e) {
       throw new HadoopException("Failed to create HTTP client.", e);
@@ -147,63 +129,6 @@ public class Hadoop implements Closeable {
               + "*******************************************");
     }
 
-=======
-      if (!secure) {
-        client = createInsecureClient();
-      }
-      else {
-        client = createClient();
-      }
-      if (username != null && password != null) {
-        client.getCredentialsProvider().setCredentials(
-            new AuthScope( host.getHostName(), host.getPort() ),
-            new UsernamePasswordCredentials( username, password ) );
-        AuthCache authCache = new BasicAuthCache();
-        BasicScheme authScheme = new BasicScheme();
-        authCache.put( host, authScheme );
-        context = new BasicHttpContext();
-        context.setAttribute( ClientContext.AUTH_CACHE, authCache );
-      }
-    } catch( GeneralSecurityException e ) {
-      throw new HadoopException( "Failed to create HTTP client.", e );
-    }
-  }
-
-  private Hadoop(String url, Map<String,String> headers, boolean secure)
-      throws HadoopException, URISyntaxException {
-    this.executor = Executors.newCachedThreadPool();
-    this.base = url;
-    this.headers = headers;
-
-    URI uri = new URI( url );
-    host = new HttpHost( uri.getHost(), uri.getPort(), uri.getScheme() );
-
-    try {
-      if (!secure) {
-        client = createInsecureClient();
-      }
-      else {
-        client = createClient();
-      }
-      if (username != null && password != null) {
-        client.getCredentialsProvider().setCredentials(
-            new AuthScope( host.getHostName(), host.getPort() ),
-            new UsernamePasswordCredentials( username, password ) );
-        AuthCache authCache = new BasicAuthCache();
-        BasicScheme authScheme = new BasicScheme();
-        authCache.put( host, authScheme );
-        context = new BasicHttpContext();
-        context.setAttribute( ClientContext.AUTH_CACHE, authCache );
-      }
-    } catch( GeneralSecurityException e ) {
-      throw new HadoopException( "Failed to create HTTP client.", e );
-    }
-  }
-
-
-  private static DefaultHttpClient createClient() throws GeneralSecurityException {
-    SchemeRegistry registry = new SchemeRegistry();
->>>>>>> Stashed changes
     KeyStore trustStore = getTrustStore();
     SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(trustStore, trustStrategy).build();
     Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
@@ -232,22 +157,25 @@ public class Hadoop implements Closeable {
     // Auth
     URI uri = URI.create(clientContext.url());
     host = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
-
-    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-    credentialsProvider.setCredentials(
-            new AuthScope(host.getHostName(), host.getPort()),
-            new UsernamePasswordCredentials(clientContext.username(), clientContext.password()));
-
-    AuthCache authCache = new BasicAuthCache();
-    BasicScheme authScheme = new BasicScheme();
-    authCache.put(host, authScheme);
-    context = new BasicHttpContext();
-    context.setAttribute(org.apache.http.client.protocol.HttpClientContext.AUTH_CACHE, authCache);
-
+    
+    CredentialsProvider credentialsProvider = null; 
+    if (clientContext.username() != null && clientContext.password() != null) {
+      credentialsProvider = new BasicCredentialsProvider();
+      credentialsProvider.setCredentials(
+              new AuthScope(host.getHostName(), host.getPort()),
+              new UsernamePasswordCredentials(clientContext.username(), clientContext.password()));
+  
+      AuthCache authCache = new BasicAuthCache();
+      BasicScheme authScheme = new BasicScheme();
+      authCache.put(host, authScheme);
+      context = new BasicHttpContext();
+      context.setAttribute(org.apache.http.client.protocol.HttpClientContext.AUTH_CACHE, authCache);
+    }
     return HttpClients.custom()
-            .setConnectionManager(connectionManager)
-            .setDefaultCredentialsProvider(credentialsProvider)
-            .build();
+        .setConnectionManager(connectionManager)
+        .setDefaultCredentialsProvider(credentialsProvider)
+        .build();
+
   }
 
   private static KeyStore getTrustStore() throws GeneralSecurityException {

http://git-wip-us.apache.org/repos/asf/knox/blob/b5bf07d7/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
new file mode 100644
index 0000000..088bd6c
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
@@ -0,0 +1,246 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.shell;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.hadoop.gateway.shell.knox.token.Token;
+import org.apache.hadoop.gateway.util.JsonUtils;
+
+/**
+ *
+ */
+public class KnoxSh {
+
+  private static final String USAGE_PREFIX = "KnoxCLI {cmd} [options]";
+  final static private String COMMANDS =
+      "   [--help]\n" +
+      "   [" + KnoxInit.USAGE + "]\n" +
+      "   [" + KnoxDestroy.USAGE + "]\n" +
+      "   [" + KnoxList.USAGE + "]\n";
+
+  /** allows stdout to be captured if necessary */
+  public PrintStream out = System.out;
+  /** allows stderr to be captured if necessary */
+  public PrintStream err = System.err;
+
+  private Command command;
+  private String gateway = null;
+  /* (non-Javadoc)
+   * @see org.apache.hadoop.util.Tool#run(java.lang.String[])
+   */
+  public int run(String[] args) throws Exception {
+    int exitCode = 0;
+    try {
+      exitCode = init(args);
+      if (exitCode != 0) {
+        return exitCode;
+      }
+      if (command != null && command.validate()) {
+        command.execute();
+      } else {
+        out.println("ERROR: Invalid Command" + "\n" + "Unrecognized option:" +
+            args[0] + "\n" +
+            "A fatal exception has occurred. Program will exit.");
+        exitCode = -2;
+      }
+    } catch (Exception e) {
+      e.printStackTrace( err );
+      err.flush();
+      return -3;
+    }
+    return exitCode;
+  }
+
+  /**
+   * Parse the command line arguments and initialize the data
+   * <pre>
+   * % knoxcli version
+   * % knoxcli service-test [--u user] [--p password] [--cluster clustername] [--hostname name] [--port port]
+   *
+   * </pre>
+   * @param args
+   * @return
+   * @throws IOException
+   */
+  private int init(String[] args) throws IOException {
+    if (args.length == 0) {
+      printKnoxShellUsage();
+      return -1;
+    }
+    for (int i = 0; i < args.length; i++) { // parse command line
+      if ( args[i].equals("destroy") ) {
+        command = new KnoxDestroy();
+      } else if ( args[i].equals("init") ) {
+        command = new KnoxInit();
+      } else if ( args[i].equals("list") ) {
+        command = new KnoxList();
+      } else if (args[i].equals("--gateway")) {
+        if( i+1 >= args.length || args[i+1].startsWith( "-" ) ) {
+          printKnoxShellUsage();
+          return -1;
+        }
+        this.gateway = args[++i];
+      } else if (args[i].equals("--help")) {
+        printKnoxShellUsage();
+        return -1;
+      } else {
+        printKnoxShellUsage();
+        //ToolRunner.printGenericCommandUsage(System.err);
+        return -1;
+      }
+    }
+    return 0;
+  }
+
+  private void printKnoxShellUsage() {
+    out.println( USAGE_PREFIX + "\n" + COMMANDS );
+    if ( command != null ) {
+      out.println(command.getUsage());
+    } else {
+      char[] chars = new char[79];
+      Arrays.fill( chars, '=' );
+      String div = new String( chars );
+
+      out.println( div );
+      out.println( KnoxInit.USAGE + "\n\n" + KnoxInit.DESC );
+      out.println();
+      out.println( div );
+      out.println(KnoxDestroy.USAGE + "\n\n" + KnoxDestroy.DESC);
+      out.println();
+      out.println( div );
+      out.println(KnoxList.USAGE + "\n\n" + KnoxList.DESC);
+      out.println();
+      out.println( div );
+    }
+  }
+
+  private abstract class Command {
+    public boolean validate() {
+      return true;
+    }
+
+    public abstract void execute() throws Exception;
+
+    public abstract String getUsage();
+  }
+
+  private class KnoxInit extends Command {
+
+    public static final String USAGE = "init";
+    public static final String DESC = "Initializes a Knox token session.";
+
+    @Override
+    public void execute() throws Exception {
+      Credentials credentials = new Credentials();
+      credentials.add("ClearInput", "Enter username: ", "user")
+                      .add("HiddenInput", "Enter pas" + "sword: ", "pass");
+      credentials.collect();
+
+      String username = credentials.get("user").string();
+      String pass = credentials.get("pass").string();
+
+      if (gateway == null) {
+        gateway = System.getenv("GATEWAY_HOME");
+      }
+
+      Hadoop session = Hadoop.login(gateway, username, pass);
+
+      String text = Token.get( session ).now().toString();
+      Map<String, String> json = JsonUtils.getMapFromJsonString(text);
+
+      //println "Access Token: " + json.access_token
+      System.out.println("knoxinit successful!");
+      System.out.println("Token Type: " + json.get("token_type"));
+      System.out.println("Expires On: " + new Date(json.get("expires_in")));
+
+      File tokenfile = new File(System.getProperty("user.home"), ".knoxtokencache");
+      FileOutputStream fos = new FileOutputStream(tokenfile);
+      fos.write(text.getBytes("UTF-8"));
+
+      Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
+      fos.close();
+
+      //add owners permission only
+      perms.add(PosixFilePermission.OWNER_READ);
+      perms.add(PosixFilePermission.OWNER_WRITE);
+
+      Files.setPosixFilePermissions(Paths.get(System.getProperty("user.home") + "/.knoxtokencache"), perms);
+
+      session.shutdown();
+    }
+
+    @Override
+    public String getUsage() {
+      return USAGE + ":\n\n" + DESC;
+    }
+
+  }
+
+  private class KnoxDestroy extends Command {
+
+    public static final String USAGE = "version";
+    public static final String DESC = "Displays Knox version information.";
+
+    @Override
+    public void execute() throws Exception {
+    }
+
+    @Override
+    public String getUsage() {
+      return USAGE + ":\n\n" + DESC;
+    }
+
+  }
+
+  private class KnoxList extends Command {
+
+    public static final String USAGE = "version";
+    public static final String DESC = "Displays Knox version information.";
+
+    @Override
+    public void execute() throws Exception {
+    }
+
+    @Override
+    public String getUsage() {
+      return USAGE + ":\n\n" + DESC;
+    }
+
+  }
+
+  /**
+   * @param args
+   * @throws Exception
+   */
+  public static void main(String[] args) throws Exception {
+    KnoxSh sh = new KnoxSh();
+    int res = sh.run(args);
+    System.exit(res);
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/b5bf07d7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c317165..ed49cd8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -790,6 +790,11 @@
                 <version>4.5.1</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpcore</artifactId>
+                <version>4.4.6</version>
+            </dependency>
+            <dependency>
                 <groupId>joda-time</groupId>
                 <artifactId>joda-time</artifactId>
                 <version>2.9.2</version>


[3/3] knox git commit: checkpoint

Posted by lm...@apache.org.
checkpoint

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/54281ba5
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/54281ba5
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/54281ba5

Branch: refs/heads/knoxinit
Commit: 54281ba585b67c8cd387c0076bc9d86184fd8351
Parents: b8a2b11
Author: Larry McCay <lm...@hortonworks.com>
Authored: Sat Feb 4 15:04:47 2017 -0500
Committer: Larry McCay <lm...@hortonworks.com>
Committed: Sat Feb 4 15:04:47 2017 -0500

----------------------------------------------------------------------
 gateway-shell/pom.xml                           |  5 --
 .../hadoop/gateway/shell/ClientContext.java     |  7 ++-
 .../org/apache/hadoop/gateway/shell/Hadoop.java |  8 ++-
 .../org/apache/hadoop/gateway/shell/KnoxSh.java | 53 ++++++++++++++++++--
 4 files changed, 63 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/54281ba5/gateway-shell/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-shell/pom.xml b/gateway-shell/pom.xml
index a91ade1..a6f1ea2 100644
--- a/gateway-shell/pom.xml
+++ b/gateway-shell/pom.xml
@@ -65,11 +65,6 @@
             <artifactId>httpclient</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpcore</artifactId>
-            <version>4.4.6</version>
-         </dependency>
-        <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/knox/blob/54281ba5/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/ClientContext.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/ClientContext.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/ClientContext.java
index 6055f68..b83daf4 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/ClientContext.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/ClientContext.java
@@ -191,6 +191,12 @@ public class ClientContext {
     return context;
   }
 
+  public static ClientContext with(final String url) {
+    ClientContext context = new ClientContext();
+    context.configuration.addProperty("url", url);
+    return context;
+  }
+
   public String username() {
     return configuration.getString("username");
   }
@@ -202,5 +208,4 @@ public class ClientContext {
   public String url() {
     return configuration.getString("url");
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/54281ba5/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
index 6bb6ba2..ed0feb3 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/Hadoop.java
@@ -91,7 +91,13 @@ public class Hadoop implements Closeable {
   public void setHeaders(Map<String, String> headers) {
     this.headers = headers;
   }
-  
+
+  public static Hadoop login( String url, Map<String,String> headers ) throws URISyntaxException {
+    Hadoop instance = new Hadoop(ClientContext.with(url));
+    instance.setHeaders(headers);
+    return instance;
+  }
+
   public static Hadoop login( String url, String username, String password ) throws URISyntaxException {
     return new Hadoop(ClientContext.with(username, password, url));
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/54281ba5/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
index 088bd6c..468b6b7 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/KnoxSh.java
@@ -17,14 +17,20 @@
  */
 package org.apache.hadoop.gateway.shell;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.nio.file.attribute.PosixFilePermission;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Map;
@@ -171,13 +177,12 @@ public class KnoxSh {
 
       Hadoop session = Hadoop.login(gateway, username, pass);
 
-      String text = Token.get( session ).now().toString();
+      String text = Token.get( session ).now().getString();
       Map<String, String> json = JsonUtils.getMapFromJsonString(text);
 
       //println "Access Token: " + json.access_token
       System.out.println("knoxinit successful!");
-      System.out.println("Token Type: " + json.get("token_type"));
-      System.out.println("Expires On: " + new Date(json.get("expires_in")));
+      displayTokenDetails(json);
 
       File tokenfile = new File(System.getProperty("user.home"), ".knoxtokencache");
       FileOutputStream fos = new FileOutputStream(tokenfile);
@@ -209,6 +214,8 @@ public class KnoxSh {
 
     @Override
     public void execute() throws Exception {
+      File tokenfile = new File(System.getProperty("user.home"), ".knoxtokencache");
+      tokenfile.delete();
     }
 
     @Override
@@ -225,6 +232,14 @@ public class KnoxSh {
 
     @Override
     public void execute() throws Exception {
+      String tokenfile = readFile(
+          System.getProperty("user.home") +
+          File.separator + ".knoxtokencache");
+
+      if (tokenfile != null) {
+        Map<String, String> json = JsonUtils.getMapFromJsonString(tokenfile);
+        displayTokenDetails(json);
+      }
     }
 
     @Override
@@ -234,6 +249,38 @@ public class KnoxSh {
 
   }
 
+  private void displayTokenDetails(Map<String, String> json) {
+    System.out.println("Token Type: " + json.get("token_type"));
+
+    DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
+
+    long milliSeconds= Long.parseLong(json.get("expires_in"));
+
+    Calendar calendar = Calendar.getInstance();
+    calendar.setTimeInMillis(milliSeconds);
+    System.out.println("Expires On: " + formatter.format(calendar.getTime()));
+  }
+
+  private String readFile(String file) throws IOException {
+    BufferedReader reader = new BufferedReader(new FileReader (file));
+    String line = null;
+    String content = null;
+    StringBuilder  stringBuilder = new StringBuilder();
+    String ls = System.getProperty("line.separator");
+
+    try {
+        while((line = reader.readLine()) != null) {
+            stringBuilder.append(line);
+            stringBuilder.append(ls);
+        }
+
+        content = stringBuilder.toString();
+    } finally {
+        reader.close();
+    }
+    return content;
+}
+
   /**
    * @param args
    * @throws Exception


[2/3] knox git commit: checkpoint

Posted by lm...@apache.org.
checkpoint

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/b8a2b11e
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/b8a2b11e
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/b8a2b11e

Branch: refs/heads/knoxinit
Commit: b8a2b11e717dee7ad79257753b42b06e080ab2cf
Parents: b5bf07d
Author: Larry McCay <lm...@hortonworks.com>
Authored: Sun Jan 29 10:09:14 2017 -0500
Committer: Larry McCay <lm...@hortonworks.com>
Committed: Sun Jan 29 10:09:14 2017 -0500

----------------------------------------------------------------------
 gateway-shell/pom.xml | 3 ++-
 pom.xml               | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/b8a2b11e/gateway-shell/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-shell/pom.xml b/gateway-shell/pom.xml
index f17cfd8..a91ade1 100644
--- a/gateway-shell/pom.xml
+++ b/gateway-shell/pom.xml
@@ -67,7 +67,8 @@
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpcore</artifactId>
-        </dependency>
+            <version>4.4.6</version>
+         </dependency>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>

http://git-wip-us.apache.org/repos/asf/knox/blob/b8a2b11e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ed49cd8..d6a8e41 100644
--- a/pom.xml
+++ b/pom.xml
@@ -787,13 +787,13 @@
             <dependency>
                 <groupId>org.apache.httpcomponents</groupId>
                 <artifactId>httpclient</artifactId>
-                <version>4.5.1</version>
+                <version>4.5.2</version>
             </dependency>
-            <dependency>
+            <!-- dependency>
                 <groupId>org.apache.httpcomponents</groupId>
                 <artifactId>httpcore</artifactId>
                 <version>4.4.6</version>
-            </dependency>
+            </dependency-->
             <dependency>
                 <groupId>joda-time</groupId>
                 <artifactId>joda-time</artifactId>