// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package jcrdemo;

import javax.jcr.AccessDeniedException;
import javax.jcr.ItemNotFoundException;
import javax.jcr.RepositoryException;

import org.apache.jackrabbit.core.id.ItemId;
import org.apache.jackrabbit.core.security.AMContext;
import org.apache.jackrabbit.core.security.AccessManager;
import org.apache.jackrabbit.core.security.authorization.AccessControlProvider;
import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
import org.apache.jackrabbit.spi.Name;
import org.apache.jackrabbit.spi.Path;

public class MyAccessManager implements AccessManager {
	public boolean canAccess(String wsn) throws RepositoryException {
		System.err.println("MyAccessManager canAccess " + wsn);
		return true;
	}
	public boolean canRead(Path pth, ItemId itm) throws RepositoryException {
		System.err.println("MyAccessManager canRead " + pth + " " + itm);
		return true;
	}
	public void checkPermission(ItemId itm, int perm) throws AccessDeniedException, ItemNotFoundException, RepositoryException {
		// nothing
		System.err.println("MyAccessManager checkPermission ItemId");
	}
	public void checkPermission(Path pth, int perm) throws AccessDeniedException, RepositoryException {
		// nothing
		System.err.println("MyAccessManager checkPermission Path");
	}
	public void close() throws Exception {
		// nothing
		System.err.println("MyAccessManager close");
	}
	public void init(AMContext ctx) throws AccessDeniedException, Exception {
		// nothing
		System.err.println("MyAccessManager init 1");
	}
	public void init(AMContext ctx, AccessControlProvider acp, WorkspaceAccessManager wam) throws AccessDeniedException, Exception {
		// nothing
		System.err.println("MyAccessManager init 3");
	}
	public boolean isGranted(ItemId itm, int perm)	throws ItemNotFoundException, RepositoryException {
		System.err.println("MyAccessManager isGranted " + itm + " " + perm);
		return true;
	}
	public boolean isGranted(Path pth, int perm) throws RepositoryException {
		System.err.println("MyAccessManager isGranted " + pth + " " + perm);
		return true;
	}
	public boolean isGranted(Path pth, Name child, int perm) throws RepositoryException {
		System.err.println("MyAccessManager isGranted " + pth + " " + child + " " + perm);
		return true;
	}
}
