portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r726976 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/ components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/ jetspeed-api/src/main/java/org/apach...
Date Tue, 16 Dec 2008 07:15:50 GMT
Author: taylor
Date: Mon Dec 15 23:15:50 2008
New Revision: 726976

URL: http://svn.apache.org/viewvc?rev=726976&view=rev
Log:
improving profiler to support any generic principal type

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
  (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
  (with props)
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/GroupCriterionResolver.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleComboCriterionResolver.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleCriterionResolver.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
    portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/security/SubjectHelper.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/profiler.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
Mon Dec 15 23:15:50 2008
@@ -20,10 +20,12 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+
 import org.apache.jetspeed.profiler.ProfileLocator;
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.ProfileResolvers;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.ojb.broker.util.collections.RemovalAwareCollection;
@@ -37,13 +39,13 @@
 public abstract class AbstractProfilingRule implements ProfilingRule
 {
     private static final long serialVersionUID = 1;    
-    protected Collection criteria = new RemovalAwareCollection();
+    protected Collection<RuleCriterion> criteria = new RemovalAwareCollection();
     protected String id;
     protected String title;
     protected String ojbConcreteClass;
     
     /** Map of profile locators kept around for reuse TODO: evict entries after max size
reached */    
-    protected Map locators = Collections.synchronizedMap(new HashMap());
+    protected Map<String, ProfileLocator> locators = Collections.synchronizedMap(new
HashMap<String, ProfileLocator>());
     
     /** Map of resolver rules for criteria. The map goes from criterion name to resolver
class */
     protected ProfileResolvers resolvers;
@@ -90,7 +92,7 @@
     /* (non-Javadoc)
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getRuleCriterion()
      */
-    public Collection getRuleCriteria()
+    public Collection<RuleCriterion> getRuleCriteria()
     {
         return criteria;
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/GroupCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/GroupCriterionResolver.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/GroupCriterionResolver.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/GroupCriterionResolver.java
Mon Dec 15 23:15:50 2008
@@ -16,14 +16,7 @@
  */
 package org.apache.jetspeed.profiler.rules.impl;
 
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.profiler.rules.RuleCriterion;
-import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.profiler.rules.FallbackCriterionResolver;
 
 /**
  * Standard Jetspeed-1 Group resolver.
@@ -36,39 +29,8 @@
  * @version $Id$
  */
 public class GroupCriterionResolver
-    extends StandardResolver
-    implements RuleCriterionResolver
+    extends PrincipalCriterionResolver
+    implements FallbackCriterionResolver
 {
-    protected final static Log log = LogFactory.getLog(UserCriterionResolver.class);
-    
-     /* (non-Javadoc)
-      * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.profiler.rules.RuleCriterion)
-      */    
-     public String resolve(RequestContext context, RuleCriterion criterion)
-     {
-         String value = super.resolve(context, criterion);
-         if (value != null)
-         {
-             return value;
-         }
-            
-         Subject subject = context.getSubject();
-         if (subject == null)
-         {
-             String msg = "Invalid (null) Subject in request pipeline";
-             log.error(msg);
-             return null;
-         }
-
-         return resolvePrincipals(context, criterion, subject, Group.class);
-      }
-     
-     /* (non-Javadoc)
-      * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#isControl()
-      */
-     public boolean isControl(RuleCriterion criterion)
-     {
-         return true;
-     }
-     
+    private static final long serialVersionUID = 1L;
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java?rev=726976&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
Mon Dec 15 23:15:50 2008
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.profiler.rules.impl;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.profiler.rules.FallbackCriterionResolver;
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.SubjectHelper;
+
+/**
+ * Fallback by Principal control resolver. Can be used with any principal type including
role and group
+ * It first looks at the value in the criterion record.
+ * If it is null, it then falls back to a request parameter.
+ * If it is null it gives up and returns null allowing subclasses
+ * to continue processing.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class PrincipalCriterionResolver extends StandardResolver implements
+        FallbackCriterionResolver
+{
+    private static final long serialVersionUID = 1L;
+    protected final static Log log = LogFactory.getLog(PrincipalCriterionResolver.class);
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.profiler.rules.RuleCriterion)
+     */    
+    public String resolve(RequestContext context, RuleCriterion criterion)
+    {
+        String value = super.resolve(context, criterion);
+        if (value != null)
+        {
+            return value;
+        }
+            
+        Subject subject = context.getSubject();
+        if (subject == null)
+        {
+            String msg = "Invalid (null) Subject in request pipeline";
+            log.error(msg);
+            return null;
+        }        
+        return resolvePrincipals(context, criterion, subject, criterion.getName());
+     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#isControl()
+     */
+    public boolean isControl(RuleCriterion criterion)
+    {
+        return true;
+    }
+    
+    protected String resolvePrincipals(RequestContext context, RuleCriterion criterion, Subject
subject, String jptName)
+    {
+        StringBuffer result = new StringBuffer();        
+        int count = 0;
+        for (JetspeedPrincipal principal : SubjectHelper.getPrincipals(subject, jptName))
       
+        {
+            if (count > 0)
+            {
+                result.append(VALUE_DELIMITER);
+            }
+            result.append(principal.getName());
+            count++;
+        }
+        if (count == 0)
+        {
+            return null;
+        }
+        return result.toString();        
+    }    
+    
+        
+    protected String combinePrincipals(RequestContext context, RuleCriterion criterion, Subject
subject, String jptName)
+    {
+        StringBuffer result = new StringBuffer();
+        int count = 0;
+        for (JetspeedPrincipal principal : SubjectHelper.getPrincipals(subject, jptName))
+        {
+            if (count > 0)
+            {
+                result.append(COMBO_DELIMITER);
+            }
+            result.append(principal.getName());
+            count++;
+        }
+        if (count == 0)
+        {
+            return null;
+        }
+        return result.toString();        
+    }
+  
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/PrincipalCriterionResolver.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleComboCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleComboCriterionResolver.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleComboCriterionResolver.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleComboCriterionResolver.java
Mon Dec 15 23:15:50 2008
@@ -20,10 +20,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.profiler.rules.FallbackCriterionResolver;
 import org.apache.jetspeed.profiler.rules.RuleCriterion;
-import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.Role;
 
 /**
  * Role combo resolver 
@@ -35,22 +34,14 @@
  * @version $Id: RoleCriterionResolver.java 187756 2004-10-15 22:58:43Z ate $
  */
 public class RoleComboCriterionResolver
-    extends StandardResolver
-    implements RuleCriterionResolver
+    extends PrincipalCriterionResolver
+    implements FallbackCriterionResolver
 {
-    protected final static Log log = LogFactory.getLog(UserCriterionResolver.class);
+    private static final long serialVersionUID = 1L;
+    protected final static Log log = LogFactory.getLog(RoleComboCriterionResolver.class);
     
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.profiler.rules.RuleCriterion)
-     */    
     public String resolve(RequestContext context, RuleCriterion criterion)
     {
-        String value = super.resolve(context, criterion);
-        if (value != null)
-        {
-            return value;
-        }
-            
         Subject subject = context.getSubject();
         if (subject == null)
         {
@@ -58,17 +49,11 @@
             log.error(msg);
             return null;
         }
-            
-        return combinePrincipals(context, criterion, subject, Role.class);
+        return combinePrincipals(context, criterion, subject, criterion.getName());
      }
     
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#isControl()
-     */
     public boolean isControl(RuleCriterion criterion)
     {
         return true;
     }
-    
-    
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleCriterionResolver.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleCriterionResolver.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleCriterionResolver.java
Mon Dec 15 23:15:50 2008
@@ -16,14 +16,7 @@
  */
 package org.apache.jetspeed.profiler.rules.impl;
 
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.profiler.rules.RuleCriterion;
-import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.profiler.rules.FallbackCriterionResolver;
 
 /**
  * Standard Jetspeed-1 Role resolver (not role-based fallback).
@@ -36,40 +29,8 @@
  * @version $Id$
  */
 public class RoleCriterionResolver
-    extends StandardResolver
-    implements RuleCriterionResolver
+    extends PrincipalCriterionResolver
+    implements FallbackCriterionResolver
 {
-    protected final static Log log = LogFactory.getLog(UserCriterionResolver.class);
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.profiler.rules.RuleCriterion)
-     */    
-    public String resolve(RequestContext context, RuleCriterion criterion)
-    {
-        String value = super.resolve(context, criterion);
-        if (value != null)
-        {
-            return value;
-        }
-            
-        Subject subject = context.getSubject();
-        if (subject == null)
-        {
-            String msg = "Invalid (null) Subject in request pipeline";
-            log.error(msg);
-            return null;
-        }
-            
-        return resolvePrincipals(context, criterion, subject, Role.class);
-     }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#isControl()
-     */
-    public boolean isControl(RuleCriterion criterion)
-    {
-        return true;
-    }
-    
-    
+    private static final long serialVersionUID = 1L;
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java
Mon Dec 15 23:15:50 2008
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.profiler.ProfileLocator;
 import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.rules.FallbackCriterionResolver;
 import org.apache.jetspeed.profiler.rules.ProfileResolvers;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 import org.apache.jetspeed.profiler.rules.RuleCriterion;
@@ -64,7 +65,7 @@
         int count = 0;
         
         // first pass, build the key
-        Iterator criteria = this.getRuleCriteria().iterator();
+        Iterator<RuleCriterion> criteria = this.getRuleCriteria().iterator();
         while (criteria.hasNext())
         {
             RuleCriterion criterion = (RuleCriterion)criteria.next();
@@ -78,8 +79,7 @@
                 resolver = getDefaultResolver();
             }
             String value = resolver.resolve(context, criterion);
-            if (value != null && (resolver instanceof RoleCriterionResolver ||
-                resolver instanceof GroupCriterionResolver))
+            if (value != null && (resolver instanceof FallbackCriterionResolver))
                   
             {
                 StringTokenizer tokenizer = new StringTokenizer(value, StandardResolver.VALUE_DELIMITER);
                 while (tokenizer.hasMoreTokens())
@@ -132,20 +132,19 @@
                 String value = resolver.resolve(context, criterion);
                 boolean isControl = resolver.isControl(criterion);
                 boolean isNavigation = resolver.isNavigation(criterion);
-                if (value != null && (resolver instanceof RoleCriterionResolver ||
-                        resolver instanceof GroupCriterionResolver))
-                    {
-                        StringTokenizer tokenizer = new StringTokenizer(value, StandardResolver.VALUE_DELIMITER);
-                        while (tokenizer.hasMoreTokens())
-                        {
-                            String token = tokenizer.nextToken();
-                            locator.add(criterion, isControl, isNavigation, token);
-                        }
-                    }
-                    else
+                if (value != null && (resolver instanceof FallbackCriterionResolver))

+                {
+                    StringTokenizer tokenizer = new StringTokenizer(value, StandardResolver.VALUE_DELIMITER);
+                    while (tokenizer.hasMoreTokens())
                     {
-                        locator.add(criterion, isControl, isNavigation, value);
+                        String token = tokenizer.nextToken();
+                        locator.add(criterion, isControl, isNavigation, token);
                     }
+                }
+                else
+                {
+                    locator.add(criterion, isControl, isNavigation, value);
+                }
             }                
         }               
              

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java
Mon Dec 15 23:15:50 2008
@@ -16,15 +16,9 @@
  */
 package org.apache.jetspeed.profiler.rules.impl;
 
-import java.security.Principal;
-import java.util.Iterator;
-
-import javax.security.auth.Subject;
-
 import org.apache.jetspeed.profiler.rules.RuleCriterion;
 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.SubjectHelper;
 
 /**
  * Standard Jetspeed-1 style resolver for criterion.
@@ -38,6 +32,7 @@
  */
 public class StandardResolver implements RuleCriterionResolver
 {
+    private static final long serialVersionUID = 1L;
     public static final String VALUE_DELIMITER = ",";
     public static final String COMBO_DELIMITER = "-";
     
@@ -70,50 +65,5 @@
     public boolean isNavigation(RuleCriterion criterion)
     {
         return false;
-    }
-    
-    protected String resolvePrincipals(RequestContext context, RuleCriterion criterion, Subject
subject, Class classe)
-    {
-        StringBuffer result = new StringBuffer();
-        Iterator principals = SubjectHelper.getPrincipals(subject, classe).iterator();
-        int count = 0;
-        while (principals.hasNext())
-        {
-            Principal principal = (Principal)principals.next();
-            if (count > 0)
-            {
-                result.append(VALUE_DELIMITER);
-            }
-            result.append(principal.getName());
-            count++;
-        }
-        if (count == 0)
-        {
-            return null;
-        }
-        return result.toString();        
-    }
-
-    protected String combinePrincipals(RequestContext context, RuleCriterion criterion, Subject
subject, Class classe)
-    {
-        StringBuffer result = new StringBuffer();
-        Iterator principals = SubjectHelper.getPrincipals(subject, classe).iterator();
-        int count = 0;
-        while (principals.hasNext())
-        {
-            Principal principal = (Principal)principals.next();
-            if (count > 0)
-            {
-                result.append(COMBO_DELIMITER);
-            }
-            result.append(principal.getName());
-            count++;
-        }
-        if (count == 0)
-        {
-            return null;
-        }
-        return result.toString();        
-    }
-    
+    }    
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
Mon Dec 15 23:15:50 2008
@@ -227,7 +227,7 @@
         context.setPath("/homepage.psml");        
         context.setSubject(subject);
         ProfileLocator locator = rule.apply(context, profiler);
-        System.out.println("locator = " + locator);
+        System.out.println("locator = " + locator);                            //     /homepage.psml:user:david:navigation:/:role:ATP:role:NB:page:/homepage.psml
         assertTrue("locator string " + locator.toString(), locator.toString().equals("/homepage.psml:user:david:navigation:/:role:ATP-NB:page:/homepage.psml"));
         
         System.out.println("COMPLETED: running test user role fallback.");

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java?rev=726976&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
(added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
Mon Dec 15 23:15:50 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.profiler.rules;
+
+/**
+ * Represents any criterion that always falls back
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public interface FallbackCriterionResolver extends RuleCriterionResolver
+{
+
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/FallbackCriterionResolver.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
Mon Dec 15 23:15:50 2008
@@ -97,7 +97,7 @@
      * 
      * @return a sorted map of rule criteria.
      */         
-    Collection getRuleCriteria();
+    Collection<RuleCriterion> getRuleCriteria();
                      
     /**
      * Gets the unique identifier for this rule

Modified: portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/security/SubjectHelper.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/security/SubjectHelper.java?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/security/SubjectHelper.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/security/SubjectHelper.java
Mon Dec 15 23:15:50 2008
@@ -158,6 +158,34 @@
     
     /**
      * <p>
+     * Given a subject, finds all principals of the given JetspeedPrincipalType(JPT)  for
that subject. If no principals
+     * of the given class is not found, null is returned.
+     * </p>
+     * 
+     * @param subject The subject supplying the principals.
+     * @param jptName the name of the Jetspeed Principal Type
+     * @return A List of all principals of type JetspeedPrincipal matching a JPT name parameter.
+     */
+    public static List<JetspeedPrincipal> getPrincipals(Subject subject, String jptName)
+    {
+        List<JetspeedPrincipal> result = new LinkedList<JetspeedPrincipal>();
+        Iterator<Principal> principals = subject.getPrincipals().iterator();
+        while (principals.hasNext())
+        {
+            Principal p = principals.next();
+            if (p instanceof JetspeedPrincipal)
+            {
+                JetspeedPrincipal jp = (JetspeedPrincipal)p;
+                if (jp.getType().getName().equals(jptName))
+                {
+                    result.add(jp);
+                }
+            }
+        }
+        return result;
+    }    
+    /**
+     * <p>
      * Given a subject, finds a specific principal by name of the given classe for that subject.
      * </p>
      * 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/profiler.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/profiler.xml?rev=726976&r1=726975&r2=726976&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/profiler.xml
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/profiler.xml
Mon Dec 15 23:15:50 2008
@@ -166,6 +166,9 @@
   <bean id='RoleCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.RoleCriterionResolver'>
     <meta key="j2:cat" value="default,profiler" />
   </bean>
+  <bean id='PrincipalCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.PrincipalCriterionResolver'>
+    <meta key="j2:cat" value="default,profiler" />
+  </bean>
   <bean id='RoleComboCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.RoleComboCriterionResolver'>
     <meta key="j2:cat" value="default,profiler" />
   </bean>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message