Class HSTSPolicy

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class HSTSPolicy extends ProxyInstance

HSTSPolicy implements HTTP policies, as described by RFC 6797.

domain represents the host that this policy applies to. The domain must be IDNA-canonicalized. HSTSPolicy(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 Details

    • HSTSPolicy

      public HSTSPolicy(MemorySegment address)
      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)

      Creates a new HSTSPolicy 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; pass SOUP_HSTS_POLICY_MAX_AGE_PAST for an already-expired policy, or a lifetime in seconds.

      If includeSubdomains is true, the strict transport security policy must also be enforced on all subdomains of domain.

      Parameters:
      domain - policy domain or hostname
      maxAge - max age of the policy
      includeSubdomains - true if the policy applies on subdomains
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the HSTSPolicy class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • fromResponse

      public static @Nullable HSTSPolicy fromResponse(Message msg)
      Parses msg's first "Strict-Transport-Security" response header and returns a HSTSPolicy.
      Parameters:
      msg - a SoupMessage
      Returns:
      a new SoupHSTSPolicy, or null if no valid "Strict-Transport-Security" response header was found.
    • full

      public static HSTSPolicy full(String domain, int maxAge, DateTime expires, boolean includeSubdomains)

      Full version of HSTSPolicy(String, int, boolean), to use with an existing expiration date.

      See HSTSPolicy(String, int, boolean) for details.

      Parameters:
      domain - policy domain or hostname
      maxAge - max age of the policy
      expires - the date of expiration of the policy or null for a permanent policy
      includeSubdomains - true if the policy applies on subdomains
      Returns:
      a new SoupHSTSPolicy.
    • sessionPolicy

      public static HSTSPolicy sessionPolicy(String domain, boolean includeSubdomains)

      Creates a new session HSTSPolicy 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 is true, the strict transport security policy must also be enforced on all subdomains of domain.

      Parameters:
      domain - policy domain or hostname
      includeSubdomains - true if the policy applies on sub domains
      Returns:
      a new SoupHSTSPolicy.
    • copy

      public HSTSPolicy copy()
      Copies policy.
      Returns:
      a copy of this HSTSPolicy
    • equal

      public boolean equal(HSTSPolicy policy2)
      Tests if this HSTSPolicy and policy2 are equal.
      Parameters:
      policy2 - a SoupHSTSPolicy
      Returns:
      whether the policies are equal.
    • free

      public void free()
      Frees policy.
    • getDomain

      public String getDomain()
      Gets policy's domain.
      Returns:
      policy's domain.
    • getExpires

      public DateTime getExpires()
      Returns the expiration date for policy.
      Returns:
      A GDateTime or null if unset
    • getMaxAge

      public int getMaxAge()
      Returns the max age for policy.
      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(String, boolean) for details.

      Returns:
      true if this HSTSPolicy is permanent, false otherwise