Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfo.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfo.java	(revision 7265)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfo.java	(revision 7265)
@@ -0,0 +1,26 @@
+/**
+ * This software is copyright (c) 2011-2022 by
+ *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
+ * This is free software. You can redistribute it
+ * and/or modify it under the terms described in
+ * the GNU General Public License v3 of which you
+ * should have received a copy. Otherwise you can download
+ * it from
+ *
+ *   http://www.gnu.org/licenses/gpl-3.0.txt
+ *
+ * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
+ *
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt
+ *  GNU General Public License v3
+ */
+package eu.clarin.sru.server;
+
+public interface SRUAuthenticationInfo {
+
+    public String getAuthentictaionMethod();
+
+
+    public String getSubject();
+
+} // interface SRUAuthenticationInfo
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfoProvider.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfoProvider.java	(revision 7265)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAuthenticationInfoProvider.java	(revision 7265)
@@ -0,0 +1,27 @@
+/**
+ * This software is copyright (c) 2011-2022 by
+ *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
+ * This is free software. You can redistribute it
+ * and/or modify it under the terms described in
+ * the GNU General Public License v3 of which you
+ * should have received a copy. Otherwise you can download
+ * it from
+ *
+ *   http://www.gnu.org/licenses/gpl-3.0.txt
+ *
+ * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
+ *
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt
+ *  GNU General Public License v3
+ */
+package eu.clarin.sru.server;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+public interface SRUAuthenticationInfoProvider {
+
+    public SRUAuthenticationInfo getAuthenticationInfo(
+            HttpServletRequest request) throws SRUException;
+
+} // interface SRUAuthenticationInfoProvider
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequest.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequest.java	(revision 7264)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequest.java	(revision 7265)
@@ -28,4 +28,20 @@
  */
 public interface SRURequest {
+    /**
+     * Get the authentication information that was extracted from the the
+     * request.
+     *
+     * @return the request authentication or <code>null</code>
+     */
+    public SRUAuthenticationInfo getAuthentication();
+
+
+    /**
+     * Get the subject of the request.
+     *
+     * @return the subject of the request or <code>null</code>
+     */
+    public String getAuthenticationSubject();
+
 
     /**
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java	(revision 7264)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java	(revision 7265)
@@ -80,5 +80,7 @@
     private final SRUServerConfig config;
     private final SRUQueryParserRegistry queryParsers;
+    private final SRUAuthenticationInfoProvider authenticationInfoProvider;
     private final HttpServletRequest request;
+    private SRUAuthenticationInfo authenticationInfo;
     private List<SRUDiagnostic> diagnostics;
     private SRUOperation operation;
@@ -249,8 +251,10 @@
     SRURequestImpl(SRUServerConfig config,
             SRUQueryParserRegistry queryParsers,
+            SRUAuthenticationInfoProvider authenticationInfoProvider,
             HttpServletRequest request) {
-        this.config       = config;
+        this.config = config;
         this.queryParsers = queryParsers;
-        this.request      = request;
+        this.authenticationInfoProvider = authenticationInfoProvider;
+        this.request = request;
     }
 
@@ -676,5 +680,4 @@
             }
 
-
             /*
              *  check if any parameters where not consumed and
@@ -694,6 +697,17 @@
 
         /*
+         * extract authentication information from, if an authentication provider is set
+         */
+        if (authenticationInfoProvider != null) {
+            try {
+                authenticationInfo = authenticationInfoProvider.getAuthenticationInfo(request);
+            } catch (SRUException e) {
+                addDiagnostic(e.getDiagnostic());
+            }
+        }
+
+        /*
          *  diagnostics == null -> consider as success
-         *  FIXME: this should ne done nicer!
+         *  FIXME: this should be done nicer!
          */
         return (diagnostics == null);
@@ -773,4 +787,20 @@
 
     @Override
+    public SRUAuthenticationInfo getAuthentication() {
+        return authenticationInfo;
+    }
+
+
+    @Override
+    public String getAuthenticationSubject() {
+        if (authenticationInfo != null) {
+            return authenticationInfo.getSubject();
+        } else {
+            return null;
+        }
+    }
+
+
+    @Override
     public SRUOperation getOperation() {
         return operation;
@@ -1014,6 +1044,11 @@
     @Override
     public void addDiagnostic(String uri, String details, String message) {
-        final SRUDiagnostic diagnostic =
-                new SRUDiagnostic(uri, details, message);
+        final SRUDiagnostic diagnostic = new SRUDiagnostic(uri, details,
+                message);
+        addDiagnostic(diagnostic);
+    }
+
+
+    private void addDiagnostic(SRUDiagnostic diagnostic) {
         if (diagnostics == null) {
             diagnostics = new ArrayList<SRUDiagnostic>();
@@ -1021,6 +1056,6 @@
         diagnostics.add(diagnostic);
     }
-
-
+    
+    
     private List<String> getParameterNames() {
         List<String> list = new ArrayList<String>();
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java	(revision 7264)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java	(revision 7265)
@@ -59,4 +59,5 @@
     private final SRUServerConfig config;
     private final SRUQueryParserRegistry queryParsers;
+    private final SRUAuthenticationInfoProvider authenticationInfoProvider;
     private final SRUSearchEngine searchEngine;
     private final XMLOutputFactory writerFactory;
@@ -70,4 +71,6 @@
      * @param queryParsers
      *            a {@link SRUQueryParserRegistry} object
+     * @param authenticationInfoProvider
+     *            a {@link SRUAuthenticationInfoProvider} or <code>null</code>
      * @param searchEngine
      *            an object implementing the {@link SRUSearchEngine} interface
@@ -75,10 +78,11 @@
      *             if config, queryParserRegistry or searchEngine is
      *             <code>null</code>
-     * @throws SRUException
-     *             if an error occurred
+     * @throws SRUConfigException
+     *             if an error occurred with configuration or initialization of the server
      */
     public SRUServer(SRUServerConfig config,
             SRUQueryParserRegistry queryParsers,
-            SRUSearchEngine searchEngine) throws SRUException {
+            SRUAuthenticationInfoProvider authenticationInfoProvider,
+            SRUSearchEngine searchEngine) throws SRUConfigException {
         if (config == null) {
             throw new NullPointerException("config == null");
@@ -95,4 +99,6 @@
         }
         this.searchEngine = searchEngine;
+
+        this.authenticationInfoProvider = authenticationInfoProvider;
 
         this.writerFactory = XMLOutputFactory.newInstance();
@@ -111,5 +117,5 @@
             HttpServletResponse response) {
         final SRURequestImpl req =
-                new SRURequestImpl(config, queryParsers, request);
+                new SRURequestImpl(config, queryParsers, authenticationInfoProvider, request);
         try {
             // set response properties
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUAuthenticationInfoProviderFactory.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUAuthenticationInfoProviderFactory.java	(revision 7265)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUAuthenticationInfoProviderFactory.java	(revision 7265)
@@ -0,0 +1,23 @@
+package eu.clarin.sru.server.utils;
+
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import eu.clarin.sru.server.SRUAuthenticationInfoProvider;
+import eu.clarin.sru.server.SRUConfigException;
+
+public interface SRUAuthenticationInfoProviderFactory {
+    /**
+     * Create a authentication info provider.
+     *
+     * @param context
+     * @param params
+     * @return
+     * @throws SRUConfigException
+     */
+    public SRUAuthenticationInfoProvider createAuthenticationInfoProvider(
+            ServletContext context, Map<String, String> params)
+            throws SRUConfigException;
+
+} // interface SRUAuthenticationProviderFactory
Index: /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUServerServlet.java
===================================================================
--- /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUServerServlet.java	(revision 7264)
+++ /SRUServer/trunk/src/main/java/eu/clarin/sru/server/utils/SRUServerServlet.java	(revision 7265)
@@ -22,4 +22,5 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -36,6 +37,6 @@
 import org.slf4j.LoggerFactory;
 
+import eu.clarin.sru.server.SRUAuthenticationInfoProvider;
 import eu.clarin.sru.server.SRUConfigException;
-import eu.clarin.sru.server.SRUException;
 import eu.clarin.sru.server.SRUQueryParserRegistry;
 import eu.clarin.sru.server.SRUServer;
@@ -145,5 +146,5 @@
          * get init-parameters from ServletConfig ...
          */
-        final HashMap<String, String> params = new HashMap<String, String>();
+        Map<String, String> params = new HashMap<>();
         for (Enumeration<?> i = cfg.getInitParameterNames();
                 i.hasMoreElements();) {
@@ -204,57 +205,69 @@
                     contextPath);
         }
-
-        // parse configuration
-        SRUServerConfig sruServerConfig;
-        try {
-            sruServerConfig =
-                    SRUServerConfig.parse(params, sruServerConfigFile);
-        } catch (SRUConfigException e) {
-            throw new ServletException("sru server configuration is invalid", e);
-        }
+        // seal parameters against tampering ...
+        params = Collections.unmodifiableMap(params);
 
         /*
-         * create an instance of the search engine ...
+         * now go ahead and setup everything ...
          */
         try {
-            logger.debug("creating new search engine from class {}",
-                    sruServerSearchEngineClass);
-            @SuppressWarnings("unchecked")
-            Class<SRUSearchEngineBase> clazz = (Class<SRUSearchEngineBase>)
-                Class.forName(sruServerSearchEngineClass);
-            Constructor<SRUSearchEngineBase> constructor =
-                    clazz.getConstructor();
-            searchEngine = constructor.newInstance();
-        } catch (ClassNotFoundException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (ClassCastException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (NoSuchMethodException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (SecurityException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (InstantiationException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (IllegalAccessException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (IllegalArgumentException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (InvocationTargetException e) {
-            throw new ServletException("error initializing sru server", e);
-        }
-
-        /*
-         * finally initialize the SRU server ...
-         */
-        try {
+            /*
+             * parse SRU server configuration
+             */
+            SRUServerConfig sruServerConfig =
+                    SRUServerConfig.parse(params, sruServerConfigFile);
+
+            /*
+             * create an instance of the search engine ...
+             */
+            try {
+                logger.debug("creating new search engine from class {}",
+                        sruServerSearchEngineClass);
+                @SuppressWarnings("unchecked")
+                Class<SRUSearchEngineBase> clazz = (Class<SRUSearchEngineBase>)
+                    Class.forName(sruServerSearchEngineClass);
+                Constructor<SRUSearchEngineBase> constructor =
+                        clazz.getConstructor();
+                searchEngine = constructor.newInstance();
+            } catch (ClassNotFoundException |
+                    NoSuchMethodException |
+                    SecurityException |
+                    InstantiationException |
+                    IllegalAccessException |
+                    IllegalArgumentException |
+                    InvocationTargetException e) {
+                throw new SRUConfigException("error creating search engine", e);
+            }
+
+            /*
+             * initialize search engine ...
+             */
             final SRUQueryParserRegistry.Builder builder =
                     new SRUQueryParserRegistry.Builder();
             searchEngine.init(ctx, sruServerConfig, builder, params);
-            final SRUQueryParserRegistry parsers = builder.build();
-            sruServer = new SRUServer(sruServerConfig, parsers, searchEngine);
+
+            /*
+             * create authentication provider
+             */
+            SRUAuthenticationInfoProvider authenticationProvider = null;
+            if (SRUAuthenticationInfoProviderFactory.class.isInstance(searchEngine)) {
+                logger.debug("creating new authentication info provider");
+
+                authenticationProvider = ((SRUAuthenticationInfoProviderFactory) searchEngine)
+                        .createAuthenticationInfoProvider(ctx, params);
+            }
+
+            /*
+             * finally create the sru server ...
+             */
+            sruServer = new SRUServer(sruServerConfig,
+                    builder.build(),
+                    authenticationProvider,
+                    searchEngine);
         } catch (SRUConfigException e) {
-            throw new ServletException("error initializing sru server", e);
-        } catch (SRUException e) {
-            throw new ServletException("error initializing sru server", e);
+            String msg = (e.getMessage() != null)
+                        ? "error configuring or inializing the server: " + e.getMessage()
+                        : "error configuring or inializing the server";
+            throw new ServletException(msg, e);
         }
     }
