https://issues.apache.org/bugzilla/show_bug.cgi?id=57208

            Bug ID: 57208
           Summary: NullPointerException on JNDIRealm when search finds no
                    results - org.apache.catalina.realm.JNDIRealm
           Product: Tomcat 7
           Version: 7.0.57
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: jasonmcint...@carfax.com

When JNDIRealm does a "getUserBySearch", and no results are found, a null
object is returned.  This causes a NPE in the next few lines where it tries to
create a user.

       if (userPatternFormatArray != null && curUserPattern >= 0) {
            user = getUserByPattern(context, username, credentials, attrIds,
curUserPattern);
        } else {
            user = getUserBySearch(context, username, attrIds);
        }

        if (userPassword == null && credentials != null) {
            // The password is available. Insert it since it may be required
for
            // role searches.
            return new User(user.getUserName(), user.getDN(), credentials,
                    user.getRoles(), user.getUserRoleId());
        }


Should probably be changed to:

       if (userPatternFormatArray != null && curUserPattern >= 0) {
            user = getUserByPattern(context, username, credentials, attrIds,
curUserPattern);
            containerLog.debug("Found user by pattern (" + user + ")");
        } else {
            user = getUserBySearch(context, username, attrIds);
            containerLog.debug("Found user by search (" + user + ")");
        }

        if (userPassword == null && credentials != null && user != null) {
            // The password is available. Insert it since it may be required
for
            // role searches.
            return new User(user.getUserName(), user.getDN(), credentials,
                    user.getRoles(), user.getUserRoleId());
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to