This is an automated email from the ASF dual-hosted git repository. ppkarwasz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/commons-xml.git
commit cd8346e8d8242c50a08cfbd89642e4b4f4043ca3 Author: Piotr P. Karwasz <[email protected]> AuthorDate: Fri May 1 00:41:04 2026 +0200 Change project coordinates to `eu.copernik:copernik-xml-factory` (#12) * Change namespace to `eu.copernik.xml.factory` * Rebrand headers, `pom.xml` and documentation While the ultimate goal is to include this project in Apache Commons or Xerces, in the ramp-up phase this project will be released under `eu.copernik` to test its utility. --- .github/dependabot.yml | 16 +-- .github/workflows/codeql-analysis.yml | 16 +-- .github/workflows/maven.yml | 16 +-- .gitignore | 1 + AGENTS.md | 20 +-- LICENSE.txt => LICENSE | 0 NOTICE.txt | 5 - README.md | 50 ++----- android-tests/README.md | 20 +-- android-tests/build.gradle.kts | 21 +-- android-tests/gradle.properties | 16 +-- .../gradle/wrapper/gradle-wrapper.properties | 17 +-- android-tests/settings.gradle.kts | 19 +-- android-tests/src/main/AndroidManifest.xml | 17 +-- pom.xml | 151 +++++++++++++++++---- .../copernik}/xml/factory/AndroidProvider.java | 58 ++++---- .../factory/DelegatingDocumentBuilderFactory.java | 19 +-- .../copernik}/xml/factory/DelegatingSAXParser.java | 19 +-- .../xml/factory/DelegatingSAXParserFactory.java | 19 +-- .../xml/factory/DelegatingSchemaFactory.java | 19 +-- .../copernik/xml/factory/DelegatingTemplates.java | 34 +++++ .../xml/factory/DelegatingTransformer.java | 19 +-- .../xml/factory/DelegatingTransformerFactory.java | 19 +-- .../copernik}/xml/factory/DelegatingXMLReader.java | 19 +-- .../copernik}/xml/factory/HardeningException.java | 19 +-- .../xml/factory/HardeningSAXParserFactory.java | 19 +-- .../copernik}/xml/factory/HardeningSchema.java | 19 +-- .../xml/factory/HardeningSchemaFactory.java | 19 +-- .../copernik}/xml/factory/HardeningTemplates.java | 19 +-- .../xml/factory/HardeningTransformer.java | 19 +-- .../xml/factory/HardeningTransformerFactory.java | 19 +-- .../copernik}/xml/factory/HardeningValidator.java | 19 +-- .../copernik}/xml/factory/JaxpSetters.java | 19 +-- .../copernik}/xml/factory/Limits.java | 22 +-- .../copernik}/xml/factory/Resolvers.java | 19 +-- .../copernik}/xml/factory/SaxonProvider.java | 19 +-- .../copernik}/xml/factory/StockJdkProvider.java | 25 +--- .../copernik}/xml/factory/WoodstoxProvider.java | 19 +-- .../copernik}/xml/factory/XalanProvider.java | 21 +-- .../copernik}/xml/factory/XercesProvider.java | 21 +-- .../copernik}/xml/factory/XmlFactories.java | 21 +-- .../commons/xml/factory/DelegatingTemplates.java | 45 ------ src/site/markdown/index.md | 41 ++---- .../copernik}/xml/factory/AttackTestSupport.java | 18 +-- .../copernik}/xml/factory/BillionLaughsTest.java | 19 +-- .../copernik}/xml/factory/DoctypeOnlyTest.java | 19 +-- .../copernik}/xml/factory/ExternalDtdTest.java | 19 +-- .../xml/factory/ExternalGeneralEntityTest.java | 19 +-- .../xml/factory/ExternalParameterEntityTest.java | 20 +-- .../copernik}/xml/factory/NoDoctypeTest.java | 19 +-- .../xml/factory/SaxonXPathExternalCallsTest.java | 19 +-- .../eu/copernik/xml/factory/SchemaImportTest.java | 29 ++++ .../eu/copernik/xml/factory/SchemaIncludeTest.java | 29 ++++ .../copernik/xml/factory/SchemaRedefineTest.java | 29 ++++ .../copernik/xml/factory/TemplatesImportTest.java | 22 +++ .../copernik/xml/factory/TemplatesIncludeTest.java | 22 +++ .../xml/factory/TransformerDocumentTest.java | 22 +++ .../factory/UnsupportedXmlImplementationTest.java | 19 +-- .../copernik}/xml/factory/XmlFactoriesTest.java | 20 +-- .../commons/xml/factory/SchemaImportTest.java | 40 ------ .../commons/xml/factory/SchemaIncludeTest.java | 40 ------ .../commons/xml/factory/SchemaRedefineTest.java | 40 ------ .../commons/xml/factory/TemplatesImportTest.java | 33 ----- .../commons/xml/factory/TemplatesIncludeTest.java | 33 ----- .../xml/factory/TransformerDocumentTest.java | 33 ----- 65 files changed, 542 insertions(+), 1055 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7125dd4..42685f2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,17 +1,5 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> +# SPDX-License-Identifier: Apache-2.0 version: 2 updates: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fff0865..e4ff2b7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,17 +1,5 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> +# SPDX-License-Identifier: Apache-2.0 name: CodeQL diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f757817..34a3f7a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,17 +1,5 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> +# SPDX-License-Identifier: Apache-2.0 name: Java CI diff --git a/.gitignore b/.gitignore index b7187a4..2509dce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Build output target +.flattened-pom.xml pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup diff --git a/AGENTS.md b/AGENTS.md index 62e71a4..474a7e1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,19 +1,7 @@ -<!--- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> +<!-- + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> # AGENTS.md diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/NOTICE.txt b/NOTICE.txt deleted file mode 100644 index 23f38ef..0000000 --- a/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -Apache Commons XML Factory -Copyright 2026 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (https://www.apache.org/). diff --git a/README.md b/README.md index 689eede..f1da175 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,9 @@ -<!--- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -# Apache Commons XML Factory - -> [!WARNING] -> This is a draft of a new [Apache Commons](https://commons.apache.org) project base on -> [this proposal](https://lists.apache.org/thread/b2tjc15vjkgsrxxkc8phlnt6801hx4xz). -> -> It is **not** an official Apache Commons library yet. +<!-- + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> + +# Copernik XML Factory Secure-by-default JAXP factory creation for Java. A single method call returns a hardened JAXP factory that can be used to **safely** parse XML files. @@ -51,8 +33,8 @@ Add the library to your build: ```xml <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-xml-factory</artifactId> + <groupId>eu.copernik</groupId> + <artifactId>copernik-xml-factory</artifactId> <version>0.1.0</version> </dependency> ``` @@ -80,7 +62,7 @@ requires a code change to this library. ```java import org.w3c.dom.Document; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; Document doc = XmlFactories.newDocumentBuilderFactory().newDocumentBuilder().parse(inputStream); ``` @@ -88,7 +70,7 @@ Document doc = XmlFactories.newDocumentBuilderFactory().newDocumentBuilder().par **SAX parsing** via `SAXParserFactory`: ```java -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newSAXParserFactory().newSAXParser().parse(inputStream, myDefaultHandler); ``` @@ -97,7 +79,7 @@ XmlFactories.newSAXParserFactory().newSAXParser().parse(inputStream, myDefaultHa ```java import javax.xml.stream.XMLStreamReader; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XMLStreamReader reader = XmlFactories.newXMLInputFactory().createXMLStreamReader(inputStream); ``` @@ -106,9 +88,7 @@ XMLStreamReader reader = XmlFactories.newXMLInputFactory().createXMLStreamReader ```java import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.stream.StreamResult; -import org.apache.commons.xml.factory.XmlFactories; - +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newTransformerFactory() .newTransformer(new StreamSource(stylesheet)) .transform(new StreamSource(inputStream), new StreamResult(outputStream)); @@ -119,7 +99,7 @@ XmlFactories.newTransformerFactory() ```java import javax.xml.xpath.XPathConstants; import org.w3c.dom.NodeList; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; NodeList hits = (NodeList) XmlFactories.newXPathFactory() .newXPath() @@ -130,7 +110,7 @@ NodeList hits = (NodeList) XmlFactories.newXPathFactory() ```java import javax.xml.transform.stream.StreamSource; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newSchemaFactory() .newSchema(new StreamSource(xsdStream)) @@ -183,4 +163,4 @@ From a command shell, run `mvn` without arguments to invoke the default Maven go ## Licensing -Licensed under the Apache License, Version 2.0. See `LICENSE.txt` and `NOTICE.txt`. +Licensed under the Apache License, Version 2.0. See `LICENSE`. diff --git a/android-tests/README.md b/android-tests/README.md index 7c86b79..dbf0267 100644 --- a/android-tests/README.md +++ b/android-tests/README.md @@ -1,19 +1,7 @@ -<!--- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> +<!-- + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> # Android instrumented tests diff --git a/android-tests/build.gradle.kts b/android-tests/build.gradle.kts index 94acbbf..3bf80a5 100644 --- a/android-tests/build.gradle.kts +++ b/android-tests/build.gradle.kts @@ -1,19 +1,8 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ + import com.android.build.api.dsl.ManagedVirtualDevice plugins { @@ -22,10 +11,10 @@ plugins { } val libraryVersion = "0.1.0-SNAPSHOT" -val libraryJar = rootProject.file("../target/commons-xml-factory-${libraryVersion}.jar") +val libraryJar = rootProject.file("../target/copernik-xml-factory-${libraryVersion}.jar") android { - namespace = "org.apache.commons.xml.factory.androidtests" + namespace = "eu.copernik.xml.factory.androidtests" compileSdk = 34 defaultConfig { diff --git a/android-tests/gradle.properties b/android-tests/gradle.properties index 69bbe55..9bd491b 100644 --- a/android-tests/gradle.properties +++ b/android-tests/gradle.properties @@ -1,17 +1,5 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> +# SPDX-License-Identifier: Apache-2.0 org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 android.useAndroidX=true diff --git a/android-tests/gradle/wrapper/gradle-wrapper.properties b/android-tests/gradle/wrapper/gradle-wrapper.properties index de501da..2d1208e 100644 --- a/android-tests/gradle/wrapper/gradle-wrapper.properties +++ b/android-tests/gradle/wrapper/gradle-wrapper.properties @@ -1,17 +1,6 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> +# SPDX-License-Identifier: Apache-2.0 + distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip diff --git a/android-tests/settings.gradle.kts b/android-tests/settings.gradle.kts index 675ef5a..6fef1d6 100644 --- a/android-tests/settings.gradle.kts +++ b/android-tests/settings.gradle.kts @@ -1,19 +1,8 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ + pluginManagement { repositories { google() @@ -30,4 +19,4 @@ dependencyResolutionManagement { } } -rootProject.name = "commons-xml-factory-android-tests" +rootProject.name = "copernik-xml-factory-android-tests" diff --git a/android-tests/src/main/AndroidManifest.xml b/android-tests/src/main/AndroidManifest.xml index 6b39031..a10945c 100644 --- a/android-tests/src/main/AndroidManifest.xml +++ b/android-tests/src/main/AndroidManifest.xml @@ -1,18 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> <manifest /> diff --git a/pom.xml b/pom.xml index e3245ca..46203f7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -22,15 +11,64 @@ <artifactId>commons-parent</artifactId> <version>98</version> </parent> - <artifactId>commons-xml-factory</artifactId> + <groupId>eu.copernik</groupId> + <artifactId>copernik-xml-factory</artifactId> <version>0.1.0-SNAPSHOT</version> - <name>Apache Commons XML Factory</name> - <url>https://commons.apache.org/proper/commons-xml-factory/</url> + <name>Copernik XML Factory</name> + <url>https://github.com/copernik-eu/copernik-xml-factory/</url> <inceptionYear>2026</inceptionYear> - <description>Apache Commons XML Factory provides secure-by-default JAXP factory creation, abstracting over + <description>XML Factory provides secure-by-default JAXP factory creation, abstracting over implementation-specific XXE hardening differences between the stock JDK and external JAXP implementations (Apache Xerces, Woodstox, Saxon-HE).</description> + <organization> + <name>Copernik</name> + <url>https://oss.copernik.eu</url> + </organization> + + <developers> + <developer> + <id>ppkarwasz</id> + <name>Piotr P. Karwasz</name> + <email>[email protected]</email> + <organization>Copernik</organization> + <organizationUrl>https://oss.copernik.eu</organizationUrl> + </developer> + </developers> + + <scm> + <connection>scm:git:https://github.com/copernik-eu/copernik-xml-factory.git</connection> + <developerConnection>scm:git:[email protected]:copernik-eu/copernik-xml-factory.git</developerConnection> + <url>https://github.com/copernik-eu/copernik-xml-factory</url> + <tag>HEAD</tag> + </scm> + + <issueManagement> + <system>GitHub Issues</system> + <url>https://github.com/copernik-eu/copernik-xml-factory/issues</url> + </issueManagement> + + <ciManagement> + <system>GitHub Actions</system> + <url>https://github.com/copernik-eu/copernik-xml-factory/actions</url> + </ciManagement> + + <!-- Issue tracking and discussion happen on GitHub. --> + <mailingLists> + <mailingList/> + </mailingLists> + + <distributionManagement> + <repository> + <id>central</id> + <url>https://central.sonatype.com</url> + </repository> + <snapshotRepository> + <id>central</id> + <url>https://central.sonatype.com/repository/maven-snapshots/</url> + </snapshotRepository> + </distributionManagement> + <properties> <!-- Release-related properties --> <commons.release.version>0.1.0</commons.release.version> @@ -40,13 +78,18 @@ <commons.bc.version>0.1.0</commons.bc.version> --> <japicmp.skip>true</japicmp.skip> <commons.release.next>0.1.1</commons.release.next> - <commons.componentid>xml-factory</commons.componentid> + <commons.componentid>copernik-xml-factory</commons.componentid> <commons.packageId>xml.factory</commons.packageId> + <commons.module.name>eu.copernik.xml.factory</commons.module.name> + <commons.distSvnStagingUrl/> + <commons.scmPubUrl/> + + <!-- OSGi bundle metadata: override commons-parent's org.apache.commons.* defaults. --> + <commons.osgi.symbolicName>eu.copernik.xml.factory</commons.osgi.symbolicName> + <commons.osgi.export>eu.copernik.xml.factory.*;version=${project.version};-noimport:=true</commons.osgi.export> <project.build.outputTimestamp>2026-04-22T00:00:00Z</project.build.outputTimestamp> - <!-- JIRA coordinates (to be assigned) - <commons.jira.id>COMMONSXMLFACTORY</commons.jira.id> - <commons.jira.pid>12300000</commons.jira.pid> --> + <!-- No JIRA: tracked in GitHub Issues. --> <changes.jira.skip>true</changes.jira.skip> <!-- Java baseline --> @@ -58,14 +101,25 @@ <commons.woodstox.version>7.1.1</commons.woodstox.version> <commons.xalan.version>2.7.3</commons.xalan.version> <commons.xerces.version>2.12.2</commons.xerces.version> + + <!-- Sonatype Central Publishing --> + <central.publishing.version>0.9.0</central.publishing.version> + + <!-- Flatten Maven plugin: produces a consumer POM at deploy time. --> + <flatten-maven-plugin.version>1.7.0</flatten-maven-plugin.version> </properties> <dependencies> + <!-- + Saxon-HE supplies types we reference at compile time (the Saxon provider). It is not part of the consumer + contract: callers who want Saxon-HE for XSLT/XPath bring it themselves, and the flatten plugin drops every + provided-scope dependency from the published POM. + --> <dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>${commons.saxon.version}</version> - <optional>true</optional> + <scope>provided</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> @@ -244,6 +298,55 @@ </executions> </plugin> + <!-- Publish to the new Sonatype Central API. --> + <plugin> + <groupId>org.sonatype.central</groupId> + <artifactId>central-publishing-maven-plugin</artifactId> + <version>${central.publishing.version}</version> + <extensions>true</extensions> + <configuration> + <publishingServerId>central</publishingServerId> + <autoPublish>false</autoPublish> + </configuration> + </plugin> + + <!-- + Flatten the POM at install/deploy time so the published artifact carries only the metadata Maven Central + requires (groupId, artifactId, version, name, description, url, license, scm, developers, dependencies) + and drops everything inherited from commons-parent that is not relevant to a consumer (mailing lists, + ciManagement, distribution properties, plugin management, etc.). + --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>flatten-maven-plugin</artifactId> + <version>${flatten-maven-plugin.version}</version> + <configuration> + <flattenMode>oss</flattenMode> + <pomElements> + <!-- Placeholder kept locally only to override commons-parent's mailing lists; not consumer-relevant. --> + <mailingLists>remove</mailingLists> + <!-- Where the artifact is published is not consumer-relevant. --> + <distributionManagement>remove</distributionManagement> + </pomElements> + </configuration> + <executions> + <execution> + <id>flatten</id> + <phase>process-resources</phase> + <goals> + <goal>flatten</goal> + </goals> + </execution> + <execution> + <id>flatten-clean</id> + <phase>clean</phase> + <goals> + <goal>clean</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> </build> </project> diff --git a/src/main/java/org/apache/commons/xml/factory/AndroidProvider.java b/src/main/java/eu/copernik/xml/factory/AndroidProvider.java similarity index 72% rename from src/main/java/org/apache/commons/xml/factory/AndroidProvider.java rename to src/main/java/eu/copernik/xml/factory/AndroidProvider.java index dd46fc2..88a336b 100644 --- a/src/main/java/org/apache/commons/xml/factory/AndroidProvider.java +++ b/src/main/java/eu/copernik/xml/factory/AndroidProvider.java @@ -1,25 +1,13 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.util.Objects; import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -41,19 +29,20 @@ * <ul> * <li>{@link SAXParserFactory} produces {@code org.apache.harmony.xml.ExpatReader}, a SAX wrapper around the platform's native Expat parser.</li> * <li>{@link DocumentBuilderFactory} produces {@code DocumentBuilderImpl}, which builds the DOM tree on top of {@code com.android.org.kxml2.io.KXmlParser} - * (a kxml2 pull parser); it does not use Expat at all.</li> + * (a kxml2 pull parser).</li> * </ul> * * <p>What the SAX/Expat surface exposes:</p> * <ul> * <li>SAX features: only {@code namespaces}, {@code namespace-prefixes}, {@code string-interning}, {@code validation}, - * {@code external-general-entities} and {@code external-parameter-entities}. The last three are read-only and cannot be enabled.</li> + * {@code external-general-entities} and {@code external-parameter-entities}. The last three are read-only and cannot be enabled. + * Setting both {@code namespaces} and {@code namespace-prefixes} triggers an automatic exception at parse time.</li> * <li>SAX properties: only {@code lexical-handler}.</li> * <li>{@link XMLConstants#FEATURE_SECURE_PROCESSING} and JAXP 1.5 {@code ACCESS_EXTERNAL_*} are not recognised.</li> * <li>Entity expansion: native libexpat enforces a built-in Billion Laughs check (compiled-in activation threshold and amplification factor), so internal * entity expansion is already bounded below us.</li> - * <li>Every external fetch (DTD subset, DOCTYPE {@code SYSTEM}, general/parameter entity) flows through the 2-arg - * {@link EntityResolver#resolveEntity}; {@code EntityResolver2.getExternalSubset} is never called.</li> + * <li>Every external fetch (DTD subset, DOCTYPE {@code SYSTEM}, general/parameter entity) flows through the 2-arg {@link EntityResolver#resolveEntity}. + * Without a resolver external fetches are ignored.</li> * </ul> * * <p>What the DOM/KXmlParser surface exposes:</p> @@ -61,13 +50,11 @@ * <li>{@link DocumentBuilderFactory#setFeature} only recognises {@code namespaces} and {@code validation}.</li> * <li>{@link DocumentBuilderFactory#setAttribute} always throws {@code IllegalArgumentException}.</li> * <li>{@link XMLConstants#FEATURE_SECURE_PROCESSING} and JAXP 1.5 {@code ACCESS_EXTERNAL_*} are not recognised.</li> - * <li>KXmlParser already drops external DTD subsets and external general entities silently (no HTTP fetch), and aborts on recursive internal entity - * declarations.</li> + * <li>Entity expansion: KXmlParser does not support user-defined entities and they are silently dropped.</li> * </ul> * * <p>The SAX path installs a {@link DtdAwareDenyResolver} as both {@link EntityResolver} and {@link LexicalHandler}: it allows the external subset to load - * silently (so a DOCTYPE that names an external DTD but does not use it parses) and throws on every external general or parameter entity reference. The DOM - * path needs no resolver: KXmlParser silently drops external DTDs and external general entities and does not consult the resolver.</p> + * silently (so a DOCTYPE that names an external DTD but does not use it parses) and throws on every external general or parameter entity reference.</p> */ final class AndroidProvider { @@ -108,7 +95,9 @@ public void startDTD(final String name, final String publicId, final String syst } } - /** {@link SAXParser} wrapper whose {@link #getXMLReader()} returns a {@link GuardedXMLReader}. */ + /** + * {@link SAXParser} wrapper whose {@link #getXMLReader()} returns a {@link GuardedXMLReader}. + */ private static final class GuardedSAXParser extends DelegatingSAXParser { private final XMLReader guardedReader; @@ -124,7 +113,9 @@ public XMLReader getXMLReader() { } } - /** {@link SAXParserFactory} wrapper that produces {@link GuardedSAXParser}s. */ + /** + * {@link SAXParserFactory} wrapper that produces {@link GuardedSAXParser}s. + */ private static final class GuardedSAXParserFactory extends DelegatingSAXParserFactory { GuardedSAXParserFactory(final SAXParserFactory delegate) { @@ -139,12 +130,11 @@ public SAXParser newSAXParser() throws ParserConfigurationException, SAXExceptio } /** - * {@link XMLReader} wrapper that surfaces ExpatReader's two-feature conflict at {@code setFeature} time instead of {@code parse} time. + * {@link XMLReader} wrapper that surfaces ExpatReader's conflicting-feature error at {@code setFeature} time rather than at {@code parse} time. * * <p>Android's {@code ExpatReader.parse()} throws {@link SAXNotSupportedException} when {@code namespaces} and {@code namespace-prefixes} are both - * enabled; on Android 33+ {@code namespaces} defaults to {@code true}, so any caller (notably Apache Xalan's identity transformer) that flips - * {@code namespace-prefixes} on triggers the throw at parse time. This wrapper relocates the throw to the offending {@code setFeature} call, where - * Apache Xalan's {@code try { ... } catch (SAXException) { /* We don't care. *<!-- -->/ }} swallows it cleanly.</p> + * enabled. Reporting the error at configuration time lets consumers, such as Apache Xalan's identity transformer, catch the exception and still parse + * the document. Without the wrapper, parsing fails.</p> */ static final class GuardedXMLReader extends DelegatingXMLReader { @@ -156,14 +146,14 @@ static final class GuardedXMLReader extends DelegatingXMLReader { public void setFeature(final String name, final boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { if (value && (NAMESPACE_PREFIXES_FEATURE.equals(name) && super.getFeature(NAMESPACES_FEATURE) - || NAMESPACES_FEATURE.equals(name) && super.getFeature(NAMESPACE_PREFIXES_FEATURE))) { - throw new SAXNotSupportedException( - "ExpatReader cannot have both '" + NAMESPACES_FEATURE - + "' and '" + NAMESPACE_PREFIXES_FEATURE + "' enabled simultaneously"); + || NAMESPACES_FEATURE.equals(name) && super.getFeature(NAMESPACE_PREFIXES_FEATURE))) { + throw new SAXNotSupportedException("ExpatReader cannot have both '" + NAMESPACES_FEATURE + "' and '" + NAMESPACE_PREFIXES_FEATURE + "' " + + "enabled simultaneously"); } super.setFeature(name, value); } } + private static final String LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler"; private static final String NAMESPACES_FEATURE = "http://xml.org/sax/features/namespaces"; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingDocumentBuilderFactory.java b/src/main/java/eu/copernik/xml/factory/DelegatingDocumentBuilderFactory.java similarity index 79% rename from src/main/java/org/apache/commons/xml/factory/DelegatingDocumentBuilderFactory.java rename to src/main/java/eu/copernik/xml/factory/DelegatingDocumentBuilderFactory.java index 66bf446..ae2a8ff 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingDocumentBuilderFactory.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingDocumentBuilderFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingSAXParser.java b/src/main/java/eu/copernik/xml/factory/DelegatingSAXParser.java similarity index 69% rename from src/main/java/org/apache/commons/xml/factory/DelegatingSAXParser.java rename to src/main/java/eu/copernik/xml/factory/DelegatingSAXParser.java index c31ecb1..e3fa908 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingSAXParser.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingSAXParser.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.parsers.SAXParser; import javax.xml.validation.Schema; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingSAXParserFactory.java b/src/main/java/eu/copernik/xml/factory/DelegatingSAXParserFactory.java similarity index 71% rename from src/main/java/org/apache/commons/xml/factory/DelegatingSAXParserFactory.java rename to src/main/java/eu/copernik/xml/factory/DelegatingSAXParserFactory.java index b460f37..b1fe7ee 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingSAXParserFactory.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingSAXParserFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingSchemaFactory.java b/src/main/java/eu/copernik/xml/factory/DelegatingSchemaFactory.java similarity index 73% rename from src/main/java/org/apache/commons/xml/factory/DelegatingSchemaFactory.java rename to src/main/java/eu/copernik/xml/factory/DelegatingSchemaFactory.java index a68c81a..14a18fb 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingSchemaFactory.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingSchemaFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.Source; import javax.xml.validation.Schema; diff --git a/src/main/java/eu/copernik/xml/factory/DelegatingTemplates.java b/src/main/java/eu/copernik/xml/factory/DelegatingTemplates.java new file mode 100644 index 0000000..6197d79 --- /dev/null +++ b/src/main/java/eu/copernik/xml/factory/DelegatingTemplates.java @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import java.util.Properties; + +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; + +/** + * {@link Templates} wrapper that forwards every method to a wrapped delegate. + */ +class DelegatingTemplates implements Templates { + + private final Templates delegate; + + DelegatingTemplates(final Templates delegate) { + this.delegate = delegate; + } + + @Override + public Properties getOutputProperties() { + return delegate.getOutputProperties(); + } + + @Override + public Transformer newTransformer() throws TransformerConfigurationException { + return delegate.newTransformer(); + } +} diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingTransformer.java b/src/main/java/eu/copernik/xml/factory/DelegatingTransformer.java similarity index 72% rename from src/main/java/org/apache/commons/xml/factory/DelegatingTransformer.java rename to src/main/java/eu/copernik/xml/factory/DelegatingTransformer.java index 2cd461d..d47a03b 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingTransformer.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingTransformer.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.util.Properties; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingTransformerFactory.java b/src/main/java/eu/copernik/xml/factory/DelegatingTransformerFactory.java similarity index 81% rename from src/main/java/org/apache/commons/xml/factory/DelegatingTransformerFactory.java rename to src/main/java/eu/copernik/xml/factory/DelegatingTransformerFactory.java index edda54f..88d5f44 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingTransformerFactory.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingTransformerFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.ErrorListener; import javax.xml.transform.Source; diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingXMLReader.java b/src/main/java/eu/copernik/xml/factory/DelegatingXMLReader.java similarity index 75% rename from src/main/java/org/apache/commons/xml/factory/DelegatingXMLReader.java rename to src/main/java/eu/copernik/xml/factory/DelegatingXMLReader.java index 5e6e0f2..fe9aed4 100644 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingXMLReader.java +++ b/src/main/java/eu/copernik/xml/factory/DelegatingXMLReader.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.io.IOException; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningException.java b/src/main/java/eu/copernik/xml/factory/HardeningException.java similarity index 52% rename from src/main/java/org/apache/commons/xml/factory/HardeningException.java rename to src/main/java/eu/copernik/xml/factory/HardeningException.java index ff6a9b8..8690016 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningException.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningException.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; /** * Thrown when a factory cannot be hardened. diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningSAXParserFactory.java b/src/main/java/eu/copernik/xml/factory/HardeningSAXParserFactory.java similarity index 55% rename from src/main/java/org/apache/commons/xml/factory/HardeningSAXParserFactory.java rename to src/main/java/eu/copernik/xml/factory/HardeningSAXParserFactory.java index efd974f..b8dee07 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningSAXParserFactory.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningSAXParserFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.util.function.UnaryOperator; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningSchema.java b/src/main/java/eu/copernik/xml/factory/HardeningSchema.java similarity index 61% rename from src/main/java/org/apache/commons/xml/factory/HardeningSchema.java rename to src/main/java/eu/copernik/xml/factory/HardeningSchema.java index 2655d78..3064642 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningSchema.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningSchema.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.util.function.UnaryOperator; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningSchemaFactory.java b/src/main/java/eu/copernik/xml/factory/HardeningSchemaFactory.java similarity index 76% rename from src/main/java/org/apache/commons/xml/factory/HardeningSchemaFactory.java rename to src/main/java/eu/copernik/xml/factory/HardeningSchemaFactory.java index eeaa15d..da37d07 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningSchemaFactory.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningSchemaFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.util.function.UnaryOperator; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningTemplates.java b/src/main/java/eu/copernik/xml/factory/HardeningTemplates.java similarity index 66% rename from src/main/java/org/apache/commons/xml/factory/HardeningTemplates.java rename to src/main/java/eu/copernik/xml/factory/HardeningTemplates.java index 09e65f5..5b058a3 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningTemplates.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningTemplates.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.Templates; import javax.xml.transform.Transformer; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningTransformer.java b/src/main/java/eu/copernik/xml/factory/HardeningTransformer.java similarity index 52% rename from src/main/java/org/apache/commons/xml/factory/HardeningTransformer.java rename to src/main/java/eu/copernik/xml/factory/HardeningTransformer.java index 12a4a67..cee653d 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningTransformer.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningTransformer.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.Result; import javax.xml.transform.Source; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningTransformerFactory.java b/src/main/java/eu/copernik/xml/factory/HardeningTransformerFactory.java similarity index 82% rename from src/main/java/org/apache/commons/xml/factory/HardeningTransformerFactory.java rename to src/main/java/eu/copernik/xml/factory/HardeningTransformerFactory.java index 23e3a57..86b0b86 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningTransformerFactory.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningTransformerFactory.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.Source; import javax.xml.transform.Templates; diff --git a/src/main/java/org/apache/commons/xml/factory/HardeningValidator.java b/src/main/java/eu/copernik/xml/factory/HardeningValidator.java similarity index 74% rename from src/main/java/org/apache/commons/xml/factory/HardeningValidator.java rename to src/main/java/eu/copernik/xml/factory/HardeningValidator.java index b970ed9..e8400a8 100644 --- a/src/main/java/org/apache/commons/xml/factory/HardeningValidator.java +++ b/src/main/java/eu/copernik/xml/factory/HardeningValidator.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.io.IOException; diff --git a/src/main/java/org/apache/commons/xml/factory/JaxpSetters.java b/src/main/java/eu/copernik/xml/factory/JaxpSetters.java similarity index 84% rename from src/main/java/org/apache/commons/xml/factory/JaxpSetters.java rename to src/main/java/eu/copernik/xml/factory/JaxpSetters.java index 8b52ba1..f9e4101 100644 --- a/src/main/java/org/apache/commons/xml/factory/JaxpSetters.java +++ b/src/main/java/eu/copernik/xml/factory/JaxpSetters.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParser; diff --git a/src/main/java/org/apache/commons/xml/factory/Limits.java b/src/main/java/eu/copernik/xml/factory/Limits.java similarity index 93% rename from src/main/java/org/apache/commons/xml/factory/Limits.java rename to src/main/java/eu/copernik/xml/factory/Limits.java index ab16351..a83d1f4 100644 --- a/src/main/java/org/apache/commons/xml/factory/Limits.java +++ b/src/main/java/eu/copernik/xml/factory/Limits.java @@ -1,23 +1,11 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; +package eu.copernik.xml.factory; -import static org.apache.commons.xml.factory.JaxpSetters.setAttribute; -import static org.apache.commons.xml.factory.JaxpSetters.setProperty; +import static eu.copernik.xml.factory.JaxpSetters.setAttribute; +import static eu.copernik.xml.factory.JaxpSetters.setProperty; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/src/main/java/org/apache/commons/xml/factory/Resolvers.java b/src/main/java/eu/copernik/xml/factory/Resolvers.java similarity index 87% rename from src/main/java/org/apache/commons/xml/factory/Resolvers.java rename to src/main/java/eu/copernik/xml/factory/Resolvers.java index 386517d..85d8ef7 100644 --- a/src/main/java/org/apache/commons/xml/factory/Resolvers.java +++ b/src/main/java/eu/copernik/xml/factory/Resolvers.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/src/main/java/org/apache/commons/xml/factory/SaxonProvider.java b/src/main/java/eu/copernik/xml/factory/SaxonProvider.java similarity index 83% rename from src/main/java/org/apache/commons/xml/factory/SaxonProvider.java rename to src/main/java/eu/copernik/xml/factory/SaxonProvider.java index 1fdde1c..a825d22 100644 --- a/src/main/java/org/apache/commons/xml/factory/SaxonProvider.java +++ b/src/main/java/eu/copernik/xml/factory/SaxonProvider.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; diff --git a/src/main/java/org/apache/commons/xml/factory/StockJdkProvider.java b/src/main/java/eu/copernik/xml/factory/StockJdkProvider.java similarity index 89% rename from src/main/java/org/apache/commons/xml/factory/StockJdkProvider.java rename to src/main/java/eu/copernik/xml/factory/StockJdkProvider.java index 54863a8..05a237d 100644 --- a/src/main/java/org/apache/commons/xml/factory/StockJdkProvider.java +++ b/src/main/java/eu/copernik/xml/factory/StockJdkProvider.java @@ -1,24 +1,13 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; -import static org.apache.commons.xml.factory.JaxpSetters.setAttribute; -import static org.apache.commons.xml.factory.JaxpSetters.setFeature; -import static org.apache.commons.xml.factory.JaxpSetters.setProperty; +package eu.copernik.xml.factory; + +import static eu.copernik.xml.factory.JaxpSetters.setAttribute; +import static eu.copernik.xml.factory.JaxpSetters.setFeature; +import static eu.copernik.xml.factory.JaxpSetters.setProperty; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilderFactory; diff --git a/src/main/java/org/apache/commons/xml/factory/WoodstoxProvider.java b/src/main/java/eu/copernik/xml/factory/WoodstoxProvider.java similarity index 83% rename from src/main/java/org/apache/commons/xml/factory/WoodstoxProvider.java rename to src/main/java/eu/copernik/xml/factory/WoodstoxProvider.java index c240616..7b3206f 100644 --- a/src/main/java/org/apache/commons/xml/factory/WoodstoxProvider.java +++ b/src/main/java/eu/copernik/xml/factory/WoodstoxProvider.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLResolver; diff --git a/src/main/java/org/apache/commons/xml/factory/XalanProvider.java b/src/main/java/eu/copernik/xml/factory/XalanProvider.java similarity index 78% rename from src/main/java/org/apache/commons/xml/factory/XalanProvider.java rename to src/main/java/eu/copernik/xml/factory/XalanProvider.java index e7384ba..403a5e6 100644 --- a/src/main/java/org/apache/commons/xml/factory/XalanProvider.java +++ b/src/main/java/eu/copernik/xml/factory/XalanProvider.java @@ -1,22 +1,11 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; -import static org.apache.commons.xml.factory.JaxpSetters.setFeature; +package eu.copernik.xml.factory; + +import static eu.copernik.xml.factory.JaxpSetters.setFeature; import javax.xml.XMLConstants; import javax.xml.transform.TransformerFactory; diff --git a/src/main/java/org/apache/commons/xml/factory/XercesProvider.java b/src/main/java/eu/copernik/xml/factory/XercesProvider.java similarity index 91% rename from src/main/java/org/apache/commons/xml/factory/XercesProvider.java rename to src/main/java/eu/copernik/xml/factory/XercesProvider.java index 26027f1..78c1620 100644 --- a/src/main/java/org/apache/commons/xml/factory/XercesProvider.java +++ b/src/main/java/eu/copernik/xml/factory/XercesProvider.java @@ -1,22 +1,11 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; -import static org.apache.commons.xml.factory.JaxpSetters.setFeature; +package eu.copernik.xml.factory; + +import static eu.copernik.xml.factory.JaxpSetters.setFeature; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; diff --git a/src/main/java/org/apache/commons/xml/factory/XmlFactories.java b/src/main/java/eu/copernik/xml/factory/XmlFactories.java similarity index 93% rename from src/main/java/org/apache/commons/xml/factory/XmlFactories.java rename to src/main/java/eu/copernik/xml/factory/XmlFactories.java index a16fa33..2f28cde 100644 --- a/src/main/java/org/apache/commons/xml/factory/XmlFactories.java +++ b/src/main/java/eu/copernik/xml/factory/XmlFactories.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilderFactory; @@ -184,7 +173,7 @@ public static XMLReader harden(final XMLReader reader) { case "com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser": return StockJdkProvider.configure(reader); case "org.apache.harmony.xml.ExpatReader": - case "org.apache.commons.xml.factory.AndroidProvider$GuardedXMLReader": + case "eu.copernik.xml.factory.AndroidProvider$GuardedXMLReader": return AndroidProvider.configure(reader); case "org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser": return XercesProvider.configure(reader); diff --git a/src/main/java/org/apache/commons/xml/factory/DelegatingTemplates.java b/src/main/java/org/apache/commons/xml/factory/DelegatingTemplates.java deleted file mode 100644 index 11eb05d..0000000 --- a/src/main/java/org/apache/commons/xml/factory/DelegatingTemplates.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import java.util.Properties; - -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; - -/** - * {@link Templates} wrapper that forwards every method to a wrapped delegate. - */ -class DelegatingTemplates implements Templates { - - private final Templates delegate; - - DelegatingTemplates(final Templates delegate) { - this.delegate = delegate; - } - - @Override - public Properties getOutputProperties() { - return delegate.getOutputProperties(); - } - - @Override - public Transformer newTransformer() throws TransformerConfigurationException { - return delegate.newTransformer(); - } -} diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index f73b356..749e520 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -1,22 +1,11 @@ <!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -# Apache Commons XML Factory - -Apache Commons XML Factory provides secure-by-default JAXP factory creation, + ~ SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + ~ SPDX-License-Identifier: Apache-2.0 + --> + +# Copernik XML Factory + +Copernik XML Factory provides secure-by-default JAXP factory creation, abstracting over implementation-specific XXE hardening differences between the stock JDK and external JAXP implementations. @@ -46,8 +35,8 @@ Add the library to your build: ```xml <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-xml-factory</artifactId> + <groupId>eu.copernik</groupId> + <artifactId>copernik-xml-factory</artifactId> <version>${commons.release.version}</version> </dependency> ``` @@ -67,7 +56,7 @@ requires a code change to this library. ```java import org.w3c.dom.Document; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; Document doc = XmlFactories.newDocumentBuilderFactory().newDocumentBuilder().parse(inputStream); ``` @@ -75,7 +64,7 @@ Document doc = XmlFactories.newDocumentBuilderFactory().newDocumentBuilder().par **SAX parsing** via `SAXParserFactory`: ```java -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newSAXParserFactory().newSAXParser().parse(inputStream, myDefaultHandler); ``` @@ -84,7 +73,7 @@ XmlFactories.newSAXParserFactory().newSAXParser().parse(inputStream, myDefaultHa ```java import javax.xml.stream.XMLStreamReader; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XMLStreamReader reader = XmlFactories.newXMLInputFactory().createXMLStreamReader(inputStream); ``` @@ -94,7 +83,7 @@ XMLStreamReader reader = XmlFactories.newXMLInputFactory().createXMLStreamReader ```java import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newTransformerFactory() .newTransformer(new StreamSource(stylesheet)) @@ -106,7 +95,7 @@ XmlFactories.newTransformerFactory() ```java import javax.xml.xpath.XPathConstants; import org.w3c.dom.NodeList; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; NodeList hits = (NodeList) XmlFactories.newXPathFactory() .newXPath() @@ -117,7 +106,7 @@ NodeList hits = (NodeList) XmlFactories.newXPathFactory() ```java import javax.xml.transform.stream.StreamSource; -import org.apache.commons.xml.factory.XmlFactories; +import eu.copernik.xml.factory.XmlFactories; XmlFactories.newSchemaFactory() .newSchema(new StreamSource(xsdStream)) diff --git a/src/test/java/org/apache/commons/xml/factory/AttackTestSupport.java b/src/test/java/eu/copernik/xml/factory/AttackTestSupport.java similarity index 98% rename from src/test/java/org/apache/commons/xml/factory/AttackTestSupport.java rename to src/test/java/eu/copernik/xml/factory/AttackTestSupport.java index 750b901..37ce3cb 100644 --- a/src/test/java/org/apache/commons/xml/factory/AttackTestSupport.java +++ b/src/test/java/eu/copernik/xml/factory/AttackTestSupport.java @@ -1,20 +1,8 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; +package eu.copernik.xml.factory; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/org/apache/commons/xml/factory/BillionLaughsTest.java b/src/test/java/eu/copernik/xml/factory/BillionLaughsTest.java similarity index 92% rename from src/test/java/org/apache/commons/xml/factory/BillionLaughsTest.java rename to src/test/java/eu/copernik/xml/factory/BillionLaughsTest.java index 23ae725..51e8745 100644 --- a/src/test/java/org/apache/commons/xml/factory/BillionLaughsTest.java +++ b/src/test/java/eu/copernik/xml/factory/BillionLaughsTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Tag; diff --git a/src/test/java/org/apache/commons/xml/factory/DoctypeOnlyTest.java b/src/test/java/eu/copernik/xml/factory/DoctypeOnlyTest.java similarity index 77% rename from src/test/java/org/apache/commons/xml/factory/DoctypeOnlyTest.java rename to src/test/java/eu/copernik/xml/factory/DoctypeOnlyTest.java index 074d892..fd93429 100644 --- a/src/test/java/org/apache/commons/xml/factory/DoctypeOnlyTest.java +++ b/src/test/java/eu/copernik/xml/factory/DoctypeOnlyTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Tag; diff --git a/src/test/java/org/apache/commons/xml/factory/ExternalDtdTest.java b/src/test/java/eu/copernik/xml/factory/ExternalDtdTest.java similarity index 84% rename from src/test/java/org/apache/commons/xml/factory/ExternalDtdTest.java rename to src/test/java/eu/copernik/xml/factory/ExternalDtdTest.java index 381110b..e334d29 100644 --- a/src/test/java/org/apache/commons/xml/factory/ExternalDtdTest.java +++ b/src/test/java/eu/copernik/xml/factory/ExternalDtdTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Tag; diff --git a/src/test/java/org/apache/commons/xml/factory/ExternalGeneralEntityTest.java b/src/test/java/eu/copernik/xml/factory/ExternalGeneralEntityTest.java similarity index 84% rename from src/test/java/org/apache/commons/xml/factory/ExternalGeneralEntityTest.java rename to src/test/java/eu/copernik/xml/factory/ExternalGeneralEntityTest.java index b1e7896..e8a4aee 100644 --- a/src/test/java/org/apache/commons/xml/factory/ExternalGeneralEntityTest.java +++ b/src/test/java/eu/copernik/xml/factory/ExternalGeneralEntityTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Tag; diff --git a/src/test/java/org/apache/commons/xml/factory/ExternalParameterEntityTest.java b/src/test/java/eu/copernik/xml/factory/ExternalParameterEntityTest.java similarity index 91% rename from src/test/java/org/apache/commons/xml/factory/ExternalParameterEntityTest.java rename to src/test/java/eu/copernik/xml/factory/ExternalParameterEntityTest.java index 3f7571b..45cfa78 100644 --- a/src/test/java/org/apache/commons/xml/factory/ExternalParameterEntityTest.java +++ b/src/test/java/eu/copernik/xml/factory/ExternalParameterEntityTest.java @@ -1,25 +1,13 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import java.io.StringReader; import java.util.concurrent.atomic.AtomicBoolean; -import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParserFactory; diff --git a/src/test/java/org/apache/commons/xml/factory/NoDoctypeTest.java b/src/test/java/eu/copernik/xml/factory/NoDoctypeTest.java similarity index 71% rename from src/test/java/org/apache/commons/xml/factory/NoDoctypeTest.java rename to src/test/java/eu/copernik/xml/factory/NoDoctypeTest.java index 37aeb2e..9c0aa27 100644 --- a/src/test/java/org/apache/commons/xml/factory/NoDoctypeTest.java +++ b/src/test/java/eu/copernik/xml/factory/NoDoctypeTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/apache/commons/xml/factory/SaxonXPathExternalCallsTest.java b/src/test/java/eu/copernik/xml/factory/SaxonXPathExternalCallsTest.java similarity index 86% rename from src/test/java/org/apache/commons/xml/factory/SaxonXPathExternalCallsTest.java rename to src/test/java/eu/copernik/xml/factory/SaxonXPathExternalCallsTest.java index 5936919..d76e475 100644 --- a/src/test/java/org/apache/commons/xml/factory/SaxonXPathExternalCallsTest.java +++ b/src/test/java/eu/copernik/xml/factory/SaxonXPathExternalCallsTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/eu/copernik/xml/factory/SchemaImportTest.java b/src/test/java/eu/copernik/xml/factory/SchemaImportTest.java new file mode 100644 index 0000000..f11299a --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/SchemaImportTest.java @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether {@code xs:import namespace="..." schemaLocation="included.xsd"} of a sibling schema in a different target namespace is resolved at compile + * time. The wrapper references an element defined only in the imported schema, so compilation cannot succeed unless the schemaLocation is fetched. + */ +@Tag("schema") +class SchemaImportTest { + + private static final String RESOURCE = "with-import.xsd"; + + @Test + void hardenedSchemaBlocks() { + AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); + } + + @Test + void unconfiguredSchemaCompiles() { + AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); + } +} diff --git a/src/test/java/eu/copernik/xml/factory/SchemaIncludeTest.java b/src/test/java/eu/copernik/xml/factory/SchemaIncludeTest.java new file mode 100644 index 0000000..de66232 --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/SchemaIncludeTest.java @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether {@code xs:include schemaLocation="included.xsd"} of a sibling schema sharing the wrapper's target namespace is resolved at compile time. The + * wrapper references an element defined only in the included schema, so compilation cannot succeed unless the schemaLocation is fetched. + */ +@Tag("schema") +class SchemaIncludeTest { + + private static final String RESOURCE = "with-include.xsd"; + + @Test + void hardenedSchemaBlocks() { + AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); + } + + @Test + void unconfiguredSchemaCompiles() { + AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); + } +} diff --git a/src/test/java/eu/copernik/xml/factory/SchemaRedefineTest.java b/src/test/java/eu/copernik/xml/factory/SchemaRedefineTest.java new file mode 100644 index 0000000..9b5d201 --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/SchemaRedefineTest.java @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether {@code xs:redefine schemaLocation="included.xsd"} that extends a complex type from a sibling schema is resolved at compile time. The wrapper + * cannot compile unless the redefined type is fetched from the sibling schema. + */ +@Tag("schema") +class SchemaRedefineTest { + + private static final String RESOURCE = "with-redefine.xsd"; + + @Test + void hardenedSchemaBlocks() { + AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); + } + + @Test + void unconfiguredSchemaCompiles() { + AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); + } +} diff --git a/src/test/java/eu/copernik/xml/factory/TemplatesImportTest.java b/src/test/java/eu/copernik/xml/factory/TemplatesImportTest.java new file mode 100644 index 0000000..e97103f --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/TemplatesImportTest.java @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether {@code xsl:import} of a sibling stylesheet is resolved at compile time. The wrapper imports a sibling that, if fetched, contributes a + * template emitting the leaked marker into the transform output. + */ +@Tag("trax") +class TemplatesImportTest { + + @Test + void hardenedTemplatesBlocks() { + AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-import.xsl")); + } +} diff --git a/src/test/java/eu/copernik/xml/factory/TemplatesIncludeTest.java b/src/test/java/eu/copernik/xml/factory/TemplatesIncludeTest.java new file mode 100644 index 0000000..cccf3ec --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/TemplatesIncludeTest.java @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether {@code xsl:include} of a sibling stylesheet is resolved at compile time. The wrapper includes a sibling that, if fetched, contributes a + * template emitting the leaked marker into the transform output. + */ +@Tag("trax") +class TemplatesIncludeTest { + + @Test + void hardenedTemplatesBlocks() { + AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-include.xsl")); + } +} diff --git a/src/test/java/eu/copernik/xml/factory/TransformerDocumentTest.java b/src/test/java/eu/copernik/xml/factory/TransformerDocumentTest.java new file mode 100644 index 0000000..45fad0f --- /dev/null +++ b/src/test/java/eu/copernik/xml/factory/TransformerDocumentTest.java @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 + */ + +package eu.copernik.xml.factory; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Checks whether the XSLT {@code document()} function is resolved at transform time. Compilation succeeds (the function call is just XPath); the leak vector + * fires only when {@code Transformer.transform} is called and the function evaluates its URI argument. + */ +@Tag("trax") +class TransformerDocumentTest { + + @Test + void hardenedTransformerBlocks() { + AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-document.xsl")); + } +} diff --git a/src/test/java/org/apache/commons/xml/factory/UnsupportedXmlImplementationTest.java b/src/test/java/eu/copernik/xml/factory/UnsupportedXmlImplementationTest.java similarity index 68% rename from src/test/java/org/apache/commons/xml/factory/UnsupportedXmlImplementationTest.java rename to src/test/java/eu/copernik/xml/factory/UnsupportedXmlImplementationTest.java index c50e5af..93cb2a4 100644 --- a/src/test/java/org/apache/commons/xml/factory/UnsupportedXmlImplementationTest.java +++ b/src/test/java/eu/copernik/xml/factory/UnsupportedXmlImplementationTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/src/test/java/org/apache/commons/xml/factory/XmlFactoriesTest.java b/src/test/java/eu/copernik/xml/factory/XmlFactoriesTest.java similarity index 82% rename from src/test/java/org/apache/commons/xml/factory/XmlFactoriesTest.java rename to src/test/java/eu/copernik/xml/factory/XmlFactoriesTest.java index 3e3399c..b2685cd 100644 --- a/src/test/java/org/apache/commons/xml/factory/XmlFactoriesTest.java +++ b/src/test/java/eu/copernik/xml/factory/XmlFactoriesTest.java @@ -1,20 +1,9 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2026 Piotr P. Karwasz <[email protected]> + * SPDX-License-Identifier: Apache-2.0 */ -package org.apache.commons.xml.factory; + +package eu.copernik.xml.factory; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -25,7 +14,6 @@ import java.io.StringReader; import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParserFactory; import javax.xml.stream.XMLInputFactory; diff --git a/src/test/java/org/apache/commons/xml/factory/SchemaImportTest.java b/src/test/java/org/apache/commons/xml/factory/SchemaImportTest.java deleted file mode 100644 index f9888db..0000000 --- a/src/test/java/org/apache/commons/xml/factory/SchemaImportTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether {@code xs:import namespace="..." schemaLocation="included.xsd"} of a sibling schema in a different target namespace is resolved at compile - * time. The wrapper references an element defined only in the imported schema, so compilation cannot succeed unless the schemaLocation is fetched. - */ -@Tag("schema") -class SchemaImportTest { - - private static final String RESOURCE = "with-import.xsd"; - - @Test - void hardenedSchemaBlocks() { - AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); - } - - @Test - void unconfiguredSchemaCompiles() { - AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); - } -} diff --git a/src/test/java/org/apache/commons/xml/factory/SchemaIncludeTest.java b/src/test/java/org/apache/commons/xml/factory/SchemaIncludeTest.java deleted file mode 100644 index 229f988..0000000 --- a/src/test/java/org/apache/commons/xml/factory/SchemaIncludeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether {@code xs:include schemaLocation="included.xsd"} of a sibling schema sharing the wrapper's target namespace is resolved at compile time. The - * wrapper references an element defined only in the included schema, so compilation cannot succeed unless the schemaLocation is fetched. - */ -@Tag("schema") -class SchemaIncludeTest { - - private static final String RESOURCE = "with-include.xsd"; - - @Test - void hardenedSchemaBlocks() { - AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); - } - - @Test - void unconfiguredSchemaCompiles() { - AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); - } -} diff --git a/src/test/java/org/apache/commons/xml/factory/SchemaRedefineTest.java b/src/test/java/org/apache/commons/xml/factory/SchemaRedefineTest.java deleted file mode 100644 index 5d10821..0000000 --- a/src/test/java/org/apache/commons/xml/factory/SchemaRedefineTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether {@code xs:redefine schemaLocation="included.xsd"} that extends a complex type from a sibling schema is resolved at compile time. The wrapper - * cannot compile unless the redefined type is fetched from the sibling schema. - */ -@Tag("schema") -class SchemaRedefineTest { - - private static final String RESOURCE = "with-redefine.xsd"; - - @Test - void hardenedSchemaBlocks() { - AttackTestSupport.assertSchemaBlocks(AttackTestSupport.resourceSource(RESOURCE)); - } - - @Test - void unconfiguredSchemaCompiles() { - AttackTestSupport.assertPermissiveSchemaCompiles(AttackTestSupport.resourceSource(RESOURCE)); - } -} diff --git a/src/test/java/org/apache/commons/xml/factory/TemplatesImportTest.java b/src/test/java/org/apache/commons/xml/factory/TemplatesImportTest.java deleted file mode 100644 index f2dc1f0..0000000 --- a/src/test/java/org/apache/commons/xml/factory/TemplatesImportTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether {@code xsl:import} of a sibling stylesheet is resolved at compile time. The wrapper imports a sibling that, if fetched, contributes a - * template emitting the leaked marker into the transform output. - */ -@Tag("trax") -class TemplatesImportTest { - - @Test - void hardenedTemplatesBlocks() { - AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-import.xsl")); - } -} diff --git a/src/test/java/org/apache/commons/xml/factory/TemplatesIncludeTest.java b/src/test/java/org/apache/commons/xml/factory/TemplatesIncludeTest.java deleted file mode 100644 index 7919153..0000000 --- a/src/test/java/org/apache/commons/xml/factory/TemplatesIncludeTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether {@code xsl:include} of a sibling stylesheet is resolved at compile time. The wrapper includes a sibling that, if fetched, contributes a - * template emitting the leaked marker into the transform output. - */ -@Tag("trax") -class TemplatesIncludeTest { - - @Test - void hardenedTemplatesBlocks() { - AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-include.xsl")); - } -} diff --git a/src/test/java/org/apache/commons/xml/factory/TransformerDocumentTest.java b/src/test/java/org/apache/commons/xml/factory/TransformerDocumentTest.java deleted file mode 100644 index 03eb413..0000000 --- a/src/test/java/org/apache/commons/xml/factory/TransformerDocumentTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.xml.factory; - -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; - -/** - * Checks whether the XSLT {@code document()} function is resolved at transform time. Compilation succeeds (the function call is just XPath); the leak vector - * fires only when {@code Transformer.transform} is called and the function evaluates its URI argument. - */ -@Tag("trax") -class TransformerDocumentTest { - - @Test - void hardenedTransformerBlocks() { - AttackTestSupport.assertTemplatesBlocks(AttackTestSupport.resourceSource("with-document.xsl")); - } -}
