You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2015/06/25 15:46:42 UTC
knox git commit: KNOX-562: Fix Null pointer exceptions in KnoxCLI
LDAP commands
Repository: knox
Updated Branches:
refs/heads/master 0baa77b86 -> b1e089a78
KNOX-562: Fix Null pointer exceptions in KnoxCLI LDAP commands
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/b1e089a7
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/b1e089a7
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/b1e089a7
Branch: refs/heads/master
Commit: b1e089a78855da4a1f51e68a9ee56a52afd820a8
Parents: 0baa77b
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Thu Jun 25 09:46:32 2015 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Thu Jun 25 09:46:32 2015 -0400
----------------------------------------------------------------------
.../org/apache/hadoop/gateway/util/KnoxCLI.java | 46 ++++++++++++--------
1 file changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/b1e089a7/gateway-server/src/main/java/org/apache/hadoop/gateway/util/KnoxCLI.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/util/KnoxCLI.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/util/KnoxCLI.java
index cfed961..ab3284b 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/util/KnoxCLI.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/util/KnoxCLI.java
@@ -1048,11 +1048,16 @@ public class KnoxCLI extends Configured implements Tool {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
out.println("Password: ");
- this.password = reader.readLine().toCharArray();
+ String pw = reader.readLine();
+ if(pw != null){
+ this.password = pw.toCharArray();
+ } else {
+ this.password = new char[0];
+ }
reader.close();
} catch (IOException e){
out.println(e.getMessage());
- this.password = "".toCharArray();
+ this.password = new char[0];
}
}
}
@@ -1197,23 +1202,28 @@ public class KnoxCLI extends Configured implements Tool {
}
// returns false if any errors are printed
- private boolean hasGroupLookupErrors(Topology topology){
+ private boolean hasGroupLookupErrors(Topology topology) {
Provider shiro = topology.getProvider("authentication", "ShiroProvider");
- Map<String, String> params = shiro.getParams();
- int errs = 0;
- errs += hasParam(params, "main.ldapRealm") ? 0 : 1;
- errs += hasParam(params, "main.ldapGroupContextFactory") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.searchBase") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.groupObjectClass") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.memberAttributeValueTemplate") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.memberAttribute") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.authorizationEnabled") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.contextFactory.systemUsername") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.contextFactory.systemPassword") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.userDnTemplate") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.contextFactory.url") ? 0 : 1;
- errs += hasParam(params, "main.ldapRealm.contextFactory.authenticationMechanism") ? 0 : 1;
- return errs > 0 ? true : false;
+ if(shiro != null) {
+ Map<String, String> params = shiro.getParams();
+ int errs = 0;
+ errs += hasParam(params, "main.ldapRealm") ? 0 : 1;
+ errs += hasParam(params, "main.ldapGroupContextFactory") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.searchBase") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.groupObjectClass") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.memberAttributeValueTemplate") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.memberAttribute") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.authorizationEnabled") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.contextFactory.systemUsername") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.contextFactory.systemPassword") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.userDnTemplate") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.contextFactory.url") ? 0 : 1;
+ errs += hasParam(params, "main.ldapRealm.contextFactory.authenticationMechanism") ? 0 : 1;
+ return errs > 0 ? true : false;
+ } else {
+ out.println("Could not obtain ShiroProvider");
+ return true;
+ }
}
// Checks to see if the param name is present. If not, notify the user