package org.neo4j.tutor.security;

import org.neo4j.api.core.Node;
import org.neo4j.impl.event.Event;
import org.neo4j.impl.event.EventData;

public class SecurityMgr1 extends AbstractSecurityMgr
{
	public boolean proActiveEventReceived( Event event, EventData data )
	{
		if ( event == SecurityEvent.ACCESS )
		{
			Node file = (Node) data.getData();
			// --- TODO
			// --- Return true if access return false if no access.
			// --- Access defined by property File.SECURITY that is of type
			// --- Boolean.
			// --- If no property exist access is granted
			// --- If property exist and equals false return false
			// --- If property exist and equals true return true
			// --- end TODO
			if ( !file.hasProperty( File.SECURITY ) )
			{
				return true;
			}
			return (( Boolean ) 
				file.getProperty( File.SECURITY )).booleanValue();
		}
		// we shouldn't get any other events but returning true by default 
		return true;
	}
}
