@@ -140,13 +140,53 @@ dependencies {
140
140
141
141
### Development
142
142
143
- #### Constructing Signature BaseString
143
+ #### Preparing HTTP Signature Token
144
+
145
+ Append this signature token into the Authorization header of the HTTP request
146
+
147
+ Params:
148
+ * realm
149
+ * authPrefix - Authorization Header scheme prefix , i.e 'Apex_l2_eg'
150
+ * httpMethod
151
+ * urlPath
152
+ * appId - App ID created in Gateway
153
+ * secret - set to null for REST L2 SHA256WITHRSA
154
+ * formList - to support parameter for form data if any
155
+ * password
156
+ * alias
157
+ * fileName
158
+ * nonce - set to null for random generated number
159
+ * timestamp - set to null for current timestamp
160
+
161
+
162
+ ``` java
163
+ String realm = " <<your_client_host_url>>"
164
+ String authPrefix = " <<authPrefix>>
165
+ String httpMethod = " get"
166
+ String url = " https: // <<Target_URL>>/api/v1/?param1=first¶m2=123";
167
+ String certFileName = " certificates/ssc.alpha.example.com.p12" ;
168
+ String password = " <<passphrase>>" ;
169
+ String alias = " alpha" ;
170
+ String appId = " <<appId>>" ;
171
+ String secret = null ;
172
+ ApiList formList = null ;
173
+ String nonce = null ;
174
+ String timestamp = null ;
175
+
176
+ try {
177
+ String signature = ApiSigning . getSignatureToken(authPrefix, authPrefix, httpMethod, url, appId, secret, formList, password, alias, certFileName, nonce, timestamp);
178
+ } catch (ApiUtilException e) {
179
+ e. printStackTrace();
180
+ }
181
+ ```
182
+
183
+ #### Constructing Signature BaseString (for reference only)
144
184
145
185
Method:
146
186
* getBaseString
147
187
148
188
Params:
149
- * authPrefix - Authorization Header scheme prefix , i.e 'prefix_appId '
189
+ * authPrefix - Authorization Header scheme prefix , i.e 'Apex_l2_eg '
150
190
* signatureMethod
151
191
* appId - App ID created in Gateway
152
192
* urlPath
@@ -156,7 +196,7 @@ Params:
156
196
* timestamp - set to null for current timestamp
157
197
158
198
``` java
159
- String url = " https://<<URL >>/api/v1/?param1=first&ab- param2=123" ;
199
+ String url = " https://<<Target_URL >>/api/v1/?param1=first¶m2=123" ;
160
200
161
201
ApiList formList = new ApiList ();
162
202
formList. add(" param1" , " data1" );
@@ -183,7 +223,7 @@ System.out.println(baseString);
183
223
184
224
```
185
225
186
- #### Constructing HMAC256 L1 Header
226
+ #### Constructing HMAC256 L1 Header (for reference only)
187
227
188
228
Method:
189
229
* getHMACSignature
@@ -207,7 +247,7 @@ try {
207
247
208
248
```
209
249
210
- #### Constructing RSA256 L2 Header
250
+ #### Constructing RSA256 L2 Header (for reference only)
211
251
212
252
Method:
213
253
* getRSASignature
@@ -217,7 +257,7 @@ Params:
217
257
* privateKey
218
258
219
259
``` java
220
- String baseString = " GET&https://<<URL>/api/v1/&ap=裕廊坊 心邻坊&<<authPrefix>>_app_id=<<appId>>&<<authPrefix>>_nonce=7231415196459608363&<<authPrefix>>_signature_method=SHA256withRSA&<<authPrefix>>_timestamp=1502164219425&<<authPrefix>>_version=1.0&oq=c# nunit mac &q=c# nunit mac " ;
260
+ String baseString = " GET&https://<<URL>/api/v1/&ap=裕廊坊 心邻坊&<<authPrefix>>_app_id=<<appId>>&<<authPrefix>>_nonce=7231415196459608363&<<authPrefix>>_signature_method=SHA256withRSA&<<authPrefix>>_timestamp=1502164219425&<<authPrefix>>_version=1.0&oq=123 &q=abc " ;
221
261
String alias = " alpha" ;
222
262
String password = " <<passphrase>>" ;
223
263
String keyStoreFileName = " certificates/ssc.alpha.example.com.p12" ;
@@ -240,43 +280,6 @@ try {
240
280
241
281
```
242
282
243
- #### Preparing HTTP Signature Token
244
-
245
- Append this signature token into the Authorization header of the HTTP request
246
-
247
- Params:
248
- * realm
249
- * authPrefix - Authorization Header scheme prefix , i.e 'prefix_appId'
250
- * httpMethod
251
- * urlPath
252
- * appId - App ID created in Gateway
253
- * secret - set to null for REST L2 SHA256WITHRSA
254
- * formList
255
- * password
256
- * alias
257
- * fileName
258
- * nonce - set to null for random generated number
259
- * timestamp - set to null for current timestamp
260
-
261
-
262
- ``` java
263
- String url = " https://<<URL>>/api/v1/?ap=裕廊坊%20心邻坊" ;
264
- String certFileName = " certificates/ssc.alpha.example.com.p12" ;
265
- String password = " <<passphrase>>" ;
266
- String alias = " alpha" ;
267
- String appId = " <<appId>>" ;
268
- String secret = null ;
269
- ApiList formList = null ;
270
- String nonce = null ;
271
- String timestamp = null ;
272
-
273
- try {
274
- String signature = ApiSigning . getSignatureToken(" http://api.test.io/l2" , " <<authPrefix>>" , " get" , url, appId, null , null , password, alias, certFileName, nonce, timestamp);
275
- } catch (ApiUtilException e) {
276
- e. printStackTrace();
277
- }
278
- ```
279
-
280
283
## Contributing
281
284
For more information about contributing PRs and issues, see [ CONTRIBUTING.md] ( .github/CONTRIBUTING.md ) .
282
285
0 commit comments