307 |
|
Iterator i = new TreeSet(_systemConfigHolder.keySet()).iterator(); |
308 |
|
while(i.hasNext()) { |
309 |
|
String key = (String) i.next(); |
310 |
+ |
// look for a key that's a group entry |
311 |
|
if (key.startsWith("group.")) { |
312 |
+ |
// get the list of hosts in the group |
313 |
|
String group = _systemConfig.getProperty(key); |
314 |
< |
// if it is in the group |
313 |
< |
if (group.indexOf(source) != -1) { |
314 |
> |
if(groupMatch(source, group)) { |
315 |
|
groupMembership.add(key.substring(6)); |
316 |
< |
_logger.write(toString(), Logger.DEBUG, "group match found for - " + source + " in - " + key); |
316 |
< |
|
317 |
< |
// if there are wildcards in the group |
318 |
< |
} else if (group.indexOf("*") != -1) { |
319 |
< |
// check the wildcards apply to this srce |
320 |
< |
if(StringUtils.wildcardCheck(source, group)) { |
321 |
< |
groupMembership.add(key.substring(6)); |
322 |
< |
_logger.write(toString(), Logger.DEBUG, "wildcard group match found for - " + source + " in - " + key); |
323 |
< |
} |
316 |
> |
_logger.write(toString(), Logger.DEBUG, "group match found for - " + source + " in group - " + key); |
317 |
|
} |
325 |
– |
|
318 |
|
} |
319 |
|
} |
320 |
|
return groupMembership; |
321 |
+ |
} |
322 |
+ |
|
323 |
+ |
/** |
324 |
+ |
* Checks that a given source is matched within the |
325 |
+ |
* given list of hosts. For example:<br> |
326 |
+ |
* <br> |
327 |
+ |
* Given "stue5de.ukc.ac.uk"<br> |
328 |
+ |
* And "raptor.ukc.ac.uk;stue*.ukc.ac.uk<br> |
329 |
+ |
* <br> |
330 |
+ |
* This method would return true as there is a match. |
331 |
+ |
* |
332 |
+ |
* This method will also match if the source is exactly |
333 |
+ |
* matched within the group of hosts (ie. no wildcard). |
334 |
+ |
* |
335 |
+ |
* @param source the string to look for |
336 |
+ |
* @param group the group to search for a match |
337 |
+ |
* |
338 |
+ |
* @return if there is a match |
339 |
+ |
*/ |
340 |
+ |
public static boolean groupMatch(String source, String group) { |
341 |
+ |
StringTokenizer st = new StringTokenizer(group, ";"); |
342 |
+ |
// go through all the hosts in the group |
343 |
+ |
while (st.hasMoreTokens()) { |
344 |
+ |
String host = st.nextToken(); |
345 |
+ |
if(StringUtils.wildcardMatch(source, host)) { |
346 |
+ |
return true; |
347 |
+ |
} |
348 |
+ |
} |
349 |
+ |
// not had a match |
350 |
+ |
return false; |
351 |
|
} |
352 |
|
|
353 |
|
/** |