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
ConstructorsConstructorDescriptionHSTSPolicy(MemorySegment address) Create a HSTSPolicy proxy instance for the provided memory address.HSTSPolicy(String domain, int maxAge, boolean includeSubdomains) Creates a newSoupHSTSPolicywith the given attributes. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copiespolicy.booleanequal(HSTSPolicy policy2) Tests if this HSTSPolicy andpolicy2are equal.voidfree()Freespolicy.static HSTSPolicyfromResponse(Message msg) Parsesmsg'sfirst "Strict-Transport-Security" response header and returns aSoupHSTSPolicy.static HSTSPolicyFull version ofHSTSPolicy(java.lang.String, int, boolean), to use with an existing expiration date.Getspolicy'sdomain.Returns the expiration date forpolicy.intReturns the max age forpolicy.static @Nullable TypegetType()Get the GType of the HSTSPolicy classbooleanGets whether this HSTSPolicy include its subdomains.booleanGets whether this HSTSPolicy is expired.booleanGets whether this HSTSPolicy is a non-permanent, non-expirable session policy.static HSTSPolicysessionPolicy(String domain, boolean includeSubdomains) Creates a new sessionSoupHSTSPolicywith the given attributes.Methods inherited from class org.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
Creates a newSoupHSTSPolicywith the given attributes.domainis a domain on which the strict transport security policy represented by this object must be enforced.maxAgeis used to set the "expires" attribute on the policy; passSOUP_HSTS_POLICY_MAX_AGE_PASTfor an already-expired policy, or a lifetime in seconds.If
includeSubdomainsistrue, the strict transport security policy must also be enforced on all subdomains ofdomain.- Parameters:
domain- policy domain or hostnamemaxAge- max age of the policyincludeSubdomains-trueif the policy applies on subdomains
-
-
Method Details
-
getType
-
fromResponse
Parsesmsg'sfirst "Strict-Transport-Security" response header and returns aSoupHSTSPolicy.- Parameters:
msg- aSoupMessage- Returns:
- a new
SoupHSTSPolicy, ornullif no valid "Strict-Transport-Security" response header was found.
-
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 ornullfor a permanent policyincludeSubdomains-trueif the policy applies on subdomains- Returns:
- a new
SoupHSTSPolicy.
-
sessionPolicy
Creates a new sessionSoupHSTSPolicywith the given attributes.A session policy is a policy that is valid during the lifetime of the
HSTSEnforcerit 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.domainis a domain on which the strict transport security policy represented by this object must be enforced.If
includeSubdomainsistrue, the strict transport security policy must also be enforced on all subdomains ofdomain.- Parameters:
domain- policy domain or hostnameincludeSubdomains-trueif the policy applies on sub domains- Returns:
- a new
SoupHSTSPolicy.
-
copy
-
equal
Tests if this HSTSPolicy andpolicy2are equal.- Parameters:
policy2- aSoupHSTSPolicy- Returns:
- whether the policies are equal.
-
free
public void free()Freespolicy. -
getDomain
-
getExpires
Returns the expiration date forpolicy.- Returns:
- A
GDateTimeornullif unset
-
getMaxAge
public int getMaxAge()Returns the max age forpolicy.- Returns:
- Max age in seconds
-
includesSubdomains
public boolean includesSubdomains()Gets whether this HSTSPolicy include its subdomains.- Returns:
trueif this HSTSPolicy includes subdomains,falseotherwise.
-
isExpired
public boolean isExpired()Gets whether this HSTSPolicy is expired.Permanent policies never expire.
- Returns:
trueif this HSTSPolicy is expired,falseotherwise.
-
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:
trueif this HSTSPolicy is permanent,falseotherwise
-