|
|
@ -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 {
|
|
|
|