java.lang.Object
org.opencastproject.urlsigning.common.Policy

public final class Policy extends Object
Represents a policy for a signed resource that looks like
  • Method Details

    • mkSimplePolicy

      public static Policy mkSimplePolicy(String baseUrl, org.joda.time.DateTime validUntil)
      Create a Policy with only the required properties.
      Parameters:
      baseUrl - The url to the resource that will be signed.
      validUntil - The date and time the resource will be available until
      Returns:
      A new Policy with the parameters set.
    • mkPolicyValidFrom

      public static Policy mkPolicyValidFrom(String baseUrl, org.joda.time.DateTime validUntil, org.joda.time.DateTime validFrom)
      Create a Policy with a date and time the resource will become available.
      Parameters:
      baseUrl - The url to the resource being signed.
      validUntil - The date and time the resource is available until.
      validFrom - The date and time the resource will become available.
      Returns:
      A new Policy for limiting access to the resource.
    • mkPolicyValidWithIP

      public static Policy mkPolicyValidWithIP(String baseUrl, org.joda.time.DateTime validUntil, String ipAddress)
      Create a Policy with the only ip address that will be allowed to view the resource.
      Parameters:
      baseUrl - The url to the resource being signed.
      validUntil - The date the resource will be available until.
      ipAddress - The ip of the client that will be allowed to view the resource.
      Returns:
      A new Policy for limiting access to the resource.
    • mkPolicyValidFromWithIP

      public static Policy mkPolicyValidFromWithIP(String baseUrl, org.joda.time.DateTime validUntil, org.joda.time.DateTime validFrom, String ipAddress)
      Create a Policy with both a date and time the resource will become available and a client ip address to restrict it to.
      Parameters:
      baseUrl - The url to the resource that is being signed.
      validUntil - The date and time the resource will be available until.
      validFrom - The date and time the resource will become available.
      ipAddress - The ip of the client that will be allowed to view the resource.
      Returns:
      A new Policy for limiting access to the resource.
    • getBaseUrl

      public String getBaseUrl()
      Returns:
      Get the url to the resource that is being signed with this policy.
    • getValidUntil

      public org.joda.time.DateTime getValidUntil()
      Returns:
      Get the date this resource is valid until.
    • getResource

      public String getResource()
      Returns:
      Get the url for the resource in this Policy.
    • setResourceStrategy

      public void setResourceStrategy(ResourceStrategy resourceStrategy)
      Set a new ResourceStrategy to transform the base url to a resource url.
      Parameters:
      resourceStrategy - The resource strategy to apply to transform the base url.
    • getClientIpAddress

      public com.google.common.base.Optional<InetAddress> getClientIpAddress()
      Returns:
      Get the optional ip address of the client that this resource will be restricted to.
    • getValidFrom

      public com.google.common.base.Optional<org.joda.time.DateTime> getValidFrom()
      Returns:
      Get the optional date and time this resource will become available.