1 57 58 package com.sun.org.apache.xerces.internal.util; 59 import com.sun.org.apache.xerces.internal.impl.Constants; 60 78 public final class SecurityManager { 79 80 84 private final static int DEFAULT_ENTITY_EXPANSION_LIMIT = 64000; 86 87 88 private final static int DEFAULT_MAX_OCCUR_NODE_LIMIT = 3000; 89 90 94 private final static int DEFAULT_ELEMENT_ATTRIBUTE_LIMIT = 10000; 95 96 97 private int entityExpansionLimit; 98 99 100 private int maxOccurLimit; 101 102 private int fElementAttributeLimit; 103 109 public SecurityManager() { 110 entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT; 111 maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT ; 112 fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT; 113 readSystemProperties(); 116 } 117 118 125 public void setEntityExpansionLimit(int limit) { 126 entityExpansionLimit = limit; 127 } 128 129 136 public int getEntityExpansionLimit() { 137 return entityExpansionLimit; 138 } 139 140 149 public void setMaxOccurNodeLimit(int limit){ 150 maxOccurLimit = limit; 151 } 152 153 162 public int getMaxOccurNodeLimit(){ 163 return maxOccurLimit; 164 } 165 166 public int getElementAttrLimit(){ 167 return fElementAttributeLimit; 168 } 169 170 public void setElementAttrLimit(int limit){ 171 fElementAttributeLimit = limit; 172 } 173 174 private void readSystemProperties(){ 175 176 try { 178 String value = System.getProperty(Constants.ENTITY_EXPANSION_LIMIT); 179 if(value != null && !value.equals("")){ 180 entityExpansionLimit = Integer.parseInt(value); 181 if (entityExpansionLimit < 0) 182 entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT; 183 } 184 else 185 entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT; 186 }catch(Exception ex){} 187 188 try { 189 String value = System.getProperty(Constants.MAX_OCCUR_LIMIT); 190 if(value != null && !value.equals("")){ 191 maxOccurLimit = Integer.parseInt(value); 192 if (maxOccurLimit < 0) 193 maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT; 194 } 195 else 196 maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT; 197 }catch(Exception ex){} 198 199 try { 200 String value = System.getProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT); 201 if(value != null && !value.equals("")){ 202 fElementAttributeLimit = Integer.parseInt(value); 203 if ( fElementAttributeLimit < 0) 204 fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT; 205 } 206 else 207 fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT; 208 209 }catch(Exception ex){} 210 211 } 212 213 } 215 | Popular Tags |