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

Print this page

        

@@ -130,11 +130,11 @@
     }
     private static final int NO_LIMIT = 0;
     /**
      * Values of the properties
      */
-    private final int[] values;
+    private int[] values;
     /**
      * States of the settings for each property
      */
     private State[] states;
     /**

@@ -167,14 +167,11 @@
      * Instantiate Security Manager in accordance with the status of
      * secure processing
      * @param secureProcessing
      */
     public XMLSecurityManager(boolean secureProcessing) {
-        limitAnalyzer = new XMLLimitAnalyzer(this);
-        values = new int[Limit.values().length];
-        states = new State[Limit.values().length];
-        isSet = new boolean[Limit.values().length];
+        init();
         this.secureProcessing = secureProcessing;
         for (Limit limit : Limit.values()) {
             if (secureProcessing) {
                 values[limit.ordinal()] = limit.secureValue;
                 states[limit.ordinal()] = State.FSP;

@@ -185,10 +182,43 @@
         }
         //read system properties or jaxp.properties
         readSystemProperties();
     }
 
+    /**
+     * Clone a security manager
+     * @param securityManager a base security manager
+     */
+    public XMLSecurityManager(XMLSecurityManager securityManager) {
+        init();
+        if (securityManager != null) {
+            this.secureProcessing = securityManager.isSecureProcessing();
+            for (Limit limit : Limit.values()) {
+                values[limit.ordinal()] = securityManager.getLimit(limit);
+                states[limit.ordinal()] = securityManager.getState(limit);
+            }
+        }
+    }
+
+    /**
+     * Initialize values
+     */
+    private void init() {
+        limitAnalyzer = new XMLLimitAnalyzer(this);
+        int numOfElements = Limit.values().length;
+        values = new int[numOfElements];
+        states = new State[numOfElements];
+        isSet = new boolean[numOfElements];        
+    }
+
+    /**
+     * Reset all limits to their default status
+     */
+    public void resetLimits() {
+        limitAnalyzer.reset();
+    }
+
     /**
      * Setting FEATURE_SECURE_PROCESSING explicitly
      */
     public void setSecureProcessing(boolean secure) {
         secureProcessing = secure;