KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > frontoffice > taglib > UserInRoleTag


1 /*
2  * ĻON content management system.
3  * Copyright (C) 2002 Guillaume Bort(gbort@msn.com). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  * Copyright 2000-2002 (C) Intalio Inc. All Rights Reserved.
7  *
8  * ĻON is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * ĻON core framework, ĻON content server, ĻON backoffice, ĻON frontoffice
14  * and ĻON admin application are parts of ĻON and are distributed under
15  * same terms of licence.
16  *
17  *
18  * ĻON includes software developed by the Apache Software Foundation (http://www.apache.org/)
19  * and software developed by the Exolab Project (http://www.exolab.org).
20  *
21  * ĻON is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  */

26
27 package org.nextime.ion.frontoffice.taglib;
28
29 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
30 import javax.servlet.jsp.*;
31 import javax.servlet.http.*;
32
33 public class UserInRoleTag extends TagSupport JavaDoc {
34     
35     protected String JavaDoc _role = null;
36
37     public String JavaDoc getRole() {
38         return _role;
39     }
40
41     public void setRole(String JavaDoc role) {
42         _role = role;
43     }
44     
45     public int doStartTag() throws JspException {
46         if (checkRole())
47             return (EVAL_BODY_INCLUDE);
48         else
49             return (SKIP_BODY);
50     }
51     
52     public int doEndTag() throws JspException {
53         return (EVAL_PAGE);
54     }
55     
56     protected boolean checkRole() {
57         return ((HttpServletRequest)pageContext.getRequest()).isUserInRole(_role);
58     }
59 }
60
61
Popular Tags