Package org.keycloak.common.util
Class KeycloakUriBuilder
java.lang.Object
org.keycloak.common.util.KeycloakUriBuilder
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildAsString
(Object... values) buildFromEncodedMap
(Map<String, ?> values) buildFromMap
(Map<String, ?> values) buildFromMap
(Map<String, ?> values, boolean encodeSlashInPath) protected URI
buildFromValues
(boolean encodeSlash, boolean encoded, Object... values) protected String
buildFromValuesAsString
(boolean encodeSlash, boolean encoded, Object... values) protected URI
buildUriFromMap
(Map<String, ?> paramMap, boolean fromEncodedMap, boolean encodeSlash) clone()
static boolean
static Matcher
createUriParamMatcher
(String string) encodedFragment
(String fragment) Set fragment, but not encode it.static KeycloakUriBuilder
static KeycloakUriBuilder
fromTemplate
(String uriTemplate) You may put path parameters anywhere within the uriTemplate except portstatic KeycloakUriBuilder
static KeycloakUriBuilder
static KeycloakUriBuilder
getHost()
getPath()
Return a unique order list of path paramsint
getPort()
getQuery()
matrixParam
(String name, Object... values) protected KeycloakUriBuilder
parseHierarchicalUri
(String uri, Matcher match, boolean template) protected static String
port
(int port) When this is called, then the port will be preserved in the build URL even if it is default port for the protocol (http, https) For example: - KeycloakUriBuilder.fromUri("https://localhost:443/path").buildAsString() will return "https://localhost/path" (port not preserved) - KeycloakUriBuilder.fromUri("https://localhost:443/path").preserveDefaultPort().buildAsString() will return "https://localhost:443/path" (port is preserved even if default port) - KeycloakUriBuilder.fromUri("https://localhost/path").preserveDefaultPort().buildAsString() will return "https://localhost/path" (port not included even if "preserveDefaultPort" as it was not in the original URL)queryParam
(String name, Object... values) static URI
relativize
(URI from, URI to) replaceMatrix
(String matrix) protected StringBuffer
replaceParameter
(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash) replacePath
(String path) replacePath
(String path, boolean template) protected StringBuffer
replacePathParameter
(String name, String value, boolean isEncoded, String string, StringBuffer buffer, boolean encodeSlash) replaceQuery
(String query) replaceQuery
(String query, boolean template) replaceQueryParam
(String name, Object... values) protected StringBuffer
replaceQueryStringParameter
(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer) resolveTemplate
(String name, Object value) resolveTemplate
(String name, Object value, boolean encodeSlashInPath) resolveTemplates
(Map<String, Object> templateValues) resolveTemplates
(Map<String, Object> templateValues, boolean encodeSlashInPath) resolveTemplatesFromEncoded
(Map<String, Object> templateValues) schemeSpecificPart
(String ssp) substitutePathParam
(String name, Object value, boolean isEncoded) Only replace path params in path of URI.uriTemplate
(String uriTemplate) You may put path parameters anywhere within the uriTemplate except port
-
Constructor Details
-
KeycloakUriBuilder
public KeycloakUriBuilder()
-
-
Method Details
-
fromUri
-
fromUri
-
fromUri
-
fromPath
- Throws:
IllegalArgumentException
-
clone
-
compare
-
relativize
-
fromTemplate
You may put path parameters anywhere within the uriTemplate except port- Parameters:
uriTemplate
-- Returns:
-
uriTemplate
You may put path parameters anywhere within the uriTemplate except port- Parameters:
uriTemplate
-- Returns:
-
parseHierarchicalUri
-
uri
- Throws:
IllegalArgumentException
-
uri
- Throws:
IllegalArgumentException
-
uri
- Throws:
IllegalArgumentException
-
scheme
- Throws:
IllegalArgumentException
-
schemeSpecificPart
- Throws:
IllegalArgumentException
-
userInfo
-
host
- Throws:
IllegalArgumentException
-
port
- Throws:
IllegalArgumentException
-
preserveDefaultPort
When this is called, then the port will be preserved in the build URL even if it is default port for the protocol (http, https) For example: - KeycloakUriBuilder.fromUri("https://localhost:443/path").buildAsString() will return "https://localhost/path" (port not preserved) - KeycloakUriBuilder.fromUri("https://localhost:443/path").preserveDefaultPort().buildAsString() will return "https://localhost:443/path" (port is preserved even if default port) - KeycloakUriBuilder.fromUri("https://localhost/path").preserveDefaultPort().buildAsString() will return "https://localhost/path" (port not included even if "preserveDefaultPort" as it was not in the original URL) -
paths
-
path
- Throws:
IllegalArgumentException
-
replaceMatrix
- Throws:
IllegalArgumentException
-
replaceQuery
- Throws:
IllegalArgumentException
-
replaceQuery
public KeycloakUriBuilder replaceQuery(String query, boolean template) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
fragment
- Throws:
IllegalArgumentException
-
fragment
public KeycloakUriBuilder fragment(String fragment, boolean template) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
encodedFragment
Set fragment, but not encode it. It assumes that given fragment was already properly encoded- Parameters:
fragment
-- Returns:
-
substitutePathParam
Only replace path params in path of URI. This changes state of URIBuilder.- Parameters:
name
-value
-isEncoded
-- Returns:
-
buildFromMap
- Throws:
IllegalArgumentException
-
buildFromEncodedMap
- Throws:
IllegalArgumentException
-
buildFromMap
public URI buildFromMap(Map<String, ?> values, boolean encodeSlashInPath) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
buildUriFromMap
protected URI buildUriFromMap(Map<String, ?> paramMap, boolean fromEncodedMap, boolean encodeSlash) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
replacePathParameter
protected StringBuffer replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer, boolean encodeSlash) -
createUriParamMatcher
-
replaceParameter
protected StringBuffer replaceParameter(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash) -
replaceQueryStringParameter
protected StringBuffer replaceQueryStringParameter(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer) -
getPathParamNamesInDeclarationOrder
Return a unique order list of path params- Returns:
-
build
- Throws:
IllegalArgumentException
-
buildAsString
- Throws:
IllegalArgumentException
-
buildFromValues
-
buildFromValuesAsString
-
matrixParam
public KeycloakUriBuilder matrixParam(String name, Object... values) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
queryParam
- Throws:
IllegalArgumentException
-
replaceQueryParam
public KeycloakUriBuilder replaceQueryParam(String name, Object... values) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getHost
-
getScheme
-
getPort
public int getPort() -
getUserInfo
-
getPath
-
getQuery
-
getFragment
-
segment
- Throws:
IllegalArgumentException
-
replacePath
-
replacePath
-
build
- Throws:
IllegalArgumentException
-
toTemplate
-
resolveTemplate
public KeycloakUriBuilder resolveTemplate(String name, Object value) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
resolveTemplates
public KeycloakUriBuilder resolveTemplates(Map<String, Object> templateValues) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
resolveTemplate
public KeycloakUriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
resolveTemplates
public KeycloakUriBuilder resolveTemplates(Map<String, Object> templateValues, boolean encodeSlashInPath) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
resolveTemplatesFromEncoded
public KeycloakUriBuilder resolveTemplatesFromEncoded(Map<String, Object> templateValues) throws IllegalArgumentException- Throws:
IllegalArgumentException
-