yoavs 2004/08/30 13:31:42 Modified: catalina/src/share/org/apache/catalina/realm RealmBase.java Log: Better null checking in RealmBase#findSecurityConstraints: see Bugzlla 30624. Revision Changes Path 1.37 +65 -5 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java Index: RealmBase.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/realm/RealmBase.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- RealmBase.java 3 Jul 2004 04:16:41 -0000 1.36 +++ RealmBase.java 30 Aug 2004 20:31:42 -0000 1.37 @@ -404,12 +404,27 @@ for (i = 0; i < constraints.length; i++) { SecurityCollection [] collection = constraints[i].findCollections(); - if (log.isDebugEnabled()) + // If collection is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( collection == null) { + continue; + } + + if (log.isDebugEnabled()) { log.debug(" Checking constraint '" + constraints[i] + "' against " + method + " " + uri + " --> " + constraints[i].included(uri, method)); + } + for(int j=0; j < collection.length; j++){ String [] patterns = collection[j].findPatterns(); + + // If patterns is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( patterns == null) { + continue; + } + for(int k=0; k < patterns.length; k++) { if(uri.equals(patterns[k])) { found = true; @@ -433,12 +448,27 @@ for (i = 0; i < constraints.length; i++) { SecurityCollection [] collection = constraints[i].findCollections(); - if (log.isDebugEnabled()) + // If collection is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( collection == null) { + continue; + } + + if (log.isDebugEnabled()) { log.debug(" Checking constraint '" + constraints[i] + "' against " + method + " " + uri + " --> " + constraints[i].included(uri, method)); + } + for(int j=0; j < collection.length; j++){ String [] patterns = collection[j].findPatterns(); + + // If patterns is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( patterns == null) { + continue; + } + boolean matched = false; int length = -1; for(int k=0; k < patterns.length; k++) { @@ -483,15 +513,30 @@ for (i = 0; i < constraints.length; i++) { SecurityCollection [] collection = constraints[i].findCollections(); + + // If collection is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( collection == null) { + continue; + } - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(" Checking constraint '" + constraints[i] + "' against " + method + " " + uri + " --> " + constraints[i].included(uri, method)); + } + boolean matched = false; int pos = -1; for(int j=0; j < collection.length; j++){ String [] patterns = collection[j].findPatterns(); + + // If patterns is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( patterns == null) { + continue; + } + for(int k=0; k < patterns.length && !matched; k++) { String pattern = patterns[k]; if(pattern.startsWith("*.")){ @@ -526,12 +571,27 @@ for (i = 0; i < constraints.length; i++) { SecurityCollection [] collection = constraints[i].findCollections(); - if (log.isDebugEnabled()) + // If collection is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( collection == null) { + continue; + } + + if (log.isDebugEnabled()) { log.debug(" Checking constraint '" + constraints[i] + "' against " + method + " " + uri + " --> " + constraints[i].included(uri, method)); + } + for(int j=0; j < collection.length; j++){ String [] patterns = collection[j].findPatterns(); + + // If patterns is null, continue to avoid an NPE + // See Bugzilla 30624 + if ( patterns == null) { + continue; + } + boolean matched = false; for(int k=0; k < patterns.length && !matched; k++) { String pattern = patterns[k];
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]