Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48516
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 22:43:23 +0000 (22:43 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 12 Jan 2010 22:43:23 +0000 (22:43 +0000)
Fix possible NPE when user does not exist in directory
Patch provided by Kevin Conaway

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@898558 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/JNDIRealm.java

index bb32f71..72a0717 100644 (file)
@@ -1929,8 +1929,12 @@ public class JNDIRealm extends RealmBase {
 
         User user = getUser(context, username);
 
-        return new GenericPrincipal(user.username, user.password ,
-                getRoles(context, user));
+        if (user != null) {
+            return new GenericPrincipal(user.username, user.password,
+                    getRoles(context, user));
+        }
+        
+        return null;
     }
 
     /**