ASF Bugzilla – Attachment 8037 Details for
Bug 22895
[PATCH] <req:isUserInRole> upgrade to support multiple roles
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for isUserInRoleTag.java
IsUserInRoleTag.txt (text/plain), 2.36 KB, created by
Matthew Sgarlata
on 2003-09-02 18:55:57 UTC
(
hide
)
Description:
Patch for isUserInRoleTag.java
Filename:
MIME Type:
Creator:
Matthew Sgarlata
Created:
2003-09-02 18:55:57 UTC
Size:
2.36 KB
patch
obsolete
>Index: IsUserInRoleTag.java >=================================================================== >RCS file: /home/cvspublic/jakarta-taglibs/request/src/org/apache/taglibs/request/IsUserInRoleTag.java,v >retrieving revision 1.3 >diff -u -r1.3 IsUserInRoleTag.java >--- IsUserInRoleTag.java 13 Jul 2001 00:09:06 -0000 1.3 >+++ IsUserInRoleTag.java 1 Sep 2003 01:37:52 -0000 >@@ -69,9 +69,10 @@ > > /** > * JSP Tag <b>isuserinrole</b>, used to determine if HttpServletRequest >- * is for an authenticated user in a role. >+ * is for an authenticated user in a comma-separated list of roles. > * <p> >- * Includes the body of the tag if an authenticated user in a role. >+ * Includes the body of the tag if an authenticated user in one of a list of >+ * roles. > * <p> > * Requires that the attribute <b>role</b> be set. > * <p> >@@ -98,22 +99,36 @@ > * </pre> > * > * @author Glenn Nielsen >+ * @author Matthew Sgarlata > */ > > public class IsUserInRoleTag extends TagSupport > { >+ private static final String ROLE_DELIMITERS = ", \t\n\r\f"; >+ > private boolean value = true; > private String role = null; > > /** >- * Determines whether remote user is in a role. >+ * Determines whether remote user is in one of the specified roles. > * > * @return SKIP_BODY if isuserinrole doesn't match value, EVAL_BODY_include if isuserinrole matches value > */ > public final int doStartTag() throws JspException > { >- boolean result = ((HttpServletRequest)pageContext.getRequest()).isUserInRole(role); >- >+ boolean result = false; >+ HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); >+ StringTokenizer tokenizer = new StringTokenizer(role, ROLE_DELIMITERS); >+ >+ // while the user has not matched one of the roles >+ while (tokenizer.hasMoreTokens() && !result) >+ { >+ if (request.isUserInRole(tokenizer.nextToken())) >+ { >+ result = true; >+ } >+ } >+ > if( value == result ) > return EVAL_BODY_INCLUDE; > >@@ -132,7 +147,9 @@ > > /** > * Set the required tag attribute <b>role</b> to the name >- * of the role you wish to test remote user for. >+ * of the role(s) you wish to test remote user for. If more than one role >+ * is to be specified, the names of the roles should be separated with >+ * commas. > * > * @param String role name > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 22895
: 8037 |
8038