View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.wss4j.stax.test;
20  
21  import org.apache.wss4j.stax.setup.WSSec;
22  import org.apache.xml.security.stax.config.ConfigurationProperties;
23  
24  import org.junit.jupiter.api.Test;
25  
26  import static org.junit.jupiter.api.Assertions.assertEquals;
27  
28  /**
29   * Test that the configuration defaults defined in security-config.xml in Santuario are still picked up
30   * correctly via wss-config.xml
31   */
32  public class ConfigurationPropertiesTest extends AbstractTestBase {
33  
34      /*
35          <Property NAME="MaximumAllowedTransformsPerReference" VAL="5"/>
36          <Property NAME="MaximumAllowedReferencesPerManifest" VAL="30"/>
37          <Property NAME="DoNotThrowExceptionForManifests" VAL="false"/>
38          <Property NAME="AllowMD5Algorithm" VAL="false"/>
39          <Property NAME="MaximumAllowedXMLStructureDepth" VAL="100"/>
40          <Property NAME="MaximumAllowedEncryptedDataEvents" VAL="200"/>
41       */
42      @Test
43      public void testConfigurationProperties() throws Exception {
44          WSSec.init();
45          assertEquals("5", ConfigurationProperties.getProperty("MaximumAllowedTransformsPerReference"));
46          assertEquals("30", ConfigurationProperties.getProperty("MaximumAllowedReferencesPerManifest"));
47          assertEquals("false", ConfigurationProperties.getProperty("DoNotThrowExceptionForManifests"));
48          assertEquals("false", ConfigurationProperties.getProperty("AllowMD5Algorithm"));
49          assertEquals("100", ConfigurationProperties.getProperty("MaximumAllowedXMLStructureDepth"));
50          assertEquals("5", ConfigurationProperties.getProperty("MaximumAllowedTransformsPerReference"));
51          assertEquals("200", ConfigurationProperties.getProperty("MaximumAllowedEncryptedDataEvents"));
52  
53          // This one is overridden in wss-config.xml
54          assertEquals("true", ConfigurationProperties.getProperty("AllowNotSameDocumentReferences"));
55      }
56  
57  }