cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 37245 - in cocoon/branches/BRANCH_2_1_X/src: blocks/portal/java/org/apache/cocoon/portal/coplet blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl blocks/portal/java/org/apache/cocoon/portal/coplet/impl blocks/portal/java/org/apache/cocoon/portal/profile/impl java/org/apache/cocoon/components/treeprocessor
Date Tue, 31 Aug 2004 08:30:00 GMT
Author: cziegeler
Date: Tue Aug 31 01:29:58 2004
New Revision: 37245

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletDescription.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Log:
Fix ClassCastException in redirect
Extend role protection for coplets

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java
Tue Aug 31 01:29:58 2004
@@ -24,7 +24,7 @@
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
  * 
- * @version CVS $Id: CopletBaseData.java,v 1.8 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public final class CopletBaseData { 
 
@@ -35,6 +35,7 @@
 	private String copletAdapterName;
 
 	public CopletBaseData() {
+        // Nothing to do
 	}
 
 	public String getId() {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
Tue Aug 31 01:29:58 2004
@@ -15,12 +15,16 @@
  */
 package org.apache.cocoon.portal.coplet;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import org.apache.cocoon.portal.factory.impl.AbstractProducible;
 import org.apache.cocoon.portal.util.DeltaApplicable;
+import org.apache.commons.lang.StringUtils;
 
 /**
  *
@@ -28,7 +32,7 @@
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
  * 
- * @version CVS $Id: CopletData.java,v 1.10 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class CopletData 
 extends AbstractProducible
@@ -40,6 +44,14 @@
 
     protected Map attributes = new HashMap();
 
+    protected String allowedRoles;
+    
+    protected String deniedRoles;
+    
+    protected transient List allowedRolesList;
+    
+    protected transient List deniedRolesList;
+    
 	/**
 	 * Signals whether a delta has been applied.
 	 */
@@ -49,6 +61,7 @@
      * Constructor
      */
     public CopletData() {
+        // Nothing to do
     }
 
     /**
@@ -153,4 +166,154 @@
 	public boolean deltaApplied() {
 		return this.deltaApplied;
 	}
+    
+    /**
+     * @return Returns the allowed roles.
+     */
+    public String getAllowedRoles() {
+        return this.allowedRoles;
+    }
+    /**
+     * @param roles The allowed roles to set.
+     */
+    public void setAllowedRoles(String roles) {
+        this.allowedRoles = roles;
+        this.allowedRolesList = null;
+    }
+    
+    /**
+     * @return Returns the denied roles.
+     */
+    public String getDeniedRoles() {
+        return this.deniedRoles;
+    }
+    /**
+     * @param roles The allowed roles to set.
+     */
+    public void setDeniedRoles(String roles) {
+        this.deniedRoles = roles;
+        this.deniedRolesList = null;
+    }
+
+    /**
+     * Return the list of roles that are allowed to access this coplet
+     * @return A list of roles or null if everyone is allowed.
+     */
+    public List getAllowedRolesList() {
+        if ( StringUtils.isBlank(this.allowedRoles) ) {
+            return null;
+        }
+        if ( this.allowedRolesList == null ) {
+            this.allowedRolesList = new ArrayList();
+            final StringTokenizer tokenizer = new StringTokenizer(this.allowedRoles, ",");
+            while ( tokenizer.hasMoreElements() ) {
+                String token = (String)tokenizer.nextElement();
+                this.allowedRolesList.add(token);
+            }
+            if ( this.allowedRolesList.size() == 0 ) {
+                this.allowedRoles = null;
+                this.allowedRolesList = null;
+            }
+        }
+        return this.allowedRolesList;
+    }
+    
+    /**
+     * Return the list of roles that are denied to access this coplet
+     * @return A list of roles or null if everyone is allowed.
+     */
+    public List getDeniedRolesList() {
+        if ( StringUtils.isBlank(this.deniedRoles) ) {
+            return null;
+        }
+        if ( this.deniedRolesList == null ) {
+            this.deniedRolesList = new ArrayList();
+            final StringTokenizer tokenizer = new StringTokenizer(this.deniedRoles, ",");
+            while ( tokenizer.hasMoreElements() ) {
+                String token = (String)tokenizer.nextElement();
+                this.deniedRolesList.add(token);
+            }
+            if ( this.deniedRolesList.size() == 0 ) {
+                this.deniedRoles = null;
+                this.deniedRolesList = null;
+            }
+        }
+        return this.deniedRolesList;
+    }
+
+    public void addToAllowedRoles(String role) {
+        List l = this.getAllowedRolesList();
+        if ( l == null ) {
+            l = new ArrayList();
+            l.add(role);
+        } else {
+            if ( !l.contains(role) ) {
+                l.add(role);
+            }
+        }
+        this.buildRolesString(l, true);
+    }
+    
+    public void removeFromAllowedRoles(String role) {
+        List l = this.getAllowedRolesList();
+        if ( l != null && l.contains(role) ) {
+            l.remove(role);
+            if ( l.size() == 0 ) {
+                this.allowedRoles = null;
+                this.allowedRolesList = null;
+            } else {
+                this.buildRolesString(l, true);
+            }
+        }
+    }
+    
+    public void addToDeniedRoles(String role) {
+        List l = this.getDeniedRolesList();
+        if ( l == null ) {
+            l = new ArrayList();
+            l.add(role);
+        } else {
+            if ( !l.contains(role) ) {
+                l.add(role);
+            }
+        }
+        this.buildRolesString(l, false);
+    }
+    
+    public void removeFromDeniedRoles(String role) {
+        List l = this.getDeniedRolesList();
+        if ( l != null && l.contains(role) ) {
+            l.remove(role);
+            if ( l.size() == 0 ) {
+                this.deniedRoles = null;
+                this.deniedRolesList = null;
+            } else {
+                this.buildRolesString(l, false);
+            }
+        }
+    }
+
+    protected void buildRolesString(List fromList, boolean allow) {
+        if ( allow ) {
+            this.allowedRolesList = fromList;
+        } else {
+            this.deniedRolesList = fromList;
+        }
+        StringBuffer buffer = new StringBuffer();
+        boolean first = true;
+        Iterator i = fromList.iterator();
+        while ( i.hasNext() ) {
+            String role = (String)i.next();
+            if ( !first ) {
+                buffer.append(',');
+            }
+            first = false;
+            buffer.append(role);
+        }
+        if ( allow ) {
+            this.allowedRoles = buffer.toString();
+        } else {
+            this.deniedRoles = buffer.toString();
+        }
+    }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletDescription.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletDescription.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletDescription.java
Tue Aug 31 01:29:58 2004
@@ -20,13 +20,14 @@
 
 
 /**
- * A configured layout
+ * A configured coplet
  * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: CopletDescription.java,v 1.2 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public interface CopletDescription
     extends ProducibleDescription  {
 
+    // no additional info for now
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
Tue Aug 31 01:29:58 2004
@@ -27,7 +27,7 @@
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
  * 
- * @version CVS $Id: CopletInstanceData.java,v 1.10 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public final class CopletInstanceData 
     extends AbstractProducible {
@@ -43,6 +43,7 @@
 	 * Constructor
 	 */
 	public CopletInstanceData() {
+        // Nothing to do
 	}
 
 	/**

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
Tue Aug 31 01:29:58 2004
@@ -34,7 +34,7 @@
  *
  * @author <a href="mailto:gerald.kahrer@rizit.at">Gerald Kahrer</a>
  * 
- * @version CVS $Id: CachingURICopletAdapter.java,v 1.5 2004/04/25 20:09:34 haul Exp $
+ * @version CVS $Id$
  */
 public class CachingURICopletAdapter
     extends URICopletAdapter
@@ -119,11 +119,11 @@
 
                 bi.deserialize(bc.getSAXFragment());
             } else {
-            this.toCache(coplet, bc.getSAXFragment());
+                this.toCache(coplet, bc.getSAXFragment());
 
-            this.toSAXFromCache(coplet, contentHandler);
+                this.toSAXFromCache(coplet, contentHandler);
+            }
         }
