changeset 1178:2dd7116ccad3

AuthOps implementation configuration options. copyright headers.
author robcast
date Thu, 04 Apr 2013 12:20:29 +0200
parents 9c956718f1da
children d4990c1463e3
files common/src/main/java/digilib/auth/AuthOps.java common/src/main/java/digilib/auth/AuthOpsFactory.java common/src/main/java/digilib/meta/DirMeta.java common/src/main/java/digilib/meta/FileMeta.java common/src/main/java/digilib/meta/IndexMetaAuthLoader.java common/src/main/java/digilib/meta/IndexMetaDirMeta.java common/src/main/java/digilib/meta/IndexMetaFileMeta.java common/src/main/java/digilib/meta/MetaFactory.java servlet/src/main/java/digilib/auth/MetaAccessServletAuthOps.java servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java servlet/src/main/java/digilib/servlet/DocumentBean.java servlet2/src/main/java/digilib/servlet/Initialiser.java servlet3/src/main/java/digilib/servlet/Initialiser.java
diffstat 13 files changed, 398 insertions(+), 240 deletions(-) [+]
line wrap: on
line diff
--- a/common/src/main/java/digilib/auth/AuthOps.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/auth/AuthOps.java	Thu Apr 04 12:20:29 2013 +0200
@@ -26,28 +26,43 @@
  * Author: Robert Casties (robcast@berlios.de)
  */
 
+import java.io.File;
+
 import digilib.conf.DigilibRequest;
 
 /** Class of operations requiring authentication. */
 public interface AuthOps {
 
-	/** Test if the request must be authorized to access the filepath.
-	 *
-	 * Information about the user is taken from the DigilibRequest.
-	 * @param request DigilibRequest with user information.
-	 * @throws AuthOpException Exception thrown on error.
-	 * @return true if the user request must be authorized.
-	 */
-	public boolean isAuthRequired(DigilibRequest request)
-		throws AuthOpException;
+    /**
+     * Test if the request must be authorized to access the filepath.
+     * 
+     * Information about the user is taken from the DigilibRequest.
+     * 
+     * @param request
+     *            DigilibRequest with user information.
+     * @throws AuthOpException
+     *             Exception thrown on error.
+     * @return true if the user request must be authorized.
+     */
+    public boolean isAuthRequired(DigilibRequest request) throws AuthOpException;
 
-	/** Test if the request is allowed to access filepath.
-	 * 
-	 * @param request Request with user information.
-	 * @throws AuthOpException Exception thrown on error.
-	 * @return true if the request is allowed.
-	 */
-	public boolean isAuthorized(DigilibRequest request)
-		throws AuthOpException;
+    /**
+     * Test if the request is allowed to access filepath.
+     * 
+     * @param request
+     *            Request with user information.
+     * @throws AuthOpException
+     *             Exception thrown on error.
+     * @return true if the request is allowed.
+     */
+    public boolean isAuthorized(DigilibRequest request) throws AuthOpException;
 
+
+    /**
+     * Configure this AuthOps instance.
+     * 
+     * @param confFile
+     * @throws AuthOpException
+     */
+    public void setConfig(File confFile) throws AuthOpException;
 }
--- a/common/src/main/java/digilib/auth/AuthOpsFactory.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/auth/AuthOpsFactory.java	Thu Apr 04 12:20:29 2013 +0200
@@ -1,12 +1,34 @@
-/**
+package digilib.auth;
+
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
  * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
  */
-package digilib.auth;
 
 import org.apache.log4j.Logger;
 
 
 /**
+ * Static factory for AuthOps.
+ * 
  * @author casties
  * 
  */
--- a/common/src/main/java/digilib/meta/DirMeta.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/DirMeta.java	Thu Apr 04 12:20:29 2013 +0200
@@ -3,9 +3,34 @@
  */
 package digilib.meta;
 
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
+ * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
+ */
+
 import digilib.io.DocuDirectory;
 
 /**
+ * Interface for directory-based metadata.
+ * 
  * @author casties
  *
  */
