Class HSTSEnforcer
- All Implemented Interfaces:
SessionFeature,Proxy
- Direct Known Subclasses:
HSTSEnforcerDB
Session.
A SoupHSTSEnforcer stores HSTS policies and enforces them when
required. SoupHSTSEnforcer implements SessionFeature, so you
can add an HSTS enforcer to a session with
Session.addFeature(org.gnome.soup.SessionFeature) or Session.addFeatureByType(org.gnome.glib.Type).
SoupHSTSEnforcer keeps track of all the HTTPS destinations that,
when connected to, return the Strict-Transport-Security header with
valid values. SoupHSTSEnforcer will forget those destinations
upon expiry or when the server requests it.
When the Session the SoupHSTSEnforcer is attached to queues or
restarts a message, the SoupHSTSEnforcer 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 SoupHSTSEnforcer are advised to listen
to changes in the Message:uri property in order to be aware of
changes in the message URI.
Note that SoupHSTSEnforcer 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 forSoupHSTSEnforcer.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.soup.SessionFeature
SessionFeature.SessionFeature$Impl, SessionFeature.SessionFeatureInterface -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new HSTSEnforcer.HSTSEnforcer(MemorySegment address) Create a HSTSEnforcer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected HSTSEnforcerasParent()Returns 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 theSoupHSTSEnforcer::changed signal.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 classbooleanhasValidPolicy(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 org.gnome.gobject.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 org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
HSTSEnforcer
Create a HSTSEnforcer proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
HSTSEnforcer
public HSTSEnforcer()Creates a new HSTSEnforcer.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDomains
Gets a list of domains for which there are policies inenforcer.- Parameters:
sessionPolicies- whether to include session policies- Returns:
- a newly allocated
list of domains. Use
org.gnome.glib.List#freeFullandGLib.free(java.lang.foreign.MemorySegment)to free the list.
-
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
SetspolicytohstsEnforcer.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(java.lang.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 fordomain.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 theSoupHSTSEnforcer::changed signal. -
onChanged
public SignalConnection<HSTSEnforcer.ChangedCallback> onChanged(HSTSEnforcer.ChangedCallback handler) Emitted whenhstsEnforcerchanges.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(org.gnome.soup.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
-