-    }
     }
 
     /**

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
Tue Aug 31 01:29:58 2004
@@ -49,6 +49,14 @@
 			<bind-xml name="title"/>
 		</field>
 
+		<field name="allowedRoles" type="java.lang.String">
+			<bind-xml name="allowed-roles"/>
+		</field>
+
+		<field name="deniedRoles" type="java.lang.String">
+			<bind-xml name="denied-roles"/>
+		</field>
+
 		<field name="attributes" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.util.AttributesFieldHandler">
 			<bind-xml name="attribute"/>
 		</field>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
Tue Aug 31 01:29:58 2004
@@ -48,7 +48,7 @@
  * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: DefaultCopletFactory.java,v 1.9 2004/03/05 13:02:11 bdelacretaz Exp
$
+ * @version CVS $Id$
  */
 public class DefaultCopletFactory  
     extends AbstractLogEnabled 
@@ -62,6 +62,9 @@
     
     protected ServiceSelector storeSelector;
 
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.coplet.CopletFactory#prepare(org.apache.cocoon.portal.coplet.CopletData)
+     */
     public void prepare(CopletData copletData)
     throws ProcessingException {
         if ( copletData != null ) {
@@ -83,6 +86,9 @@
         }
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.coplet.CopletFactory#prepare(org.apache.cocoon.portal.coplet.CopletInstanceData)
+     */
     public void prepare(CopletInstanceData copletInstanceData)
     throws ProcessingException {
         if ( copletInstanceData != null ) {
@@ -105,6 +111,9 @@
     }
 
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.coplet.CopletFactory#newInstance(org.apache.cocoon.portal.coplet.CopletData)
+     */
     public CopletInstanceData newInstance(CopletData copletData)
     throws ProcessingException {
         String name = copletData.getName();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Tue Aug 31 01:29:58 2004
@@ -15,8 +15,6 @@
  */
 package org.apache.cocoon.portal.profile.impl;
 
-import java.util.List;
-
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
@@ -27,7 +25,6 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.portal.PortalService;
-import org.apache.cocoon.portal.coplet.CopletData;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.profile.ProfileManager;
@@ -37,7 +34,7 @@
  * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: AbstractProfileManager.java,v 1.7 2004/04/28 13:58:16 cziegeler Exp
$
+ * @version CVS $Id$
  */
 public abstract class AbstractProfileManager 
     extends AbstractLogEnabled 
@@ -55,67 +52,33 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(org.apache.cocoon.portal.coplet.CopletData)
-     */
-    public List getCopletInstanceData(CopletData data) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
-     */
-    public CopletInstanceData getCopletInstanceData(String copletID) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(java.lang.String,
java.lang.String)
-     */
-    public Layout getPortalLayout(String layoutKey, String layoutID) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void register(CopletInstanceData coplet) {
-        // TODO Auto-generated method stub
-
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.layout.Layout)
      */
     public void register(Layout layout) {
-        // TODO Auto-generated method stub
-
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles()
      */
     public void saveUserProfiles() {
-        // TODO Auto-generated method stub
-
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void unregister(CopletInstanceData coplet) {
-        // TODO Auto-generated method stub
-
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.layout.Layout)
      */
     public void unregister(Layout layout) {
-        // TODO Auto-generated method stub
-
     }
 
     /**
@@ -207,6 +170,9 @@
         }
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
     public void configure(Configuration configuration) throws ConfigurationException {
         Configuration child = configuration.getChild("default-layout-key");
         // get configured default LayoutKey

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationProfileManager.java
Tue Aug 31 01:29:58 2004
@@ -328,7 +328,7 @@
                 this.attributes.put(key, new Object[] {object, newValidity});
 			}
 
-			return new Object[]{object, Boolean.TRUE};
+			return new Object[] {object, Boolean.TRUE};
         } catch (ProfileException pe) {
             this.getLogger().error("Error loading profile: " + pe.getMessage(), pe);
             throw pe;

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Tue Aug 31 01:29:58 2004
@@ -46,7 +46,9 @@
  * 
  * @version CVS $Id: ConcreteTreeProcessor.java,v 1.1 2004/06/05 08:18:50 sylvain Exp $
  */
-public class ConcreteTreeProcessor extends AbstractLogEnabled implements Processor {
+public class ConcreteTreeProcessor 
+extends AbstractLogEnabled 
+implements Processor, Disposable {
 
 	/** The processor that wraps us */
 	private TreeProcessor wrappingProcessor;
@@ -297,16 +299,22 @@
         }
         
         // Process the redirect
-// No more reset since with TreeProcessorRedirector, we need to pop values from the redirect
location
-//        context.reset();
-        // The following is a fix for bug #26854 and #26571
+        // No more reset since with TreeProcessorRedirector, we need to pop values from the
redirect location
+        // context.reset();
+        // The following is a fix for bug #26854 and #26571        
         final boolean result = processor.process(newEnv, context);
+        if ( facade != null ) {
+            newEnv = facade.getDelegate();
+        }
         if ( ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() != null ) {
             environment.redirect( false, ((ForwardEnvironmentWrapper)newEnv).getRedirectURL()
);
         }
         return result;
     }
     
+	/* (non-Javadoc)
+	 * @see org.apache.avalon.framework.activity.Disposable#dispose()
+	 */
 	public void dispose() {
         if (this.disposableNodes != null) {
             // we must dispose the nodes in reverse order

Mime
View raw message