@@ -27,23 +27,23 @@ final class AuthorizationHelper {
27
27
* This API is a helper method to create auth header based on client request using masterkey.
28
28
*
29
29
* @param verb the verb.
30
- * @param resourceId the resource id.
30
+ * @param resourceIdOrFullName the resource id or full name
31
31
* @param resourceType the resource type.
32
32
* @param headers the request headers.
33
33
* @param masterKey the master key.
34
34
* @return the key authorization signature.
35
35
*/
36
36
public static String GenerateKeyAuthorizationSignature (String verb ,
37
- String resourceId ,
37
+ String resourceIdOrFullName ,
38
38
ResourceType resourceType ,
39
39
Map <String , String > headers ,
40
40
String masterKey ) {
41
41
if (verb == null || verb .isEmpty ()) {
42
42
throw new IllegalArgumentException ("verb" );
43
43
}
44
44
45
- if (resourceId == null ) {
46
- resourceId = "" ;
45
+ if (resourceIdOrFullName == null ) {
46
+ resourceIdOrFullName = "" ;
47
47
}
48
48
49
49
if (resourceType == null ) {
@@ -60,26 +60,25 @@ public static String GenerateKeyAuthorizationSignature(String verb,
60
60
61
61
byte [] decodedBytes = Base64 .decodeBase64 (masterKey .getBytes ());
62
62
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 );
68
69
69
70
if (headers .containsKey (HttpConstants .HttpHeaders .X_DATE )) {
70
- text += headers .get (HttpConstants .HttpHeaders .X_DATE );
71
+ body += headers .get (HttpConstants .HttpHeaders .X_DATE ). toLowerCase ( );
71
72
}
72
73
73
- text += '\n' ;
74
+ body += '\n' ;
74
75
75
76
if (headers .containsKey (HttpConstants .HttpHeaders .HTTP_DATE )) {
76
- text += headers .get (HttpConstants .HttpHeaders .HTTP_DATE );
77
+ body += headers .get (HttpConstants .HttpHeaders .HTTP_DATE ). toLowerCase ( );
77
78
}
78
79
79
- text += '\n' ;
80
-
81
- String body = text .toLowerCase ();
82
-
80
+ body += '\n' ;
81
+
83
82
Mac mac = null ;
84
83
try {
85
84
mac = Mac .getInstance ("HMACSHA256" );
@@ -96,7 +95,7 @@ public static String GenerateKeyAuthorizationSignature(String verb,
96
95
97
96
byte [] digest = mac .doFinal (body .getBytes ());
98
97
99
- String auth = Helper .encodeBase64String (digest );
98
+ String auth = Utils .encodeBase64String (digest );
100
99
101
100
String authtoken = "type=master&ver=1.0&sig=" + auth ;
102
101
0 commit comments