Class DefaultHttpUserRequest

java.lang.Object
se.swedenconnect.signservice.core.http.DefaultHttpUserRequest
All Implemented Interfaces:
HttpUserRequest

public class DefaultHttpUserRequest extends Object implements HttpUserRequest
Default implementation of the HttpUserRequest interface. Its primary use is in frontend/backup deployments where it can help serializing/deserializing to and from JSON.
  • Constructor Details

    • DefaultHttpUserRequest

      public DefaultHttpUserRequest()
      Default constructor.
  • Method Details

    • getMethod

      @Nonnull public String getMethod()
      Gets the HTTP method with which this request was made (i.e., GET, POST, PUT, ...).
      Specified by:
      getMethod in interface HttpUserRequest
      Returns:
      name of HTTP method used to send the request
    • getRequestUrl

      @Nonnull public String getRequestUrl()
      Gets the complete request URL of the user HTTP request that was received by the frontend. This includes the protocol, host, (port), context path and servlet path. This string does not include any potential query parameters.
      Specified by:
      getRequestUrl in interface HttpUserRequest
      Returns:
      complete request URL
    • getServerBaseUrl

      @Nonnull public String getServerBaseUrl()
      Gets the frontend "server base URL", which is the protocol, host and context path.
      Specified by:
      getServerBaseUrl in interface HttpUserRequest
      Returns:
      the frontend server base URL
    • getServerServletPath

      @Nonnull public String getServerServletPath()
      Gets the part of this request's URL that calls the frontend's servlet. This path starts with a "/" character and includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.

      This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern.

      Specified by:
      getServerServletPath in interface HttpUserRequest
      Returns:
      the frontend's servlet path that matched this request
    • getClientIpAddress

      @Nonnull public String getClientIpAddress()
      Gets the client IP address.
      Specified by:
      getClientIpAddress in interface HttpUserRequest
      Returns:
      the client IP addres
    • getParameter

      @Nullable public String getParameter(@Nonnull String name)
      Gets the value of a request parameter as a string, or null if the parameter does not exist.

      Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

      In case you know, or want to be sure, that the parameter contains multiple values, use HttpUserRequest.getParameters().

      Specified by:
      getParameter in interface HttpUserRequest
      Parameters:
      name - the parameter name
      Returns:
      the parameter value, or null if it does not exist
      See Also:
    • getParameters

      @Nonnull public Map<String,String[]> getParameters()
      Gets a map of all request parameters, where the map entry key is the parameter name and the map entry value(s) is the parameter value.

      Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

      Specified by:
      getParameters in interface HttpUserRequest
      Returns:
      a map (possibly empty) of parameter names and values
      See Also:
    • getHeader

      @Nullable public String getHeader(@Nonnull String name)
      Gets the value of the specified request header. If the request did not include a header of the specified name, this method returns null.

      If there are multiple headers with the same name, this method returns the first header value in the request.

      Note: The header name is case insensitive.

      Specified by:
      getHeader in interface HttpUserRequest
      Parameters:
      name - the header name
      Returns:
      the header value, or null
      See Also:
    • getHeaders

      @Nonnull public Map<String,String[]> getHeaders()
      Gets a map of all request headers where the map entry key is the header name and the map entry value is the header value(s).
      Specified by:
      getHeaders in interface HttpUserRequest
      Returns:
      a (possibly empty) map of header names and values
      See Also: