Iterator<ConditionKeys> itr = keySet.iterator();
if (!itr.hasNext()) return false;
// -> returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
// For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
IpAddressRange toCompareWith = IpAddressRange.parseRange( context.getRemoveAddr());
if (null == toCompareWith) return false;
// -> all keys in a condition are ANDed together (one false one terminates the entire condition)
while( itr.hasNext())
{
ConditionKeys keyName = itr.next();
IpAddressRange[] valueList = getKeyValues( keyName );
boolean keyResult = false;
// -> stop when we hit the first true key value (i.e., key values are 'OR'ed together)
for( int i=0; i < valueList.length && !keyResult; i++ )
{
switch( condition ) {
case IpAddress:
if (valueList[i].contains( toCompareWith )) keyResult = true;
break;
case NotIpAddres:
if (!valueList[i].contains( toCompareWith )) keyResult = true;
break;
default:
return false;
}
logger.info( "S3PolicyIPAddressCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith.toString() + ", valueInRule: " + valueList[i].toString() + ", result: " + keyResult );
}
// -> if all key values are false, false then that key is false and then the entire condition is then false
if (!keyResult) return false;
}