PolicyUtils { public static String toBase64EncodedPolicy(Policy policy) { return base64Encode(PolicyUtils.toJson(policy).toJSONString()); } private  PolicyUtils(); static String base64Encode(String value); static String base64Decode(String value); static Policy fromJson(String policyJson); @SuppressWarnings("unchecked") static JSONObject toJson(Policy policy); static Policy fromBase64EncodedPolicy(String encodedPolicy); static String toBase64EncodedPolicy(Policy policy); static String getPolicySignature(Policy policy, String encryptionKey);  }
@Test public void testToBase64EncodedPolicy() throws UnsupportedEncodingException { String resource = "http: DateTime before = new DateTime(2015, 03, 01, 00, 46, 17, 0, DateTimeZone.UTC); Policy policy = Policy.mkSimplePolicy("http: Policy result = PolicyUtils.fromBase64EncodedPolicy(PolicyUtils.toBase64EncodedPolicy(policy)); assertEquals(resource, result.getBaseUrl()); assertEquals(before, result.getValidUntil()); }