Package org.wildfly.security.http
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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addResponseHeader(String headerName, String headerValue)
Add the specified header and value to the end of the current response headers,void
authenticationComplete(SecurityIdentity securityIdentity, String mechanismName)
Notification that authentication has been completed for a specific identity using a specific authentication mechanism.void
authenticationFailed(String message, String mechanismName)
Notification that authentication has failed using the mechanism specified.void
badRequest(HttpAuthenticationException error, String mechanismName)
Notification that authentication has failed for a specific mechanism due to being a bad request.default int
forward(String path)
Forward the current request to a different path.List<HttpServerCookie>
getCookies()
Returns aList
containing all of theHttpServerCookie
objects the client sent with this request.default String
getFirstRequestHeaderValue(String headerName)
Get the first value for the header specified in the HTTP request.default String
getFirstRequestParameterValue(String name)
Get the first value for the parameter specified.default Certificate[]
getPeerCertificates(boolean renegotiate)
Get the peer certificates (if any) associated with the current connection.default String
getRemoteUser()
Returns a remotely authenticated userList<String>
getRequestHeaderValues(String headerName)
Get a list of all of the values set for the specified header within the HTTP request.InputStream
getRequestInputStream()
Returns the request input stream.String
getRequestMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.default Set<String>
getRequestParameterNames()
Returns the names of all parameters either from the query string or from the form data where available.Map<String,List<String>>
getRequestParameters()
Returns the parameters received in the current request.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.String
getRequestPath()
Get the request path.URI
getRequestURI()
Get the URI representation for the current request.OutputStream
getResponseOutputStream()
Returns the response output stream.InetSocketAddress
getSourceAddress()
Get the source address of the HTTP request.default SSLSession
getSSLSession()
Get theSSLSession
(if any) that has been established for the connection in use.default boolean
resumeRequest()
Resume a previously suspended request.default void
setRequestInputStreamSupplier(Supplier<InputStream> requestInputStreamSupplier)
Set the request input stream supplier.void
setResponseCookie(HttpServerCookie cookie)
Sets a response cookie.void
setStatusCode(int statusCode)
Set the required status code.default boolean
suspendRequest()
Suspend the current request so that it can be subsequently resumed.-
Methods inherited from interface org.wildfly.security.http.HttpServerScopes
getScope, getScope, getScopeIds
-
-
-
-
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 notnull
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. Adefault
implementation of this method is provided although implementations of this SPI may choose to provide their own optimised implementation.- Parameters:
headerName
- the notnull
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 theSSLSession
(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, ornull
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 returnnull
.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 failuremechanismName
- 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 tohttp://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 aList
containing all of theHttpServerCookie
objects the client sent with this request. This method should return an emptyList
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.
-
getRemoteUser
default String getRemoteUser()
Returns a remotely authenticated user- Returns:
- the remote user principal or
null
if no remote user was authenticated.
-
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.
-
setRequestInputStreamSupplier
default void setRequestInputStreamSupplier(Supplier<InputStream> requestInputStreamSupplier)
Set the request input stream supplier. The default implementation does nothing.- Parameters:
requestInputStreamSupplier
- the request input stream supplier
-
-