1 10 package org.mmbase.bridge.jsp.taglib.security; 11 12 import org.mmbase.bridge.*; 13 import org.mmbase.bridge.jsp.taglib.util.Attribute; 14 import org.mmbase.bridge.jsp.taglib.Condition; 15 import org.mmbase.bridge.jsp.taglib.CloudReferrerTag; 16 17 import javax.servlet.jsp.JspTagException ; 18 19 20 27 28 public class MayReadTag extends CloudReferrerTag implements Condition { 29 30 protected Attribute inverse = Attribute.NULL; 31 protected Attribute referid = Attribute.NULL; 32 protected Attribute number = Attribute.NULL; 33 34 public void setInverse(String b) throws JspTagException { 35 inverse = getAttribute(b); 36 } 37 public void setNumber(String n) throws JspTagException { 38 number = getAttribute(n); 39 } 40 public void setReferid(String r) throws JspTagException { 41 referid = getAttribute(r); 42 } 43 protected boolean getInverse() throws JspTagException { 44 return inverse.getBoolean(this, false); 45 } 46 47 public int doStartTag() throws JspTagException { 48 Cloud cloud = getCloudVar(); 49 String n = number.getString(this); 50 String rid = referid.getString(this); 51 String nodeNumber; 52 if ("".equals(n)) { 53 nodeNumber = getString(rid); 54 } else { 55 nodeNumber = n; 56 if (! rid.equals("")) { 57 throw new JspTagException ("Cannot specify both 'number' and 'referid"); 58 } 59 } 60 if (cloud.mayRead(nodeNumber) != getInverse()) { 61 return EVAL_BODY; 62 } else { 63 return SKIP_BODY; 64 } 65 } 66 public int doAfterBody() throws JspTagException { 67 if (EVAL_BODY == EVAL_BODY_BUFFERED) { try{ 69 if(bodyContent != null) { 70 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 71 } 72 } catch(java.io.IOException e){ 73 throw new JspTagException ("IO Error: " + e.getMessage()); 74 } 75 } 76 return SKIP_BODY; 77 } 78 } 79 | Popular Tags |