Class ResourceRequestUtil

java.lang.Object
org.opencastproject.urlsigning.utils.ResourceRequestUtil

public final class ResourceRequestUtil extends Object
A utility class to transform ResourceRequests into query strings and back.
  • Method Details

    • parseQueryString

      protected static List<org.apache.http.NameValuePair> parseQueryString(String queryString)
      Get a list of all of the query string parameters and their values.
      Parameters:
      queryString - The query string to process.
      Returns:
      A List of NameValuePair representing the query string parameters
    • policyMatchesSignature

      protected static boolean policyMatchesSignature(Policy policy, String signature, String encryptionKey)
      Determine if the policy matches the encrypted signature.
      Parameters:
      policy - The policy to compare to the encrypted signature.
      signature - The encrypted policy that was sent.
      encryptionKey - The encryption key to use to encrypt the policy.
      Returns:
      If the policy encrypted matches the signature.
    • policyToResourceRequestQueryString

      public static String policyToResourceRequestQueryString(Policy policy, String encryptionKeyId, String encryptionKey) throws Exception
      Transform a Policy into a ResourceRequest query string.
      Parameters:
      policy - The Policy to use in the ResourceRequest
      encryptionKeyId - The id of the encryption key.
      encryptionKey - The actual encryption key.
      Returns:
      A query string created from the policy.
      Throws:
      Exception - Thrown if there is a problem encoding or encrypting the policy.
    • resourceRequestToQueryString

      public static String resourceRequestToQueryString(ResourceRequest resourceRequest)
      Transform a ResourceRequest into a query string.
      Parameters:
      resourceRequest - The ResourceRequest to transform.
      Returns:
      The query string version of the ResourceRequest
    • resourceRequestFromQueryString

      public static ResourceRequest resourceRequestFromQueryString(String queryString, String clientIp, String resourceUri, Properties encryptionKeys, boolean strict)
      Parameters:
      queryString - The query string for this request to determine its validity.
      clientIp - The IP of the client requesting the resource.
      resourceUri - The base uri for the resource.
      encryptionKeys - The available encryption key ids and their keys.
      strict - If false it will only compare the path to the resource instead of the entire URL including scheme, hostname, port etc.
      Returns:
      ResourceRequest
    • isNotSigned

      public static boolean isNotSigned(URI uri)
      Check to see if a URI has not been signed already.
      Parameters:
      uri - The URI to check to see if it was not signed.
      Returns:
      True if not signed, false if signed.
    • isSigned

      public static boolean isSigned(URI uri)
      Check to see if a URI has been signed already.
      Parameters:
      uri - The URI to check to see if it was signed.
      Returns:
      True if signed, false if not.