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 javax.servlet.http.*; 24 import javax.servlet.jsp.*; 25 import javax.servlet.jsp.tagext.*; 26 27 import com.pow2.acl.dao.*; 28 import com.pow2.user.*; 29 import org.apache.log4j.*; 30 31 32 /*** 33 * Base tag for ACL tags. 34 * 35 * @author Luca Fossato 36 * @created 24 aprile 2002 37 */ 38 public class ACLTag extends TagSupport 39 { 40 /*** ACL Data Access Object */ 41 protected static ACLDAO acldao = ACLDAO.instance(); 42 43 /*** Log4j category; */ 44 protected static Category cat = Category.getInstance(ACLTag.class); 45 46 /*** group name */ 47 protected String group; 48 49 /*** permission name */ 50 protected String permission; 51 52 /*** role name */ 53 protected String role; 54 55 /*** indicate if the user is authenticated */ 56 protected boolean userAuthenticated; 57 58 /*** */ 59 protected boolean value; 60 61 62 /*** 63 * Default constructor 64 */ 65 public ACLTag() 66 { 67 super(); 68 userAuthenticated = false; 69 value = true; 70 } 71 72 73 /*** 74 * Process the end tag. 75 * 76 * @return Description of the Returned Value 77 * @exception JspTagException Description of Exception 78 */ 79 public int doEndTag() throws JspTagException 80 { 81 return EVAL_PAGE; 82 } 83 84 85 /*** 86 * Retrieve the user object from the session context. 87 * 88 * @return the user object, or null if the user does not exist 89 * @exception JspTagException if the user object cannot be retrieved 90 * from the request object 91 */ 92 protected User getUser() throws JspTagException 93 { 94 HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); 95 User user = UserManager.instance().getUser(request); 96 97 if (user == null) 98 throw new JspTagException("the user retrieved from the session context is null"); 99 100 return user; 101 } 102 103 104 /*** 105 * Sets the group attribute of the ACLTag object 106 * 107 * @param group The new group value 108 */ 109 public void setGroup(String group) 110 { 111 this.group = group; 112 } 113 114 115 /*** 116 * Sets the permission attribute of the ACLTag object 117 * 118 * @param permission The new permission value 119 */ 120 public void setPermission(String permission) 121 { 122 this.permission = permission; 123 } 124 125 126 /*** 127 * Sets the role attribute of the ACLTag object 128 * 129 * @param role The new role value 130 */ 131 public void setRole(String role) 132 { 133 this.role = role; 134 } 135 136 137 /*** 138 * Sets the value attribute of the ACLTag object 139 * 140 * @param value The new value value 141 */ 142 public void setValue(boolean value) 143 { 144 this.value = value; 145 } 146 147 148 /*** 149 * Gets the value attribute of the ACLTag object 150 * 151 * @return The value value 152 */ 153 public boolean isValue() 154 { 155 return value; 156 } 157 158 159 /*** 160 * If <code>value</code> is false, return 161 * the negated value of <code>result</code>. 162 * 163 * @return if <code>value</code> is false, return 164 * the negated value of <code>result</code> 165 */ 166 protected boolean booleanValue(boolean result) 167 { 168 return value ? result : !result; 169 } 170 }

This page was automatically generated by Maven