Class ResourceRequestUtil
java.lang.Object
org.opencastproject.urlsigning.utils.ResourceRequestUtil
A utility class to transform ResourceRequests into query strings and back.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisNotSigned(URI uri) Check to see if aURIhas not been signed already.static booleanCheck to see if aURIhas been signed already.protected static List<org.apache.http.NameValuePair> parseQueryString(String queryString) Get a list of all of the query string parameters and their values.protected static booleanpolicyMatchesSignature(Policy policy, String signature, String encryptionKey) Determine if the policy matches the encrypted signature.static StringpolicyToResourceRequestQueryString(Policy policy, String encryptionKeyId, String encryptionKey) Transform aPolicyinto aResourceRequestquery string.static ResourceRequestresourceRequestFromQueryString(String queryString, String clientIp, String resourceUri, Properties encryptionKeys, boolean strict) static StringresourceRequestToQueryString(ResourceRequest resourceRequest) Transform aResourceRequestinto a query string.
-
Method Details
-
parseQueryString
Get a list of all of the query string parameters and their values.- Parameters:
queryString- The query string to process.- Returns:
- A
ListofNameValuePairrepresenting 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 aPolicyinto aResourceRequestquery string.- Parameters:
policy- ThePolicyto use in theResourceRequestencryptionKeyId- 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
Transform aResourceRequestinto a query string.- Parameters:
resourceRequest- TheResourceRequestto 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
Check to see if aURIhas not been signed already.- Parameters:
uri- TheURIto check to see if it was not signed.- Returns:
- True if not signed, false if signed.
-
isSigned
Check to see if aURIhas been signed already.- Parameters:
uri- TheURIto check to see if it was signed.- Returns:
- True if signed, false if not.
-