--- a/common/src/main/java/digilib/meta/FileMeta.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/FileMeta.java	Thu Apr 04 12:20:29 2013 +0200
@@ -3,9 +3,34 @@
  */
 package digilib.meta;
 
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
+ * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
+ */
+
 import digilib.io.DocuDirent;
 
 /**
+ * Interface for file-based metadata.
+ * 
  * @author casties
  *
  */
--- a/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/IndexMetaAuthLoader.java	Thu Apr 04 12:20:29 2013 +0200
@@ -234,8 +234,6 @@
             } else if (event == XMLStreamConstants.CHARACTERS) {
                 text.append(reader.getText());
             } else if (event == XMLStreamConstants.END_ELEMENT) {
-                // get tag TODO: make namespace aware
-                String thisTag = reader.getLocalName();
                 if (tagsMatchPath(accessNameTag)) {
                     /*
                      * access/name tag
--- a/common/src/main/java/digilib/meta/IndexMetaDirMeta.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/IndexMetaDirMeta.java	Thu Apr 04 12:20:29 2013 +0200
@@ -3,6 +3,29 @@
  */
 package digilib.meta;
 
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
+ * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
+ */
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Map;
@@ -15,6 +38,8 @@
 import digilib.io.FileOps.FileClass;
 
 /**
+ * DirMeta implementation reading index.meta files.
+ * 
  * @author casties
  *
  */
--- a/common/src/main/java/digilib/meta/IndexMetaFileMeta.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/IndexMetaFileMeta.java	Thu Apr 04 12:20:29 2013 +0200
@@ -3,6 +3,29 @@
  */
 package digilib.meta;
 
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
+ * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
+ */
+
 import java.io.File;
 import java.util.Map;
 
@@ -12,6 +35,8 @@
 import digilib.io.DocuDirent;
 
 /**
+ * FileMeta implementation reading index.meta files.
+ * 
  * @author casties
  * 
  */
--- a/common/src/main/java/digilib/meta/MetaFactory.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/common/src/main/java/digilib/meta/MetaFactory.java	Thu Apr 04 12:20:29 2013 +0200
@@ -3,10 +3,35 @@
  */
 package digilib.meta;
 
+/*
+ * #%L
+ * digilib-common
+ * %%
+ * Copyright (C) 2013 MPIWG Berlin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as 
+ * published by the Free Software Foundation, either version 3 of the 
+ * License, or (at your option) any later version.
+ * 
+ * This program 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 Lesser Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Lesser Public 
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ * Author: Robert Casties (robcast@berlios.de)
+ */
+
 import org.apache.log4j.Logger;
 
 
 /**
+ * Static factory for FileMeta and DirMeta implementations.
+ * 
  * @author casties
  * 
  */
--- a/servlet/src/main/java/digilib/auth/MetaAccessServletAuthOps.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/servlet/src/main/java/digilib/auth/MetaAccessServletAuthOps.java	Thu Apr 04 12:20:29 2013 +0200
@@ -2,12 +2,13 @@
 
 /*
  * #%L
- * XMLAuthOps -- Authentication class implementation using XML files
+ * Authentication class implementation using access information from 
+ * file metadata.
  * 
  * Digital Image Library servlet components
  * 
  * %%
- * Copyright (C) 2001 - 2013 MPIWG Berlin
+ * Copyright (C) 2013 MPIWG Berlin
  * %%
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as 
--- a/servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java	Thu Apr 04 12:20:29 2013 +0200
@@ -33,6 +33,8 @@
 
 import javax.servlet.ServletContext;
 
+import digilib.auth.AuthOps;
+import digilib.auth.AuthOpsFactory;
 import digilib.image.DocuImageImpl;
 import digilib.io.FileOps;
 import digilib.meta.DirMeta;
@@ -143,6 +145,8 @@
         newParameter("filemeta-class", "digilib.meta.IndexMetaFileMeta", null, 'f');
         // DirMeta implementation
         newParameter("dirmeta-class", "digilib.meta.IndexMetaDirMeta", null, 'f');
+        // AuthOps implementation
+        newParameter("authops-class", "digilib.auth.PathServletAuthOps", null, 'f');
         
         // TODO: move pdf-stuff to its own config
         // number of pdf-generation threads
@@ -256,6 +260,10 @@
         Class<DirMeta> dirMetaClass = (Class<DirMeta>) Class.forName(getAsString("dirmeta-class"));
         newParameter("servlet.dirmeta.class", dirMetaClass, null, 's');
         MetaFactory.setDirMetaClass(dirMetaClass);
+        // initialise AuthOpsFactory
+        Class<AuthOps> authOpsClass = (Class<AuthOps>) Class.forName(getAsString("authops-class"));
+        newParameter("servlet.authops.class", authOpsClass, null, 's');
+        AuthOpsFactory.setAuthOpsClass(authOpsClass);
     }
 
 }
--- a/servlet/src/main/java/digilib/servlet/DocumentBean.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/servlet/src/main/java/digilib/servlet/DocumentBean.java	Thu Apr 04 12:20:29 2013 +0200
@@ -27,8 +27,6 @@
  * Author: Robert Casties (robcast@berlios.de)
  */
 
-import java.util.List;
-
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
--- a/servlet2/src/main/java/digilib/servlet/Initialiser.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/servlet2/src/main/java/digilib/servlet/Initialiser.java	Thu Apr 04 12:20:29 2013 +0200
@@ -42,7 +42,7 @@
 import org.apache.log4j.xml.DOMConfigurator;
 
 import digilib.auth.AuthOps;
-import digilib.auth.PathServletAuthOps;
+import digilib.auth.AuthOpsFactory;
 import digilib.conf.DigilibServletConfiguration;
 import digilib.image.DocuImage;
 import digilib.io.AliasingDocuDirCache;
@@ -54,127 +54,122 @@
  * Singleton initalisation listener for setup tasks and resources.
  * 
  * @author casties
- *  
+ * 
  */
 public class Initialiser implements ServletContextListener {
 
+    /** servlet version */
+    public static final String version = "0.3";
 
-	/** servlet version */
-	public static final String version = "0.3";
+    /** general logger for this class */
+    private static Logger logger = Logger.getLogger("digilib.init");
 
-	/** general logger for this class */
-	private static Logger logger = Logger.getLogger("digilib.init");
+    /** DocuDirCache instance */
+    DocuDirCache dirCache;
 
-	/** DocuDirCache instance */
-	DocuDirCache dirCache;
-
-	/** DigilibConfiguration instance */
-	DigilibServletConfiguration dlConfig;
+    /** DigilibConfiguration instance */
+    DigilibServletConfiguration dlConfig;
 
-	/** Executor for digilib image jobs (AsyncServletWorker doesn't return anything) */
-	DigilibJobCenter<DocuImage> imageEx;
-	
-	/** Executor for PDF jobs */
-	DigilibJobCenter<OutputStream> pdfEx;
-	
-	/** Executor for PDF image jobs */
-	DigilibJobCenter<DocuImage> pdfImageEx;
-	
-	/**
-	 * Initialisation on first run.
-	 */
+    /**
+     * Executor for digilib image jobs (AsyncServletWorker doesn't return
+     * anything)
+     */
+    DigilibJobCenter<DocuImage> imageEx;
+
+    /** Executor for PDF jobs */
+    DigilibJobCenter<OutputStream> pdfEx;
+
+    /** Executor for PDF image jobs */
+    DigilibJobCenter<DocuImage> pdfImageEx;
+
+    /**
+     * Initialisation on first run.
+     */
     public void contextInitialized(ServletContextEvent cte) {
         ServletContext context = cte.getServletContext();
-        context.log("***** Digital Image Library Initialiser (version "
-                + version + ") *****");
-		System.out.println("***** Digital Image Library Initialiser (version "
-						+ version + ") *****");
+        context.log("***** Digital Image Library Initialiser (version " + version + ") *****");
+        System.out.println("***** Digital Image Library Initialiser (version " + version + ") *****");
 
-		// see if there is a Configuration instance
-		dlConfig = (DigilibServletConfiguration) context.getAttribute("digilib.servlet.configuration");
-		if (dlConfig == null) {
-			// create new Configuration
-			try {
-				dlConfig = new DigilibServletConfiguration(context);
-				// add servlet version
-				dlConfig.newParameter("servlet.version", Scaler.getVersion(), null, 's');
+        // see if there is a Configuration instance
+        dlConfig = (DigilibServletConfiguration) context.getAttribute("digilib.servlet.configuration");
+        if (dlConfig == null) {
+            // create new Configuration
+            try {
+                dlConfig = new DigilibServletConfiguration(context);
+                // add servlet version
+                dlConfig.newParameter("servlet.version", Scaler.getVersion(), null, 's');
 
-				/*
-				 * further initialization
-				 */
+                /*
+                 * further initialization
+                 */
 
-				// set up the logger
-				File logConf = ServletOps.getConfigFile((File) dlConfig
-						.getValue("log-config-file"), context);
-				DOMConfigurator.configure(logConf.getAbsolutePath());
-				dlConfig.setValue("log-config-file", logConf);
-				// say hello in the log file
-				logger
-						.info("***** Digital Image Library Initialiser (version "
-								+ version + ") *****");
-				// directory cache
-				String[] bd = (String[]) dlConfig.getValue("basedir-list");
-				FileClass[] fcs = { FileClass.IMAGE, FileClass.TEXT };
-				if (dlConfig.getAsBoolean("use-mapping")) {
-					// with mapping file
-					File mapConf = ServletOps.getConfigFile((File) dlConfig
-							.getValue("mapping-file"), context);
-					dirCache = new AliasingDocuDirCache(bd, fcs, mapConf,
-							dlConfig);
-					dlConfig.setValue("mapping-file", mapConf);
-				} else {
-					// without mapping
-					dirCache = new DocuDirCache(bd, fcs, dlConfig);
-				}
-				dlConfig.setValue("servlet.dir.cache", dirCache);
-				// useAuthentication
-				if (dlConfig.getAsBoolean("use-authorization")) {
-					// DB version
-					//authOp = new DBAuthOpsImpl(util);
-					// XML version
-					File authConf = ServletOps.getConfigFile((File) dlConfig
-							.getValue("auth-file"), context);
-					AuthOps authOp = new PathServletAuthOps(authConf);
-					dlConfig.setValue("servlet.auth.op", authOp);
-					dlConfig.setValue("auth-file", authConf);
-				}
-				// DocuImage class
-				DocuImage di = DigilibServletConfiguration.getDocuImageInstance();
-				dlConfig.setValue("servlet.docuimage.class", di.getClass().getName());
-				// disk cache for image toolkit
-				boolean dc = dlConfig.getAsBoolean("img-diskcache-allowed");
-				// TODO: methods for all toolkits?
-				ImageIO.setUseCache(dc);
-				// digilib worker threads
-				int nt = dlConfig.getAsInt("worker-threads");
+                // set up the logger
+                File logConf = ServletOps.getConfigFile((File) dlConfig.getValue("log-config-file"), context);
+                DOMConfigurator.configure(logConf.getAbsolutePath());
+                dlConfig.setValue("log-config-file", logConf);
+                // say hello in the log file
+                logger.info("***** Digital Image Library Initialiser (version " + version + ") *****");
+                // directory cache
+                String[] bd = (String[]) dlConfig.getValue("basedir-list");
+                FileClass[] fcs = { FileClass.IMAGE, FileClass.TEXT };
+                if (dlConfig.getAsBoolean("use-mapping")) {
+                    // with mapping file
+                    File mapConf = ServletOps.getConfigFile((File) dlConfig.getValue("mapping-file"), context);
+                    dirCache = new AliasingDocuDirCache(bd, fcs, mapConf, dlConfig);
+                    dlConfig.setValue("mapping-file", mapConf);
+                } else {
+                    // without mapping
+                    dirCache = new DocuDirCache(bd, fcs, dlConfig);
+                }
+                dlConfig.setValue("servlet.dir.cache", dirCache);
+                // useAuthentication
+                if (dlConfig.getAsBoolean("use-authorization")) {
+                    AuthOps authOp = AuthOpsFactory.getAuthOpsInstance();
+                    // get config file
+                    File authConf = ServletOps.getConfigFile((File) dlConfig.getValue("auth-file"), context);
+                    if (authConf != null) {
+                        authOp.setConfig(authConf);
+                    }
+                    dlConfig.setValue("servlet.auth.op", authOp);
+                    dlConfig.setValue("auth-file", authConf);
+                }
+                // DocuImage class
+                DocuImage di = DigilibServletConfiguration.getDocuImageInstance();
+                dlConfig.setValue("servlet.docuimage.class", di.getClass().getName());
+                // disk cache for image toolkit
+                boolean dc = dlConfig.getAsBoolean("img-diskcache-allowed");
+                // TODO: methods for all toolkits?
+                ImageIO.setUseCache(dc);
+                // digilib worker threads
+                int nt = dlConfig.getAsInt("worker-threads");
                 int mt = dlConfig.getAsInt("max-waiting-threads");
-				imageEx = new DigilibJobCenter<DocuImage>(nt, mt, false, "servlet.worker.imageexecutor");
-                dlConfig.setValue("servlet.worker.imageexecutor", imageEx);				
-				// PDF worker threads
-				int pnt = dlConfig.getAsInt("pdf-worker-threads");
+                imageEx = new DigilibJobCenter<DocuImage>(nt, mt, false, "servlet.worker.imageexecutor");
+                dlConfig.setValue("servlet.worker.imageexecutor", imageEx);
+                // PDF worker threads
+                int pnt = dlConfig.getAsInt("pdf-worker-threads");
                 int pmt = dlConfig.getAsInt("pdf-max-waiting-threads");
-				pdfEx = new DigilibJobCenter<OutputStream>(pnt, pmt, false, "servlet.worker.pdfexecutor");
-                dlConfig.setValue("servlet.worker.pdfexecutor", pdfEx);				
-				// PDF image worker threads
-				int pint = dlConfig.getAsInt("pdf-image-worker-threads");
+                pdfEx = new DigilibJobCenter<OutputStream>(pnt, pmt, false, "servlet.worker.pdfexecutor");
+                dlConfig.setValue("servlet.worker.pdfexecutor", pdfEx);
+                // PDF image worker threads
+                int pint = dlConfig.getAsInt("pdf-image-worker-threads");
                 int pimt = dlConfig.getAsInt("pdf-image-max-waiting-threads");
-				pdfImageEx = new DigilibJobCenter<DocuImage>(pint, pimt, false, "servlet.worker.pdfimageexecutor");
-                dlConfig.setValue("servlet.worker.pdfimageexecutor", pdfImageEx);				
-				// set as the servlets main config
-				context.setAttribute("digilib.servlet.configuration", dlConfig);
+                pdfImageEx = new DigilibJobCenter<DocuImage>(pint, pimt, false, "servlet.worker.pdfimageexecutor");
+                dlConfig.setValue("servlet.worker.pdfimageexecutor", pdfImageEx);
+                // set as the servlets main config
+                context.setAttribute("digilib.servlet.configuration", dlConfig);
 
-			} catch (Exception e) {
-				logger.error("Error in initialisation: ", e);
-			}
-		} else {
-			// say hello in the log file
-			logger.info("***** Digital Image Library Initialiser (version "
-							+ version + ") *****");
-			logger.warn("Already initialised!");
-		}
-	}
+            } catch (Exception e) {
+                logger.error("Error in initialisation: ", e);
+            }
+        } else {
+            // say hello in the log file
+            logger.info("***** Digital Image Library Initialiser (version " + version + ") *****");
+            logger.warn("Already initialised!");
+        }
+    }
 
-    /** clean up local resources
+    /**
+     * clean up local resources
      * 
      */
     public void contextDestroyed(ServletContextEvent arg0) {
@@ -188,7 +183,7 @@
             List<Runnable> rj = imageEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down image job queue: "+nrj);
+                logger.error("Still running threads when shutting down image job queue: " + nrj);
             }
         }
         if (pdfEx != null) {
@@ -196,7 +191,7 @@
             List<Runnable> rj = pdfEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down PDF job queue: "+nrj);
+                logger.error("Still running threads when shutting down PDF job queue: " + nrj);
             }
         }
         if (pdfImageEx != null) {
@@ -204,7 +199,7 @@
             List<Runnable> rj = pdfImageEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down PDF-image job queue: "+nrj);
+                logger.error("Still running threads when shutting down PDF-image job queue: " + nrj);
             }
         }
     }
