Class LicenseFilter
java.lang.Object
com.sodius.oslc.server.services.HttpFilter
com.sodius.oslc.server.security.services.LicenseFilter
- All Implemented Interfaces:
Filter
Allows to check license when accessing end-points.
When the license is not verified, the filter strategy depends on the Accept header received:
- For a known OSLC media type (
application/rdf+xml,application/xml,text/xml,application/json,text/turtle), the filter chain is aborted and the response contains an OSLC Error entity. - For a
text/htmlor a wildcard media type, the filter chain is processed and an error message is added as an attribute of the request. This enables the servlet to provide an HTML page which displays a license error message at its convenience, using thegetLicenseError(HttpServletRequest)method. - For any other media types, the filter chain is aborted and the response contains an error message with a
text/plaincontent type.
- Since:
- 2.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) Processes this filter and either executes or blocks the chain.getLicenseError(HttpServletRequest request) Allows to request attribute containing a license error message, if any.protected voidhandleLicenseException(HttpServletRequest request, HttpServletResponse response, FilterChain chain, OslcError error) Handles the behavior of the filter when the license is not verified, depending on the receivedAcceptheader.Methods inherited from class com.sodius.oslc.server.services.HttpFilter
destroy, doFilter, handleOslcError, init
-
Constructor Details
-
LicenseFilter
public LicenseFilter()
-
-
Method Details
-
doFilter
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException Description copied from class:HttpFilterProcesses this filter and either executes or blocks the chain.Subclasses may throw a
OslcWebApplicationExceptionto report anOslcError. This filter will automatically serialize such error in the HTTP response.- Specified by:
doFilterin classHttpFilter- Parameters:
request- the request.response- the response.chain- the filter chain to process.- Throws:
IOException- if an I/O error occurs.ServletException- if the filter execution fails.
-
getLicenseError
Allows to request attribute containing a license error message, if any. This shall be used by a servlet producing HTML content to include the license error as part of the page, at its convenience.- Parameters:
request- the received request- Returns:
- an optional string if an error message is present, optional empty otherwise.
-
handleLicenseException
protected void handleLicenseException(HttpServletRequest request, HttpServletResponse response, FilterChain chain, OslcError error) throws IOException, ServletException Handles the behavior of the filter when the license is not verified, depending on the receivedAcceptheader.- Parameters:
request- the received requestresponse- the response to sendchain- the filter chain to proceederror- the license error received when checking license- Throws:
IOException- exception can be thrown when writing responseServletException- exception can be thrown when processing filter- Since:
- 2.0.0
-