Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authority check for forUrl #430

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

lennartdohmann
Copy link
Contributor

Add authority check for forUrl to get a VaasClientException if it is a client side mistake

Copy link
Collaborator

@GermanCoding GermanCoding left a comment

Choose a reason for hiding this comment

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

LGTM

@unglaublicherdude
Copy link
Contributor

Hm. Wouldn't a toUri be more effective here? Have not tested if that would fail.

@unglaublicherdude
Copy link
Contributor

https://www.baeldung.com/java-validate-url

Just want to avoid that we build our own url validation

@unglaublicherdude
Copy link
Contributor

Yeah. To Uri should work.

    public void testing() {
        Exception exception = assertThrows(URISyntaxException.class, () -> {
            var url_1 = new URL("https://").toURI();
        });
    }

@unglaublicherdude
Copy link
Contributor

unglaublicherdude commented Apr 9, 2024

A different question is: Why not just accept URIs instead of URLs as parameter.

@GermanCoding
Copy link
Collaborator

A different question is: Why not just accept URIs instead of URLs as parameter.

I don't think this makes sense. For example, this

urn:oasis:names:specification:docbook:dtd:xml:4.1.2

is a valid URI as per RFC 3986 (it's a URN, which is also a type of URI). However, it is not a URL. URIs are supersets of URLs and include much more than just URLs. However, we only want to support URLs (and not even all types of URLs, e.g. not file URLs)

@unglaublicherdude
Copy link
Contributor

But than at least we are not consistent

https://github.com/GDATASoftwareAG/vaas/blob/main/java/src/main/java/de/gdata/vaas/ClientCredentialsGrantAuthenticator.java#L32

@lennartdohmann
Copy link
Contributor Author

lennartdohmann commented Apr 18, 2024

But the marked usage of type URI makes kind of sense there because a few lines blow the HTTPRequest builder expects an URI. Otherwise you would create an URI there, convert it to URL and then convert it back to the supertype URI for use.

@unglaublicherdude unglaublicherdude merged commit ed52ea3 into main Apr 22, 2024
5 checks passed
@unglaublicherdude unglaublicherdude deleted the java/add-authority-check-for-url branch April 22, 2024 08:42
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.

None yet

3 participants