src/com/sun/org/apache/xerces/internal/utils/XMLSecurityPropertyManager.java

Print this page




  74      * Values of the properties as defined in enum Properties
  75      */
  76     private final String[] values;
  77     /**
  78      * States of the settings for each property in Properties above
  79      */
  80     private State[] states = {State.DEFAULT, State.DEFAULT};
  81 
  82     /**
  83      * Default constructor. Establishes default values
  84      */
  85     public XMLSecurityPropertyManager() {
  86         values = new String[Property.values().length];
  87         for (Property property : Property.values()) {
  88             values[property.ordinal()] = property.defaultValue();
  89         }
  90         //read system properties or jaxp.properties
  91         readSystemProperties();
  92     }
  93 













  94 
  95     /**
  96      * Set limit by property name and state
  97      * @param propertyName property name
  98      * @param state the state of the property
  99      * @param value the value of the property
 100      * @return true if the property is managed by the security property manager;
 101      *         false if otherwise.
 102      */
 103     public boolean setValue(String propertyName, State state, Object value) {
 104         int index = getIndex(propertyName);
 105         if (index > -1) {
 106             setValue(index, state, (String)value);
 107             return true;
 108         }
 109         return false;
 110     }
 111 
 112     /**
 113      * Set the value for a specific property.


 171      */
 172     public String getValueByIndex(int index) {
 173         return values[index];
 174     }
 175 
 176     /**
 177      * Get the index by property name
 178      * @param propertyName property name
 179      * @return the index of the property if found; return -1 if not
 180      */
 181     public int getIndex(String propertyName){
 182         for (Property property : Property.values()) {
 183             if (property.equalsName(propertyName)) {
 184                 //internally, ordinal is used as index
 185                 return property.ordinal();
 186             }
 187         }
 188         return -1;
 189     }
 190 









 191     /**
 192      * Read from system properties, or those in jaxp.properties
 193      */
 194     private void readSystemProperties() {
 195         getSystemProperty(Property.ACCESS_EXTERNAL_DTD,
 196                 Constants.SP_ACCESS_EXTERNAL_DTD);
 197         getSystemProperty(Property.ACCESS_EXTERNAL_SCHEMA,
 198                 Constants.SP_ACCESS_EXTERNAL_SCHEMA);
 199     }
 200 
 201     /**
 202      * Read from system properties, or those in jaxp.properties
 203      *
 204      * @param property the property
 205      * @param systemProperty the name of the system property
 206      */
 207     private void getSystemProperty(Property property, String systemProperty) {
 208         try {
 209             String value = SecuritySupport.getSystemProperty(systemProperty);
 210             if (value != null) {


  74      * Values of the properties as defined in enum Properties
  75      */
  76     private final String[] values;
  77     /**
  78      * States of the settings for each property in Properties above
  79      */
  80     private State[] states = {State.DEFAULT, State.DEFAULT};
  81 
  82     /**
  83      * Default constructor. Establishes default values
  84      */
  85     public XMLSecurityPropertyManager() {
  86         values = new String[Property.values().length];
  87         for (Property property : Property.values()) {
  88             values[property.ordinal()] = property.defaultValue();
  89         }
  90         //read system properties or jaxp.properties
  91         readSystemProperties();
  92     }
  93 
  94     /**
  95      * Clone a XMLSecurityPropertyManager
  96      * @param propertyManager the base XMLSecurityPropertyManager
  97      */
  98     public XMLSecurityPropertyManager(XMLSecurityPropertyManager propertyManager) {
  99         values = new String[Property.values().length];
 100         if (propertyManager != null) {
 101             for (Property property : Property.values()) {
 102                 values[property.ordinal()] = propertyManager.getValue(property);
 103                 states[property.ordinal()] = propertyManager.getState(property);            
 104             }
 105         }
 106     }
 107 
 108     /**
 109      * Set limit by property name and state
 110      * @param propertyName property name
 111      * @param state the state of the property
 112      * @param value the value of the property
 113      * @return true if the property is managed by the security property manager;
 114      *         false if otherwise.
 115      */
 116     public boolean setValue(String propertyName, State state, Object value) {
 117         int index = getIndex(propertyName);
 118         if (index > -1) {
 119             setValue(index, state, (String)value);
 120             return true;
 121         }
 122         return false;
 123     }
 124 
 125     /**
 126      * Set the value for a specific property.


 184      */
 185     public String getValueByIndex(int index) {
 186         return values[index];
 187     }
 188 
 189     /**
 190      * Get the index by property name
 191      * @param propertyName property name
 192      * @return the index of the property if found; return -1 if not
 193      */
 194     public int getIndex(String propertyName){
 195         for (Property property : Property.values()) {
 196             if (property.equalsName(propertyName)) {
 197                 //internally, ordinal is used as index
 198                 return property.ordinal();
 199             }
 200         }
 201         return -1;
 202     }
 203 
 204     /**
 205      * Return the state of a property
 206      * @param property
 207      * @return return the state of the property 
 208      */
 209     public State getState(Property property) {
 210         return states[property.ordinal()];
 211     }
 212     
 213     /**
 214      * Read from system properties, or those in jaxp.properties
 215      */
 216     private void readSystemProperties() {
 217         getSystemProperty(Property.ACCESS_EXTERNAL_DTD,
 218                 Constants.SP_ACCESS_EXTERNAL_DTD);
 219         getSystemProperty(Property.ACCESS_EXTERNAL_SCHEMA,
 220                 Constants.SP_ACCESS_EXTERNAL_SCHEMA);
 221     }
 222 
 223     /**
 224      * Read from system properties, or those in jaxp.properties
 225      *
 226      * @param property the property
 227      * @param systemProperty the name of the system property
 228      */
 229     private void getSystemProperty(Property property, String systemProperty) {
 230         try {
 231             String value = SecuritySupport.getSystemProperty(systemProperty);
 232             if (value != null) {