cziegeler 02/05/29 08:38:09 Modified: src/java/org/apache/cocoon/components CocoonComponentManager.java src/java/org/apache/cocoon/webapps/authentication/components AuthenticationManager.java HandlerManager.java Log: New authentication manager Revision Changes Path 1.22 +3 -3 xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java Index: CocoonComponentManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- CocoonComponentManager.java 29 May 2002 13:38:48 -0000 1.21 +++ CocoonComponentManager.java 29 May 2002 15:38:09 -0000 1.22 @@ -81,7 +81,7 @@ * and by handling the lookup of the <code>SourceResolver</code> (in development) * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: CocoonComponentManager.java,v 1.21 2002/05/29 13:38:48 cziegeler Exp $ + * @version CVS $Id: CocoonComponentManager.java,v 1.22 2002/05/29 15:38:09 cziegeler Exp $ */ public final class CocoonComponentManager extends ExcaliburComponentManager @@ -225,6 +225,8 @@ if (component instanceof Recomposable) { ((Recomposable) component).recompose(this); } + ((RequestLifecycleComponent) component).setup((org.apache.cocoon.environment.SourceResolver)objects[0], + (Map)objects[1]); if (component instanceof SitemapConfigurable) { for(int i=0; i < stack.size(); i++) { Object[] o = (Object[])stack.get(i); @@ -237,8 +239,6 @@ } } } - ((RequestLifecycleComponent) component).setup((org.apache.cocoon.environment.SourceResolver)objects[0], - (Map)objects[1]); } catch (Exception local) { throw new ComponentException("Exception during setup of RequestLifecycleComponent with role '"+role+"'", local); } 1.7 +16 -13 xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java Index: AuthenticationManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/AuthenticationManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AuthenticationManager.java 29 May 2002 13:38:48 -0000 1.6 +++ AuthenticationManager.java 29 May 2002 15:38:09 -0000 1.7 @@ -98,7 +98,7 @@ * This is the basis authentication component. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: AuthenticationManager.java,v 1.6 2002/05/29 13:38:48 cziegeler Exp $ + * @version CVS $Id: AuthenticationManager.java,v 1.7 2002/05/29 15:38:09 cziegeler Exp $ */ public final class AuthenticationManager extends AbstractSessionComponent @@ -115,6 +115,9 @@ private static final String SESSION_CONTEXT_ATTRIBUTE_ADMIN_ROLE = "org.apache.cocoon.webapps.authentication.adminrole"; + /** The handler manager */ + private HandlerManager handlerManager = new HandlerManager(); + /** All Handlers hashed by their name */ private Map configuredHandlers; @@ -161,14 +164,6 @@ } /** - * Set the configuration - * The configuration is set global once when the AuthAction is - * configured, allowing other components to use the AuthenticationManager - * instance - */ - private static Configuration authenticationConfiguration; - - /** * Recyclable */ public void recycle() { @@ -178,6 +173,9 @@ this.handler = null; this.handlerName = null; this.userHandlers = null; + + // clear handlers + this.handlerManager.clearAvailableHandlers(); } /** @@ -185,7 +183,15 @@ */ public void setSitemapConfiguration(Configuration config) throws ConfigurationException { - authenticationConfiguration = config; + try { + // synchronized + this.configureHandlers(config); + } catch (ProcessingException pe) { + throw new ConfigurationException("Exception during configuration of handlers."); + } + + //this.handlerManager.addConfiguration( config, this.resolver, this.request ); + //this.handlerManager.addAvailableHandlers( config ); } /** @@ -197,9 +203,6 @@ public void setup(SourceResolver resolver, Map objectModel) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel); - - // synchronized - this.configureHandlers(AuthenticationManager.authenticationConfiguration); // get the media of the current request String useragent = request.getHeader("User-Agent"); 1.3 +48 -13 xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java Index: HandlerManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/authentication/components/HandlerManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HandlerManager.java 29 May 2002 15:05:59 -0000 1.2 +++ HandlerManager.java 29 May 2002 15:38:09 -0000 1.3 @@ -62,7 +62,7 @@ * This is a utility class managing the authentication handlers * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: HandlerManager.java,v 1.2 2002/05/29 15:05:59 cziegeler Exp $ + * @version CVS $Id: HandlerManager.java,v 1.3 2002/05/29 15:38:09 cziegeler Exp $ */ public final class HandlerManager { @@ -74,18 +74,21 @@ /** All configured handlers */ protected static Map configuredHandlers = new HashMap(4); + /** The available handlers for the current request */ + protected Map availableHandlers = new HashMap(4); + /** * Add new configurations to the pool */ public void addConfiguration(Configuration conf, SourceResolver resolver, Request request) - throws ConfigurationException, ProcessingException { + throws ConfigurationException { if (null != conf && - !this.configuredConfigurations.contains(conf)) { - synchronized (this.configuredConfigurations) { - if (!this.configuredConfigurations.contains(conf)) { - this.configuredConfigurations.add( conf ); + !configuredConfigurations.contains(conf)) { + synchronized (configuredConfigurations) { + if (!configuredConfigurations.contains(conf)) { + configuredConfigurations.add( conf ); // test for handlers Configuration handlersWrapper = conf.getChild("handlers", false); @@ -107,12 +110,12 @@ protected void addHandler(Configuration configuration, SourceResolver resolver, Request request) - throws ConfigurationException, ProcessingException { + throws ConfigurationException { // get handler name final String name = configuration.getAttribute("name"); // test if handler is unique - if (this.configuredHandlers.get(name) != null) { + if (configuredHandlers.get(name) != null) { throw new ConfigurationException("Handler names must be unique: " + name); } @@ -120,14 +123,16 @@ Handler currentHandler = new Handler(name); // store handler - this.configuredHandlers.put(name, currentHandler); + configuredHandlers.put(name, currentHandler); try { currentHandler.configure(resolver,request, configuration); + } catch (ProcessingException se) { + throw new ConfigurationException("Exception during configuration of handler: " + name, se); } catch (org.xml.sax.SAXException se) { - throw new ProcessingException("Exception during configuration of handler: " + name, se); + throw new ConfigurationException("Exception during configuration of handler: " + name, se); } catch (java.io.IOException se) { - throw new ProcessingException("Exception during configuration of handler: " + name, se); + throw new ConfigurationException("Exception during configuration of handler: " + name, se); } } @@ -135,7 +140,37 @@ * Clear all */ public void clearConfigurations() { - this.configuredConfigurations.clear(); - this.configuredHandlers.clear(); + configuredConfigurations.clear(); + configuredHandlers.clear(); + } + + /** + * Clear available handlers + */ + public void clearAvailableHandlers() { + this.availableHandlers.clear(); + } + + /** + * Add to available handlers + */ + public void addAvailableHandlers(Configuration conf) + throws ConfigurationException { + if ( null != conf ) { + final Configuration handlersConf = conf.getChild("handlers", false); + if ( null != handlersConf ) { + Configuration[] handlers = handlersConf.getChildren("handler"); + if ( null != handlers ) { + for(int i=0; i < handlers.length; i++) { + final String name = handlers[i].getAttribute("name"); + final Object o = this.configuredHandlers.get(name); + if ( null == o) + throw new ConfigurationException("Handler " + name + " is missing in configuration."); + this.availableHandlers.put(name, o); + } + } + } + } } + }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]