FELIX-2326: NullPointerException thrown from PropertiesLoginModule if a user doesn't exist in the properties file
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@945085 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java
index 2077903..8219b4e 100644
--- a/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java
+++ b/karaf/jaas/modules/src/main/java/org/apache/felix/karaf/jaas/modules/properties/PropertiesLoginModule.java
@@ -93,13 +93,19 @@
tmpPassword = new char[0];
}
- String userInfos = (String) users.get(user);
+ String userInfos = null;
+
+ try {
+ userInfos = (String) users.get(user);
+ } catch (NullPointerException e) {
+ //error handled in the next statement
+ }
if (userInfos == null) {
- throw new FailedLoginException("User does not exist");
+ throw new FailedLoginException("User " + user + " does not exist");
}
String[] infos = userInfos.split(",");
if (!new String(tmpPassword).equals(infos[0])) {
- throw new FailedLoginException("Password does not match");
+ throw new FailedLoginException("Password for " + user + " does not match");
}
principals = new HashSet<Principal>();
@@ -111,7 +117,7 @@
users.clear();
if (debug) {
- LOG.debug("login " + user);
+ LOG.debug("Successfully logged in " + user);
}
return true;
}