Interface HttpExchangeSpi

  • All Superinterfaces:
    HttpServerScopes

    public interface HttpExchangeSpi
    extends HttpServerScopes
    The SPI to be implemented to bridge the Elytron APIs with the available APIs of the web server being integrated with.
    Author:
    Darran Lofthouse
    • Method Detail

      • getRequestHeaderValues

        List<String> getRequestHeaderValues​(String headerName)
        Get a list of all of the values set for the specified header within the HTTP request.
        Parameters:
        headerName - the not null name of the header the values are required for.
        Returns:
        a list of the values set for this header, if the header is not set on the request then null should be returned.
      • addResponseHeader

        void addResponseHeader​(String headerName,
                               String headerValue)
        Add the specified header and value to the end of the current response headers,
        Parameters:
        headerName - the name of the header.
        headerValue - the value of the header.
      • getFirstRequestHeaderValue

        default String getFirstRequestHeaderValue​(String headerName)
        Get the first value for the header specified in the HTTP request. A default implementation of this method is provided although implementations of this SPI may choose to provide their own optimised implementation.
        Parameters:
        headerName - the not null name of the header the value is required for.
        Returns:
        the value for the first instance of the header specified, if the header is not present then null should be returned instead.
      • getSSLSession

        default SSLSession getSSLSession()
        Get the SSLSession (if any) that has been established for the connection in use.
        Returns:
        the SSLSession (if any) that has been established for the connection in use, or null if none exists.
      • getPeerCertificates

        default Certificate[] getPeerCertificates​(boolean renegotiate)
        Get the peer certificates (if any) associated with the current connection. Although re-negotiation may be requested the underlying implementation may not support re-negotiation and will continue to return null. null will also still be returned if after re-negotiation peer certificates are still not available.
        Parameters:
        renegotiate - if no certificates are available should re-negotiation of the session be attempted.
        Returns:
        the peer certificates associated with the current connection or null if none associated.
      • setStatusCode

        void setStatusCode​(int statusCode)
        Set the required status code. This method is only expected to be called once after a response code has been selected.
        Parameters:
        statusCode - the desired status code.
      • authenticationComplete

        void authenticationComplete​(SecurityIdentity securityIdentity,
                                    String mechanismName)
        Notification that authentication has been completed for a specific identity using a specific authentication mechanism.
        Parameters:
        securityIdentity - the identity of the authenticated account.
        mechanismName - the name of the mechanism that was used to authenticate the account.
      • authenticationFailed

        void authenticationFailed​(String message,
                                  String mechanismName)
        Notification that authentication has failed using the mechanism specified.
        Parameters:
        message - an error message describing the failure
        mechanismName - a failed mechanism name
      • badRequest

        void badRequest​(HttpAuthenticationException error,
                        String mechanismName)
        Notification that authentication has failed for a specific mechanism due to being a bad request.
        Parameters:
        error - an exception to describe the error.
        mechanismName - a failed mechanism name
      • getRequestMethod

        String getRequestMethod()
        Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
        Returns:
        a String specifying the name of the method with which this request was made
      • getRequestURI

        URI getRequestURI()
        Get the URI representation for the current request.
        Returns:
        the URI representation for the current request.
      • getRequestPath

        String getRequestPath()
        Get the request path. This is the path relative to the context path. E.g.: for a request to http://my.appserver.com/my-application/path/sub-path this method is going to return /path/sub-path.
        Returns:
        the request relative path
      • getRequestParameters

        Map<String,​List<String>> getRequestParameters()
        Returns the parameters received in the current request. These parameters will be from both the query string and the form data when available. Where a parameter is named both in the query string and in the form data the list will contain the values from the query string followed by the values from the form data.
        Returns:
        the parameters received in the current request.
      • getRequestParameterNames

        default Set<String> getRequestParameterNames()
        Returns the names of all parameters either from the query string or from the form data where available.
        Returns:
        the names of all parameters either from the query string or from the form data where available.
      • getRequestParameterValues

        default List<String> getRequestParameterValues​(String name)
        Return the values for the parameter specified, where a parameter is specified both in the query string and in the form data the query string values will be first in the array.
        Parameters:
        name - the name of the desires parameter values.
        Returns:
        the values for the parameter specified or null if the parameter was not in the request.
      • getFirstRequestParameterValue

        default String getFirstRequestParameterValue​(String name)
        Get the first value for the parameter specified.
        Parameters:
        name - the name of the parameter the first value is required for.
        Returns:
        the first value of the named parameter or null if the paramter is not available.
      • getCookies

        List<HttpServerCookie> getCookies()
        Returns a List containing all of the HttpServerCookie objects the client sent with this request. This method should return an empty List if no cookies were sent.
        Returns:
        a List of all the cookies included with this request.
      • getRequestInputStream

        InputStream getRequestInputStream()
        Returns the request input stream.
        Returns:
        the input stream or null if not supported.
      • getSourceAddress

        InetSocketAddress getSourceAddress()
        Get the source address of the HTTP request.
        Returns:
        the source address of the HTTP request
      • setResponseCookie

        void setResponseCookie​(HttpServerCookie cookie)
        Sets a response cookie.
        Parameters:
        cookie - the cookie
      • getResponseOutputStream

        OutputStream getResponseOutputStream()
        Returns the response output stream.
        Returns:
        the output stream or null if not supported.
      • forward

        default int forward​(String path)
        Forward the current request to a different path.
        Returns:
        the desired status code from forwarding or -1 if forwarding was not successful.
      • suspendRequest

        default boolean suspendRequest()
        Suspend the current request so that it can be subsequently resumed. The server may use any strategy it deems appropriate to suspend the current request and store the state ready for a subsequent request.
        Returns:
        true if suspension is supported, false otherwise.
      • resumeRequest

        default boolean resumeRequest()
        Resume a previously suspended request.
        Returns:
        true if resuming a request is supported, false otherwise.