@ThreadSafe public final class UnifiedResponseDefaultSettings extends Object
UnifiedResponse objects.| Modifier and Type | Method and Description |
|---|---|
static void |
addCookie(javax.servlet.http.Cookie aCookie)
Add the passed cookie.
|
static void |
addResponseHeader(String sName,
String sValue)
Adds a response header to the response according to the passed name and
value.
|
static com.helger.commons.collection.impl.ICommonsOrderedMap<String,javax.servlet.http.Cookie> |
getAllCookies() |
static com.helger.commons.http.HttpHeaderMap |
getResponseHeaderMap() |
static boolean |
hasCookies() |
static com.helger.commons.state.EChange |
removeAllCookies()
Remove all cookies.
|
static com.helger.commons.state.EChange |
removeAllResponseHeaders()
Remove all response headers currently present.
|
static com.helger.commons.state.EChange |
removeCookie(String sName)
Remove the cookie with the specified name.
|
static com.helger.commons.state.EChange |
removeResponseHeaders(String sName)
Removes the response headers matching the passed name from the response.
|
static void |
removeStrictTransportSecurity()
Remove the `Strict-Transport-Security` headers from the default settings.
|
static void |
setAllowMimeSniffing(boolean bAllow)
When specifying
false, this method uses a special response
header to prevent certain browsers from MIME-sniffing a response away from
the declared content-type. |
static void |
setEnableXSSFilter(boolean bEnable)
This header enables the Cross-site scripting (XSS) filter built into most
recent web browsers.
|
static void |
setReferrerPolicy(com.helger.http.EHttpReferrerPolicy eReferrerPolicy)
Set the default referrer policy to use.
|
static void |
setResponseHeader(String sName,
String sValue)
Sets a response header to the response according to the passed name and
value.
|
static void |
setStrictTransportSecurity(int nMaxAgeSeconds,
boolean bIncludeSubdomains)
HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that
is specified by a web application through the use of a special response
header.
|
static void |
setXFrameOptions(EXFrameOptionType eType,
com.helger.commons.url.ISimpleURL aDomain)
The X-Frame-Options HTTP response header can be used to indicate whether or
not a browser should be allowed to render a page in a <frame>,
<iframe> or <object> .
|
@Nonnull @ReturnsMutableCopy public static com.helger.commons.http.HttpHeaderMap getResponseHeaderMap()
null header map.public static void setAllowMimeSniffing(boolean bAllow)
false, this method uses a special response
header to prevent certain browsers from MIME-sniffing a response away from
the declared content-type. When passing true, that header is
removed.bAllow - Whether or not sniffing should be allowed (default is
true).public static void setEnableXSSFilter(boolean bEnable)
bEnable - true to enable the header, false to disable
it.public static void setStrictTransportSecurity(@Nonnegative int nMaxAgeSeconds, boolean bIncludeSubdomains)
nMaxAgeSeconds - number of seconds, after the reception of the STS header field, during
which the UA regards the host (from whom the message was received) as
a Known HSTS Host.bIncludeSubdomains - if enabled, this signals the UA that the HSTS Policy applies to this
HSTS Host as well as any sub-domains of the host's domain name.public static void removeStrictTransportSecurity()
public static void setXFrameOptions(@Nullable EXFrameOptionType eType, @Nullable com.helger.commons.url.ISimpleURL aDomain)
X-Frame-Options: DENY X-Frame-Options: SAMEORIGIN X-Frame-Options: ALLOW-FROM https://example.com/
eType - The X-Frame-Options type to be set. May not be null.aDomain - The domain URL to be used in "ALLOW-FROM". May be null
for the other cases.public static void setReferrerPolicy(@Nullable com.helger.http.EHttpReferrerPolicy eReferrerPolicy)
eReferrerPolicy - Policy to use. May be null.public static void setResponseHeader(@Nonnull @Nonempty String sName, @Nonnull @Nonempty String sValue)
sName - Name of the header. May neither be null nor empty.sValue - Value of the header. May neither be null nor empty.public static void addResponseHeader(@Nonnull @Nonempty String sName, @Nonnull @Nonempty String sValue)
sName - Name of the header. May neither be null nor empty.sValue - Value of the header. May neither be null nor empty.@Nonnull public static com.helger.commons.state.EChange removeResponseHeaders(@Nonnull @Nonempty String sName)
UnifiedResponseDefaultSettings directly offers. Use this method only
in emergency and make sure you validate the header field and allowed value!sName - Name of the header to be removed. May neither be null nor
empty.EChange.CHANGED in header was removed.@Nonnull public static com.helger.commons.state.EChange removeAllResponseHeaders()
EChangepublic static boolean hasCookies()
true if at least one cookie is present.@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsOrderedMap<String,javax.servlet.http.Cookie> getAllCookies()
null but maybe
empty.public static void addCookie(@Nonnull javax.servlet.http.Cookie aCookie)
aCookie - The cookie to be added. May not be null.@Nonnull public static com.helger.commons.state.EChange removeCookie(@Nullable String sName)
sName - The name of the cookie to be removed. May be null.EChange@Nonnull public static com.helger.commons.state.EChange removeAllCookies()
EChange.CHANGED if at least one cookie was removed.Copyright © 2016–2019 Philip Helger. All rights reserved.