Package org.keycloak.common.util
Class UriUtils
java.lang.Object
org.keycloak.common.util.UriUtils
- Author:
- Stian Thorgersen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckUrl(SslRequired sslRequired, String url, String name) static MultivaluedHashMap<String,String> decodeQueryString(String queryString) static Stringstatic Stringstatic Stringstatic booleanhasExplicitPort(URI uri) Whether the URI authority includes an explicit port separator (including an empty port).static booleanWhether the URI authority is safe for wildcard redirect matching.static booleanstatic booleanoriginEquals(String originA, String originB) static MultivaluedHashMap<String,String> parseQueryParameters(String queryString, boolean decode) static MultivaluedHashMap<String,String> parseQueryParameters(String queryString, boolean decodeNames, boolean decodeValues) Parses a query string, decoding parameter names and values independently.static booleanrawUserInfoEqual(URI uriA, URI uriB) Compare user-info case-sensitively, including registry-name authorities whereURI.getRawUserInfo()is left null by Java.static booleanschemeAndHostEqual(URI uriA, URI uriB) static booleanschemeHostAndPortEqual(URI uriA, URI uriB) static StringstripQueryParam(String url, String name)
-
Constructor Details
-
UriUtils
public UriUtils()
-
-
Method Details
-
getOrigin
-
getOrigin
-
isOrigin
-
originEquals
-
schemeAndHostEqual
-
schemeHostAndPortEqual
-
rawUserInfoEqual
Compare user-info case-sensitively, including registry-name authorities whereURI.getRawUserInfo()is left null by Java. -
hasExplicitPort
Whether the URI authority includes an explicit port separator (including an empty port). Used for port-wildcard redirect prefixes such ashttps://example.com:*. IPv6 literals are handled so colons inside[...]are not treated as a port. -
isAuthoritySafeForWildcards
Whether the URI authority is safe for wildcard redirect matching.Allows hosts Java parses normally and RFC 3986 registry-names (e.g. underscores) that leave
URI.getHost()null, while rejecting authorities with user-info or invalid ports. See CVE-2026-7504. -
getHost
-
parseQueryParameters
public static MultivaluedHashMap<String,String> parseQueryParameters(String queryString, boolean decode) -
parseQueryParameters
public static MultivaluedHashMap<String,String> parseQueryParameters(String queryString, boolean decodeNames, boolean decodeValues) Parses a query string, decoding parameter names and values independently. Names are decoded while parsing so that occurrences of the same decoded name (e.g.%53AMLResponseandSAMLResponse) keep their order of appearance in the query string.- Parameters:
queryString- raw query stringdecodeNames- whether to URL-decode parameter namesdecodeValues- whether to URL-decode parameter values- Returns:
- the parsed parameters
-
decodeQueryString
-
stripQueryParam
-
checkUrl
public static void checkUrl(SslRequired sslRequired, String url, String name) throws IllegalArgumentException - Throws:
IllegalArgumentException
-