You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by el...@apache.org on 2017/08/11 03:47:32 UTC
[1/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Repository: hbase
Updated Branches:
refs/heads/branch-1 97c6ee512 -> d72ba890d
refs/heads/branch-1.1 b74576e2e -> ebc1d2bf2
refs/heads/branch-1.2 9f809748d -> a732b67ce
refs/heads/branch-1.3 d87b63e73 -> a2a28a780
refs/heads/branch-2 8197a31bb -> ee15c2c29
refs/heads/master 4dd24c52b -> 8da77b414
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d72ba890
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d72ba890
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d72ba890
Branch: refs/heads/branch-1
Commit: d72ba890d9dedd7a58d5d36a54d31b47dcd6d035
Parents: 97c6ee5
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:15:40 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/d72ba890/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 6578bb4..d2ddcc7 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
4. Here is a lazy example that just pulls in all hbase dependency jars and that goes against default location on localhost.
It should work with a standalone hbase instance started by doing ./bin/start-hbase.sh:
{java -cp ./hbase-examples/target/hbase-examples-2.0.0-SNAPSHOT.jar:`./bin/hbase classpath` org.apache.hadoop.hbase.thrift.DemoClient localhost 9090}
http://git-wip-us.apache.org/repos/asf/hbase/blob/d72ba890/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index 64adc93..e5400f3 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}
[2/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Posted by el...@apache.org.
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a2a28a78
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a2a28a78
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a2a28a78
Branch: refs/heads/branch-1.3
Commit: a2a28a7806549b3dd337163432ad12d944add634
Parents: d87b63e
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:27:03 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/a2a28a78/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 6578bb4..d2ddcc7 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
4. Here is a lazy example that just pulls in all hbase dependency jars and that goes against default location on localhost.
It should work with a standalone hbase instance started by doing ./bin/start-hbase.sh:
{java -cp ./hbase-examples/target/hbase-examples-2.0.0-SNAPSHOT.jar:`./bin/hbase classpath` org.apache.hadoop.hbase.thrift.DemoClient localhost 9090}
http://git-wip-us.apache.org/repos/asf/hbase/blob/a2a28a78/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index 64adc93..e5400f3 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}
[4/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Posted by el...@apache.org.
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ebc1d2bf
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ebc1d2bf
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ebc1d2bf
Branch: refs/heads/branch-1.1
Commit: ebc1d2bf2c52bbaf5e2bc81afab6298558978239
Parents: b74576e
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:44:00 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ebc1d2bf/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 700e41f..bc82595 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
* Ruby: hbase-examples/src/main/ruby/DemoClient.rb
1. Modify the import path in the file to point to {$THRIFT_HOME}/lib/rb/lib.
http://git-wip-us.apache.org/repos/asf/hbase/blob/ebc1d2bf/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index 64adc93..e5400f3 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}
[5/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Posted by el...@apache.org.
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8da77b41
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8da77b41
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8da77b41
Branch: refs/heads/master
Commit: 8da77b414657f0ee3b093913de5f92eba17ecd2a
Parents: 4dd24c5
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:47:07 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/8da77b41/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 22d1103..bf28180 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
4. Here is a lazy example that just pulls in all hbase dependency jars and that goes against default location on localhost.
It should work with a standalone hbase instance started by doing ./bin/start-hbase.sh:
{java -cp ./hbase-examples/target/hbase-examples-2.0.0-SNAPSHOT.jar:`./bin/hbase classpath` org.apache.hadoop.hbase.thrift.DemoClient localhost 9090}
http://git-wip-us.apache.org/repos/asf/hbase/blob/8da77b41/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index cb0cfbb..706f82f 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}
[6/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Posted by el...@apache.org.
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ee15c2c2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ee15c2c2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ee15c2c2
Branch: refs/heads/branch-2
Commit: ee15c2c296d49e943c61b99e851449ee94394621
Parents: 8197a31
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:47:17 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ee15c2c2/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 22d1103..bf28180 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
4. Here is a lazy example that just pulls in all hbase dependency jars and that goes against default location on localhost.
It should work with a standalone hbase instance started by doing ./bin/start-hbase.sh:
{java -cp ./hbase-examples/target/hbase-examples-2.0.0-SNAPSHOT.jar:`./bin/hbase classpath` org.apache.hadoop.hbase.thrift.DemoClient localhost 9090}
http://git-wip-us.apache.org/repos/asf/hbase/blob/ee15c2c2/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index cb0cfbb..706f82f 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}
[3/6] hbase git commit: HBASE-18387: [Thrift] Make principal
configurable in DemoClient.java
Posted by el...@apache.org.
HBASE-18387: [Thrift] Make principal configurable in DemoClient.java
Added optional (fourth) parameter "server-principal"
The solution is backward compatible, in case not given, uses "hbase" as default value
If the third parameter is skipped the fourth cannot be set.
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a732b67c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a732b67c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a732b67c
Branch: refs/heads/branch-1.2
Commit: a732b67ce8c7c08f867807ce7f1b0b47352a7d5e
Parents: 9f80974
Author: Tamas Penzes <ta...@cloudera.com>
Authored: Tue Aug 8 13:45:09 2017 +0200
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 10 23:38:15 2017 -0400
----------------------------------------------------------------------
hbase-examples/README.txt | 3 ++-
.../org/apache/hadoop/hbase/thrift/DemoClient.java | 15 ++++++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/a732b67c/hbase-examples/README.txt
----------------------------------------------------------------------
diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index 6578bb4..d2ddcc7 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -28,7 +28,8 @@ Example code.
2. If HBase server is not secure, or authentication is not enabled for the Thrift server, execute:
{java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port>}
3. If HBase server is secure, and authentication is enabled for the Thrift server, run kinit at first, then execute:
- {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true}
+ {java -cp hbase-examples-[VERSION].jar:${HBASE_EXAMPLE_CLASSPATH} org.apache.hadoop.hbase.thrift.DemoClient <host> <port> true <server-principal>}
+ <server-principal> should only be specified when the client connects to a secure cluster. It's default value is "hbase".
4. Here is a lazy example that just pulls in all hbase dependency jars and that goes against default location on localhost.
It should work with a standalone hbase instance started by doing ./bin/start-hbase.sh:
{java -cp ./hbase-examples/target/hbase-examples-2.0.0-SNAPSHOT.jar:`./bin/hbase classpath` org.apache.hadoop.hbase.thrift.DemoClient localhost 9090}
http://git-wip-us.apache.org/repos/asf/hbase/blob/a732b67c/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
----------------------------------------------------------------------
diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
index 64adc93..e5400f3 100644
--- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
+++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/thrift/DemoClient.java
@@ -60,13 +60,14 @@ public class DemoClient {
CharsetDecoder decoder = null;
private static boolean secure = false;
+ private static String serverPrincipal = "hbase";
public static void main(String[] args) throws Exception {
- if (args.length < 2 || args.length > 3) {
+ if (args.length < 2 || args.length > 4 || (args.length > 2 && !isBoolean(args[2]))) {
System.out.println("Invalid arguments!");
- System.out.println("Usage: DemoClient host port [secure=false]");
+ System.out.println("Usage: DemoClient host port [secure=false [server-principal=hbase] ]");
System.exit(-1);
}
@@ -77,6 +78,10 @@ public class DemoClient {
secure = Boolean.parseBoolean(args[2]);
}
+ if (args.length == 4) {
+ serverPrincipal = args[3];
+ }
+
final DemoClient client = new DemoClient();
Subject.doAs(getSubject(),
new PrivilegedExceptionAction<Void>() {
@@ -88,6 +93,10 @@ public class DemoClient {
});
}
+ private static boolean isBoolean(String s){
+ return Boolean.TRUE.toString().equalsIgnoreCase(s) || Boolean.FALSE.toString().equalsIgnoreCase(s);
+ }
+
DemoClient() {
decoder = Charset.forName("UTF-8").newDecoder();
}
@@ -123,7 +132,7 @@ public class DemoClient {
* The HBase cluster must be secure, allow proxy user.
*/
transport = new TSaslClientTransport("GSSAPI", null,
- "hbase", // Thrift server user name, should be an authorized proxy user.
+ serverPrincipal, // Thrift server user name, should be an authorized proxy user.
host, // Thrift server domain
saslProperties, null, transport);
}