@Test public void testBuildCanonicalizedResource() { String resource = "/projects/odps_test_tunnel_project/instances"; String prefix = "x-odps-"; Request request = new Request(); request.setMethod(Method.POST); request.setHeader(Headers.ODPS_USER_AGENT, "JavaSDK/0.12.0;Linux"); request.setHeader(Headers.DATE, "Tue, 13 May 2014 09:22:20 GMT"); request.setHeader(Headers.CONTENT_LENGTH, "369"); request.setHeader(Headers.CONTENT_MD5, "746a0402967096663daa8bd1a2ff5c7c"); request.setHeader(Headers.USER_AGENT, "JavaSDK/0.12.0;Linux"); request.setHeader(Headers.CONTENT_TYPE, "application/xml"); request.setBodyLength(0L); String expectedResult = "POST\n746a0402967096663daa8bd1a2ff5c7c\napplication/xml\n" + "Tue, 13 May 2014 09:22:20 GMT\nx-odps-user-agent:JavaSDK/0.12.0;Linux\n" + "/projects/odps_test_tunnel_project/instances"; String result = SecurityUtils.buildCanonicalString(resource, request, prefix); Assert.assertEquals(expectedResult, result); }
protected static String buildCanonicalizedResource(String resource, Map<String, String> params) { StringBuilder builder = new StringBuilder(); builder.append(resource); if (params != null && params.size() > 0) { String[] names = params.keySet().toArray(new String[params.size()]); Arrays.sort(names); char separater = '?'; for (String name : names) { builder.append(separater); builder.append(name); String paramValue = params.get(name); if (paramValue != null && paramValue.length() > 0) { builder.append("=").append(paramValue); } separater = '&'; } } String str = builder.toString(); return str; }
SecurityUtils { protected static String buildCanonicalizedResource(String resource, Map<String, String> params) { StringBuilder builder = new StringBuilder(); builder.append(resource); if (params != null && params.size() > 0) { String[] names = params.keySet().toArray(new String[params.size()]); Arrays.sort(names); char separater = '?'; for (String name : names) { builder.append(separater); builder.append(name); String paramValue = params.get(name); if (paramValue != null && paramValue.length() > 0) { builder.append("=").append(paramValue); } separater = '&'; } } String str = builder.toString(); return str; } }
SecurityUtils { protected static String buildCanonicalizedResource(String resource, Map<String, String> params) { StringBuilder builder = new StringBuilder(); builder.append(resource); if (params != null && params.size() > 0) { String[] names = params.keySet().toArray(new String[params.size()]); Arrays.sort(names); char separater = '?'; for (String name : names) { builder.append(separater); builder.append(name); String paramValue = params.get(name); if (paramValue != null && paramValue.length() > 0) { builder.append("=").append(paramValue); } separater = '&'; } } String str = builder.toString(); return str; }  }
SecurityUtils { protected static String buildCanonicalizedResource(String resource, Map<String, String> params) { StringBuilder builder = new StringBuilder(); builder.append(resource); if (params != null && params.size() > 0) { String[] names = params.keySet().toArray(new String[params.size()]); Arrays.sort(names); char separater = '?'; for (String name : names) { builder.append(separater); builder.append(name); String paramValue = params.get(name); if (paramValue != null && paramValue.length() > 0) { builder.append("=").append(paramValue); } separater = '&'; } } String str = builder.toString(); return str; }  static String md5Signature(String message); static String getApplicationSignature(
      String accountProvider, String accessId, String signedString); }
SecurityUtils { protected static String buildCanonicalizedResource(String resource, Map<String, String> params) { StringBuilder builder = new StringBuilder(); builder.append(resource); if (params != null && params.size() > 0) { String[] names = params.keySet().toArray(new String[params.size()]); Arrays.sort(names); char separater = '?'; for (String name : names) { builder.append(separater); builder.append(name); String paramValue = params.get(name); if (paramValue != null && paramValue.length() > 0) { builder.append("=").append(paramValue); } separater = '&'; } } String str = builder.toString(); return str; }  static String md5Signature(String message); static String getApplicationSignature(
      String accountProvider, String accessId, String signedString);  }