/*
 * Filename: Authenticator.java
 *
 * Author: Joe Wang
 *
 * Copyright (c) 2003-2005 
 * The Trustees of Columbia University in the City of New York
 * Columbia University Information Technology
 *
 * This file is part of NINJa.
 *
 * NINJa is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * NINJa is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NINJa; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

package edu.columbia.print.ninja.core.authenticate;
/**
 * An Authenticator authenticates the printing of a print job.
 * It is used before and after printing and can be used for
 * both authentication and accounting purposes.  An example
 * might have an authenticator request a password prior to printing
 * and update a database after printing.
 * @author Joe Wang <jw168@columbia.edu>
 * @since 1.0
 */
public interface Authenticator extends java.io.Serializable {

	/**
	 * Authenticate a print job prior to printing.
	 * This method will be executed on the client side.
	 * An array of integers is returned indicating which jobs
	 * have successfuly passed preauthorization.
	 * @param docs the attributes associated with the documents
	 * @param jobs the attributes associated with the jobs
	 * @param reqs the attributes associated with the requests
	 * @param consume indicates wether these jobs will consume media
	 *        An example of consumption might be where the job is sent to a
	 *        line printer.  An example of non-consumption would be a job
         *        that is forwarded to another queue or a job that is deleted.
	 * @param stub the container of this authenticator
	 * @param cbh handles requests generated in preauthing
	 * @param cookies The cookies to be used during post authentication
	 */
	public int[] preauthenticate(javax.print.attribute.DocAttributeSet[] docs, net.jini.print.job.PrintRequest[] reqs, boolean consume, AuthStub stub, javax.security.auth.callback.CallbackHandler cbh, Object[] cookies) throws Exception;

	public boolean authenticate(Object cookie) throws Exception;

        /**
	 * Authenticate print jobs after printing.
	 * This method will be executed on the server side.  There is one
	 * invocation of this method for each document.
	 * @param attrs the resulting PrintJob attributes
	 * @param cookie the cookie generated during preauthentication
	 */
	public void postauthenticate(javax.print.attribute.PrintJobAttributeSet attrs, Object cookie);

	}