--- a/servlet3/src/main/java/digilib/servlet/Initialiser.java	Thu Apr 04 11:21:16 2013 +0200
+++ b/servlet3/src/main/java/digilib/servlet/Initialiser.java	Thu Apr 04 12:20:29 2013 +0200
@@ -43,7 +43,7 @@
 import org.apache.log4j.xml.DOMConfigurator;
 
 import digilib.auth.AuthOps;
-import digilib.auth.PathServletAuthOps;
+import digilib.auth.AuthOpsFactory;
 import digilib.conf.DigilibConfiguration;
 import digilib.conf.DigilibServletConfiguration;
 import digilib.image.DocuImage;
@@ -56,132 +56,128 @@
  * Singleton initialisation listener for setup tasks and resources.
  * 
  * @author casties
- *  
+ * 
  */
 @WebListener
 public class Initialiser implements ServletContextListener, ServletRequestListener {
 
+    /** servlet version */
+    public static final String version = "0.4";
 
-	/** servlet version */
-	public static final String version = "0.4";
+    /** gengeral logger for this class */
+    private static Logger logger = Logger.getLogger("digilib.init");
 
-	/** gengeral logger for this class */
-	private static Logger logger = Logger.getLogger("digilib.init");
+    /** DocuDirCache instance */
+    DocuDirCache dirCache;
 
-	/** DocuDirCache instance */
-	DocuDirCache dirCache;
-
-	/** DigilibConfiguration instance */
-	DigilibServletConfiguration dlConfig;
+    /** DigilibConfiguration instance */
+    DigilibServletConfiguration dlConfig;
 
-	/** Executor for digilib image jobs (AsyncServletWorker doesn't return anything) */
-	DigilibJobCenter<DocuImage> imageEx;
-	
-	/** Executor for PDF jobs */
-	DigilibJobCenter<OutputStream> pdfEx;
-	
-	/** Executor for PDF image jobs */
-	DigilibJobCenter<DocuImage> pdfImageEx;
-	
-	/**
-	 * Initialisation on first run.
-	 */
+    /**
+     * Executor for digilib image jobs (AsyncServletWorker doesn't return
+     * anything)
+     */
+    DigilibJobCenter<DocuImage> imageEx;
+
+    /** Executor for PDF jobs */
+    DigilibJobCenter<OutputStream> pdfEx;
+
+    /** Executor for PDF image jobs */
+    DigilibJobCenter<DocuImage> pdfImageEx;
+
+    /**
+     * Initialisation on first run.
+     */
     public void contextInitialized(ServletContextEvent cte) {
         ServletContext context = cte.getServletContext();
 
-		System.out.println("***** Digital Image Library Initialiser (version "
-						+ version + ") *****");
+        System.out.println("***** Digital Image Library Initialiser (version " + version + ") *****");
 
-		// see if there is a Configuration instance
-		dlConfig = (DigilibServletConfiguration) context.getAttribute("digilib.servlet.configuration");
-		if (dlConfig == null) {
-			// create new Configuration
-			try {
-				dlConfig = new DigilibServletConfiguration(context);
+        // see if there is a Configuration instance
+        dlConfig = (DigilibServletConfiguration) context.getAttribute("digilib.servlet.configuration");
+        if (dlConfig == null) {
+            // create new Configuration
+            try {
+                dlConfig = new DigilibServletConfiguration(context);
                 // add servlet version
                 dlConfig.newParameter("servlet.version", Scaler.getVersion(), null, 's');
 
-				/*
-				 * further initialization
-				 */
+                /*
+                 * further initialization
+                 */
 
-				// set up the logger
-				File logConf = ServletOps.getConfigFile((File) dlConfig
-						.getValue("log-config-file"), context);
-				if (logConf.canRead()) {
-				    DOMConfigurator.configure(logConf.getAbsolutePath());
-				    dlConfig.setValue("log-config-file", logConf);
-				}
-				// say hello in the log file
-				logger
-						.info("***** Digital Image Library Initialiser (version "
-								+ version + ") *****");
-				// directory cache
-				String[] bd = (String[]) dlConfig.getValue("basedir-list");
-				FileClass[] fcs = { FileClass.IMAGE, FileClass.TEXT };
-				if (dlConfig.getAsBoolean("use-mapping")) {
-					// with mapping file
-					File mapConf = ServletOps.getConfigFile((File) dlConfig
-							.getValue("mapping-file"), context);
-					dirCache = new AliasingDocuDirCache(bd, fcs, mapConf,
-							dlConfig);
-					dlConfig.setValue("mapping-file", mapConf);
-				} else {
-					// without mapping
-					dirCache = new DocuDirCache(bd, fcs, dlConfig);
-				}
-				dlConfig.setValue("servlet.dir.cache", dirCache);
-				// useAuthentication
-				if (dlConfig.getAsBoolean("use-authorization")) {
-					// DB version
-					//authOp = new DBAuthOpsImpl(util);
-					// XML version
-					File authConf = ServletOps.getConfigFile((File) dlConfig
-							.getValue("auth-file"), context);
-					AuthOps authOp = new PathServletAuthOps(authConf);
-					dlConfig.setValue("servlet.auth.op", authOp);
-					dlConfig.setValue("auth-file", authConf);
-				}
-				// DocuImage class
-				DocuImage di = DigilibConfiguration.getDocuImageInstance();
-				dlConfig.setValue("servlet.docuimage.class", di.getClass().getName());
-				// disk cache for image toolkit
-				boolean dc = dlConfig.getAsBoolean("img-diskcache-allowed");
-				// TODO: methods for all toolkits?
-				ImageIO.setUseCache(dc);
-				// digilib worker threads
-				int nt = dlConfig.getAsInt("worker-threads");
+                // set up the logger
+                File logConf = ServletOps.getConfigFile((File) dlConfig.getValue("log-config-file"), context);
+                if (logConf.canRead()) {
+                    DOMConfigurator.configure(logConf.getAbsolutePath());
+                    dlConfig.setValue("log-config-file", logConf);
+                }
+                // say hello in the log file
+                logger.info("***** Digital Image Library Initialiser (version " + version + ") *****");
+                // directory cache
+                String[] bd = (String[]) dlConfig.getValue("basedir-list");
+                FileClass[] fcs = { FileClass.IMAGE, FileClass.TEXT };
+                if (dlConfig.getAsBoolean("use-mapping")) {
+                    // with mapping file
+                    File mapConf = ServletOps.getConfigFile((File) dlConfig.getValue("mapping-file"), context);
+                    dirCache = new AliasingDocuDirCache(bd, fcs, mapConf, dlConfig);
+                    dlConfig.setValue("mapping-file", mapConf);
+                } else {
+                    // without mapping
+                    dirCache = new DocuDirCache(bd, fcs, dlConfig);
+                }
+                dlConfig.setValue("servlet.dir.cache", dirCache);
+                // useAuthentication
+                if (dlConfig.getAsBoolean("use-authorization")) {
+                    AuthOps authOp = AuthOpsFactory.getAuthOpsInstance();
+                    // get config file
+                    File authConf = ServletOps.getConfigFile((File) dlConfig.getValue("auth-file"), context);
+                    if (authConf != null) {
+                        authOp.setConfig(authConf);
+                    }
+                    dlConfig.setValue("servlet.auth.op", authOp);
+                    dlConfig.setValue("auth-file", authConf);
+                }
+                // DocuImage class
+                DocuImage di = DigilibConfiguration.getDocuImageInstance();
+                dlConfig.setValue("servlet.docuimage.class", di.getClass().getName());
+                // disk cache for image toolkit
+                boolean dc = dlConfig.getAsBoolean("img-diskcache-allowed");
+                // TODO: methods for all toolkits?
+                ImageIO.setUseCache(dc);
+                // digilib worker threads
+                int nt = dlConfig.getAsInt("worker-threads");
                 int mt = dlConfig.getAsInt("max-waiting-threads");
-				imageEx = new DigilibJobCenter<DocuImage>(nt, mt, false, "servlet.worker.imageexecutor");
+                imageEx = new DigilibJobCenter<DocuImage>(nt, mt, false, "servlet.worker.imageexecutor");
                 dlConfig.setValue("servlet.worker.imageexecutor", imageEx);
                 // digilib worker timeout
                 long to = dlConfig.getAsInt("worker-timeout");
                 AsyncServletWorker.setTimeout(to);
-				// PDF worker threads
-				int pnt = dlConfig.getAsInt("pdf-worker-threads");
+                // PDF worker threads
+                int pnt = dlConfig.getAsInt("pdf-worker-threads");
                 int pmt = dlConfig.getAsInt("pdf-max-waiting-threads");
-				pdfEx = new DigilibJobCenter<OutputStream>(pnt, pmt, false, "servlet.worker.pdfexecutor");
-                dlConfig.setValue("servlet.worker.pdfexecutor", pdfEx);				
-				// PDF image worker threads
-				int pint = dlConfig.getAsInt("pdf-image-worker-threads");
+                pdfEx = new DigilibJobCenter<OutputStream>(pnt, pmt, false, "servlet.worker.pdfexecutor");
+                dlConfig.setValue("servlet.worker.pdfexecutor", pdfEx);
+                // PDF image worker threads
+                int pint = dlConfig.getAsInt("pdf-image-worker-threads");
                 int pimt = dlConfig.getAsInt("pdf-image-max-waiting-threads");
-				pdfImageEx = new DigilibJobCenter<DocuImage>(pint, pimt, false, "servlet.worker.pdfimageexecutor");
-                dlConfig.setValue("servlet.worker.pdfimageexecutor", pdfImageEx);				
-				// set as the servlets main config
-				context.setAttribute("digilib.servlet.configuration", dlConfig);
+                pdfImageEx = new DigilibJobCenter<DocuImage>(pint, pimt, false, "servlet.worker.pdfimageexecutor");
+                dlConfig.setValue("servlet.worker.pdfimageexecutor", pdfImageEx);
+                // set as the servlets main config
+                context.setAttribute("digilib.servlet.configuration", dlConfig);
 
-			} catch (Exception e) {
-				logger.error("Error in initialisation: ", e);
-			}
-		} else {
-			// say hello in the log file
-			logger.info("***** Digital Image Library Initialiser (version "
-							+ version + ") *****");
-			logger.warn("Already initialised!");
-		}
-	}
+            } catch (Exception e) {
+                logger.error("Error in initialisation: ", e);
+            }
+        } else {
+            // say hello in the log file
+            logger.info("***** Digital Image Library Initialiser (version " + version + ") *****");
+            logger.warn("Already initialised!");
+        }
+    }
 
