Package io.vertx.mutiny.ext.web.handler
Class CSPHandler
java.lang.Object
io.vertx.mutiny.ext.web.handler.CSPHandler
- All Implemented Interfaces:
MutinyDelegate,io.vertx.core.Handler<RoutingContext>,SecurityPolicyHandler,Consumer<RoutingContext>
public class CSPHandler
extends Object
implements SecurityPolicyHandler, io.vertx.core.Handler<RoutingContext>, Consumer<RoutingContext>, MutinyDelegate
Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of
attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from
data theft to site defacement to distribution of malware.
CSP is designed to be fully backward compatible. Browsers that don't support it still work with servers that
implement it, and vice-versa: browsers that don't support CSP simply ignore it, functioning as usual, defaulting to
the standard same-origin policy for web content. If the site doesn't offer the CSP header, browsers likewise use the
standard same-origin policy.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Paulo Lopes
- See Also:
-
CSPHandler
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.ext.web.handler.SecurityPolicyHandler
SecurityPolicyHandler.SecurityPolicyHandlerImpl -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCSPHandler(io.vertx.ext.web.handler.CSPHandler delegate) Create a new instance ofCSPHandlerdelegating to the given (non-null) instance ofCSPHandler.CSPHandler(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(RoutingContext item) Handle an item.addDirective(String name, String value) Adds a single directive entry to the handler.static CSPHandlercreate()Creates a new instance of the handler.booleanio.vertx.ext.web.handler.CSPHandlerGet the delegate instance.voidhandle(RoutingContext item) Handle an item.inthashCode()static CSPHandlernewInstance(io.vertx.ext.web.handler.CSPHandler delegate) Creates a new instance of theCSPHandler.setDirective(String name, String value) Sets a single directive entry to the handler.setReportOnly(boolean reportOnly) To ease deployment, CSP can be deployed in report-only mode.toString()
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
CSPHandler
public CSPHandler(io.vertx.ext.web.handler.CSPHandler delegate) Create a new instance ofCSPHandlerdelegating to the given (non-null) instance ofCSPHandler. -
CSPHandler
-
-
Method Details
-
accept
Handle an item. This method is generated from theoriginalmethod."- Specified by:
acceptin interfaceConsumer<RoutingContext>- Specified by:
acceptin interfaceSecurityPolicyHandler
-
handle
Handle an item. This method is generated from theoriginalmethod."- Specified by:
handlein interfaceio.vertx.core.Handler<RoutingContext>- Specified by:
handlein interfaceSecurityPolicyHandler
-
getDelegate
public io.vertx.ext.web.handler.CSPHandler getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceSecurityPolicyHandler- Returns:
- the delegate instance
-
create
Creates a new instance of the handler.- Returns:
- a new CSP handler.
-
setDirective
Sets a single directive entry to the handler. All previously set or added directives will be replaced. For more information on directives see: Content-Security-Policy.- Parameters:
name- the directive namevalue- the directive value.- Returns:
- fluent self
-
addDirective
Adds a single directive entry to the handler. All previously set or added directives will be preserved. For more information on directives see: Content-Security-Policy.- Parameters:
name- the directive namevalue- the directive value.- Returns:
- fluent self
-
setReportOnly
To ease deployment, CSP can be deployed in report-only mode. The policy is not enforced, but any violations are reported to a provided URI. Additionally, a report-only header can be used to test a future revision to a policy without actually deploying it.- Parameters:
reportOnly- enable report only- Returns:
- fluent self.
-
newInstance
Creates a new instance of theCSPHandler. -
hashCode
public int hashCode() -
equals
-
toString
-