Class HSTSPolicy
- All Implemented Interfaces:
Proxy
SoupHSTSPolicy
implements HTTP policies, as described by
RFC 6797.
domain
represents the host that this policy applies to. The domain
must be IDNA-canonicalized. HSTSPolicy(java.lang.String, int, boolean)
and related methods
will do this for you.
maxAge
contains the 'max-age' value from the Strict Transport
Security header and indicates the time to live of this policy,
in seconds.
expires
will be non-null
if the policy has been set by the host and
hence has an expiry time. If expires
is null
, it indicates that the
policy is a permanent session policy set by the user agent.
If includeSubdomains
is true
, the Strict Transport Security policy
must also be enforced on subdomains of domain
.
-
Constructor Summary
ConstructorDescriptionHSTSPolicy
(MemorySegment address) Create a HSTSPolicy proxy instance for the provided memory address.HSTSPolicy
(String domain, int maxAge, boolean includeSubdomains) Creates a newSoupHSTSPolicy
with the given attributes. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copies this HSTSPolicy.boolean
equal
(HSTSPolicy policy2) Tests if this HSTSPolicy andpolicy2
are equal.void
free()
Frees this HSTSPolicy.static HSTSPolicy
fromResponse
(Message msg) Parsesmsg
's first "Strict-Transport-Security" response header and returns aSoupHSTSPolicy
.static HSTSPolicy
Full version ofHSTSPolicy(java.lang.String, int, boolean)
, to use with an existing expiration date.Gets this HSTSPolicy's domain.Returns the expiration date for this HSTSPolicy.int
Returns the max age for this HSTSPolicy.static Type
getType()
Get the GType of the HSTSPolicy classboolean
Gets whether this HSTSPolicy include its subdomains.boolean
Gets whether this HSTSPolicy is expired.boolean
Gets whether this HSTSPolicy is a non-permanent, non-expirable session policy.static HSTSPolicy
sessionPolicy
(String domain, boolean includeSubdomains) Creates a new sessionSoupHSTSPolicy
with the given attributes.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
HSTSPolicy
Create a HSTSPolicy proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
HSTSPolicy
public HSTSPolicy(String domain, int maxAge, boolean includeSubdomains) throws UnsupportedPlatformException Creates a newSoupHSTSPolicy
with the given attributes.domain
is a domain on which the strict transport security policy represented by this object must be enforced.maxAge
is used to set the "expires" attribute on the policy; passSOUP_HSTS_POLICY_MAX_AGE_PAST
for an already-expired policy, or a lifetime in seconds.If
includeSubdomains
istrue
, the strict transport security policy must also be enforced on all subdomains ofdomain
.- Parameters:
domain
- policy domain or hostnamemaxAge
- max age of the policyincludeSubdomains
-true
if the policy applies on subdomains- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
fromResponse
Parsesmsg
's first "Strict-Transport-Security" response header and returns aSoupHSTSPolicy
.- Parameters:
msg
- aSoupMessage
- Returns:
- a new
SoupHSTSPolicy
, ornull
if no valid "Strict-Transport-Security" response header was found. - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
full
public static HSTSPolicy full(String domain, int maxAge, DateTime expires, boolean includeSubdomains) Full version ofHSTSPolicy(java.lang.String, int, boolean)
, to use with an existing expiration date.See
HSTSPolicy(java.lang.String, int, boolean)
for details.- Parameters:
domain
- policy domain or hostnamemaxAge
- max age of the policyexpires
- the date of expiration of the policy ornull
for a permanent policyincludeSubdomains
-true
if the policy applies on subdomains- Returns:
- a new
SoupHSTSPolicy
. - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
sessionPolicy
Creates a new sessionSoupHSTSPolicy
with the given attributes.A session policy is a policy that is valid during the lifetime of the
HSTSEnforcer
it is added to. Contrary to regular policies, it has no expiration date and is not stored in persistent enforcers. These policies are useful for user-agent to load their own or user-defined rules.domain
is a domain on which the strict transport security policy represented by this object must be enforced.If
includeSubdomains
istrue
, the strict transport security policy must also be enforced on all subdomains ofdomain
.- Parameters:
domain
- policy domain or hostnameincludeSubdomains
-true
if the policy applies on sub domains- Returns:
- a new
SoupHSTSPolicy
. - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
copy
-
equal
Tests if this HSTSPolicy andpolicy2
are equal.- Parameters:
policy2
- aSoupHSTSPolicy
- Returns:
- whether the policies are equal.
-
free
public void free()Frees this HSTSPolicy. -
getDomain
-
getExpires
Returns the expiration date for this HSTSPolicy.- Returns:
- A
GDateTime
ornull
if unset
-
getMaxAge
public int getMaxAge()Returns the max age for this HSTSPolicy.- Returns:
- Max age in seconds
-
includesSubdomains
public boolean includesSubdomains()Gets whether this HSTSPolicy include its subdomains.- Returns:
true
if this HSTSPolicy includes subdomains,false
otherwise.
-
isExpired
public boolean isExpired()Gets whether this HSTSPolicy is expired.Permanent policies never expire.
- Returns:
true
if this HSTSPolicy is expired,false
otherwise.
-
isSessionPolicy
public boolean isSessionPolicy()Gets whether this HSTSPolicy is a non-permanent, non-expirable session policy.See
sessionPolicy(java.lang.String, boolean)
for details.- Returns:
true
if this HSTSPolicy is permanent,false
otherwise
-