-    /** clean up local resources
+    /**
+     * clean up local resources
      * 
      */
     public void contextDestroyed(ServletContextEvent arg0) {
@@ -195,7 +191,7 @@
             List<Runnable> rj = imageEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down image job queue: "+nrj);
+                logger.error("Still running threads when shutting down image job queue: " + nrj);
             }
         }
         if (pdfEx != null) {
@@ -203,7 +199,7 @@
             List<Runnable> rj = pdfEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down PDF job queue: "+nrj);
+                logger.error("Still running threads when shutting down PDF job queue: " + nrj);
             }
         }
         if (pdfImageEx != null) {
@@ -211,7 +207,7 @@
             List<Runnable> rj = pdfImageEx.shutdownNow();
             int nrj = rj.size();
             if (nrj > 0) {
-                logger.error("Still running threads when shutting down PDF-image job queue: "+nrj);
+                logger.error("Still running threads when shutting down PDF-image job queue: " + nrj);
             }
         }
     }
@@ -219,14 +215,14 @@
     @Override
     public void requestDestroyed(ServletRequestEvent arg0) {
         int i = dlConfig.openRequestCnt.decrementAndGet();
-        logger.debug("ServletRequest destroyed. (cnt="+i+")");
+        logger.debug("ServletRequest destroyed. (cnt=" + i + ")");
     }
 
     @Override
     public void requestInitialized(ServletRequestEvent arg0) {
         dlConfig.webappRequestCnt.incrementAndGet();
         int i = dlConfig.openRequestCnt.incrementAndGet();
-        logger.debug("ServletRequest created. (cnt="+i+")");
+        logger.debug("ServletRequest created. (cnt=" + i + ")");
     }
 
 }