--- old/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Fri Nov 15 11:27:40 2013 +++ new/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Fri Nov 15 11:27:40 2013 @@ -132,7 +132,7 @@ /** * Values of the properties */ - private final int[] values; + private int[] values; /** * States of the settings for each property */ @@ -169,10 +169,7 @@ * @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) { @@ -187,6 +184,39 @@ 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 */