Package org.keycloak.common.util
Class KeycloakUriBuilder
- java.lang.Object
- 
- org.keycloak.common.util.KeycloakUriBuilder
 
- 
 public class KeycloakUriBuilder extends Object - Version:
- $Revision: 1 $
- Author:
- Bill Burke
 
- 
- 
Constructor SummaryConstructors Constructor Description KeycloakUriBuilder()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description URIbuild(Object... values)URIbuild(Object[] values, boolean encodeSlashInPath)StringbuildAsString(Object... values)URIbuildFromEncodedMap(Map<String,?> values)URIbuildFromMap(Map<String,?> values)URIbuildFromMap(Map<String,?> values, boolean encodeSlashInPath)protected URIbuildFromValues(boolean encodeSlash, boolean encoded, Object... values)protected StringbuildFromValuesAsString(boolean encodeSlash, boolean encoded, Object... values)protected URIbuildUriFromMap(Map<String,?> paramMap, boolean fromEncodedMap, boolean encodeSlash)KeycloakUriBuilderclone()static booleancompare(String s1, String s2)static MatchercreateUriParamMatcher(String string)KeycloakUriBuilderencodedFragment(String fragment)Set fragment, but not encode it.KeycloakUriBuilderfragment(String fragment)static KeycloakUriBuilderfromPath(String path)static KeycloakUriBuilderfromTemplate(String uriTemplate)You may put path parameters anywhere within the uriTemplate except portstatic KeycloakUriBuilderfromUri(String uriTemplate)static KeycloakUriBuilderfromUri(URI uri)StringgetFragment()StringgetHost()StringgetPath()List<String>getPathParamNamesInDeclarationOrder()Return a unique order list of path paramsintgetPort()StringgetQuery()StringgetScheme()StringgetUserInfo()KeycloakUriBuilderhost(String host)KeycloakUriBuildermatrixParam(String name, Object... values)protected KeycloakUriBuilderparseHierarchicalUri(String uriTemplate, Matcher match)KeycloakUriBuilderpath(String segment)protected static Stringpaths(boolean encode, String basePath, String... segments)KeycloakUriBuilderport(int port)KeycloakUriBuilderpreserveDefaultPort()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)KeycloakUriBuilderqueryParam(String name, Object... values)static URIrelativize(URI from, URI to)KeycloakUriBuilderreplaceMatrix(String matrix)protected StringBufferreplaceParameter(Map<String,?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash)KeycloakUriBuilderreplacePath(String path)protected StringBufferreplacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer, boolean encodeSlash)KeycloakUriBuilderreplaceQuery(String query)KeycloakUriBuilderreplaceQueryParam(String name, Object... values)protected StringBufferreplaceQueryStringParameter(Map<String,?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer)KeycloakUriBuilderresolveTemplate(String name, Object value)KeycloakUriBuilderresolveTemplate(String name, Object value, boolean encodeSlashInPath)KeycloakUriBuilderresolveTemplates(Map<String,Object> templateValues)KeycloakUriBuilderresolveTemplates(Map<String,Object> templateValues, boolean encodeSlashInPath)KeycloakUriBuilderresolveTemplatesFromEncoded(Map<String,Object> templateValues)KeycloakUriBuilderscheme(String scheme)KeycloakUriBuilderschemeSpecificPart(String ssp)KeycloakUriBuildersegment(String... segments)KeycloakUriBuildersubstitutePathParam(String name, Object value, boolean isEncoded)Only replace path params in path of URI.StringtoTemplate()KeycloakUriBuilderuri(String uriTemplate)KeycloakUriBuilderuri(URI uri)KeycloakUriBuilderuriTemplate(String uriTemplate)You may put path parameters anywhere within the uriTemplate except portKeycloakUriBuilderuserInfo(String ui)
 
- 
- 
- 
Method Detail- 
fromUripublic static KeycloakUriBuilder fromUri(URI uri) 
 - 
fromUripublic static KeycloakUriBuilder fromUri(String uriTemplate) 
 - 
fromPathpublic static KeycloakUriBuilder fromPath(String path) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
clonepublic KeycloakUriBuilder clone() 
 - 
fromTemplatepublic static KeycloakUriBuilder fromTemplate(String uriTemplate) You may put path parameters anywhere within the uriTemplate except port- Parameters:
- uriTemplate-
- Returns:
 
 - 
