mschachter    01/07/20 16:34:04

  Modified:    doc      struts-logic.xml todo-1.1.xml
               src/share/org/apache/struts/taglib/logic PresentTag.java
  Log:
   - enhancement for multiple role checking in logic:present and logic:notPresent tag
  
  Submitted by: James Bonaiuto
  Proposed  by: David Winterfeldt
  
  Revision  Changes    Path
  1.9       +5 -1      jakarta-struts/doc/struts-logic.xml
  
  Index: struts-logic.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/doc/struts-logic.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- struts-logic.xml  2001/07/08 04:15:11     1.8
  +++ struts-logic.xml  2001/07/20 23:34:04     1.9
  @@ -1321,7 +1321,11 @@
         <rtexprvalue>true</rtexprvalue>
         <info>
         <p>Checks whether the currently authenticated user (if any) has been
  -      associated with the specified security role.</p>
  +      associated with any of the specified security roles. Use a comma-delimited
  +       list to check for multiple roles. Example:
  +       <code>&lt;logic:present role="role1,role2,role3"&gt;
  +                 code.....
  +                     &lt;/logic:present&gt;</code></p>
         </info>
       </attribute>
   
  
  
  
  1.4       +0 -13     jakarta-struts/doc/todo-1.1.xml
  
  Index: todo-1.1.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/doc/todo-1.1.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- todo-1.1.xml      2001/05/11 17:10:47     1.3
  +++ todo-1.1.xml      2001/07/20 23:34:04     1.4
  @@ -427,19 +427,6 @@
         </info>
       </task>
   
  -    <task name="Enhance Role Checking">
  -      <info>
  -        <p>Enhance <code>&lt;logic:present&gt;</code> to accept a comma
  -        delimited list of roles in the <code>role</code> attribute, and
  -        process the nested body content if <em>any</em> of the listed roles
  -        where owned by the current user.  A corresponding change to
  -        <code>&lt;logic:notPresent&gt;</code> would process the nested body
  -        content only if <em>none</em> of the listed roles were owned by
  -        the present user.</p>
  -        [STRUTS-USER, David Winterfeldt, 01/03/2001]
  -      </info>
  -    </task>
  -
     </task-list>
   
   
  
  
  
  1.10      +13 -7     
jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java
  
  Index: PresentTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PresentTag.java   2001/07/16 00:44:57     1.9
  +++ PresentTag.java   2001/07/20 23:34:04     1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 
1.9 2001/07/16 00:44:57 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2001/07/16 00:44:57 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/PresentTag.java,v 
1.10 2001/07/20 23:34:04 mschachter Exp $
  + * $Revision: 1.10 $
  + * $Date: 2001/07/20 23:34:04 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,7 @@
   
   
   import java.security.Principal;
  +import java.util.StringTokenizer;
   import javax.servlet.http.Cookie;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.jsp.JspException;
  @@ -77,12 +78,14 @@
    * is present for this request.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2001/07/16 00:44:57 $
  + * @version $Revision: 1.10 $ $Date: 2001/07/20 23:34:04 $
    */
   
   public class PresentTag extends ConditionalTagBase {
   
   
  +    public static final String ROLE_DELIMITER = ",";
  +    
       // ------------------------------------------------------ Protected Methods
   
   
  @@ -146,9 +149,12 @@
                   pageContext.getRequest().getParameter(parameter);
               present = (value != null);
           } else if (role != null) {
  -            HttpServletRequest request =
  -                (HttpServletRequest) pageContext.getRequest();
  -            present = request.isUserInRole(role);
  +            HttpServletRequest request = (HttpServletRequest)
  +                                                       pageContext.getRequest();
  +            StringTokenizer st = new StringTokenizer(role, ROLE_DELIMITER, false);
  +            while(!present && st.hasMoreTokens()){
  +             present = request.isUserInRole(st.nextToken());
  +            }
           } else if (user != null) {
               HttpServletRequest request =
                   (HttpServletRequest) pageContext.getRequest();
  
  
  

Reply via email to