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 voidaddResponseHeader(String headerName, String headerValue)Add the specified header and value to the end of the current response headers,voidauthenticationComplete(SecurityIdentity securityIdentity, String mechanismName)Notification that authentication has been completed for a specific identity using a specific authentication mechanism.voidauthenticationFailed(String message, String mechanismName)Notification that authentication has failed using the mechanism specified.voidbadRequest(HttpAuthenticationException error, String mechanismName)Notification that authentication has failed for a specific mechanism due to being a bad request.default intforward(String path)Forward the current request to a different path.List<HttpServerCookie>getCookies()Returns aListcontaining all of theHttpServerCookieobjects the client sent with this request.default StringgetFirstRequestHeaderValue(String headerName)Get the first value for the header specified in the HTTP request.default StringgetFirstRequestParameterValue(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 StringgetRemoteUser()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.InputStreamgetRequestInputStream()Returns the request input stream.StringgetRequestMethod()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.StringgetRequestPath()Get the request path.URIgetRequestURI()Get the URI representation for the current request.OutputStreamgetResponseOutputStream()Returns the response output stream.InetSocketAddressgetSourceAddress()Get the source address of the HTTP request.default SSLSessiongetSSLSession()Get theSSLSession(if any) that has been established for the connection in use.default booleanresumeRequest()Resume a previously suspended request.default voidsetRequestInputStreamSupplier(Supplier<InputStream> requestInputStreamSupplier)Set the request input stream supplier.voidsetResponseCookie(HttpServerCookie cookie)Sets a response cookie.voidsetStatusCode(int statusCode)Set the required status code.default booleansuspendRequest()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 notnullname 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
nullshould 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. Adefaultimplementation of this method is provided although implementations of this SPI may choose to provide their own optimised implementation.- Parameters:
headerName- the notnullname 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
nullshould 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, ornullif 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.nullwill 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
nullif 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
Stringspecifying 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-paththis 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
nullif 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
nullif the paramter is not available.
-
getCookies
List<HttpServerCookie> getCookies()
Returns aListcontaining all of theHttpServerCookieobjects the client sent with this request. This method should return an emptyListif no cookies were sent.- Returns:
- a
Listof all the cookies included with this request.
-
getRequestInputStream
InputStream getRequestInputStream()
Returns the request input stream.- Returns:
- the input stream or
nullif 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
nullif not supported.
-
forward
default int forward(String path)
Forward the current request to a different path.- Returns:
- the desired status code from forwarding or
-1if forwarding was not successful.
-
getRemoteUser
default String getRemoteUser()
Returns a remotely authenticated user- Returns:
- the remote user principal or
nullif 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:
trueif suspension is supported,falseotherwise.
-
resumeRequest
default boolean resumeRequest()
Resume a previously suspended request.- Returns:
trueif resuming a request is supported,falseotherwise.
-
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
-
-