Class HSTSEnforcer
- All Implemented Interfaces:
SessionFeature, Proxy
- Direct Known Subclasses:
HSTSEnforcerDB
Automatic HTTP Strict Transport Security enforcing for Session.
A HSTSEnforcer stores HSTS policies and enforces them when
required. HSTSEnforcer implements SessionFeature, so you
can add an HSTS enforcer to a session with
Session.addFeature(SessionFeature) or Session.addFeatureByType(Type).
HSTSEnforcer keeps track of all the HTTPS destinations that,
when connected to, return the Strict-Transport-Security header with
valid values. HSTSEnforcer will forget those destinations
upon expiry or when the server requests it.
When the Session the HSTSEnforcer is attached to queues or
restarts a message, the HSTSEnforcer will rewrite the URI to HTTPS if
the destination is a known HSTS host and is contacted over an insecure
transport protocol (HTTP). Users of HSTSEnforcer are advised to listen
to changes in the Message:uri property in order to be aware of
changes in the message URI.
Note that HSTSEnforcer does not support any form of long-term
HSTS policy persistence. See HSTSEnforcerDB for a persistent
enforcer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHSTSEnforcer.Builder<B extends HSTSEnforcer.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theChangedCallbackcallback.static classClass structure forHSTSEnforcer.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface SessionFeature
SessionFeature.SessionFeature$Impl, SessionFeature.SessionFeatureInterface -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new HSTSEnforcer.HSTSEnforcer(MemorySegment address) Create a HSTSEnforcer instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected HSTSEnforcerasParent()Return this instance as if it were its parent type.static HSTSEnforcer.Builder<? extends HSTSEnforcer.Builder> builder()AHSTSEnforcer.Builderobject constructs aHSTSEnforcerwith the specified properties.protected voidchanged(HSTSPolicy oldPolicy, HSTSPolicy newPolicy) The class closure for theHSTSEnforcer::changedsignal.voidemitChanged(@Nullable HSTSPolicy oldPolicy, @Nullable HSTSPolicy newPolicy) Emits the "changed" signal.getDomains(boolean sessionPolicies) Gets a list of domains for which there are policies inenforcer.static MemoryLayoutThe memory layout of the native struct.getPolicies(boolean sessionPolicies) Gets a list with the policies inenforcer.static @Nullable TypegetType()Get the GType of the HSTSEnforcer class.booleanhasValidPolicy(String domain) Gets whether this HSTSEnforcer has a currently valid policy fordomain.booleanGets whether this HSTSEnforcer stores policies persistenly.onChanged(HSTSEnforcer.ChangedCallback handler) Emitted whenhstsEnforcerchanges.voidsetPolicy(HSTSPolicy policy) SetspolicytohstsEnforcer.voidsetSessionPolicy(String domain, boolean includeSubdomains) Sets a session policy fordomain.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
HSTSEnforcer
Create a HSTSEnforcer instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
HSTSEnforcer
public HSTSEnforcer()Create a new HSTSEnforcer.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
getDomains
-
getPolicies
Gets a list with the policies inenforcer.- Parameters:
sessionPolicies- whether to include session policies- Returns:
- a newly
allocated list of policies. Use
org.gnome.glib.List.freeFullandHSTSPolicy.free()to free the list.
-
hasValidPolicy
Gets whether this HSTSEnforcer has a currently valid policy fordomain.- Parameters:
domain- a domain.- Returns:
trueif access todomainshould happen over HTTPS, false otherwise.
-
isPersistent
public boolean isPersistent()Gets whether this HSTSEnforcer stores policies persistenly.- Returns:
trueif this HSTSEnforcer storage is persistent orfalseotherwise.
-
setPolicy
Sets
policytohstsEnforcer.If
policyis expired, any existing HSTS policy for its host will be removed instead. If a policy existed for this host, it will be replaced. Otherwise, the new policy will be inserted. If the policy is a session policy, that is, one created withHSTSPolicy.sessionPolicy(String, boolean), the policy will not expire and will be enforced during the lifetime ofhstsEnforcer'sSession.- Parameters:
policy- the policy of the HSTS host
-
setSessionPolicy
Sets a session policy for
domain.A session policy is a policy that is permanent to the lifetime of
hstsEnforcer'sSessionand doesn't expire.- Parameters:
domain- policy domain or hostnameincludeSubdomains-trueif the policy applies on sub domains
-
changed
The class closure for theHSTSEnforcer::changedsignal. -
onChanged
public SignalConnection<HSTSEnforcer.ChangedCallback> onChanged(HSTSEnforcer.ChangedCallback handler) Emitted when
hstsEnforcerchanges.If a policy has been added,
newPolicywill contain the newly-added policy andoldPolicywill benull. If a policy has been deleted,oldPolicywill contain the to-be-deleted policy andnewPolicywill benull. If a policy has been changed,oldPolicywill contain its old value, andnewPolicyits new value.Note that you shouldn't modify the policies from a callback to this signal.
- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChanged
Emits the "changed" signal. SeeonChanged(HSTSEnforcer.ChangedCallback). -
builder
AHSTSEnforcer.Builderobject constructs aHSTSEnforcerwith the specified properties. Use the variousset...()methods to set properties, and finish construction withHSTSEnforcer.Builder.build().- Returns:
- the builder object
-