* First call hasPermission() for entry level "Browse" and "ReturnDN" perm
* tests. If we hasPermission() returns false we immediately short the
* process and return false.
*/
LdapPrincipal principal = opContext.getSession().getEffectivePrincipal();
Dn userDn = principal.getDn();
Set<Dn> userGroups = groupCache.getGroups( userDn.getNormName() );
Collection<ACITuple> tuples = new HashSet<ACITuple>();
addPerscriptiveAciTuples( opContext, tuples, normName, clonedEntry );
addEntryAciTuples( tuples, ( ( ClonedServerEntry ) clonedEntry ).getOriginalEntry() );
addSubentryAciTuples( opContext, tuples, normName, ( ( ClonedServerEntry ) clonedEntry ).getOriginalEntry() );
AciContext aciContext = new AciContext( schemaManager, opContext );
aciContext.setUserGroupNames( userGroups );
aciContext.setUserDn( userDn );
aciContext.setAuthenticationLevel( principal.getAuthenticationLevel() );
aciContext.setEntryDn( normName );
aciContext.setMicroOperations( SEARCH_ENTRY_PERMS );
aciContext.setAciTuples( tuples );
aciContext.setEntry( ( ( ClonedServerEntry ) clonedEntry ).getOriginalEntry() );
if ( !engine.hasPermission( aciContext ) )
{
return false;
}
/*
* For each attribute type we check if access is allowed to the type. If not
* the attribute is yanked out of the entry to be returned. If permission is
* allowed we move on to check if the values are allowed. Values that are
* not allowed are removed from the attribute. If the attribute has no more
* values remaining then the entire attribute is removed.
*/
List<AttributeType> attributeToRemove = new ArrayList<AttributeType>();
for ( Attribute attribute : clonedEntry.getAttributes() )
{
// if attribute type scope access is not allowed then remove the attribute and continue
AttributeType attributeType = attribute.getAttributeType();
Attribute attr = clonedEntry.get( attributeType );
aciContext = new AciContext( schemaManager, opContext );
aciContext.setUserGroupNames( userGroups );
aciContext.setUserDn( userDn );
aciContext.setAuthenticationLevel( principal.getAuthenticationLevel() );
aciContext.setEntryDn( normName );
aciContext.setAttributeType( attributeType );
aciContext.setMicroOperations( SEARCH_ATTRVAL_PERMS );
aciContext.setAciTuples( tuples );
aciContext.setEntry( clonedEntry );
if ( !engine.hasPermission( aciContext ) )
{
attributeToRemove.add( attributeType );
continue;
}
List<Value<?>> valueToRemove = new ArrayList<Value<?>>();
// attribute type scope is ok now let's determine value level scope
for ( Value<?> value : attr )
{
aciContext = new AciContext( schemaManager, opContext );
aciContext.setUserGroupNames( userGroups );
aciContext.setUserDn( userDn );
aciContext.setAuthenticationLevel( principal.getAuthenticationLevel() );
aciContext.setEntryDn( normName );
aciContext.setAttributeType( attr.getAttributeType() );
aciContext.setAttrValue( value );
aciContext.setMicroOperations( SEARCH_ATTRVAL_PERMS );
aciContext.setAciTuples( tuples );