Skip to content

REF-7: Support non-file resource URLs (WildFly/JBoss vfs:) in ResourceUtil (issue #80) - #86

Merged
thomasnymand merged 2 commits into
masterfrom
feature/REF-7-resourceutil-vfs-url
Jul 6, 2026
Merged

REF-7: Support non-file resource URLs (WildFly/JBoss vfs:) in ResourceUtil (issue #80)#86
thomasnymand merged 2 commits into
masterfrom
feature/REF-7-resourceutil-vfs-url

Conversation

@thomasnymand

Copy link
Copy Markdown
Collaborator

Fixes #80

Summary

On WildFly/JBoss, loading resources failed with an IllegalArgumentException during the authentication flow.

Root cause: ResourceUtil.getResourceAsFile() only special-cased jar: URLs and converted every other URL with new File(url.toURI()). WildFly/JBoss serves classpath resources through its virtual file system, so the classloader returns vfs: / vfszip: URLs. new File(uri) requires a file: scheme and throws IllegalArgumentException: URI scheme is not "file" for those.

Fix

Extract a package-private toFile(URL, String) that:

  • uses a plain file: URL directly, and
  • stream-copies any other protocol (jar:, vfs:, vfszip:, ...) to a temporary file.

This generalizes the previous jar-only handling to any non-file: protocol, so no per-app-server special-casing is needed.

Test

ResourceUtilTest gets a new case that simulates a WildFly vfs: URL via a synthetic URLStreamHandler. It asserts that the old new File(url.toURI()) throws IllegalArgumentException (the #80 bug) and that toFile() resolves the same URL to a readable file with the original content. Existing jar: / classpath / external-file cases still pass.

Full suite: Tests run: 108, Failures: 0, Errors: 0.

🤖 Generated with Claude Code

…eUtil (issue #80)

ResourceUtil.getResourceAsFile only special-cased 'jar:' URLs and turned
every other URL into a File via new File(url.toURI()). On WildFly/JBoss
the classloader returns 'vfs:'/'vfszip:' URLs, for which that throws
IllegalArgumentException ("URI scheme is not 'file'"), breaking resource
loading during the authentication flow.

Extract a package-private toFile(URL, String) that uses a plain 'file:'
URL directly and stream-copies any other protocol (jar:, vfs:, vfszip:,
...) to a temporary file. Add a ResourceUtilTest case that simulates a
WildFly vfs: URL and verifies it resolves to a readable file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@mthiim mthiim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

Comment thread oiosaml/src/main/java/dk/gov/oio/saml/util/ResourceUtil.java
…to temp file

Files.createTempFile uses the resourceName as the temp-file prefix, and a
prefix containing '/' (e.g. "config/oiosaml.properties" or a resource in
WEB-INF/classes/config on WildFly VFS) is rejected with
IllegalArgumentException. Use only the last path segment as the prefix and
add an "oiosaml-" prefix to guarantee the minimum length. Addresses review
feedback on #86.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thomasnymand
thomasnymand merged commit 4641ada into master Jul 6, 2026
2 checks passed
@thomasnymand
thomasnymand deleted the feature/REF-7-resourceutil-vfs-url branch July 6, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Illegal argument exception reading oiosaml.properties file in oiosaml3-3.2.1 version

2 participants