Class UrlBuilder

java.lang.Object
de.uplanet.lucy.server.auxiliaries.UrlBuilder

@VelocityCallable("singleton") public final class UrlBuilder extends Object
  • Constructor Details

    • UrlBuilder

      public UrlBuilder()
  • Method Details

    • createBaseUrl

      public de.uplanet.lucy.server.util.URL createBaseUrl(de.uplanet.lucy.server.connector.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 de.uplanet.lucy.server.util.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:
    • createAbsoluteBaseUrl

      public de.uplanet.lucy.server.util.URL createAbsoluteBaseUrl(de.uplanet.lucy.server.connector.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.
    • createAbsoluteBaseUrl

      public de.uplanet.lucy.server.util.URL createAbsoluteBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
      Throws:
      MalformedURLException
      See Also:
    • createWebSocketBaseUrl

      public de.uplanet.lucy.server.util.URL createWebSocketBaseUrl(de.uplanet.lucy.server.connector.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 is ws or wss instead of http or https.

      Parameters:
      p_request - The request.
      Returns:
      The WebSocket URL.
      Throws:
      MalformedURLException - If a parsing error occurred.
      See Also:
    • createWebSocketBaseUrl

      public de.uplanet.lucy.server.util.URL createWebSocketBaseUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
      Throws:
      MalformedURLException
      See Also:
    • createAbsoluteRequestBaseDirectoryUrl

      public de.uplanet.lucy.server.util.URL createAbsoluteRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.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 de.uplanet.lucy.server.util.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:
    • parseUrl

      public de.uplanet.lucy.server.util.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:
      true if the URL is valid, or false otherwise.
    • isValidUrl

      public boolean isValidUrl(String p_str)
      Validate given URLs.
      Parameters:
      p_str - The URL.
      Returns:
      true if the URL is valid, or false otherwise.
    • isSafeWebUrl

      public boolean isSafeWebUrl(String p_strUrl)
      Calls isSafeWebUrl(String, boolean) with the second parameter set to false to disallow single quotes in the URL.
      Parameters:
      p_strUrl - The URL.
      Returns:
      true if the URL is considered safe, or false otherwise.
    • 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, or https, or ftp, 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 - true if single quotes are allowed to occur in the attribute value, or false otherwise.
      Returns:
      true if the URL is considered safe, or false otherwise.
    • 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 de.uplanet.lucy.server.util.URL createDefaultUrl(de.uplanet.lucy.server.connector.IServerBridgeRequest p_request)
      Deprecated.
      Parameters:
      p_request - The request.
      Returns:
      The URL.
    • createDefaultUrl

      @Deprecated public de.uplanet.lucy.server.util.URL createDefaultUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx)
      Parameters:
      p_ctx - The processing context.
      Returns:
      The URL.
    • createAbsoluteBaseDirectoryUrl

      @Deprecated public de.uplanet.lucy.server.util.URL createAbsoluteBaseDirectoryUrl(de.uplanet.lucy.server.connector.IServerBridgeRequest p_request) throws MalformedURLException
      Parameters:
      p_request - The request.
      Returns:
      The URL.
      Throws:
      MalformedURLException - If a parsing error occurred.
    • createAbsoluteBaseDirectoryUrl

      @Deprecated public de.uplanet.lucy.server.util.URL createAbsoluteBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
      Parameters:
      p_ctx - The processing context.
      Returns:
      The URL.
      Throws:
      MalformedURLException - If a parsing error occurred.
    • createRequestBaseDirectoryUrl

      @Deprecated public de.uplanet.lucy.server.util.URL createRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IServerBridgeRequest p_request) throws MalformedURLException
      Parameters:
      p_request - The request.
      Returns:
      The URL.
      Throws:
      MalformedURLException - If a parsing error occurred.
    • createRequestBaseDirectoryUrl

      @Deprecated public de.uplanet.lucy.server.util.URL createRequestBaseDirectoryUrl(de.uplanet.lucy.server.connector.IRequestProcessingContext p_ctx) throws MalformedURLException
      Parameters:
      p_ctx - The processing context.
      Returns:
      The URL.
      Throws:
      MalformedURLException - If a parsing error occurred.