uriTemplatepublic KeycloakUriBuilder uriTemplate(String uriTemplate) You may put path parameters anywhere within the uriTemplate except port- Parameters:
- uriTemplate-
- Returns:
 
 - 
parseHierarchicalUriprotected KeycloakUriBuilder parseHierarchicalUri(String uriTemplate, Matcher match) 
 - 
uripublic KeycloakUriBuilder uri(String uriTemplate) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
uripublic KeycloakUriBuilder uri(URI uri) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
schemepublic KeycloakUriBuilder scheme(String scheme) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
schemeSpecificPartpublic KeycloakUriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
userInfopublic KeycloakUriBuilder userInfo(String ui) 
 - 
hostpublic KeycloakUriBuilder host(String host) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
portpublic KeycloakUriBuilder port(int port) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
preserveDefaultPortpublic KeycloakUriBuilder 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)
 - 
pathpublic KeycloakUriBuilder path(String segment) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
replaceMatrixpublic KeycloakUriBuilder replaceMatrix(String matrix) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
replaceQuerypublic KeycloakUriBuilder replaceQuery(String query) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
fragmentpublic KeycloakUriBuilder fragment(String fragment) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
encodedFragmentpublic KeycloakUriBuilder encodedFragment(String fragment) Set fragment, but not encode it. It assumes that given fragment was already properly encoded- Parameters:
- fragment-
- Returns:
 
 - 
substitutePathParampublic KeycloakUriBuilder substitutePathParam(String name, Object value, boolean isEncoded) Only replace path params in path of URI. This changes state of URIBuilder.- Parameters:
- name-
- value-
- isEncoded-
- Returns:
 
 - 
buildFromMappublic URI buildFromMap(Map<String,?> values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
buildFromEncodedMappublic URI buildFromEncodedMap(Map<String,?> values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
buildFromMappublic URI buildFromMap(Map<String,?> values, boolean encodeSlashInPath) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
buildUriFromMapprotected URI buildUriFromMap(Map<String,?> paramMap, boolean fromEncodedMap, boolean encodeSlash) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
replacePathParameterprotected StringBuffer replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer, boolean encodeSlash) 
 - 
replaceParameterprotected StringBuffer replaceParameter(Map<String,?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash) 
 - 
replaceQueryStringParameterprotected StringBuffer replaceQueryStringParameter(Map<String,?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer) 
 - 
getPathParamNamesInDeclarationOrderpublic List<String> getPathParamNamesInDeclarationOrder() Return a unique order list of path params- Returns:
 
 - 
buildpublic URI build(Object... values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
buildAsStringpublic String buildAsString(Object... values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
buildFromValuesprotected URI buildFromValues(boolean encodeSlash, boolean encoded, Object... values) 
 - 
buildFromValuesAsStringprotected String buildFromValuesAsString(boolean encodeSlash, boolean encoded, Object... values) 
 - 
matrixParampublic KeycloakUriBuilder matrixParam(String name, Object... values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
queryParampublic KeycloakUriBuilder queryParam(String name, Object... values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
replaceQueryParampublic KeycloakUriBuilder replaceQueryParam(String name, Object... values) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
getHostpublic String getHost() 
 - 
getSchemepublic String getScheme() 
 - 
getPortpublic int getPort() 
 - 
getUserInfopublic String getUserInfo() 
 - 
getPathpublic String getPath() 
 - 
getQuerypublic String getQuery() 
 - 
getFragmentpublic String getFragment() 
 - 
segmentpublic KeycloakUriBuilder segment(String... segments) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
replacePathpublic KeycloakUriBuilder replacePath(String path) 
 - 
buildpublic URI build(Object[] values, boolean encodeSlashInPath) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
toTemplatepublic String toTemplate() 
 - 
resolveTemplatepublic KeycloakUriBuilder resolveTemplate(String name, Object value) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
resolveTemplatespublic KeycloakUriBuilder resolveTemplates(Map<String,Object> templateValues) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
resolveTemplatepublic KeycloakUriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
resolveTemplatespublic KeycloakUriBuilder resolveTemplates(Map<String,Object> templateValues, boolean encodeSlashInPath) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 - 
resolveTemplatesFromEncodedpublic KeycloakUriBuilder resolveTemplatesFromEncoded(Map<String,Object> templateValues) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 
- 
 
-