Add todo Comments

fixApiVersions
Dharmakeerthi Lasantha 1 year ago
parent 0927dfc835
commit a09d72c33c

@ -129,19 +129,6 @@
org.json.simple;version="[1.1,2)",
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
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,
org.wso2.carbon.apimgt.api;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)
throws APIManagerException {
APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance()
.getApiApplicationServices();
ConsumerRESTAPIServices consumerRESTAPIServices =
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password);
ApiApplicationInfo applicationInfo = getApplicationInfo(username, password);
try {
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 =
consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName);
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
boolean isNewApplication = false;
if (applications.length == 0) {
isNewApplication = true;
application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application();
application.setName(applicationName);
application = consumerRESTAPIServices.createApplication(applicationInfo, application);
@ -158,22 +159,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
}
}
if (application != null) {
if (!application.getKeys().isEmpty()) {
//todo return Application Keys
return null;
} else{
ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application);
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey;
}
} else{
String msg = "Application retrieval process failed.";
log.error(msg);
throw new APIManagerException(msg);
if (isNewApplication) {
ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application);
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey;
} else {
return null;
}
} catch (APIServicesException e) {
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;
}
private ApiApplicationInfo applicationInfo(APIApplicationServices apiApplicationServices, String username, String password)
private ApiApplicationInfo getApplicationInfo(String username, String password)
throws APIManagerException {
APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance()
.getApiApplicationServices();
APIApplicationKey apiApplicationKey;
io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo;
try {

@ -45,6 +45,7 @@ public class KeyManagerServiceImpl implements KeyManagerService {
public Response dynamicClientRegistration(DCRRequest dcrRequest) {
try {
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
//todo lasantha - can pass password from here - modify DCRRequest object
DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(),
dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod());
return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build();

@ -118,10 +118,13 @@ public class KeyMgtServiceImpl implements KeyMgtService {
createUserIfNotExists(subTenantUserUsername, subTenantUserPassword);
// DCR for the requesting user
//todo lasantha -> need to pass password of user
OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod);
String requestingUserAccessToken = createAccessToken(dcrApplication);
// get application id
//todo --> can use requestingUserAccessToken token here to get application data - modify getApplication
// method signature
Application application = getApplication(clientName, owner);
String applicationUUID = application.getUUID();
@ -420,6 +423,7 @@ public class KeyMgtServiceImpl implements KeyMgtService {
try {
APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance();
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, "");
// // 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();
try {
//todo - lasantha - can't get password from here
DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username,
"client_credentials", null, new String[] {"device_management"}, false, validityTime);
deviceConfig.setClientId(dcrResponse.getClientId());

Loading…
Cancel
Save