Class UrlBuilder
- java.lang.Object
-
- de.uplanet.lucy.server.auxiliaries.UrlBuilder
-
@VelocityCallable("singleton") public final class UrlBuilder extends Object
-
-
Constructor Summary
Constructors Constructor Description UrlBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description URLcreateAbsoluteBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)Deprecated.UsecreateAbsoluteBaseUrl(IRequestProcessingContext)instead.URLcreateAbsoluteBaseDirectoryUrl(IServerBridgeRequest p_request)Deprecated.UsecreateAbsoluteBaseUrl(IServerBridgeRequest)instead.URLcreateAbsoluteBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)URLcreateAbsoluteBaseUrl(IServerBridgeRequest p_request)Create an absolute base URL from the given request.URLcreateAbsoluteRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)Reconstructs the URL the client used to make the request.URLcreateAbsoluteRequestBaseDirectoryUrl(IServerBridgeRequest p_request)Reconstructs the URL the client used to make the request.URLcreateBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)Create a base URL, i.e.URLcreateBaseUrl(IServerBridgeRequest p_request)Create a base URL, i.e.URLcreateDefaultUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)Deprecated.UsecreateBaseUrl(IRequestProcessingContext)instead.URLcreateDefaultUrl(IServerBridgeRequest p_request)Deprecated.UsecreateBaseUrl(IServerBridgeRequest)instead.URLcreateRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)Deprecated.URLcreateRequestBaseDirectoryUrl(IServerBridgeRequest p_request)Deprecated.URLcreateWebSocketBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)URLcreateWebSocketBaseUrl(IServerBridgeRequest p_request)Create a WebSocket URL from the given request.StringencodeUri(String p_strUri)Percent encode the given URI using UTF-8 as character set..booleanisSafeWebUrl(String p_strUrl)CallsisSafeWebUrl(String, boolean)with the second parameter set tofalseto disallow single quotes in the URL.booleanisSafeWebUrl(String p_strUrl, boolean p_bAllowSingleQuotes)Check if the given URL is a safe URL in Intrexx' sense.booleanisValidUri(String p_str)Validate given URLs.booleanisValidUrl(String p_str)Validate given URLs.URIparseUri(String p_strUri)Create an URI object from the given URI.URLparseUrl(String p_strUrl)Create an URL from the given string.
-
-
-
Method Detail
-
createBaseUrl
public URL createBaseUrl(IServerBridgeRequest p_request)
Create a base URL, i.e. a relative URL containing solely the root path/.- Parameters:
p_request- The request.- Returns:
- The
/base URL.
-
createBaseUrl
public URL createBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)
Create a base URL, i.e. a relative URL containing solely the root path/.- Parameters:
p_ctx- The processing context.- Returns:
- The
/base URL. - See Also:
createBaseUrl(IServerBridgeRequest)
-
createAbsoluteBaseUrl
public URL createAbsoluteBaseUrl(IServerBridgeRequest p_request) throws MalformedURLException
Create an absolute base URL from the given request.The returned absolute URL will always contain a terminating slash
/.This method tries to create an absolute base URL as follows
- First, if the
doc("internal/cfg/portal.cfg")/portal/uris/uri[@name='web.url.base.default']configuration parameter exists, return it. This is the preferred way. The following is a fallback in case the portal's default URL is not configured. - Second, try to create an absolute URL from
SERVERVAR.SCHEME,SERVERVAR.SERVER_NAME,SERVERVAR.SERVER_PORT, and return it.
- Parameters:
p_request- The request.- Returns:
- The base URL.
- Throws:
MalformedURLException- If a parsing error occurred.
- First, if the
-
createAbsoluteBaseUrl
public URL createAbsoluteBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
- Throws:
MalformedURLException- See Also:
createAbsoluteBaseUrl(IServerBridgeRequest)
-
createWebSocketBaseUrl
public URL createWebSocketBaseUrl(IServerBridgeRequest p_request) throws MalformedURLException
Create a WebSocket URL from the given request.This method uses the same algorithm as
createAbsoluteBaseUrl(IServerBridgeRequest)except that the scheme iswsorwssinstead ofhttporhttps.- Parameters:
p_request- The request.- Returns:
- The WebSocket URL.
- Throws:
MalformedURLException- If a parsing error occurred.- See Also:
createAbsoluteBaseUrl(IServerBridgeRequest)
-
createWebSocketBaseUrl
public URL createWebSocketBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
- Throws:
MalformedURLException- See Also:
createWebSocketBaseUrl(IServerBridgeRequest)
-
createAbsoluteRequestBaseDirectoryUrl
public URL createAbsoluteRequestBaseDirectoryUrl(IServerBridgeRequest p_request) throws MalformedURLException
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, (optional) port number, and server path without the document part.The document part is the rightmost path component that is not followed by a slash.
- Parameters:
p_request- The request.- Returns:
- The request base directory URL.
- Throws:
MalformedURLException
-
createAbsoluteRequestBaseDirectoryUrl
public URL createAbsoluteRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, (optional) port number, and server path without the document part.The document part is the rightmost path component that is not followed by a slash.
- Parameters:
p_ctx- The processing context.- Returns:
- The request base directory URL.
- Throws:
MalformedURLException- If a parsing error occurred.- See Also:
createAbsoluteRequestBaseDirectoryUrl(IServerBridgeRequest)
-
parseUrl
public URL parseUrl(String p_strUrl) throws MalformedURLException
Create an URL from the given string.- Parameters:
p_strUrl- The string to be parsed.- Returns:
- The URL.
- Throws:
MalformedURLException- If a parsing error occurred.
-
isValidUri
public boolean isValidUri(String p_str)
Validate given URLs.- Parameters:
p_str- The URL.- Returns:
trueif the URL is valid, orfalseotherwise.
-
isValidUrl
public boolean isValidUrl(String p_str)
Validate given URLs.- Parameters:
p_str- The URL.- Returns:
trueif the URL is valid, orfalseotherwise.
-
isSafeWebUrl
public boolean isSafeWebUrl(String p_strUrl)
CallsisSafeWebUrl(String, boolean)with the second parameter set tofalseto disallow single quotes in the URL.- Parameters:
p_strUrl- The URL.- Returns:
trueif the URL is considered safe, orfalseotherwise.
-
isSafeWebUrl
public boolean isSafeWebUrl(String p_strUrl, boolean p_bAllowSingleQuotes)
Check if the given URL is a safe URL in Intrexx' sense.The URL must meet the following conditions to be considered a safe Web ULR:
- The URL must only contain characters allowed by the spec (http://tools.ietf.org/html/rfc3986).
- The URL must not contain numeric or named HTML character references.
- The scheme must be either
http, orhttps, orftp, or the URL must be a relative URL. - If the URL is absolute it must have an authority part.
- If the URL is relative it must not have an authority part.
- Parameters:
p_strUrl- The URL.p_bAllowSingleQuotes-trueif single quotes are allowed to occur in the attribute value, orfalseotherwise.- Returns:
trueif the URL is considered safe, orfalseotherwise.
-
parseUri
public URI parseUri(String p_strUri) throws URISyntaxException
Create an URI object from the given URI.- Parameters:
p_strUri- The URI.- Returns:
- An URI object.
- Throws:
URISyntaxException- If a syntax error occurred.
-
encodeUri
public String encodeUri(String p_strUri) throws URISyntaxException
Percent encode the given URI using UTF-8 as character set..- Parameters:
p_strUri- The URI.- Returns:
- The encoded URI.
- Throws:
URISyntaxException- If a syntax error occurred.
-
createDefaultUrl
@Deprecated public URL createDefaultUrl(IServerBridgeRequest p_request)
Deprecated.UsecreateBaseUrl(IServerBridgeRequest)instead.The same ascreateBaseUrl(IServerBridgeRequest).- Parameters:
p_request- The request.- Returns:
- The URL.
-
createDefaultUrl
@Deprecated public URL createDefaultUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)
Deprecated.UsecreateBaseUrl(IRequestProcessingContext)instead.The same ascreateBaseUrl(IRequestProcessingContext).- Parameters:
p_ctx- The processing context.- Returns:
- The URL.
-
createAbsoluteBaseDirectoryUrl
@Deprecated public URL createAbsoluteBaseDirectoryUrl(IServerBridgeRequest p_request) throws MalformedURLException
Deprecated.UsecreateAbsoluteBaseUrl(IServerBridgeRequest)instead.The same ascreateAbsoluteBaseUrl(IServerBridgeRequest).- Parameters:
p_request- The request.- Returns:
- The URL.
- Throws:
MalformedURLException- If a parsing error occurred.
-
createAbsoluteBaseDirectoryUrl
@Deprecated public URL createAbsoluteBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
Deprecated.UsecreateAbsoluteBaseUrl(IRequestProcessingContext)instead.The same ascreateAbsoluteBaseUrl(IRequestProcessingContext).- Parameters:
p_ctx- The processing context.- Returns:
- The URL.
- Throws:
MalformedURLException- If a parsing error occurred.
-
createRequestBaseDirectoryUrl
@Deprecated public URL createRequestBaseDirectoryUrl(IServerBridgeRequest p_request) throws MalformedURLException
Deprecated.- Parameters:
p_request- The request.- Returns:
- The URL.
- Throws:
MalformedURLException- If a parsing error occurred.
-
createRequestBaseDirectoryUrl
@Deprecated public URL createRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
Deprecated.- Parameters:
p_ctx- The processing context.- Returns:
- The URL.
- Throws:
MalformedURLException- If a parsing error occurred.
-
-