Class HSTSEnforcer
- All Implemented Interfaces:
Proxy
,SessionFeature
- 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
Modifier and TypeClassDescriptionstatic class
HSTSEnforcer.Builder<B extends HSTSEnforcer.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangedCallback
callback.static class
Class structure forSoupHSTSEnforcer
.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.soup.SessionFeature
SessionFeature.SessionFeatureImpl, SessionFeature.SessionFeatureInterface
-
Constructor Summary
ConstructorDescriptionCreates a newSoupHSTSEnforcer
.HSTSEnforcer
(MemorySegment address) Create a HSTSEnforcer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected HSTSEnforcer
asParent()
Returns this instance as if it were its parent type.static HSTSEnforcer.Builder
<? extends HSTSEnforcer.Builder> builder()
AHSTSEnforcer.Builder
object constructs aHSTSEnforcer
with the specified properties.protected void
changed
(HSTSPolicy oldPolicy, HSTSPolicy newPolicy) The class closure for theSoupHSTSEnforcer
::changed signal.void
emitChanged
(HSTSPolicy oldPolicy, HSTSPolicy newPolicy) Emits the "changed" signal.getDomains
(boolean sessionPolicies) Gets a list of domains for which there are policies inenforcer
.static MemoryLayout
The memory layout of the native struct.getPolicies
(boolean sessionPolicies) Gets a list with the policies inenforcer
.static Type
getType()
Get the GType of the HSTSEnforcer classboolean
hasValidPolicy
(String domain) Gets whether this HSTSEnforcer has a currently valid policy fordomain
.boolean
Gets whether this HSTSEnforcer stores policies persistenly.onChanged
(HSTSEnforcer.ChangedCallback handler) Emitted whenhstsEnforcer
changes.void
setPolicy
(HSTSPolicy policy) Setspolicy
to this HSTSEnforcer.void
setSessionPolicy
(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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
Creates a newSoupHSTSEnforcer
.The base
SoupHSTSEnforcer
class does not support persistent storage of HSTS policies, seeHSTSEnforcerDB
for that.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
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 Javasuper
keyword, 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
invalid reference
org.gnome.glib.List#freeFull
GLib.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
invalid reference
org.gnome.glib.List#freeFull
HSTSPolicy.free()
to free the list.
-
hasValidPolicy
Gets whether this HSTSEnforcer has a currently valid policy fordomain
.- Parameters:
domain
- a domain.- Returns:
true
if access todomain
should happen over HTTPS, false otherwise.
-
isPersistent
public boolean isPersistent()Gets whether this HSTSEnforcer stores policies persistenly.- Returns:
true
if this HSTSEnforcer storage is persistent orfalse
otherwise.
-
setPolicy
Setspolicy
to this HSTSEnforcer.If
policy
is 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 of this HSTSEnforcer'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 this HSTSEnforcer's
Session
and doesn't expire.- Parameters:
domain
- policy domain or hostnameincludeSubdomains
-true
if the policy applies on sub domains
-
changed
The class closure for theSoupHSTSEnforcer
::changed signal. -
onChanged
public SignalConnection<HSTSEnforcer.ChangedCallback> onChanged(HSTSEnforcer.ChangedCallback handler) Emitted whenhstsEnforcer
changes.If a policy has been added,
newPolicy
will contain the newly-added policy andoldPolicy
will benull
. If a policy has been deleted,oldPolicy
will contain the to-be-deleted policy andnewPolicy
will benull
. If a policy has been changed,oldPolicy
will contain its old value, andnewPolicy
its 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.Builder
object constructs aHSTSEnforcer
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withHSTSEnforcer.Builder.build()
.
-