cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components Manager.java DefaultAuthenticationManager.java
Date Fri, 21 Mar 2003 08:54:30 GMT
cziegeler    2003/03/21 00:54:30

  Modified:    src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components
                        Manager.java DefaultAuthenticationManager.java
  Log:
  Start refactoring authentication framework
  
  Revision  Changes    Path
  1.2       +18 -1     cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/Manager.java
  
  Index: Manager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/Manager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Manager.java	20 Mar 2003 15:27:05 -0000	1.1
  +++ Manager.java	21 Mar 2003 08:54:30 -0000	1.2
  @@ -51,6 +51,7 @@
   package org.apache.cocoon.webapps.authentication.components;
   
   import java.io.IOException;
  +import java.util.Map;
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.excalibur.source.SourceParameters;
  @@ -99,4 +100,20 @@
       DocumentFragment authenticate(String              loginHandlerName,
                                     SourceParameters    parameters)
       throws ProcessingException, IOException;
  +
  +    /**
  +     * Build parameters for loading and saving of application data
  +     */
  +    SourceParameters createParameters(String handler, 
  +                                      String applicationName,
  +                                      String path)
  +    throws ProcessingException;
  +    
  +    /**
  +     * Create a map for the actions
  +     * The result is cached!
  +     */
  +    Map createMap(String handler, String applicationName)
  +    throws ProcessingException;
  +    
   }
  
  
  
  1.2       +83 -5     cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java
  
  Index: DefaultAuthenticationManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/authentication-fw/java/org/apache/cocoon/webapps/authentication/components/DefaultAuthenticationManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultAuthenticationManager.java	20 Mar 2003 15:27:05 -0000	1.1
  +++ DefaultAuthenticationManager.java	21 Mar 2003 08:54:30 -0000	1.2
  @@ -51,6 +51,8 @@
   package org.apache.cocoon.webapps.authentication.components;
   
   import java.io.IOException;
  +import java.util.Collections;
  +import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
   
  @@ -58,6 +60,7 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.RequestLifecycleComponent;
   import org.apache.cocoon.components.SitemapConfigurable;
  @@ -572,7 +575,7 @@
                                       String path)
       throws ProcessingException {
           // synchronized
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("BEGIN loadApplicationXML application=" + appHandler.getName()
+ ", path="+path);
           }
           Object o = this.getSessionManager().getSession(true);
  @@ -626,12 +629,34 @@
   
           } // end synchronized
   
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("END loadApplicationXML");
           }
       }
   
       /**
  +     * Check if application for path is loaded
  +     */
  +    private void checkLoaded(SessionContextImpl context,
  +                               String             path,
  +                               ApplicationHandler applicationHandler)
  +    throws ProcessingException {
  +        // synchronized as loadApplicationXML is synced
  +        if ( this.getLogger().isDebugEnabled() ) {
  +            this.getLogger().debug("BEGIN checkLoaded path="+path);
  +        }
  +        if ( path.equals("/") || path.startsWith("/application") ) {
  +            if (applicationHandler != null) {
  +                this.loadApplicationXML(context, applicationHandler, "/");
  +            }
  +        }
  +
  +        if ( this.getLogger().isDebugEnabled() ) {
  +            this.getLogger().debug("END checkLoaded");
  +        }
  +    }
  +    
  +    /**
        * Build parameters for loading and saving of application data
        */
       private SourceParameters createParameters(SourceParameters parameters,
  @@ -640,7 +665,7 @@
                                                   String             appName)
       throws ProcessingException {
           // synchronized
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("BEGIN createParameters handler=" + myHandler +
                                 ", path="+path+ ", application=" + appName);
           }
  @@ -652,10 +677,63 @@
                                                         this.manager);
           parameters = context.createParameters(parameters, myHandler, path, appName);
   
  -        if (this.getLogger().isDebugEnabled() == true) {
  +        if (this.getLogger().isDebugEnabled() ) {
               this.getLogger().debug("END createParameters parameters="+parameters);
           }
           return parameters;
  +    }
  +
  +    /**
  +     * Build parameters for loading and saving of application data
  +     */
  +    public SourceParameters createParameters(String handler, 
  +                                              String applicationName,
  +                                              String path)
  +    throws ProcessingException {
  +        // synchronized
  +        if (handler == null) {
  +            return new SourceParameters();
  +        }
  +        if (path == null) {
  +            SessionContext context = this.getAuthenticationSessionContext(false);
  +            SourceParameters pars = (SourceParameters)context.getAttribute("cachedparameters_"
+ handler);
  +            if (pars == null) {
  +                 pars = this.createParameters(null, handler, path, applicationName);
  +                 context.setAttribute("cachedparameters_" + handler, pars);
  +            }
  +            return pars;
  +        }
  +        return this.createParameters(null, handler, path, applicationName);
  +    }
  +
  +    /**
  +     * Create a map for the actions
  +     * The result is cached!
  +     */
  +    public Map createMap(String handler, String applicationName)
  +    throws ProcessingException {
  +        if (handler == null) {
  +            // this is only a fallback
  +            return Collections.EMPTY_MAP;
  +        }
  +        SessionContext context = this.getAuthenticationSessionContext(false);
  +        Map map = (Map)context.getAttribute("cachedmap_" + handler);
  +        if (map == null) {
  +            map = new HashMap();
  +            Parameters pars = this.createParameters(handler, applicationName, null).getFirstParameters();
  +            String[] names = pars.getNames();
  +            if (names != null) {
  +                String key;
  +                String value;
  +                for(int i=0;i<names.length;i++) {
  +                    key = names[i];
  +                    value = pars.getParameter(key, null);
  +                    if (value != null) map.put(key, value);
  +                }
  +            }
  +            context.setAttribute("cachedmap_" + handler, map);
  +        }
  +        return map;
       }
   }
   
  
  
  

Mime
View raw message