ResourceRequestUtil { protected static List<NameValuePair> parseQueryString(String queryString) { if (StringUtils.isBlank(queryString)) { return new ArrayList<NameValuePair>(); } return URLEncodedUtils.parse(queryString.replaceFirst("\\?", ""), StandardCharsets.UTF_8); } private  ResourceRequestUtil(); static String policyToResourceRequestQueryString(Policy policy, String encryptionKeyId, String encryptionKey); static String resourceRequestToQueryString(ResourceRequest resourceRequest); static ResourceRequest resourceRequestFromQueryString(String queryString, String clientIp, String resourceUri,
          Properties encryptionKeys, boolean strict); static boolean isNotSigned(URI uri); static boolean isSigned(URI uri);  }
@Test public void testQueryStringParsing() { String policyValue = "{policy:'value'}"; String signatureValue = "randomString"; String queryString = "?" + ResourceRequest.POLICY_KEY + "=" + policyValue + "&" + ResourceRequest.SIGNATURE_KEY + "=" + signatureValue + "&" + ResourceRequest.ENCRYPTION_ID_KEY + "=" + keyId; List<NameValuePair> parameters = ResourceRequestUtil.parseQueryString(queryString); boolean foundOrg = false; boolean foundPolicy = false; boolean foundSignature = false; for (NameValuePair nameValuePair : parameters) { if (ResourceRequest.ENCRYPTION_ID_KEY.equals(nameValuePair.getName())) { assertEquals(keyId, nameValuePair.getValue()); foundOrg = true; } if (ResourceRequest.POLICY_KEY.equals(nameValuePair.getName())) { assertEquals(policyValue, nameValuePair.getValue()); foundPolicy = true; } if (ResourceRequest.SIGNATURE_KEY.equals(nameValuePair.getName())) { assertEquals(signatureValue, nameValuePair.getValue()); foundSignature = true; } } assertTrue("Didn't find the organization value.", foundOrg); assertTrue("Didn't find the policy value.", foundPolicy); assertTrue("Didn't find the signature value.", foundSignature); }