@@ -27,23 +27,23 @@ final class AuthorizationHelper {
2727 * This API is a helper method to create auth header based on client request using masterkey.
2828 *
2929 * @param verb the verb.
30- * @param resourceId the resource id.
30+ * @param resourceIdOrFullName the resource id or full name
3131 * @param resourceType the resource type.
3232 * @param headers the request headers.
3333 * @param masterKey the master key.
3434 * @return the key authorization signature.
3535 */
3636 public static String GenerateKeyAuthorizationSignature (String verb ,
37- String resourceId ,
37+ String resourceIdOrFullName ,
3838 ResourceType resourceType ,
3939 Map <String , String > headers ,
4040 String masterKey ) {
4141 if (verb == null || verb .isEmpty ()) {
4242 throw new IllegalArgumentException ("verb" );
4343 }
4444
45- if (resourceId == null ) {
46- resourceId = "" ;
45+ if (resourceIdOrFullName == null ) {
46+ resourceIdOrFullName = "" ;
4747 }
4848
4949 if (resourceType == null ) {
@@ -60,26 +60,25 @@ public static String GenerateKeyAuthorizationSignature(String verb,
6060
6161 byte [] decodedBytes = Base64 .decodeBase64 (masterKey .getBytes ());
6262 SecretKey signingKey = new SecretKeySpec (decodedBytes , "HMACSHA256" );
63-
64- String text = String .format ("%s\n %s\n %s\n " ,
65- verb ,
66- AuthorizationHelper .getResourceSegement (resourceType ),
67- resourceId .toLowerCase ());
63+
64+ // Skipping lower casing of resourceId since it may now contain "ID" of the resource as part of the FullName
65+ String body = String .format ("%s\n %s\n %s\n " ,
66+ verb .toLowerCase (),
67+ AuthorizationHelper .getResourceSegement (resourceType ).toLowerCase (),
68+ resourceIdOrFullName );
6869
6970 if (headers .containsKey (HttpConstants .HttpHeaders .X_DATE )) {
70- text += headers .get (HttpConstants .HttpHeaders .X_DATE );
71+ body += headers .get (HttpConstants .HttpHeaders .X_DATE ). toLowerCase ( );
7172 }
7273
73- text += '\n' ;
74+ body += '\n' ;
7475
7576 if (headers .containsKey (HttpConstants .HttpHeaders .HTTP_DATE )) {
76- text += headers .get (HttpConstants .HttpHeaders .HTTP_DATE );
77+ body += headers .get (HttpConstants .HttpHeaders .HTTP_DATE ). toLowerCase ( );
7778 }
7879
79- text += '\n' ;
80-
81- String body = text .toLowerCase ();
82-
80+ body += '\n' ;
81+
8382 Mac mac = null ;
8483 try {
8584 mac = Mac .getInstance ("HMACSHA256" );
@@ -96,7 +95,7 @@ public static String GenerateKeyAuthorizationSignature(String verb,
9695
9796 byte [] digest = mac .doFinal (body .getBytes ());
9897
99- String auth = Helper .encodeBase64String (digest );
98+ String auth = Utils .encodeBase64String (digest );
10099
101100 String authtoken = "type=master&ver=1.0&sig=" + auth ;
102101
0 commit comments