private boolean isRelated( ACITuple tuple, OperationScope scope, Name userName, Name entryName, String attrId, Object attrValue, Attributes entry ) throws NamingException, InternalError
{
for( Iterator i = tuple.getProtectedItems().iterator(); i.hasNext(); )
{
ProtectedItem item = ( ProtectedItem ) i.next();
if( item == ProtectedItem.ENTRY )
{
if( scope == OperationScope.ENTRY )
{
return true;
}
}
else if( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES )
{
if( scope != OperationScope.ATTRIBUTE_TYPE &&
scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
if( isUserAttribute( attrId ) )
{
return true;
}
}
else if( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES )
{
if( scope != OperationScope.ATTRIBUTE_TYPE &&
scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
if( isUserAttribute( attrId ) )
{
return true;
}
}
else if( item instanceof ProtectedItem.AllAttributeValues )
{
if( scope != OperationScope.ATTRIBUTE_TYPE &&
scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
ProtectedItem.AllAttributeValues aav = ( ProtectedItem.AllAttributeValues ) item;
for( Iterator j = aav.iterator(); j.hasNext(); )
{
if( attrId.equalsIgnoreCase( ( String ) j.next() ) )
{
return true;
}
}
}
else if( item instanceof ProtectedItem.AttributeType )
{
if( scope != OperationScope.ATTRIBUTE_TYPE )
{
continue;
}
ProtectedItem.AttributeType at = ( ProtectedItem.AttributeType ) item;
for( Iterator j = at.iterator(); j.hasNext(); )
{
if( attrId.equalsIgnoreCase( ( String ) j.next() ) )
{
return true;
}
}
}
else if( item instanceof ProtectedItem.AttributeValue )
{
if( scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
ProtectedItem.AttributeValue av = ( ProtectedItem.AttributeValue ) item;
for( Iterator j = av.iterator(); j.hasNext(); )
{
Attribute attr = ( Attribute ) j.next();
if( attrId.equalsIgnoreCase( attr.getID() ) &&
attr.contains( attrValue ) )
{
return true;
}
}
}
else if( item instanceof ProtectedItem.Classes )
{
ProtectedItem.Classes c = ( ProtectedItem.Classes ) item;
if( refinementEvaluator.evaluate(
c.getClasses(), entry.get( "objectClass" ) ) )
{
return true;
}
}
else if( item instanceof ProtectedItem.MaxImmSub )
{
return true;
}
else if( item instanceof ProtectedItem.MaxValueCount )
{
if( scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
ProtectedItem.MaxValueCount mvc = ( ProtectedItem.MaxValueCount ) item;
for( Iterator j = mvc.iterator(); j.hasNext(); )
{
MaxValueCountItem mvcItem = ( MaxValueCountItem ) j.next();
if( attrId.equalsIgnoreCase( mvcItem.getAttributeType() ) )
{
return true;
}
}
}
else if( item instanceof ProtectedItem.RangeOfValues )
{
ProtectedItem.RangeOfValues rov = ( ProtectedItem.RangeOfValues ) item;
if( entryEvaluator.evaluate( rov.getFilter(), entryName.toString(), entry ) )
{
return true;
}
}
else if( item instanceof ProtectedItem.RestrictedBy )
{
if( scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
continue;
}
ProtectedItem.RestrictedBy rb = ( ProtectedItem.RestrictedBy ) item;
for( Iterator j = rb.iterator(); j.hasNext(); )
{
RestrictedByItem rbItem = ( RestrictedByItem ) j.next();
if( attrId.equalsIgnoreCase( rbItem.getAttributeType() ) )
{
return true;
}
}
}
else if( item instanceof ProtectedItem.SelfValue )
{
if( scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE &&
scope != OperationScope.ATTRIBUTE_TYPE )
{
continue;
}
ProtectedItem.SelfValue sv = ( ProtectedItem.SelfValue ) item;
for( Iterator j = sv.iterator(); j.hasNext(); )
{
String svItem = String.valueOf( j.next() );
if( svItem.equalsIgnoreCase( attrId ) )
{
Attribute attr = entry.get( attrId );
if( attr != null && ( attr.contains( userName ) || attr.contains( userName.toString() ) ) )
{
return true;
}
}
}
}
else
{
throw new InternalError( "Unexpected protectedItem: " + item.getClass().getName() );
}
}
return false;
}