mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add todo Comments
This commit is contained in:
parent
0927dfc835
commit
a09d72c33c
@ -129,19 +129,6 @@
|
|||||||
org.json.simple;version="[1.1,2)",
|
org.json.simple;version="[1.1,2)",
|
||||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||||
org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}",
|
|
||||||
org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}",
|
|
||||||
org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}",
|
|
||||||
io.entgra.device.mgt.core.apimgt.application.extension.bean,
|
|
||||||
io.entgra.device.mgt.core.apimgt.application.extension.dto,
|
|
||||||
io.entgra.device.mgt.core.apimgt.application.extension.exception,
|
|
||||||
org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}",
|
|
||||||
org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}",
|
|
||||||
org.wso2.carbon.context;version="${carbon.kernel.version.range}",
|
|
||||||
io.entgra.device.mgt.core.identity.jwt.client.extension,
|
|
||||||
io.entgra.device.mgt.core.identity.jwt.client.extension.dto,
|
|
||||||
io.entgra.device.mgt.core.identity.jwt.client.extension.exception,
|
|
||||||
io.entgra.device.mgt.core.identity.jwt.client.extension.service,
|
|
||||||
io.entgra.device.mgt.core.apimgt.extension.rest.api,
|
io.entgra.device.mgt.core.apimgt.extension.rest.api,
|
||||||
org.wso2.carbon.apimgt.api;version="[9.28,10)",
|
org.wso2.carbon.apimgt.api;version="[9.28,10)",
|
||||||
org.wso2.carbon.apimgt.api.dto;version="[9.28,10)",
|
org.wso2.carbon.apimgt.api.dto;version="[9.28,10)",
|
||||||
|
|||||||
@ -109,12 +109,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|||||||
String validityTime, String password)
|
String validityTime, String password)
|
||||||
throws APIManagerException {
|
throws APIManagerException {
|
||||||
|
|
||||||
APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance()
|
|
||||||
.getApiApplicationServices();
|
|
||||||
ConsumerRESTAPIServices consumerRESTAPIServices =
|
ConsumerRESTAPIServices consumerRESTAPIServices =
|
||||||
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
||||||
|
|
||||||
ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password);
|
ApiApplicationInfo applicationInfo = getApplicationInfo(username, password);
|
||||||
try {
|
try {
|
||||||
List<APIInfo> uniqueApiList = new ArrayList<>();
|
List<APIInfo> uniqueApiList = new ArrayList<>();
|
||||||
|
|
||||||
@ -138,7 +137,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|||||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
|
||||||
consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName);
|
consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName);
|
||||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
|
||||||
|
boolean isNewApplication = false;
|
||||||
if (applications.length == 0) {
|
if (applications.length == 0) {
|
||||||
|
isNewApplication = true;
|
||||||
application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application();
|
application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application();
|
||||||
application.setName(applicationName);
|
application.setName(applicationName);
|
||||||
application = consumerRESTAPIServices.createApplication(applicationInfo, application);
|
application = consumerRESTAPIServices.createApplication(applicationInfo, application);
|
||||||
@ -158,22 +159,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (application != null) {
|
if (isNewApplication) {
|
||||||
if (!application.getKeys().isEmpty()) {
|
ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application);
|
||||||
//todo return Application Keys
|
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
|
||||||
return null;
|
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
|
||||||
} else{
|
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
|
||||||
|
return apiApplicationKey;
|
||||||
ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application);
|
} else {
|
||||||
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
|
return null;
|
||||||
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
|
|
||||||
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
|
|
||||||
return apiApplicationKey;
|
|
||||||
}
|
|
||||||
} else{
|
|
||||||
String msg = "Application retrieval process failed.";
|
|
||||||
log.error(msg);
|
|
||||||
throw new APIManagerException(msg);
|
|
||||||
}
|
}
|
||||||
} catch (APIServicesException e) {
|
} catch (APIServicesException e) {
|
||||||
String msg = "Error occurred while processing the response of APIM REST endpoints.";
|
String msg = "Error occurred while processing the response of APIM REST endpoints.";
|
||||||
@ -555,9 +548,12 @@ Otherwise, Generate Application Keys and return them
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiApplicationInfo applicationInfo(APIApplicationServices apiApplicationServices, String username, String password)
|
private ApiApplicationInfo getApplicationInfo(String username, String password)
|
||||||
throws APIManagerException {
|
throws APIManagerException {
|
||||||
|
|
||||||
|
APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance()
|
||||||
|
.getApiApplicationServices();
|
||||||
|
|
||||||
APIApplicationKey apiApplicationKey;
|
APIApplicationKey apiApplicationKey;
|
||||||
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo;
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -45,6 +45,7 @@ public class KeyManagerServiceImpl implements KeyManagerService {
|
|||||||
public Response dynamicClientRegistration(DCRRequest dcrRequest) {
|
public Response dynamicClientRegistration(DCRRequest dcrRequest) {
|
||||||
try {
|
try {
|
||||||
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
|
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
|
||||||
|
//todo lasantha - can pass password from here - modify DCRRequest object
|
||||||
DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(),
|
DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(),
|
||||||
dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod());
|
dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod());
|
||||||
return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build();
|
return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build();
|
||||||
|
|||||||
@ -118,10 +118,13 @@ public class KeyMgtServiceImpl implements KeyMgtService {
|
|||||||
createUserIfNotExists(subTenantUserUsername, subTenantUserPassword);
|
createUserIfNotExists(subTenantUserUsername, subTenantUserPassword);
|
||||||
|
|
||||||
// DCR for the requesting user
|
// DCR for the requesting user
|
||||||
|
//todo lasantha -> need to pass password of user
|
||||||
OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod);
|
OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod);
|
||||||
String requestingUserAccessToken = createAccessToken(dcrApplication);
|
String requestingUserAccessToken = createAccessToken(dcrApplication);
|
||||||
|
|
||||||
// get application id
|
// get application id
|
||||||
|
//todo --> can use requestingUserAccessToken token here to get application data - modify getApplication
|
||||||
|
// method signature
|
||||||
Application application = getApplication(clientName, owner);
|
Application application = getApplication(clientName, owner);
|
||||||
String applicationUUID = application.getUUID();
|
String applicationUUID = application.getUUID();
|
||||||
|
|
||||||
@ -420,6 +423,7 @@ public class KeyMgtServiceImpl implements KeyMgtService {
|
|||||||
try {
|
try {
|
||||||
APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance();
|
APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance();
|
||||||
APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner);
|
APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner);
|
||||||
|
//todo modify the method signature and use access token and call REST API to get application data
|
||||||
return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, "");
|
return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, "");
|
||||||
// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp"
|
// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp"
|
||||||
|
|
||||||
|
|||||||
@ -797,6 +797,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
|
|
||||||
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
|
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
|
||||||
try {
|
try {
|
||||||
|
//todo - lasantha - can't get password from here
|
||||||
DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username,
|
DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username,
|
||||||
"client_credentials", null, new String[] {"device_management"}, false, validityTime);
|
"client_credentials", null, new String[] {"device_management"}, false, validityTime);
|
||||||
deviceConfig.setClientId(dcrResponse.getClientId());
|
deviceConfig.setClientId(dcrResponse.getClientId());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user