-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API 2.3.0 Testing: IAMService, notification management
- Loading branch information
1 parent
8c0f8ea
commit 2b84535
Showing
11 changed files
with
529 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/envisioniot/example/sample/aep/iamservice/GetOrganization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (C), 2015-2022, Envision | ||
* FileName: GetOrganization | ||
* Author: arihant.jain | ||
* Date: 24/3/2022 | ||
* Description: | ||
* History: | ||
* <author> <time> <version> <desc> | ||
*/ | ||
|
||
package com.envisioniot.example.sample.aep.iamservice; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.envision.apim.poseidon.config.PConfig; | ||
import com.envision.apim.poseidon.core.Poseidon; | ||
import com.envisioniot.example.sample.utility.Request; | ||
|
||
/** | ||
* https://www.envisioniot.com/docs/iam-api/en/2.3.0/get_org.html <br> | ||
* | ||
* @author arihant.jain | ||
* @create 24/3/2022 | ||
* @since -- | ||
*/ | ||
|
||
public class GetOrganization { | ||
public JSONObject getOrganization( | ||
String accessKey, | ||
String secretKey, | ||
String url, | ||
String orgId, | ||
String bearerToken) | ||
{ | ||
Request request = new Request(); | ||
request.setHeaderParam("Authorization", "Bearer " + bearerToken); | ||
request.setHeaderParam("Content-Type", "application/json"); | ||
request.setBodyParams("id", orgId); | ||
request.setMethod("POST"); | ||
|
||
try { | ||
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug()) | ||
.url(url + "/enos-iam-service/v2.0/organization/info") | ||
.getResponse(request, JSONObject.class); | ||
|
||
return response; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/envisioniot/example/sample/aep/iamservice/GetSessionInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (C), 2015-2022, Envision | ||
* FileName: GetSessionInformation | ||
* Author: arihant.jain | ||
* Date: 23/3/2022 | ||
* Description: | ||
* History: | ||
* <author> <time> <version> <desc> | ||
*/ | ||
|
||
package com.envisioniot.example.sample.aep.iamservice; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.envision.apim.poseidon.config.PConfig; | ||
import com.envision.apim.poseidon.core.Poseidon; | ||
import com.envisioniot.example.sample.utility.Request; | ||
|
||
/** | ||
* https://www.envisioniot.com/docs/iam-api/en/2.3.0/get_session_information.html <br> | ||
* | ||
* @author arihant.jain | ||
* @create 23/3/2022 | ||
* @since -- | ||
*/ | ||
|
||
public class GetSessionInformation { | ||
public JSONObject getSessionInformation( | ||
String accessKey, | ||
String secretKey, | ||
String url, | ||
String bearerToken) | ||
{ | ||
|
||
Request request = new Request(); | ||
request.setHeaderParam("Authorization", "Bearer " + bearerToken); | ||
|
||
request.setMethod("POST"); | ||
|
||
try { | ||
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug()) | ||
.url(url + "/enos-iam-service/v2.0/session/info") | ||
.getResponse(request, JSONObject.class); | ||
|
||
//System.out.println(response); | ||
return response; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/envisioniot/example/sample/aep/iamservice/IAMApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (C), 2015-2022, Envision | ||
* FileName: IAMApp | ||
* Author: arihant.jain | ||
* Date: 23/3/2022 | ||
* Description: | ||
* History: | ||
* <author> <time> <version> <desc> | ||
*/ | ||
|
||
package com.envisioniot.example.sample.aep.iamservice; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* https://www.envisioniot.com/docs/iam-api/en/2.3.0/overview.html <br> | ||
* | ||
* @author arihant.jain | ||
* @create 23/3/2022 | ||
* @since -- | ||
*/ | ||
|
||
public class IAMApp { | ||
public void IAMAppGeneral(String accessKey, String secretKey, String orgId, String url) { | ||
|
||
// Log In | ||
LogIn login = new LogIn(); | ||
// Log In: Declaring optional parameters | ||
HashMap<String, Object> logInOptionalParameters = new HashMap<>(); | ||
logInOptionalParameters.put("clientIp", "10.81.2.169"); | ||
logInOptionalParameters.put("expireInterval", 950); | ||
logInOptionalParameters.put("captcha", "yourCaptcha"); | ||
//logInOptionalParameters.put("keyId", "yourKeyID"); | ||
JSONObject data = login.logIn | ||
(accessKey, secretKey, url, 0, null, "yourPrincipal", "yourCredentials", logInOptionalParameters); | ||
String bearerToken = (String) data.get("sessionId"); | ||
|
||
// Get Session Information | ||
GetSessionInformation getSessionInformation = new GetSessionInformation(); | ||
getSessionInformation.getSessionInformation(accessKey, secretKey, url, bearerToken); | ||
//getSessionInformation.getSessionInformation(accessKey, secretKey, url, " "); | ||
|
||
// Get Organization | ||
GetOrganization getOrganization = new GetOrganization(); | ||
getOrganization.getOrganization(accessKey, secretKey, url, orgId, bearerToken); | ||
|
||
// List User Organization | ||
ListUserOrganization listuserorganization = new ListUserOrganization(); | ||
listuserorganization.listUserOrganization(accessKey, secretKey, url, bearerToken); | ||
|
||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/envisioniot/example/sample/aep/iamservice/ListUserOrganization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (C), 2015-2022, Envision | ||
* FileName: ListUserOrganization | ||
* Author: arihant.jain | ||
* Date: 24/3/2022 | ||
* Description: | ||
* History: | ||
* <author> <time> <version> <desc> | ||
*/ | ||
|
||
package com.envisioniot.example.sample.aep.iamservice; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.envision.apim.poseidon.config.PConfig; | ||
import com.envision.apim.poseidon.core.Poseidon; | ||
import com.envisioniot.example.sample.utility.Request; | ||
|
||
/** | ||
* https://www.envisioniot.com/docs/iam-api/en/2.3.0/list_user_organization.html <br> | ||
* | ||
* @author arihant.jain | ||
* @create 24/3/2022 | ||
* @since -- | ||
*/ | ||
|
||
public class ListUserOrganization { | ||
public JSONObject listUserOrganization( | ||
String accessKey, | ||
String secretKey, | ||
String url, | ||
String bearerToken) | ||
{ | ||
Request request = new Request(); | ||
request.setHeaderParam("Authorization", "Bearer " + bearerToken); | ||
request.setMethod("POST"); | ||
|
||
try { | ||
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug()) | ||
.url(url + "/enos-iam-service/v2.0/user/organization/list") | ||
.getResponse(request, JSONObject.class); | ||
|
||
return response; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/envisioniot/example/sample/aep/iamservice/LogIn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (C), 2015-2022, Envision | ||
* FileName: LogIn | ||
* Author: arihant.jain | ||
* Date: 23/3/2022 | ||
* Description: | ||
* History: | ||
* <author> <time> <version> <desc> | ||
*/ | ||
|
||
package com.envisioniot.example.sample.aep.iamservice; | ||
|
||
import com.alibaba.fastjson.JSONObject; | ||
import com.envision.apim.poseidon.config.PConfig; | ||
import com.envision.apim.poseidon.core.Poseidon; | ||
import com.envisioniot.example.sample.utility.Request; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* https://www.envisioniot.com/docs/iam-api/en/2.3.0/login.html <br> | ||
* | ||
* @author arihant.jain | ||
* @create 23/3/2022 | ||
* @since -- | ||
*/ | ||
|
||
public class LogIn { | ||
public JSONObject logIn( | ||
String accessKey, | ||
String secretKey, | ||
String url, | ||
Object authType, | ||
String linkName, | ||
String principal, | ||
String credentials, | ||
HashMap<String, Object> logInOptionalParams) | ||
{ | ||
|
||
Request request = new Request(); | ||
request.setBodyParams("principal", principal); | ||
request.setBodyParams("credentials", credentials); | ||
request.setBodyParams("authType", authType); | ||
if(linkName != null){ request.setBodyParams("linkName", linkName); } | ||
if(logInOptionalParams != null){ request.setBodyParams(logInOptionalParams); } | ||
|
||
request.setMethod("POST"); | ||
|
||
try { | ||
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug()) | ||
.url(url + "/enos-iam-service/v2.0/login") | ||
.getResponse(request, JSONObject.class); | ||
|
||
System.out.println(response); | ||
return response; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
|
||
} | ||
} |
Oops, something went wrong.