1 19 20 package com.sslexplorer.core.tags; 21 22 import javax.servlet.jsp.tagext.TagSupport ; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 import com.sslexplorer.core.CoreUtil; 28 import com.sslexplorer.properties.Property; 29 import com.sslexplorer.properties.impl.systemconfig.SystemConfigKey; 30 import com.sslexplorer.security.LogonControllerFactory; 31 import com.sslexplorer.security.SecurityErrorException; 32 import com.sslexplorer.security.User; 33 34 public class CheckPropertyNotEqualsTag extends TagSupport { 35 36 final static Log log = LogFactory.getLog(CheckPropertyNotEqualsTag.class); 37 38 String propertyName; 39 String propertyValue; 40 boolean regExp; 41 boolean userProfile; 42 43 public CheckPropertyNotEqualsTag() { 44 } 45 46 public int doStartTag() { 47 48 User user = null; 49 try { 50 user = LogonControllerFactory.getInstance().getUser(pageContext.getSession(), null); 51 } catch (SecurityErrorException ex) { 52 } 53 String val; 54 try { 55 if(userProfile) { 56 val = CoreUtil.getUsersProfileProperty(pageContext.getSession(), propertyName, user); 57 } 58 else { 59 val = Property.getProperty(new SystemConfigKey(propertyName)); 60 } 61 if (regExp) { 62 if (!val.matches(propertyValue)) { 63 return EVAL_BODY_INCLUDE; 64 } else { 65 return SKIP_BODY; 66 } 67 } else { 68 if (!propertyValue.equals(val)) { 69 return EVAL_BODY_INCLUDE; 70 } else { 71 return SKIP_BODY; 72 } 73 } 74 } catch (Exception e) { 75 log.error("Could not determine property value.", e); 76 return SKIP_BODY; 77 } 78 } 79 80 public void setUserProfile(boolean userProfile) { 81 this.userProfile = userProfile; 82 } 83 84 public void setRegExp(boolean regExp) { 85 this.regExp = regExp; 86 } 87 88 public void setPropertyName(String propertyName) { 89 this.propertyName = propertyName; 90 } 91 92 public void setPropertyValue(String propertyValue) { 93 this.propertyValue = propertyValue; 94 } 95 96 public void release() { 97 super.release(); 98 userProfile = false; 99 regExp = false; 100 propertyName = null; 101 propertyValue = null; 102 } 103 104 } | Popular Tags |