View Javadoc
1 /*** 2 * The contents of this file are subject to the Mozilla Public 3 * License Version 1.1 (the "License"); you may not use this file 4 * except in compliance with the License. You may obtain a copy of 5 * the License at http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS 8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 * implied. See the License for the specific language governing 10 * rights and limitations under the License. 11 * 12 * The Original Code is pow2ACL library. 13 * 14 * The Initial Owner of the Original Code is Power Of Two S.R.L. 15 * Portions created by Power Of Two S.R.L. are Copyright (C) Power Of Two S.R.L. 16 * All Rights Reserved. 17 * 18 * Contributor(s): 19 */ 20 21 package com.pow2.acl.taglib; 22 23 import com.pow2.acl.Group; 24 import com.pow2.acl.Role; 25 26 import com.pow2.acl.dao.ACLDAO; 27 import com.pow2.user.User; 28 import com.pow2.util.Util; 29 import javax.servlet.http.HttpServletResponse; 30 31 import javax.servlet.http.HttpSession; 32 33 import javax.servlet.jsp.*; 34 import javax.servlet.jsp.tagext.*; 35 36 /*** 37 * @author Massimiliano Farnea 38 */ 39 public class IsUserInRoleTag extends ACLTag 40 { 41 /*** Default constructor */ 42 public IsUserInRoleTag() 43 { 44 super(); 45 46 role = ""; 47 group = null; 48 } 49 50 51 /*** 52 * Process the start tag for this instance. 53 * <br> 54 * 55 * Eval body if User is in Role 56 * 57 * @return Description of the Returned Value 58 * @exception JspTagException if an error occures. 59 */ 60 public int doStartTag() throws JspTagException 61 { 62 // user cannot be null ;^) 63 User user = getUser(); 64 65 try 66 { 67 if (!Util.isNull(role)) 68 { 69 Role rl = new Role(role); 70 71 if (!Util.isNull(group)) 72 userAuthenticated = acldao.isUserInRole(user, new Group(group), rl); 73 else 74 userAuthenticated = acldao.isUserInRole(user, rl); 75 } 76 } 77 catch (Exception e) 78 { 79 cat.error("::doStartTag - exception: ", e); 80 throw new JspTagException("Error: " + e.getMessage()); 81 } 82 83 return booleanValue(userAuthenticated) ? EVAL_BODY_INCLUDE : SKIP_BODY; 84 } 85 }

This page was automatically generated by Maven