mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add app updating intial changes
This commit is contained in:
parent
7e65d9f980
commit
5848d68c63
@ -24,7 +24,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplication
|
||||
import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException;
|
||||
import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder;
|
||||
import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
|
||||
@ -36,9 +36,6 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClie
|
||||
import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
@ -229,7 +226,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
|
||||
|
||||
private ApiApplicationKey handleNewAPIApplication(String applicationName, List<APIInfo> uniqueApiList,
|
||||
TokenInfo tokenInfo, String keyType, String validityTime) throws APIManagerException {
|
||||
TokenInfo tokenInfo, String keyType, String validityTime,
|
||||
ApplicationGrantTypeUpdater applicationGrantTypeUpdater,
|
||||
boolean isMappingRequired) throws APIManagerException {
|
||||
ConsumerRESTAPIServices consumerRESTAPIServices =
|
||||
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
||||
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();
|
||||
@ -252,10 +251,26 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
}
|
||||
|
||||
tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null));
|
||||
ApplicationKey applicationKey;
|
||||
if (isMappingRequired) {
|
||||
|
||||
}
|
||||
|
||||
if (isMappingRequired) {
|
||||
// If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if
|
||||
// it is a requirement then we have to call the method with enabling the flag.
|
||||
applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application,
|
||||
keyManager.getName(), keyType);
|
||||
} else {
|
||||
applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(),
|
||||
keyManager.getName(), validityTime, keyType);
|
||||
}
|
||||
|
||||
|
||||
// ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application,
|
||||
// keyManager.getName(), keyType);
|
||||
ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(),
|
||||
keyManager.getName(), validityTime, keyType);
|
||||
// ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(),
|
||||
// keyManager.getName(), validityTime, keyType);
|
||||
|
||||
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
|
||||
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ApplicationGrantTypeUpdater {
|
||||
|
||||
private String callbackUrl;
|
||||
|
||||
private ArrayList<String> supportedGrantTypes;
|
||||
|
||||
public String getCallbackUrl() {
|
||||
return callbackUrl;
|
||||
}
|
||||
|
||||
public void setCallbackUrl(String callbackUrl) {
|
||||
this.callbackUrl = callbackUrl;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSupportedGrantTypes() {
|
||||
return supportedGrantTypes;
|
||||
}
|
||||
|
||||
public void setSupportedGrantTypes(ArrayList<String> supportedGrantTypes) {
|
||||
this.supportedGrantTypes = supportedGrantTypes;
|
||||
}
|
||||
}
|
||||
@ -28,5 +28,9 @@ public class KeyMgtException extends Exception {
|
||||
public KeyMgtException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public KeyMgtException(String errorMessage, Exception e) {
|
||||
super(errorMessage, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -86,8 +86,8 @@ public class KeyMgtServiceImpl implements KeyMgtService {
|
||||
.getTenantManager().getTenantId(tenantDomain);
|
||||
} catch (UserStoreException e) {
|
||||
msg = "Error while loading tenant configuration";
|
||||
log.error(msg);
|
||||
throw new KeyMgtException(msg);
|
||||
log.error(msg, e);
|
||||
throw new KeyMgtException(msg, e);
|
||||
}
|
||||
|
||||
kmConfig = getKeyManagerConfig();
|
||||
@ -116,8 +116,8 @@ public class KeyMgtServiceImpl implements KeyMgtService {
|
||||
.getRealmProperty("reserved_tenant_user_password");
|
||||
} catch (UserStoreException e) {
|
||||
msg = "Error while loading user realm configuration";
|
||||
log.error(msg);
|
||||
throw new KeyMgtException(msg);
|
||||
log.error(msg, e);
|
||||
throw new KeyMgtException(msg, e);
|
||||
}
|
||||
createUserIfNotExists(subTenantUserUsername, subTenantUserPassword);
|
||||
|
||||
@ -415,8 +415,8 @@ public class KeyMgtServiceImpl implements KeyMgtService {
|
||||
client.newCall(request).execute();
|
||||
} catch (IOException e) {
|
||||
msg = "Error occurred while invoking create key manager endpoint";
|
||||
log.error(msg);
|
||||
throw new KeyMgtException(msg);
|
||||
log.error(msg, e);
|
||||
throw new KeyMgtException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user