Skip to content

Commit 82d7330

Browse files
author
Karthik Thirumalasetti
authored
Update README.md
1 parent 8feb554 commit 82d7330

File tree

1 file changed

+43
-74
lines changed

1 file changed

+43
-74
lines changed

README.md

Lines changed: 43 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
# About appsfly.io Dev Kit Java Utils
2-
Java Utils contains resources to help communicate with appsfly.io secure server through encryption.
2+
This library contains resources to help communicate with appsfly.io execution server.
3+
For all communications with execution server, your application should be registered and a secret key needs to be generated.
34

4-
appsfly.io does not whitelist IPs. instead a checkSum should be generated with the Secret Key.
5-
To get a Secret Key contact [email protected]
5+
Please contact [email protected] for your credientials.
66

77
### Get Started
8-
To start posting messages securely we need the following:
98

9+
Application Params
10+
| Key | Description |
11+
| ----- | ----------- |
12+
| SECRET_KEY | Secret Key is required for encryption. Secret Key should be generated on the Appsfly publisher dashboard. |
13+
| APP_KEY | Application key to identify the publisher instance. |
14+
| EXECUTOR_URL | Url to reach appsfly.io Microservices. |
1015

11-
| Value | Key | Description |
12-
| --- | --- | --- |
13-
| Module Handle | MODULE_HANDLE | Unique handle of the micro module. This will be provided by the service provider. |
14-
| Secret Key | SECRET_KEY | Secret Key is required for encryption. Secret Key should be generated on the Appsfly publisher dashboard. |
15-
| App Key | APP_KEY | Application key to identify the publisher instance. |
16-
| Executor Url | EXECUTOR_URL | Url to reach appsfly.io Microservices. |
16+
**NOTE:** Above params are needed for checksum generation. Please refer to the methods mention below.
1717

18+
Micro Module Params
19+
| Key | Description |
20+
| ----- | ----------- |
21+
| MODULE_HANDLE | Each micromodule of a service provider is identified by MODULE_HANDLE |
22+
| UUID | UniqueID to identify user session.|
1823

19-
**NOTE:** You will have to generate a checkSum from the parameters, headers with the secret key provided by appsfly.io.
24+
Intent Params
25+
| Key | Description |
26+
| ----- | ----------- |
27+
| INTENT | Intent is like an endpoint you are accessing to send message |
28+
| PAYLOAD | Data payload |
2029

2130
# Integration options
22-
### Option 1: Package
23-
The SDK can be included to handle the encryption and decryption along with checkSum generation and verification.
24-
You can use it to avoid boiler plate code. If not, you can use the api endpoint.
31+
32+
### Option 1: SDK
33+
The SDK can be included to handle authorization. There is no need for you to handle checksum generation and verification.
2534

2635
#### Configuration
2736
```
@@ -30,82 +39,42 @@ AppInstance.AFConfig config = new AppInstance.AFConfig("EXECUTOR_URL", "SECRET_K
3039
#### Execution
3140
```
3241
AppInstance travelProvider = new AppInstance(config, "MODULE_HANDLE");
33-
travelProvider.exec("INTENT", "PAYLOAD", new Callback() {
42+
travelProvider.exec("INTENT", JSONObject("PAYLOAD"), "UUID", new Callback() {
3443
@Override
3544
public void onResponse(JSONObject response) {
36-
System.out.println(response);
37-
// Payment Done Response
3845
// We have already verified the checksum from you
3946
}
4047
4148
@Override
4249
public void onError(JSONObject error) {
43-
System.out.println(error);
50+
// Handle error
4451
}
4552
});
4653
```
4754

48-
### Option 2: API Endpoint ( "/executor/exec" )
55+
### Option 2: API Endpoint
4956

50-
appsfly.io exposes a single API endpoint to access Microservices directly. Headers are used for authentication and sessions will be managed accordingly.
57+
appsfly.io exposes a single API endpoint to access Microservices directly.
5158

5259
API endpoint : "https://microapps.appsfly.io/executor/exec"
5360

54-
#### Auth Headers
55-
56-
| Headers | Description |
57-
| --- | --- |
58-
| X-UUID | Unique ID of the execution. Generally it will be unique for unique user. |
59-
| X-App-Key | App Key generated in appsfly.io publisher dashboard. |
60-
| X-Module-Handle | Module Handle provided by service provider |
61-
| X-Checksum | Checksum generated by appsfly.io utils |
62-
| Content-Type | Content Type of body. Must be application/json |
63-
64-
#### Body Params
61+
####
62+
POST
6563

66-
| Body Parameters | Description |
64+
#### Headers
65+
| Header | Description |
6766
| --- | --- |
68-
| Intent:String | Intent String to access the service |
69-
| data:JSON | Provide to execute the intent |
67+
| X-UUID | UUID |
68+
| X-App-Key | APP_KEY|
69+
| X-Module-Handle | MODULE_HANDLE|
70+
| X-Checksum | CHECKSUM. Please go through this gist to generate checksum. |
71+
| Content-Type | Must be "application/json" |
72+
73+
#### Body
74+
` {
75+
"intent":"INTENT",
76+
"data":"PAYLOAD"
77+
} `
7078

7179
#### Response
72-
73-
Microservice will respond based on the intent provided along with the checksum (X-Checksum) in the headers. The checksum is the combination of the api response and the secret key.
74-
75-
### Generation of checksum
76-
77-
```
78-
// Generate payload string
79-
String payload = body + "|" + microModuleId + "|" + config.appKey + "|" + userID;
80-
// Generate checksum
81-
String checksum = CtyptoUtil.getInstance().getChecksum(payload.getBytes(), config.secretKey);
82-
83-
// HTTP Request
84-
Request request = new Request.Builder()
85-
.url(this.config.repoUrl+"/executor/exec")
86-
.addHeader("X-Module-Handle", microModuleId)
87-
.addHeader("X-App-Key", config.appKey)
88-
.addHeader("X-Checksum", checksum)
89-
.addHeader("X-UUID", userID)
90-
.post(RequestBody.create(JSON, body.toString()))
91-
.build();
92-
```
93-
94-
### Verification of checkSum
95-
96-
```
97-
// Fetch Checksum from headers
98-
String checksum = response.headers().get("X-Checksum");
99-
if(checksum!=null){
100-
// Verify checksum with body and secret key
101-
boolean verified = CtyptoUtil.getInstance().verifychecksum(response.body().bytes(), checksum, config.secretKey);
102-
if (verified){
103-
callback.onResponse(new JSONObject(response.body().bytes()));
104-
}
105-
else{
106-
callback.onError(new JSONObject(){{
107-
put("message", "Checksum Validation Failed");
108-
}});
109-
}
110-
}
111-
```
80+
Response format will be dependent on microservice. Please go through this documentation for different microservices.

0 commit comments

Comments
 (0)