|
|
@ -120,32 +120,44 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
// tokenInfo.setAccessToken(accessToken);
|
|
|
|
// tokenInfo.setAccessToken(accessToken);
|
|
|
|
// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime,
|
|
|
|
// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime,
|
|
|
|
// tokenInfo, null, false);
|
|
|
|
// tokenInfo, null, false);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
|
|
|
|
|
|
|
|
// String keyType, String username,
|
|
|
|
|
|
|
|
// boolean isAllowedAllDomains,
|
|
|
|
|
|
|
|
// String validityTime, String password,
|
|
|
|
|
|
|
|
// ArrayList<String> supportedGrantTypes,
|
|
|
|
|
|
|
|
// String callbackUrl,
|
|
|
|
|
|
|
|
// boolean isMappingRequired)
|
|
|
|
|
|
|
|
// throws APIManagerException {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// ApiApplicationInfo applicationInfo = getApplicationInfo(username, password);
|
|
|
|
|
|
|
|
// TokenInfo tokenInfo = new TokenInfo();
|
|
|
|
|
|
|
|
// tokenInfo.setApiApplicationInfo(applicationInfo);
|
|
|
|
|
|
|
|
// tokenInfo.setAccessToken(null);
|
|
|
|
|
|
|
|
// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime,
|
|
|
|
|
|
|
|
// tokenInfo, supportedGrantTypes, callbackUrl, isMappingRequired);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
|
|
|
|
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
|
|
|
|
String keyType, String username,
|
|
|
|
String keyType, String username,
|
|
|
|
boolean isAllowedAllDomains,
|
|
|
|
boolean isAllowedAllDomains,
|
|
|
|
String validityTime, String password,
|
|
|
|
String validityTime,
|
|
|
|
ApplicationGrantTypeUpdater applicationGrantTypeUpdater,
|
|
|
|
String password, String accessToken,
|
|
|
|
|
|
|
|
ArrayList<String> supportedGrantTypes,
|
|
|
|
|
|
|
|
String callbackUrl,
|
|
|
|
boolean isMappingRequired)
|
|
|
|
boolean isMappingRequired)
|
|
|
|
throws APIManagerException {
|
|
|
|
throws APIManagerException {
|
|
|
|
|
|
|
|
|
|
|
|
ApiApplicationInfo applicationInfo = getApplicationInfo(username, password);
|
|
|
|
|
|
|
|
TokenInfo tokenInfo = new TokenInfo();
|
|
|
|
TokenInfo tokenInfo = new TokenInfo();
|
|
|
|
tokenInfo.setApiApplicationInfo(applicationInfo);
|
|
|
|
if (StringUtils.isEmpty(accessToken)) {
|
|
|
|
tokenInfo.setAccessToken(null);
|
|
|
|
ApiApplicationInfo applicationInfo = getApplicationInfo(username, password);
|
|
|
|
return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime,
|
|
|
|
tokenInfo.setApiApplicationInfo(applicationInfo);
|
|
|
|
tokenInfo, applicationGrantTypeUpdater, isMappingRequired);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
tokenInfo.setAccessToken(accessToken);
|
|
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
|
|
|
|
|
|
|
|
String keyType,
|
|
|
|
|
|
|
|
boolean isAllowedAllDomains,
|
|
|
|
|
|
|
|
String validityTime, TokenInfo tokenInfo,
|
|
|
|
|
|
|
|
ApplicationGrantTypeUpdater applicationGrantTypeUpdater,
|
|
|
|
|
|
|
|
boolean isMappingRequired) throws APIManagerException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConsumerRESTAPIServices consumerRESTAPIServices =
|
|
|
|
ConsumerRESTAPIServices consumerRESTAPIServices =
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
@ -171,7 +183,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName);
|
|
|
|
consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName);
|
|
|
|
if (applications.length == 0) {
|
|
|
|
if (applications.length == 0) {
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
|
|
|
|
validityTime, applicationGrantTypeUpdater, isMappingRequired);
|
|
|
|
validityTime, supportedGrantTypes, callbackUrl, isMappingRequired);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (applications.length == 1) {
|
|
|
|
if (applications.length == 1) {
|
|
|
|
Optional<io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application> applicationOpt =
|
|
|
|
Optional<io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application> applicationOpt =
|
|
|
@ -185,7 +197,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
// Todo add a comment
|
|
|
|
// Todo add a comment
|
|
|
|
consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId());
|
|
|
|
consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId());
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
|
|
|
|
validityTime, applicationGrantTypeUpdater, isMappingRequired);
|
|
|
|
validityTime, supportedGrantTypes, callbackUrl, isMappingRequired);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId());
|
|
|
|
Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId());
|
|
|
|
for (Subscription subscription : subscriptions) {
|
|
|
|
for (Subscription subscription : subscriptions) {
|
|
|
@ -239,7 +251,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
|
|
|
|
|
|
|
|
private ApiApplicationKey handleNewAPIApplication(String applicationName, List<APIInfo> uniqueApiList,
|
|
|
|
private ApiApplicationKey handleNewAPIApplication(String applicationName, List<APIInfo> uniqueApiList,
|
|
|
|
TokenInfo tokenInfo, String keyType, String validityTime,
|
|
|
|
TokenInfo tokenInfo, String keyType, String validityTime,
|
|
|
|
ApplicationGrantTypeUpdater applicationGrantTypeUpdater,
|
|
|
|
ArrayList<String> supportedGrantTypes, String callbackUrl,
|
|
|
|
boolean isMappingRequired) throws APIManagerException {
|
|
|
|
boolean isMappingRequired) throws APIManagerException {
|
|
|
|
ConsumerRESTAPIServices consumerRESTAPIServices =
|
|
|
|
ConsumerRESTAPIServices consumerRESTAPIServices =
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
@ -264,9 +276,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
|
|
|
|
|
|
|
|
tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null));
|
|
|
|
tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null));
|
|
|
|
ApplicationKey applicationKey;
|
|
|
|
ApplicationKey applicationKey;
|
|
|
|
if (isMappingRequired) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isMappingRequired) {
|
|
|
|
if (isMappingRequired) {
|
|
|
|
// If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if
|
|
|
|
// If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if
|
|
|
@ -279,11 +289,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager,
|
|
|
|
// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager,
|
|
|
|
// String supportedGrantTypes, String callbackUrl)
|
|
|
|
// String supportedGrantTypes, String callbackUrl)
|
|
|
|
if (applicationGrantTypeUpdater != null) {
|
|
|
|
if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) {
|
|
|
|
applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(),
|
|
|
|
applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(),
|
|
|
|
applicationKey.getKeyMappingId(), keyManager.getName(),
|
|
|
|
applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl);
|
|
|
|
applicationGrantTypeUpdater.getSupportedGrantTypes(),
|
|
|
|
|
|
|
|
applicationGrantTypeUpdater.getCallbackUrl());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -671,7 +679,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
.getRealmConfiguration().getAdminUserName(),
|
|
|
|
.getRealmConfiguration().getAdminUserName(),
|
|
|
|
registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
.getRealmConfiguration().getAdminPassword(), null, false);
|
|
|
|
.getRealmConfiguration().getAdminPassword(), null, null, null, false);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|