From 6e0fe2e26e89f188e5a709bf48a9767807686659 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 08:51:41 +0530 Subject: [PATCH 001/157] Integrate with APIM dev-portal APIs --- .../APIManagementProviderServiceImpl.java | 56 ++++++++++++++++++- .../extension/service/KeyMgtServiceImpl.java | 2 + .../publisher/APIPublisherServiceImpl.java | 4 +- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index d00f483fa4..1094fa3806 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -84,8 +84,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" if (application != null) { // todo:apim - apiConsumer.removeApplication(application, username); + //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" } } catch (APIManagementException e) { throw new APIManagerException("Failed to remove api application : " + applicationName, e); @@ -102,6 +104,37 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException { + +/* + +todo - Modify generateAndRetrieveApplicationKeys + +Check the existence of the API application. + +if Application is not exists + Create the Application + +If super tenants + Get set of tagged APIs +If the tenant domain is not super tenant + Get set of tagged APIs from super tenant space + +If new Application + Subscribed to tagged APIs +Else + Get all subscribed APIs of application + Filter out APIs and subscribed to APIs which can be subscribed + Filter -> Use set of tagged APis + Remove already subscribed APIs from the set + Subscribed to remaining APIs + +Get Application keys from application + If API keys are there return API keys + +Otherwise, Generate Application Keys and return them + + */ + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (StringUtils.isEmpty(username)) { username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; @@ -109,15 +142,20 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// cnt rm +// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" int applicationId = 0; Subscriber subscriber = null; if (application == null) { subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm if (subscriber == null) { // create subscriber // todo:apim - apiConsumer.addSubscriber(username, ""); +// cnt rm subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm } //create application application = new Application(applicationName, subscriber); @@ -125,23 +163,30 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application.setGroupId(""); application.setTokenType("OAUTH"); // todo:apim - apiConsumer.addApplication(application, username); +// cnt rm application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// cnt rm } else { subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm } Set subscribedAPIs = null; // todo:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); + //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340" +// cnt rm + log.info("Already subscribed API count: " + subscribedAPIs.size()); // subscribe to apis. - Set tempApiIds = new HashSet<>(); APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; if (tags != null && tags.length > 0) { for (String tag : tags) { boolean startedTenantFlow = false; Set apisWithTag = null; // todo:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); +// curl -k "https://localhost:9443/api/am/devportal/v3/apis" +// cnt rm /** * From APIM 4.0.0, APIs published in the super tenant can only be listed by @@ -165,11 +210,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } apisWithTag = null; // todo:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// cnt rm startedTenantFlow = true; } Set apiTypeWrapperList = new HashSet<>(); if (apisWithTag != null && apisWithTag.size() > 0) { + Set tempApiIds = new HashSet<>(); for (API apiInfo : apisWithTag) { String id = apiInfo.getId().getProviderName().replace("@", "-AT-") + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); @@ -177,6 +224,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (subscribedAPIs.size() > 0) { for (SubscribedAPI subscribedAPI : subscribedAPIs) { // todo:apim +// cnt rm // if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { // subscriptionExist = true; // break; @@ -220,6 +268,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { // todo:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); +// cnt rm } } } @@ -250,8 +299,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIAdmin apiAdmin = new APIAdminImpl(); String keyManagerId = null; try { - List keyManagerConfigurations = null; // todo:apim - apiAdmin -// .getKeyManagerConfigurationsByTenant(tenantDomain); + List keyManagerConfigurations = null; // todo:apim - + // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); if (keyManagerConfigurations != null) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { keyManagerId = keyManagerConfigurationDTO.getUuid(); @@ -283,6 +332,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); // todo:apim - commected as it says never throw since we commented apim calls above +// cnt rm // } catch (APIManagementException e) { } catch (Exception e) { throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 4be11a8551..fdacd7fdd4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -436,6 +436,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); 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" + } catch (APIManagementException e) { msg = "Error while trying to retrieve the application"; log.error(msg); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 1e13a899c8..fda57d0d59 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -239,8 +239,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { // need remove the local scope and add as a shared scope if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, apiScope.getKey())) { - //todo:apim - // if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { + //resolve- todo:apim- resolve +// if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { if (true) { // collect scope to move as shared scopes scopesToMoveAsSharedScopes.add(apiScope); From c98237dc6f188e8cdcd8e8e2ef8438369a5136ca Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 1 Jun 2023 09:50:58 +0000 Subject: [PATCH 002/157] Implement service for consumer rest APIs Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../rest/api/ConsumerRESTAPIServices.java | 64 +++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 404 ++++++++++++++++++ .../rest/api/bean/APIMConsumer/APIKey.java | 41 ++ .../api/bean/APIMConsumer/Application.java | 143 +++++++ .../api/bean/APIMConsumer/Subscription.java | 106 +++++ .../rest/api/constants/Constants.java | 11 +- .../PublisherRESTAPIServiceComponent.java | 5 + 7 files changed, 773 insertions(+), 1 deletion(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java new file mode 100644 index 0000000000..0dd8783663 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api; + +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +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.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; +import org.json.JSONObject; + +import java.util.List; +import java.util.Map; + +public interface ConsumerRESTAPIServices { + JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Application application) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParam) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Subscription subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIServicesException, BadRequestException, UnexpectedResponseException; +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java new file mode 100644 index 0000000000..383098dd3d --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api; + +import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; +import okhttp3.*; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + + private static final Log log = LogFactory.getLog(ConsumerRESTAPIServicesImpl.class); + private static final OkHttpClient client = new OkHttpClient(HttpsTrustManagerUtils.getSSLClient().newBuilder()); + private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final Gson gson = new Gson(); + private static final String host = System.getProperty(Constants.IOT_CORE_HOST); + private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); + private static final String endPointPrefix = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + + Constants.COLON + port; + + @Override + public JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; + Request request = new Request.Builder() + .url(getAllApplicationsUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getAllApplications(apiApplicationKey, refreshedAccessToken, appName); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Application application) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; + + String applicationInfo = "{\n" + + " \"name\": \"" + application.getName() + "\",\n" + + " \"throttlingPolicy\": \"" + application.getThrottlingPolicy() + "\",\n" + + " \"description\": \"" + application.getDescription() + "\",\n" + + " \"tokenType\": \"" + application.getTokenType() + "\",\n" + + " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + + " \"attributes\": " + application.getAttributes().toString() + ",\n" + + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, applicationInfo); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_CREATED == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return createApplication(apiApplicationKey, refreshedAccessToken, application); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getAllSubscriptions(apiApplicationKey, refreshedAccessToken, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParams) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; + + for (Map.Entry query : queryParams.entrySet()) { + getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); + } + + Request request = new Request.Builder() + .url(getAPIsURL) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Subscription subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; + + String subscriptionObject = "{\n" + + " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + + " \"apiId\": \"" + subscriptions.getApiId() + "\",\n" + + " \"throttlingPolicy\": \"" + subscriptions.getThrottlingPolicy() + "\",\n" + + " \"requestedThrottlingPolicy\": \"" + subscriptions.getRequestedThrottlingPolicy() + "\"\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_CREATED == response.code()) { + return gson.fromJson(response.body().string(), Subscription.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return createSubscription(apiApplicationKey, refreshedAccessToken, subscriptions); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; + + String subscriptionsList = gson.toJson(subscriptions); + + RequestBody requestBody = RequestBody.create(JSON, subscriptionsList); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Subscription.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return createSubscriptions(apiApplicationKey, refreshedAccessToken, subscriptions); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + applicationId + + "/generate-keys"; + + String keyInfo = "{\n" + + " \"validityPeriod\": 3600,\n" + + " \"additionalProperties\": {}\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, keyInfo); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), APIKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return generateApplicationKeys(apiApplicationKey, refreshedAccessToken, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + + @Override + public JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; + Request request = new Request.Builder() + .url(getAllKeyManagersUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + JSONObject jsonObject = new JSONObject(response.body().string()); + return jsonObject; + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getAllKeyManagers(apiApplicationKey, refreshedAccessToken); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java new file mode 100644 index 0000000000..022f1831b4 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +public class APIKey { + + private String apikey; + private int validityTime; + + public String getApikey() { + return apikey; + } + + public void setApikey(String apikey) { + this.apikey = apikey; + } + + public int getValidityTime() { + return validityTime; + } + + public void setValidityTime(int validityTime) { + this.validityTime = validityTime; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java new file mode 100644 index 0000000000..4764f001b9 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +public class Application { + private String applicationId; + private String name; + private String throttlingPolicy; + private String description; + private String tokenType; + private String status; + private List groups; + private int subscriptionCount; + private List keys; + private JSONObject attributes; + private List subscriptionScopes; + private String owner; + private boolean hashEnabled; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getThrottlingPolicy() { + return throttlingPolicy; + } + + public void setThrottlingPolicy(String throttlingPolicy) { + this.throttlingPolicy = throttlingPolicy; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public int getSubscriptionCount() { + return subscriptionCount; + } + + public void setSubscriptionCount(int subscriptionCount) { + this.subscriptionCount = subscriptionCount; + } + + public List getKeys() { + return keys; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + public JSONObject getAttributes() { + return attributes; + } + + public void setAttributes(JSONObject attributes) { + this.attributes = attributes; + } + + public List getSubscriptionScopes() { + return subscriptionScopes; + } + + public void setSubscriptionScopes(List subscriptionScopes) { + this.subscriptionScopes = subscriptionScopes; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public boolean isHashEnabled() { + return hashEnabled; + } + + public void setHashEnabled(boolean hashEnabled) { + this.hashEnabled = hashEnabled; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java new file mode 100644 index 0000000000..edfbce6b6a --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import org.json.JSONObject; + +public class Subscription { + + private String subscriptionId; + private String applicationId; + private String apiId; + private JSONObject apiInfo; + private JSONObject applicationInfo; + private String throttlingPolicy; + private String requestedThrottlingPolicy; + private String status; + private String redirectionParams; + + public String getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getApiId() { + return apiId; + } + + public void setApiId(String apiId) { + this.apiId = apiId; + } + + public JSONObject getApiInfo() { + return apiInfo; + } + + public void setApiInfo(JSONObject apiInfo) { + this.apiInfo = apiInfo; + } + + public JSONObject getApplicationInfo() { + return applicationInfo; + } + + public void setApplicationInfo(JSONObject applicationInfo) { + this.applicationInfo = applicationInfo; + } + + public String getThrottlingPolicy() { + return throttlingPolicy; + } + + public void setThrottlingPolicy(String throttlingPolicy) { + this.throttlingPolicy = throttlingPolicy; + } + + public String getRequestedThrottlingPolicy() { + return requestedThrottlingPolicy; + } + + public void setRequestedThrottlingPolicy(String requestedThrottlingPolicy) { + this.requestedThrottlingPolicy = requestedThrottlingPolicy; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getRedirectionParams() { + return redirectionParams; + } + + public void setRedirectionParams(String redirectionParams) { + this.redirectionParams = redirectionParams; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 5a577e3eb1..5ce6c023c9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -24,6 +24,9 @@ public final class Constants { } public static final String EMPTY_STRING = ""; + public static final String AMPERSAND = "&"; + public static final String SLASH = "/"; + public static final String EQUAL = "="; public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; @@ -34,7 +37,9 @@ public final class Constants { public static final String OAUTH_TOKEN_TYPE = "token_type"; public static final String REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; public static final String SCOPE_PARAM_NAME = "scope"; - public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage apim:api_import_export apim:api_publish"; + public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage apim:api_import_export " + + "apim:api_publish apim:admin apim:api_key apim:app_import_export apim:app_manage apim:store_settings " + + "apim:sub_alert_manage apim:sub_manage apim:subscribe openid"; public static final String DCR_END_POINT = "WorkflowConfigurations.DCREndPoint"; public static final String TOKE_END_POINT = "WorkflowConfigurations.TokenEndPoint"; public static final String ADAPTER_CONF_KEEP_ALIVE = "keepAlive"; @@ -65,6 +70,10 @@ public final class Constants { public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v2/scopes/"; public static final String API_ENDPOINT = "/api/am/publisher/v2/apis/"; public static final String GET_ALL_APIS = "/api/am/publisher/v2/apis?limit=1000"; + public static final String APPLICATIONS_API = "/api/am/devportal/v3/applications"; + public static final String SUBSCRIPTION_API = "/api/am/devportal/v3/subscriptions"; + public static final String DEV_PORTAL_API = "/api/am/devportal/v3/apis?limit=1000"; + public static final String KEY_MANAGERS_API = "/api/am/devportal/v2/key-managers"; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index 799d5ee1c9..86cb5109e3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServicesImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -51,6 +53,9 @@ public class PublisherRESTAPIServiceComponent { bundleContext.registerService(APIApplicationServices.class.getName(), apiApplicationServices, null); PublisherRESTAPIDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + ConsumerRESTAPIServices consumerRESTAPIServices = new ConsumerRESTAPIServicesImpl(); + bundleContext.registerService(ConsumerRESTAPIServices.class.getName(), consumerRESTAPIServices, null); + if (log.isDebugEnabled()) { log.debug("API Application bundle has been successfully initialized"); } From 22f4da908f096123d31b8501873fc3eb47c4d1a2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 17:13:51 +0530 Subject: [PATCH 003/157] Add Consumer REST API integration --- .../pom.xml | 6 ++++ ...ApplicationManagerExtensionDataHolder.java | 10 ++++++ ...ationManagerExtensionServiceComponent.java | 32 +++++++++++++++++++ .../internal/PublisherRESTAPIDataHolder.java | 11 +++++++ .../PublisherRESTAPIServiceComponent.java | 3 +- 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 9968446869..d9a1370d00 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -74,6 +74,11 @@ io.entgra.device.mgt.core.identity.jwt.client.extension provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.apimgt.extension.rest.api + + @@ -121,6 +126,7 @@ 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.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 8a4cf4f1a6..893e17034b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -35,6 +36,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantRegistryLoader tenantRegistryLoader; private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; + private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationManagerExtensionDataHolder() { } @@ -103,4 +105,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setJwtClientManagerService(JWTClientManagerService jwtClientManagerService) { this.jwtClientManagerService = jwtClientManagerService; } + + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 53dccb67d8..9e9166d11a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -48,6 +49,12 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" + * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setConsumerRESTAPIServices" + * unbind="unsetConsumerRESTAPIServices" */ public class APIApplicationManagerExtensionServiceComponent { @@ -113,4 +120,29 @@ public class APIApplicationManagerExtensionServiceComponent { } APIApplicationManagerExtensionDataHolder.getInstance().setRealmService(null); } + + /** + * Sets APIM Consumer REST API service. + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Setting Realm Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); + } + + /** + * Unset APIM Consumer REST API service + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Realm Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(null); + } + } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java index 9a53757b0b..4995df95ef 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; public class PublisherRESTAPIDataHolder { @@ -26,6 +27,8 @@ public class PublisherRESTAPIDataHolder { private APIApplicationServices apiApplicationServices; private APIManagerConfigurationService apiManagerConfigurationService; + private ConsumerRESTAPIServices consumerRESTAPIServices; + private static PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); private PublisherRESTAPIDataHolder() { @@ -54,4 +57,12 @@ public class PublisherRESTAPIDataHolder { return apiManagerConfigurationService; } + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } + } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java index 86cb5109e3..cb5c992664 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java @@ -40,7 +40,7 @@ import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; */ public class PublisherRESTAPIServiceComponent { - private static Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); + private static final Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { @@ -55,6 +55,7 @@ public class PublisherRESTAPIServiceComponent { ConsumerRESTAPIServices consumerRESTAPIServices = new ConsumerRESTAPIServicesImpl(); bundleContext.registerService(ConsumerRESTAPIServices.class.getName(), consumerRESTAPIServices, null); + PublisherRESTAPIDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); if (log.isDebugEnabled()) { log.debug("API Application bundle has been successfully initialized"); From 2d37dcb340ed84c83e67d5f92db812f7be241787 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 11:17:29 +0530 Subject: [PATCH 004/157] Add API app registering refactored code --- .../APIManagementProviderService.java | 5 +++ .../APIManagementProviderServiceImpl.java | 36 ++++++++++++++++++ ...ApplicationManagerExtensionDataHolder.java | 10 +++++ ...ationManagerExtensionServiceComponent.java | 38 +++++++++++++++++-- 4 files changed, 86 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index a46dc715b7..d2d2fe4674 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -50,6 +50,11 @@ public interface APIManagementProviderService { String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException; + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException; + /** * Remove APIM Application. */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 1094fa3806..872d374c90 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,6 +18,11 @@ package io.entgra.device.mgt.core.apimgt.application.extension; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -96,6 +101,37 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException { + + + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + + /* + + */ + + try { + consumerRESTAPIServices.getAllApplications(null, null, null); + } catch (APIServicesException e) { + e.printStackTrace(); + } catch (BadRequestException e) { + e.printStackTrace(); + } catch (UnexpectedResponseException e) { + e.printStackTrace(); + } + + return null; + + + } + + /** * {@inheritDoc} */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 893e17034b..1074edd9d7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; @@ -37,6 +38,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; + private APIApplicationServices apiApplicationServices; private APIApplicationManagerExtensionDataHolder() { } @@ -113,4 +115,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } + + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 9e9166d11a..b2f82e6c31 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,12 +50,18 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" * cardinality="0..1" * policy="dynamic" * bind="setConsumerRESTAPIServices" * unbind="unsetConsumerRESTAPIServices" + * @scr.reference name="apimgt.extension.APIApplicationService" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setAPIApplicationServices" + * unbind="unsetAPIApplicationServices" */ public class APIApplicationManagerExtensionServiceComponent { @@ -128,7 +135,7 @@ public class APIApplicationManagerExtensionServiceComponent { */ protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { if (log.isDebugEnabled()) { - log.debug("Setting Realm Service"); + log.debug("Setting APIM Consumer REST API Service"); } APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); } @@ -140,9 +147,34 @@ public class APIApplicationManagerExtensionServiceComponent { */ protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { if (log.isDebugEnabled()) { - log.debug("Unsetting Realm Service"); + log.debug("Unsetting APIM Consumer REST API Service"); } APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(null); } + + /** + * Sets DCR REST API service. + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void setAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Setting DCR REST API Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + } + + /** + * Unset DCR REST API service + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void unsetAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting DCR REST API Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(null); + } + } From c46a459e6d0d71b96e69cb1fc04721a09ba1f38b Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 17:03:33 +0530 Subject: [PATCH 005/157] Add Application key generating logic --- .../APIManagementProviderServiceImpl.java | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 872d374c90..52a1925df6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension; +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.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; @@ -54,11 +55,7 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClient import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * This class represents an implementation of APIManagementProviderService. @@ -107,17 +104,36 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + try { + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - /* + List uniqueApiList = new ArrayList(); + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + + for (String tag: tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + if ("carbon.super".equals(tenantDomain)) { + consumerRESTAPIServices.getAllApis(null, null, queryParams); + } else { + //call All API getting call with carbon super header param + } + + uniqueApiList.add("Test"); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); - */ - try { - consumerRESTAPIServices.getAllApplications(null, null, null); } catch (APIServicesException e) { e.printStackTrace(); } catch (BadRequestException e) { From a513c13037ec1120bff89959fe987790fba6ba20 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 5 Jun 2023 15:17:01 +0530 Subject: [PATCH 006/157] Improvements in consumer rest apis --- .../rest/api/ConsumerRESTAPIServices.java | 21 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 40 ++- .../rest/api/bean/APIMConsumer/APIInfo.java | 312 ++++++++++++++++++ .../rest/api/bean/APIMConsumer/APIKey.java | 4 + .../api/bean/APIMConsumer/Application.java | 4 + .../ApplicationConfigurations.java | 110 ++++++ .../api/bean/APIMConsumer/KeyManager.java | 184 +++++++++++ .../api/bean/APIMConsumer/Subscription.java | 12 +- 8 files changed, 653 insertions(+), 34 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 0dd8783663..bbdc6cf0fe 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -18,47 +18,48 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; +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.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; -import org.json.JSONObject; import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam) + APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParam) throws APIServicesException, BadRequestException, UnexpectedResponseException; Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 383098dd3d..4f406b16bb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -19,9 +19,11 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; +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.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; @@ -33,6 +35,7 @@ import okhttp3.*; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; import org.json.JSONObject; import java.io.IOException; @@ -51,7 +54,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + public Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; @@ -65,8 +68,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -141,8 +144,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; @@ -156,8 +159,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -181,8 +184,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams) + public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -201,8 +204,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -227,7 +230,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; @@ -274,8 +277,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + public Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; @@ -293,7 +296,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), Subscription.class); + JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -364,7 +368,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + public KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; @@ -378,8 +382,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java new file mode 100644 index 0000000000..f18647899f --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; +import org.json.JSONObject; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * This class represents the Consumer API Information. + */ + +public class APIInfo { + + private String id; + private String name; + private String description; + private String context; + private String version; + private String provider; + private JSONObject apiDefinition; + private String wsdlUri; + private String lifeCycleStatus; + private boolean isDefaultVersion; + private String type; + private Set transport; + private List operations; + private String authorizationHeader; + private String securityScheme; + private Set tags; + private List tiers; + private boolean hasThumbnail; + private String additionalProperties; + private JSONObject monetization; + private List endpointURLs; + private JSONObject businessInformation; + private List environmentList; + private List scopes; + private String avgRating; + private JSONObject advertiseInfo; + private boolean isSubscriptionAvailable; + private List categories; + private List keyManagers = new ArrayList(); + private String createdTime; + private String lastUpdatedTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public JSONObject getApiDefinition() { + return apiDefinition; + } + + public void setApiDefinition(JSONObject apiDefinition) { + this.apiDefinition = apiDefinition; + } + + public String getWsdlUri() { + return wsdlUri; + } + + public void setWsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + } + + public String getLifeCycleStatus() { + return lifeCycleStatus; + } + + public void setLifeCycleStatus(String lifeCycleStatus) { + this.lifeCycleStatus = lifeCycleStatus; + } + + public boolean isDefaultVersion() { + return isDefaultVersion; + } + + public void setDefaultVersion(boolean defaultVersion) { + isDefaultVersion = defaultVersion; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Set getTransport() { + return transport; + } + + public void setTransport(Set transport) { + this.transport = transport; + } + + public List getOperations() { + return operations; + } + + public void setOperations(List operations) { + this.operations = operations; + } + + public String getAuthorizationHeader() { + return authorizationHeader; + } + + public void setAuthorizationHeader(String authorizationHeader) { + this.authorizationHeader = authorizationHeader; + } + + public String getSecurityScheme() { + return securityScheme; + } + + public void setSecurityScheme(String securityScheme) { + this.securityScheme = securityScheme; + } + + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } + + public List getTiers() { + return tiers; + } + + public void setTiers(List tiers) { + this.tiers = tiers; + } + + public boolean isHasThumbnail() { + return hasThumbnail; + } + + public void setHasThumbnail(boolean hasThumbnail) { + this.hasThumbnail = hasThumbnail; + } + + public String getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(String additionalProperties) { + this.additionalProperties = additionalProperties; + } + + public JSONObject getMonetization() { + return monetization; + } + + public void setMonetization(JSONObject monetization) { + this.monetization = monetization; + } + + public List getEndpointURLs() { + return endpointURLs; + } + + public void setEndpointURLs(List endpointURLs) { + this.endpointURLs = endpointURLs; + } + + public JSONObject getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(JSONObject businessInformation) { + this.businessInformation = businessInformation; + } + + public List getEnvironmentList() { + return environmentList; + } + + public void setEnvironmentList(List environmentList) { + this.environmentList = environmentList; + } + + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public String getAvgRating() { + return avgRating; + } + + public void setAvgRating(String avgRating) { + this.avgRating = avgRating; + } + + public JSONObject getAdvertiseInfo() { + return advertiseInfo; + } + + public void setAdvertiseInfo(JSONObject advertiseInfo) { + this.advertiseInfo = advertiseInfo; + } + + public boolean isSubscriptionAvailable() { + return isSubscriptionAvailable; + } + + public void setSubscriptionAvailable(boolean subscriptionAvailable) { + isSubscriptionAvailable = subscriptionAvailable; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getKeyManagers() { + return keyManagers; + } + + public void setKeyManagers(List keyManagers) { + this.keyManagers = keyManagers; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(String lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java index 022f1831b4..5cdaa83577 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIKey.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +/** + * This class represents the Consumer API Key Information. + */ + public class APIKey { private String apikey; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java index 4764f001b9..e137109098 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java @@ -22,6 +22,10 @@ import org.json.JSONObject; import java.util.List; +/** + * This class represents the Consumer Application Information. + */ + public class Application { private String applicationId; private String name; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java new file mode 100644 index 0000000000..9634b77528 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationConfigurations.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import io.apicurio.datamodels.asyncapi.v2.visitors.Aai20Traverser; + +import java.util.List; + +/** + * This class represents the Consumer Application configuration Information. + */ +public class ApplicationConfigurations { + + private String name; + private String label; + private String type; + private boolean required; + private boolean mask; + private boolean multiple; + private String tooltip; + private List values; + private String defaults; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public boolean isMask() { + return mask; + } + + public void setMask(boolean mask) { + this.mask = mask; + } + + public boolean isMultiple() { + return multiple; + } + + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + + public String getTooltip() { + return tooltip; + } + + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + public String getDefaults() { + return defaults; + } + + public void setDefaults(String defaults) { + this.defaults = defaults; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java new file mode 100644 index 0000000000..ac34e006dd --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/KeyManager.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +/** + * This class represents the Consumer Key manager Information. + */ + +public class KeyManager { + + private String id; + private String name; + private String type; + private String displayName; + private String description; + private boolean enabled; + private List availableGrantTypes; + private String tokenEndpoint; + private String revokeEndpoint; + private String userInfoEndpoint; + private String enableTokenGeneration; + private String enableTokenEncryption; + private String enableTokenHashing; + private String enableOAuthAppCreation; + private String enableMapOAuthConsumerApps; + private List applicationConfiguration; + private JSONObject additionalProperties; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public List getAvailableGrantTypes() { + return availableGrantTypes; + } + + public void setAvailableGrantTypes(List availableGrantTypes) { + this.availableGrantTypes = availableGrantTypes; + } + + public String getTokenEndpoint() { + return tokenEndpoint; + } + + public void setTokenEndpoint(String tokenEndpoint) { + this.tokenEndpoint = tokenEndpoint; + } + + public String getRevokeEndpoint() { + return revokeEndpoint; + } + + public void setRevokeEndpoint(String revokeEndpoint) { + this.revokeEndpoint = revokeEndpoint; + } + + public String getUserInfoEndpoint() { + return userInfoEndpoint; + } + + public void setUserInfoEndpoint(String userInfoEndpoint) { + this.userInfoEndpoint = userInfoEndpoint; + } + + public String getEnableTokenGeneration() { + return enableTokenGeneration; + } + + public void setEnableTokenGeneration(String enableTokenGeneration) { + this.enableTokenGeneration = enableTokenGeneration; + } + + public String getEnableTokenEncryption() { + return enableTokenEncryption; + } + + public void setEnableTokenEncryption(String enableTokenEncryption) { + this.enableTokenEncryption = enableTokenEncryption; + } + + public String getEnableTokenHashing() { + return enableTokenHashing; + } + + public void setEnableTokenHashing(String enableTokenHashing) { + this.enableTokenHashing = enableTokenHashing; + } + + public String getEnableOAuthAppCreation() { + return enableOAuthAppCreation; + } + + public void setEnableOAuthAppCreation(String enableOAuthAppCreation) { + this.enableOAuthAppCreation = enableOAuthAppCreation; + } + + public String getEnableMapOAuthConsumerApps() { + return enableMapOAuthConsumerApps; + } + + public void setEnableMapOAuthConsumerApps(String enableMapOAuthConsumerApps) { + this.enableMapOAuthConsumerApps = enableMapOAuthConsumerApps; + } + + public List getApplicationConfiguration() { + return applicationConfiguration; + } + + public void setApplicationConfiguration(List applicationConfiguration) { + this.applicationConfiguration = applicationConfiguration; + } + + public JSONObject getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(JSONObject additionalProperties) { + this.additionalProperties = additionalProperties; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index edfbce6b6a..dca36b9669 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -25,8 +25,8 @@ public class Subscription { private String subscriptionId; private String applicationId; private String apiId; - private JSONObject apiInfo; - private JSONObject applicationInfo; + private APIInfo apiInfo; + private Application applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -56,19 +56,19 @@ public class Subscription { this.apiId = apiId; } - public JSONObject getApiInfo() { + public APIInfo getApiInfo() { return apiInfo; } - public void setApiInfo(JSONObject apiInfo) { + public void setApiInfo(APIInfo apiInfo) { this.apiInfo = apiInfo; } - public JSONObject getApplicationInfo() { + public Application getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(JSONObject applicationInfo) { + public void setApplicationInfo(Application applicationInfo) { this.applicationInfo = applicationInfo; } From a8d45ee41a347db7e0ed616195c40c3c2d02b641 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 6 Jun 2023 13:38:28 +0530 Subject: [PATCH 007/157] Create methods for consumer api app creation and get details of app --- .../rest/api/APIApplicationServices.java | 6 ++ .../rest/api/APIApplicationServicesImpl.java | 33 ++++++++++ .../rest/api/ConsumerRESTAPIServices.java | 4 ++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 39 +++++++++++ .../api/bean/APIMConsumer/Application.java | 6 +- .../rest/api/bean/APIMConsumer/Scopes.java | 65 +++++++++++++++++++ 6 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index d628c4ce25..5b19bf9e3c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -26,6 +26,12 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException; + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 05ecf1fd9e..7209041ad6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; + import java.io.IOException; public class APIApplicationServicesImpl implements APIApplicationServices { @@ -78,6 +79,38 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } } + @Override + public APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException { + + String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("callbackUrl", Constants.EMPTY_STRING); + jsonObject.put("clientName", username); + jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("owner", username); + jsonObject.put("saasApp", true); + + RequestBody requestBody = RequestBody.Companion.create(jsonObject.toString(), JSON); + Request request = new Request.Builder() + .url(applicationEndpoint) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Credentials.basic(username, password)) + .post(requestBody) + .build(); + try { + Response response = client.newCall(request).execute(); + return gson.fromJson(response.body().string(), APIApplicationKey.class); + } catch (IOException e) { + msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(e); + } + } + @Override public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) throws APIServicesException { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index bbdc6cf0fe..3f62abce55 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -36,6 +36,10 @@ public interface ConsumerRESTAPIServices { Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 4f406b16bb..ec28fe6e9b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -92,6 +92,45 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + Request request = new Request.Builder() + .url(getAllApplicationsUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + //TODO: max attempt count + return getDetailsOfAnApplication(apiApplicationKey, refreshedAccessToken, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java index e137109098..50fb64147d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java @@ -37,7 +37,7 @@ public class Application { private int subscriptionCount; private List keys; private JSONObject attributes; - private List subscriptionScopes; + private List subscriptionScopes; private String owner; private boolean hashEnabled; @@ -121,11 +121,11 @@ public class Application { this.attributes = attributes; } - public List getSubscriptionScopes() { + public List getSubscriptionScopes() { return subscriptionScopes; } - public void setSubscriptionScopes(List subscriptionScopes) { + public void setSubscriptionScopes(List subscriptionScopes) { this.subscriptionScopes = subscriptionScopes; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java new file mode 100644 index 0000000000..a2b55005b6 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Scopes.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import java.util.List; + +/** + * This class represents the scope data. + */ + +public class Scopes { + + private String key; + private String name; + private List roles; + private String description; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} From 45d98d5e49157e4df76f4d8bff7a455a18a6524c Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 6 Jun 2023 16:01:32 +0530 Subject: [PATCH 008/157] Improve get all api method to accept header params --- .../rest/api/ConsumerRESTAPIServices.java | 2 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 3f62abce55..e908e60ffd 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -49,7 +49,7 @@ public interface ConsumerRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam) + Map queryParam, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index ec28fe6e9b..cec4a927fe 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -224,7 +224,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams) + Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -233,12 +233,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); } - Request request = new Request.Builder() - .url(getAPIsURL) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .get() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(getAPIsURL); + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()); + for (Map.Entry header : headerParams.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -251,7 +254,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count - return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams); + return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams, headerParams); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); From c53c8f3d63512d5253d826be2f3b344fd449dab4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 7 Jun 2023 10:43:34 +0530 Subject: [PATCH 009/157] minor fix --- .../extension/APIManagementProviderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 52a1925df6..50bd278fe6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -118,9 +118,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe for (String tag: tags) { Map queryParams = new HashMap<>(); + Map headerParams = new HashMap<>(); queryParams.put("tag", tag); if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams); + consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); } else { //call All API getting call with carbon super header param } From 6bf6adf2b5b1561f09f6a23a5a5946159fb544b2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 7 Jun 2023 20:58:48 +0530 Subject: [PATCH 010/157] Add API integration --- .../APIManagementProviderServiceImpl.java | 68 ++++++++++++++++--- .../api/bean/APIMConsumer/Subscription.java | 2 - 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 50bd278fe6..40037475ec 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -20,7 +20,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension; 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.RegistrationProfile; +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.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -110,29 +111,74 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - List uniqueApiList = new ArrayList(); + List uniqueApiList = new ArrayList<>(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - for (String tag: tags) { + for (String tag : tags) { Map queryParams = new HashMap<>(); Map headerParams = new HashMap<>(); queryParams.put("tag", tag); - if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - } else { - //call All API getting call with carbon super header param + APIInfo[] apiInfos; + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); } + apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - uniqueApiList.add("Test"); - Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); uniqueApiList.clear(); uniqueApiList.addAll(taggedAPISet); } - consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + if (applications.length == 0) { + 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 = consumerRESTAPIServices.createApplication(null, null, application); + List subscriptions = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptions.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + } else { + if (applications.length == 1) { + Optional application = + Arrays.stream(applications).findFirst(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + application.get().getApplicationId()); + for (Subscription subscription : subscriptions) { + if (uniqueApiList.contains(subscription.getApiInfo())) { + uniqueApiList.remove(subscription.getApiInfo()); + } else { + uniqueApiList.add(subscription.getApiInfo()); + } + } + + + //duplicate code block + List subscriptionList = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.get().getApplicationId()); + subscriptionList.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + + } } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index dca36b9669..085b87785f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; - public class Subscription { private String subscriptionId; From 0e622450648044a678c3a3ee7e7d118e3407c239 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 7 Jun 2023 23:19:57 +0530 Subject: [PATCH 011/157] modify generateAndRetrieveApplicationKeys method --- .../APIManagementProviderServiceImpl.java | 25 ++++++++++++++----- .../rest/api/APIApplicationServices.java | 5 +--- .../rest/api/APIApplicationServicesImpl.java | 5 +--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 40037475ec..1e8fc44518 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationService 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.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -110,9 +111,21 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + APIApplicationKey apiApplicationKey; + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; + try { + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + } catch (APIServicesException e) { + String errorMsg = "Error occurred while generating the API application"; + log.error(errorMsg, e); + throw new APIManagerException(e); + } + try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); List uniqueApiList = new ArrayList<>(); @@ -126,7 +139,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (!"carbon.super".equals(tenantDomain)) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } - apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); + apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationKey, accessTokenInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -139,7 +152,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(null, null, application); + application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); @@ -147,12 +160,12 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptions.add(subscription); } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); } else { if (applications.length == 1) { Optional application = Arrays.stream(applications).findFirst(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, application.get().getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { @@ -171,7 +184,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.get().getApplicationId()); subscriptionList.add(subscription); } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index 5b19bf9e3c..1cdceff56a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -26,10 +26,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 7209041ad6..8e80e1f5f5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -80,10 +80,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); From d251253948ec211e2683ce94fa35acf001240fec Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 8 Jun 2023 06:02:23 +0530 Subject: [PATCH 012/157] Improve application key generating functionality --- .../APIManagementProviderServiceImpl.java | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 1e8fc44518..ba57bb3045 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -120,12 +120,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } catch (APIServicesException e) { String errorMsg = "Error occurred while generating the API application"; log.error(errorMsg, e); - throw new APIManagerException(e); + throw new APIManagerException(errorMsg, e); } try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = null; List uniqueApiList = new ArrayList<>(); @@ -148,11 +149,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } if (applications.length == 0) { - 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 = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); + List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); @@ -163,10 +163,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); } else { if (applications.length == 1) { - Optional application = + Optional applicationOpt = Arrays.stream(applications).findFirst(); + application = applicationOpt.get(); Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, - application.get().getApplicationId()); + application.getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { uniqueApiList.remove(subscription.getApiInfo()); @@ -175,13 +176,12 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } - - //duplicate code block + //todo duplicate code block -> move to a private method List subscriptionList = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.get().getApplicationId()); + subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); } consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); @@ -190,21 +190,38 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg); throw new APIManagerException(msg); } - } - + if (application != null) { + if (!application.getKeys().isEmpty()) { + //todo return Application Keys + return null; + } else{ + //todo this method has to br modified and return different object, this is not mapped with the + // response. + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey apiKey = + consumerRESTAPIServices.generateApplicationKeys(apiApplicationKey, accessTokenInfo, + application.getApplicationId()); + return null; + } + } else{ + String msg = "Application retrieval process failed."; + log.error(msg); + throw new APIManagerException(msg); + } } catch (APIServicesException e) { - e.printStackTrace(); + String msg = "Error occurred wile processing the response of APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } catch (BadRequestException e) { - e.printStackTrace(); + String msg = "Provided incorrect payload when invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } catch (UnexpectedResponseException e) { - e.printStackTrace(); + String msg = "Error occurred while invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } - - return null; - - } From 94e1df617ad52b07ef2e58d6d5804edc53fe0883 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 9 Jun 2023 02:55:20 +0530 Subject: [PATCH 013/157] Get apiApplication registration to single method and fix generateApplicationKeys --- .../APIManagementProviderServiceImpl.java | 60 +++++--- .../rest/api/ConsumerRESTAPIServices.java | 34 ++-- .../rest/api/ConsumerRESTAPIServicesImpl.java | 145 ++++++++++-------- .../api/bean/APIMConsumer/ApplicationKey.java | 138 +++++++++++++++++ .../rest/api/dto/ApiApplicationInfo.java | 61 ++++++++ 5 files changed, 331 insertions(+), 107 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationKey.java create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/ApiApplicationInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index ba57bb3045..18e706f8fc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -21,8 +21,10 @@ package io.entgra.device.mgt.core.apimgt.application.extension; 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; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -111,21 +113,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - APIApplicationKey apiApplicationKey; - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; - try { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); - accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - } catch (APIServicesException e) { - String errorMsg = "Error occurred while generating the API application"; - log.error(errorMsg, e); - throw new APIManagerException(errorMsg, e); - } - + ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = null; List uniqueApiList = new ArrayList<>(); @@ -140,7 +131,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (!"carbon.super".equals(tenantDomain)) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } - apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationKey, accessTokenInfo, queryParams, headerParams); + apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -151,7 +142,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (applications.length == 0) { application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); + application = consumerRESTAPIServices.createApplication(applicationInfo, application); List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { @@ -160,14 +151,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptions.add(subscription); } - consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); + consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptions); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, - application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { uniqueApiList.remove(subscription.getApiInfo()); @@ -184,7 +174,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); } - consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptionList); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -199,9 +189,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } else{ //todo this method has to br modified and return different object, this is not mapped with the // response. - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey apiKey = - consumerRESTAPIServices.generateApplicationKeys(apiApplicationKey, accessTokenInfo, - application.getApplicationId()); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); return null; } } else{ @@ -560,4 +548,32 @@ Otherwise, Generate Application Keys and return them } return info; } + + private ApiApplicationInfo applicationInfo(APIApplicationServices apiApplicationServices, String username, String password) + throws APIManagerException { + + APIApplicationKey apiApplicationKey; + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; + try { + if (username == null && password == null) { + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + } else { + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + } + accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + } catch (APIServicesException e) { + String errorMsg = "Error occurred while generating the API application"; + log.error(errorMsg, e); + throw new APIManagerException(errorMsg, e); + } + + ApiApplicationInfo applicationInfo = null; + applicationInfo.setClientId(apiApplicationKey.getClientId()); + applicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); + applicationInfo.setAccess_token(accessTokenInfo.getAccess_token()); + applicationInfo.setRefresh_token(accessTokenInfo.getRefresh_token()); + + return applicationInfo; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index e908e60ffd..fc90c14463 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -18,13 +18,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; -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.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -33,37 +28,30 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo applicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Application application) + Application createApplication(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParam, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index cec4a927fe..fe341bc416 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -19,14 +19,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; -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.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -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.constants.Constants; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -54,14 +50,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request request = new Request.Builder() .url(getAllApplicationsUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + applicationInfo.getAccess_token()) .get() .build(); @@ -73,10 +69,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApplications(apiApplicationKey, refreshedAccessToken, appName); + return getAllApplications(refreshedApiApplicationInfo, appName); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -93,15 +90,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request request = new Request.Builder() .url(getAllApplicationsUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -112,10 +108,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getDetailsOfAnApplication(apiApplicationKey, refreshedAccessToken, applicationId); + return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -132,8 +129,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; @@ -152,7 +148,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -163,10 +159,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createApplication(apiApplicationKey, refreshedAccessToken, application); + return createApplication(refreshedApiApplicationInfo, application); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -183,15 +180,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -203,10 +199,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllSubscriptions(apiApplicationKey, refreshedAccessToken, applicationId); + return getAllSubscriptions(rehreshedApiApplicationInfo, applicationId); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -223,8 +220,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams, Map headerParams) + public APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParams, + Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -236,7 +233,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL); builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()); + + applicationInfo.getAccess_token()); for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -251,10 +248,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams, headerParams); + return getAllApis(rehreshedApiApplicationInfo, queryParams, headerParams); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -271,8 +269,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo applicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; @@ -288,7 +285,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + applicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -299,10 +296,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscription(apiApplicationKey, refreshedAccessToken, subscriptions); + return createSubscription(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -319,8 +317,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; @@ -331,7 +328,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -343,10 +340,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscriptions(apiApplicationKey, refreshedAccessToken, subscriptions); + return createSubscriptions(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -363,15 +361,25 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + applicationId + - "/generate-keys"; + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + + application.getApplicationId() + "/generate-keys"; String keyInfo = "{\n" + - " \"validityPeriod\": 3600,\n" + + " \"keyType\": \"PRODUCTION\",\n" + + " \"keyManager\": \"Resident Key Manager\",\n" + + " \"grantTypesToBeSupported\": [\n" + + " \"password\",\n" + + " \"client_credentials\"\n" + + " ],\n" + + " \"callbackUrl\": \"http://sample.com/callback/url\",\n" + + " \"scopes\": [\n" + + " \"am_application_scope\",\n" + + " \"default\"\n" + + " ],\n" + + " \"validityTime\": 3600,\n" + " \"additionalProperties\": {}\n" + "}"; @@ -379,21 +387,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), APIKey.class); + return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(apiApplicationKey, refreshedAccessToken, applicationId); + return generateApplicationKeys(refreshedApiApplicationKey, application); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -410,14 +419,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request request = new Request.Builder() .url(getAllKeyManagersUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -429,10 +438,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllKeyManagers(apiApplicationKey, refreshedAccessToken); + return getAllKeyManagers(refreshedApiApplicationInfo); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -447,4 +457,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { throw new APIServicesException(msg, e); } } + + private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo refreshedApplicationInfo, AccessTokenInfo refreshedToken) { + + ApiApplicationInfo applicationInfo = null; + applicationInfo.setClientId(refreshedApplicationInfo.getClientId()); + applicationInfo.setClientSecret(refreshedApplicationInfo.getClientSecret()); + applicationInfo.setAccess_token(refreshedToken.getAccess_token()); + applicationInfo.setRefresh_token(refreshedToken.getRefresh_token()); + + return applicationInfo; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationKey.java new file mode 100644 index 0000000000..c51564af2c --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationKey.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +/** + * This class represents the Consumer Application key Information. + */ +public class ApplicationKey { + + private String keyMappingId; + private String keyManager; + private String consumerKey; + private String consumerSecret; + private List supportedGrantTypes; + private String callbackUrl; + private String keyState; + private String keyType; + private String mode; + private String groupId; + private JSONObject token; + private JSONObject additionalProperties; + + public String getKeyMappingId() { + return keyMappingId; + } + + public void setKeyMappingId(String keyMappingId) { + this.keyMappingId = keyMappingId; + } + + public String getKeyManager() { + return keyManager; + } + + public void setKeyManager(String keyManager) { + this.keyManager = keyManager; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public List getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(List supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public String getKeyState() { + return keyState; + } + + public void setKeyState(String keyState) { + this.keyState = keyState; + } + + public String getKeyType() { + return keyType; + } + + public void setKeyType(String keyType) { + this.keyType = keyType; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public JSONObject getToken() { + return token; + } + + public void setToken(JSONObject token) { + this.token = token; + } + + public JSONObject getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(JSONObject additionalProperties) { + this.additionalProperties = additionalProperties; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/ApiApplicationInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/ApiApplicationInfo.java new file mode 100644 index 0000000000..169ce76442 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/ApiApplicationInfo.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto; + +/** + * This holds the API application client information and token information. + */ +public class ApiApplicationInfo { + private String clientId; + private String clientSecret; + private String refresh_token; + private String access_token; + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getRefresh_token() { + return refresh_token; + } + + public void setRefresh_token(String refresh_token) { + this.refresh_token = refresh_token; + } + + public String getAccess_token() { + return access_token; + } + + public void setAccess_token(String access_token) { + this.access_token = access_token; + } +} From 189a572d310a6841f7ab18301b7dfac08c3f98da Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 04:51:05 +0530 Subject: [PATCH 014/157] Improve functionality --- .../APIManagementProviderServiceImpl.java | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 18e706f8fc..7fa6c440c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -106,10 +106,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException { - - APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); + String validityTime, String password) + throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() + .getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -117,21 +118,21 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { 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 = null; + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; List uniqueApiList = new ArrayList<>(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + Map headerParams = new HashMap<>(); + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); + } + for (String tag : tags) { Map queryParams = new HashMap<>(); - Map headerParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos; - if (!"carbon.super".equals(tenantDomain)) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); + + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -143,15 +144,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); application = consumerRESTAPIServices.createApplication(applicationInfo, application); - - List subscriptions = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptions.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptions); + addSubscriptions(application, uniqueApiList, applicationInfo); } else { if (applications.length == 1) { Optional applicationOpt = @@ -165,16 +158,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe uniqueApiList.add(subscription.getApiInfo()); } } - - //todo duplicate code block -> move to a private method - List subscriptionList = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptionList.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptionList); + addSubscriptions(application, uniqueApiList, applicationInfo); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -187,18 +171,20 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe //todo return Application Keys return null; } else{ - //todo this method has to br modified and return different object, this is not mapped with the - // response. + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); - return null; + 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); + throw new APIManagerException(msg); } } catch (APIServicesException e) { - String msg = "Error occurred wile processing the response of APIM REST endpoints."; + String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); throw new APIManagerException(msg, e); } catch (BadRequestException e) { @@ -212,6 +198,34 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + /** + * + * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. + * + * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} + * @param apiInfos {@link List} + * @param apiApplicationInfo {@link ApiApplicationInfo} + * + * @throws BadRequestException if incorrect data provided to call subscribing REST API. + * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. + * @throws APIServicesException if error occurred while invoking the subscribing REST API. + */ + private void addSubscriptions( + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, + List apiInfos, ApiApplicationInfo apiApplicationInfo) + throws BadRequestException, UnexpectedResponseException, APIServicesException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + List subscriptionList = new ArrayList<>(); + apiInfos.forEach(apiInfo -> { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptionList.add(subscription); + }); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); + } /** * {@inheritDoc} From c227969a61a91558831efc2f73ea4bb5b763c0ac Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 05:06:01 +0530 Subject: [PATCH 015/157] Improve the functionality --- .../APIManagementProviderService.java | 2 +- .../APIManagementProviderServiceImpl.java | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index d2d2fe4674..51ac50cf08 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -50,7 +50,7 @@ public interface APIManagementProviderService { String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException; - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 7fa6c440c6..1bf3d1ded1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -103,7 +103,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, String validityTime, String password) @@ -116,15 +116,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); try { - 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; - List uniqueApiList = new ArrayList<>(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); Map headerParams = new HashMap<>(); - if (!"carbon.super".equals(tenantDomain)) { + if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } @@ -140,6 +135,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe uniqueApiList.addAll(taggedAPISet); } + 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; if (applications.length == 0) { application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); @@ -151,13 +149,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Arrays.stream(applications).findFirst(); application = applicationOpt.get(); Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); - for (Subscription subscription : subscriptions) { - if (uniqueApiList.contains(subscription.getApiInfo())) { - uniqueApiList.remove(subscription.getApiInfo()); - } else { - uniqueApiList.add(subscription.getApiInfo()); - } - } + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); addSubscriptions(application, uniqueApiList, applicationInfo); } else { String msg = "Found more than one application for application name: " + applicationName; From f741df7c4baba3d8e0f31430766f019d44be6cb2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 14:12:30 +0530 Subject: [PATCH 016/157] Add ToDos --- .../api/ApiApplicationRegistrationServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 687fe5be5e..5dc89a80c4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -59,6 +59,9 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(); + //todo + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( @@ -107,6 +110,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { + //todo + registrationProfile.getPassword(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, @@ -118,6 +123,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); + //todo + registrationProfile.getPassword(); synchronized (ApiApplicationRegistrationServiceImpl.class) { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), From a09d72c33ccecee5757dd29eafd959311ba14e3e Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Sat, 10 Jun 2023 11:43:27 +0530 Subject: [PATCH 017/157] Add todo Comments --- .../pom.xml | 13 ------- .../APIManagementProviderServiceImpl.java | 36 +++++++++---------- .../extension/api/KeyManagerServiceImpl.java | 1 + .../extension/service/KeyMgtServiceImpl.java | 4 +++ .../impl/DeviceManagementServiceImpl.java | 1 + 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index ed7542738a..6ad08c770a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -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)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 67bf9ef56b..ad58ab4f33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -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 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 { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 96f506d99e..dbfee32906 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -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(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index aee387abc4..936011e90f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -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" diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index d1ddfaa44f..579f09c606 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -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()); From 3b8405e72ea9b6a1fcf8bc78aafbce82b6c4a170 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 12 Jun 2023 14:37:00 +0530 Subject: [PATCH 018/157] Fix version issues in REST APIs --- .../apimgt/extension/rest/api/constants/Constants.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 5ce6c023c9..6c3cf21c89 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -66,14 +66,14 @@ public final class Constants { public static final String SPACE = " "; public static final String IOT_CORE_HOST = "iot.core.host"; public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port"; - public static final String GET_ALL_SCOPES = "/api/am/publisher/v2/scopes?limit=1000"; - public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v2/scopes/"; - public static final String API_ENDPOINT = "/api/am/publisher/v2/apis/"; - public static final String GET_ALL_APIS = "/api/am/publisher/v2/apis?limit=1000"; + public static final String GET_ALL_SCOPES = "/api/am/publisher/v4/scopes?limit=1000"; + public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v4/scopes/"; + public static final String API_ENDPOINT = "/api/am/publisher/v4/apis/"; + public static final String GET_ALL_APIS = "/api/am/publisher/v4/apis?limit=1000"; public static final String APPLICATIONS_API = "/api/am/devportal/v3/applications"; public static final String SUBSCRIPTION_API = "/api/am/devportal/v3/subscriptions"; public static final String DEV_PORTAL_API = "/api/am/devportal/v3/apis?limit=1000"; - public static final String KEY_MANAGERS_API = "/api/am/devportal/v2/key-managers"; + public static final String KEY_MANAGERS_API = "/api/am/devportal/v3/key-managers"; } From af17e4fa8e971334c2c67446b2cd86c2a6ea0dc3 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 12 Jun 2023 16:27:38 +0530 Subject: [PATCH 019/157] Improve APIM application key generate method --- .../pom.xml | 7 ++ .../APIManagementProviderServiceImpl.java | 41 +++++++++++- ...ApplicationManagerExtensionDataHolder.java | 10 +++ ...ationManagerExtensionServiceComponent.java | 31 +++++++++ .../keymgt/extension/api/DCRRequest.java | 6 ++ .../pom.xml | 6 ++ .../extension/internal/KeyMgtDataHolder.java | 20 ++++++ .../internal/KeyMgtServiceComponent.java | 67 ++++++++++++++++++- 8 files changed, 184 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 6ad08c770a..7434c58e54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -84,6 +84,12 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + + + @@ -124,6 +130,7 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", org.apache.commons.lang;version="[2.6,3)", org.apache.commons.logging;version="[1.2,2)", org.json.simple;version="[1.1,2)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index ad58ab4f33..6ab71de887 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,6 +24,10 @@ 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.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; @@ -41,6 +45,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -159,13 +164,47 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = + "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + //todo call the API key retrieving call, return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } return null; } } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 1074edd9d7..d6a3bb2fc5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; 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.device.mgt.common.metadata.mgt.MetadataManagementService; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -39,6 +40,7 @@ public class APIApplicationManagerExtensionDataHolder { private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationServices apiApplicationServices; + private MetadataManagementService metadataManagementService; private APIApplicationManagerExtensionDataHolder() { } @@ -123,4 +125,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { this.apiApplicationServices = apiApplicationServices; } + + public MetadataManagementService getMetadataManagementService() { + return metadataManagementService; + } + + public void setMetadataManagementService(MetadataManagementService metadataManagementService) { + this.metadataManagementService = metadataManagementService; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index f761bfbf38..b3dc6dbd9d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -21,6 +21,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationService import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -178,4 +179,34 @@ public class APIApplicationManagerExtensionServiceComponent { } APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(null); } + + /** + * Sets Meta Data Mgt service. + * + * @param metadataManagementService An instance of MetadataManagementService + */ + @Reference( + name = "meta.data.mgt.service", + service = io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetAMetaMgtServices") + protected void setMetaMgtServices(MetadataManagementService metadataManagementService) { + if (log.isDebugEnabled()) { + log.debug("Setting Meta data mgt Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setMetadataManagementService(metadataManagementService); + } + + /** + * Unset Meta Data Mgt service + * + * @param metadataManagementService An instance of MetadataManagementService + */ + protected void unsetAMetaMgtServices(MetadataManagementService metadataManagementService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Meta Data mgt Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setMetadataManagementService(null); + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java index c8171451f6..8f492c2234 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java @@ -32,6 +32,8 @@ public class DCRRequest { @XmlElement(required = true) private String username; @XmlElement(required = true) + private String password; + @XmlElement(required = true) private String grantTypes; @XmlElement private String callBackUrl; @@ -98,4 +100,8 @@ public class DCRRequest { public void setValidityPeriod(int validityPeriod) { this.validityPeriod = validityPeriod; } + + public String getPassword() { return password; } + + public void setPassword(String password) { this.password = password; } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 5d2d371df5..53374f48c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -55,6 +55,11 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.apimgt.extension.rest.api + + @@ -108,6 +113,7 @@ org.wso2.carbon.apimgt.keymgt.model;version="[9.28,10)", org.wso2.carbon.apimgt.keymgt.model.entity;version="[9.28,10)", org.wso2.carbon.apimgt.keymgt.service;version="[9.28,10)", + io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.context;version="[4.8,5)", org.wso2.carbon.user.api;version="[1.0,2)", org.wso2.carbon.user.core.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java index fd711781a1..96e96000be 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java @@ -18,12 +18,16 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.internal; +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.keymgt.extension.service.KeyMgtService; public class KeyMgtDataHolder { private static final KeyMgtDataHolder thisInstance = new KeyMgtDataHolder(); private KeyMgtService keyMgtService; + private ConsumerRESTAPIServices consumerRESTAPIServices; + private APIApplicationServices apiApplicationServices; public static KeyMgtDataHolder getInstance() { return thisInstance; @@ -37,4 +41,20 @@ public class KeyMgtDataHolder { this.keyMgtService = keyMgtService; } + + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } + + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java index 395bdc0107..96a05f15f5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java @@ -18,15 +18,16 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.internal; +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.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.*; + @Component( name = "io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtServiceComponent", immediate = true) @@ -63,4 +64,64 @@ public class KeyMgtServiceComponent { log.debug("De-activating Key Management Service Component"); } } + + /** + * Sets APIM Consumer REST API service. + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + @Reference( + name = "APIM.consumer.service", + service = io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConsumerRESTAPIServices") + protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Setting APIM Consumer REST API Service"); + } + KeyMgtDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); + } + + /** + * Unset APIM Consumer REST API service + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting APIM Consumer REST API Service"); + } + KeyMgtDataHolder.getInstance().setConsumerRESTAPIServices(null); + } + + /** + * Sets DCR REST API service. + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + @Reference( + name = "APIM.application.service", + service = io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetAPIApplicationServices") + protected void setAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Setting DCR REST API Service"); + } + KeyMgtDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + } + + /** + * Unset DCR REST API service + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void unsetAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting DCR REST API Service"); + } + KeyMgtDataHolder.getInstance().setApiApplicationServices(null); + } } From 730f3aaa0793ee34adc0ae3f88cee8e0ea5fc92a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 13 Jun 2023 04:06:04 +0530 Subject: [PATCH 020/157] Improve API publishing functionality --- ...ApiApplicationRegistrationServiceImpl.java | 14 +-- .../APIManagementProviderServiceImpl.java | 84 ++++++++--------- .../publisher/APIPublisherServiceImpl.java | 91 ++++++++----------- .../application/mgt/core/util/OAuthUtils.java | 10 +- 4 files changed, 85 insertions(+), 114 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index f3fb909372..133a5d1a9c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -59,15 +59,13 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(); - //todo - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, - ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); + ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -110,12 +108,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { - //todo - registrationProfile.getPassword(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod); + registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -123,13 +119,11 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); - //todo - registrationProfile.getPassword(); synchronized (ApiApplicationRegistrationServiceImpl.class) { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), - registrationProfile.isAllowedToAllDomains(), validityPeriod); + registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6ab71de887..66ba639ea0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -45,7 +45,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -64,7 +63,14 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * This class represents an implementation of APIManagementProviderService. @@ -197,6 +203,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; //todo call the API key retrieving call, return apiApplicationKey; @@ -296,41 +307,29 @@ Otherwise, Generate Application Keys and return them } try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// cnt rm -// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" - + Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); int applicationId = 0; Subscriber subscriber = null; if (application == null) { - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); if (subscriber == null) { // create subscriber - // todo:apim - apiConsumer.addSubscriber(username, ""); -// cnt rm - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); } //create application application = new Application(applicationName, subscriber); application.setTier(ApiApplicationConstants.DEFAULT_TIER); application.setGroupId(""); application.setTokenType("OAUTH"); - // todo:apim - apiConsumer.addApplication(application, username); -// cnt rm - application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// cnt rm + // todo:resolve:apim - apiConsumer.addApplication(application, username); + application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); } else { - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); } Set subscribedAPIs = - null; // todo:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); - - //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340" -// cnt rm + null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); log.info("Already subscribed API count: " + subscribedAPIs.size()); @@ -339,9 +338,7 @@ Otherwise, Generate Application Keys and return them if (tags != null && tags.length > 0) { for (String tag : tags) { boolean startedTenantFlow = false; - Set apisWithTag = null; // todo:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); -// curl -k "https://localhost:9443/api/am/devportal/v3/apis" -// cnt rm + Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); /** * From APIM 4.0.0, APIs published in the super tenant can only be listed by @@ -364,8 +361,7 @@ Otherwise, Generate Application Keys and return them ". Caused by to inability to get super tenant username", e); } - apisWithTag = null; // todo:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// cnt rm + apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); startedTenantFlow = true; } @@ -378,8 +374,7 @@ Otherwise, Generate Application Keys and return them boolean subscriptionExist = false; if (subscribedAPIs.size() > 0) { for (SubscribedAPI subscribedAPI : subscribedAPIs) { - // todo:apim -// cnt rm + // todo:resolve:apim // if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { // subscriptionExist = true; // break; @@ -422,8 +417,7 @@ Otherwise, Generate Application Keys and return them * Oauth app for a child tenant. */ for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { - // todo:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); -// cnt rm + // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); } } } @@ -454,7 +448,7 @@ Otherwise, Generate Application Keys and return them APIAdmin apiAdmin = new APIAdminImpl(); String keyManagerId = null; try { - List keyManagerConfigurations = null; // todo:apim - + List keyManagerConfigurations = null; // todo:resolve:apim - // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); if (keyManagerConfigurations != null) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { @@ -474,7 +468,7 @@ Otherwise, Generate Application Keys and return them "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + "\"username\":\"" + username + "\"}"; - Map keyDetails = null; // todo:apim - apiConsumer + Map keyDetails = null; // todo:resolve:apim - apiConsumer // .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", // allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", // jsonString, keyManagerId, tenantDomain); @@ -486,7 +480,7 @@ Otherwise, Generate Application Keys and return them return apiApplicationKey; } throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -// todo:apim - commected as it says never throw since we commented apim calls above +// todo:resolve:apim - commected as it says never throw since we commented apim calls above // cnt rm // } catch (APIManagementException e) { } catch (Exception e) { @@ -525,11 +519,10 @@ Otherwise, Generate Application Keys and return them JWTClientManagerService jwtClientManagerService = APIApplicationManagerExtensionDataHolder.getInstance() .getJwtClientManagerService(); JWTClient jwtClient = jwtClientManagerService.getJWTClient(); - AccessTokenInfo accessTokenForAdmin = jwtClient + + return jwtClient .getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), username, scopes); - - return accessTokenForAdmin; } catch (JWTClientException e) { String msg = "JWT Error occurred while registering Application to get access token."; log.error(msg, e); @@ -546,7 +539,8 @@ Otherwise, Generate Application Keys and return them } /** - * Get Client credentials + * Get Client credentials of application belongs to tenant admin + * * @param tenantDomain Tenant Domain * @param tags Tags * @param applicationName Application Name @@ -554,7 +548,7 @@ Otherwise, Generate Application Keys and return them * @param validityPeriod Validity Period * @return {@link ApiApplicationKey} * @throws APIManagerException if error occurred while generating access token - * @throws UserStoreException if error ocurred while getting admin username. + * @throws UserStoreException if error occurred while getting admin username. */ private ApiApplicationKey getClientCredentials(String tenantDomain, String[] tags, String applicationName, String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { @@ -565,7 +559,6 @@ Otherwise, Generate Application Keys and return them registrationProfile.setTags(tags); registrationProfile.setApplicationName(applicationName); - ApiApplicationKey info = null; if (tenantDomain == null || tenantDomain.isEmpty()) { tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; } @@ -576,15 +569,14 @@ Otherwise, Generate Application Keys and return them PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() .getAdminUserName()); - if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) { - info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), - registrationProfile.getTags(), tokenType, null, - registrationProfile.isAllowedToAllDomains(), validityPeriod); - } + return generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), + registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); } finally { PrivilegedCarbonContext.endTenantFlow(); } - return info; } private ApiApplicationInfo getApplicationInfo(String username, String password) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 8d30d3daf2..fe98a8cef8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -153,17 +153,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { } if (!apiFound) { // add new scopes as shared scopes - for (ApiScope apiScope : apiConfig.getScopes()) { - if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, - apiScope.getKey())) { - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); - } - } + addNewSharedScope(apiConfig.getScopes(), publisherRESTAPIServices, apiApplicationKey, + accessTokenInfo); APIInfo api = getAPI(apiConfig, true); JSONObject createdAPI = publisherRESTAPIServices.addAPI(apiApplicationKey, accessTokenInfo, api); if (apiConfig.getEndpointType() != null && "WS".equals(apiConfig.getEndpointType())) { @@ -202,7 +193,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } else { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { - // With 4.x to 5.x upgrade // - there cannot be same local scope assigned in 2 different APIs // - local scopes will be deprecated in the future, so need to move all scopes as shared scopes @@ -217,50 +207,17 @@ public class APIPublisherServiceImpl implements APIPublisherService { // 1. add new scopes as shared scopes // 2. update the API adding scopes for the URI Templates - Set scopesToMoveAsSharedScopes = new HashSet<>(); - for (ApiScope apiScope : apiConfig.getScopes()) { - // if the scope is not available as shared scope, and it is assigned to an API as a local scope - // need remove the local scope and add as a shared scope - if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, - apiScope.getKey())) { - //resolve- todo:apim- resolve -// if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { - if (true) { - // collect scope to move as shared scopes - scopesToMoveAsSharedScopes.add(apiScope); - } else { - // if new scope add as shared scope - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); + // It is guaranteed that there is no local scope if we update from 5.0.0 to the most + // recent version. Therefore, if the scope is not already available as a shared scope, + // new scopes must be added as shared scopes. Additionally, it is necessary to + // upgrade to 5.0.0 first before updating from 5.0.0 to the most recent version if we + // are updating from a version that is older than 5.0.0. - } - } - } + addNewSharedScope(apiConfig.getScopes(), publisherRESTAPIServices, apiApplicationKey, + accessTokenInfo); - // Get existing API - JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, - apiIdentifier); - if (scopesToMoveAsSharedScopes.size() > 0) { - // update API to remove local scopes - APIInfo api = getAPI(apiConfig, false); - api.setLifeCycleStatus(existingAPI.getString("lifeCycleStatus")); - publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api); - - for (ApiScope apiScope : scopesToMoveAsSharedScopes) { - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); - } - } - - existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, apiIdentifier); + JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, + accessTokenInfo, apiIdentifier); APIInfo api = getAPI(apiConfig, true); api.setLastUpdatedTime(existingAPI.getString("lifeCycleStatus")); api.setId(existingAPI.getString("id")); @@ -408,6 +365,32 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } + /** + * Add new Shared Scopes + * + * @param apiScopes set of API scopes + * @param publisherRESTAPIServices {@link PublisherRESTAPIServices} + * @param apiApplicationKey API application Key + * @param accessTokenInfo Details of access token + * @throws BadRequestException if invalid payload receives to add new shared scopes. + * @throws UnexpectedResponseException if the response is not either 200 or 400. + * @throws APIServicesException if error occurred while processing the response. + */ + private void addNewSharedScope(Set apiScopes, PublisherRESTAPIServices publisherRESTAPIServices, + APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { + for (ApiScope apiScope : apiScopes) { + if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, + apiScope.getKey())) { + Scope scope = new Scope(); + scope.setName(apiScope.getName()); + scope.setDescription(apiScope.getDescription()); + scope.setKey(apiScope.getKey()); + scope.setRoles(apiScope.getRoles()); + publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); + } + } + } + @Override public void updateScopeRoleMapping() throws APIManagerPublisherException { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index 272a5b45b0..c5975cb500 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -55,16 +55,18 @@ public class OAuthUtils { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. - getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); APIManagementProviderService apiManagementProviderService = (APIManagementProviderService) ctx. getOSGiService(APIManagementProviderService.class, null); apiApplicationKeyInfo = apiManagementProviderService. generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, - null, registrationProfile.isAllowedToAllDomains(), - Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD); + username, registrationProfile.isAllowedToAllDomains(), + Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); } finally { PrivilegedCarbonContext.endTenantFlow(); } From 7826e5c285eabf7ef73b276aeb2b4b5d83c1bafa Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 13 Jun 2023 07:22:14 +0530 Subject: [PATCH 021/157] Fix key generation method --- .../APIManagementProviderServiceImpl.java | 10 ++- .../rest/api/ConsumerRESTAPIServices.java | 8 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 90 +++++++++++++++++-- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 66ba639ea0..7ab72f71b3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,6 +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.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -172,7 +173,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); + KeyManager keyManager = consumerRESTAPIServices.getAllKeyManagers(applicationInfo)[0]; + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -210,7 +212,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - //todo call the API key retrieving call, return apiApplicationKey; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); + ApiApplicationKey apiApplicationKey = null; + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } catch (MetadataManagementException e) { String msg = "Error occurred while getting meta data for meta key: " + applicationName; log.error(msg, e); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index fc90c14463..0eda468baa 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -37,6 +37,9 @@ public interface ConsumerRESTAPIServices { Application createApplication(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; @@ -49,7 +52,10 @@ public interface ConsumerRESTAPIServices { Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application) + ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application, KeyManager keyManager) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index fe341bc416..a4594d6678 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -179,6 +179,46 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + + Request request = new Request.Builder() + .url(deleteScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()) + .delete() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return deleteApplication(refreshedApiApplicationInfo, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { @@ -361,20 +401,20 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, KeyManager keyManager) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + application.getApplicationId() + "/generate-keys"; String keyInfo = "{\n" + " \"keyType\": \"PRODUCTION\",\n" + - " \"keyManager\": \"Resident Key Manager\",\n" + + " \"keyManager\": \""+ keyManager.getName() +"\",\n" + " \"grantTypesToBeSupported\": [\n" + " \"password\",\n" + " \"client_credentials\"\n" + " ],\n" + - " \"callbackUrl\": \"http://sample.com/callback/url\",\n" + + " \"callbackUrl\": \"\",\n" + " \"scopes\": [\n" + " \"am_application_scope\",\n" + " \"default\"\n" + @@ -402,7 +442,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, application); + return generateApplicationKeys(refreshedApiApplicationKey, application, keyManager); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -418,6 +458,46 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; + + Request request = new Request.Builder() + .url(getKeyDetails) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getKeyDetails(refreshedApiApplicationKey, applicationId, keyMapId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { From 1edaa8a2a506f3d1ed0382414c2bda7ea8b5c33a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 13 Jun 2023 08:48:22 +0530 Subject: [PATCH 022/157] Improve API key generating method --- .../APIManagementProviderServiceImpl.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 7ab72f71b3..293faeabbb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -173,7 +173,15 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager keyManager = consumerRESTAPIServices.getAllKeyManagers(applicationInfo)[0]; + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + throw new APIManagerException(msg); + } ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); @@ -199,21 +207,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { - String msg = - "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + String msg = "Couldn't find application key data from meta data mgt service. Meta key: " + + applicationName; log.error(msg); throw new APIManagerException(msg); } String[] metaValues = metaData.getMetaValue().split(":"); if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName; + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); log.error(msg); throw new APIManagerException(msg); } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); - ApiApplicationKey apiApplicationKey = null; + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); return apiApplicationKey; @@ -222,7 +231,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg, e); throw new APIManagerException(msg, e); } - return null; } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; From d40dccc240ed908ba8d27ba07a94374272cbe045 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 14 Jun 2023 12:37:10 +0530 Subject: [PATCH 023/157] Add improvements to token generation for devices --- .../extension/service/KeyMgtServiceImpl.java | 1 + .../impl/DeviceManagementServiceImpl.java | 22 +++++++++++++++++++ .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 ++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 936011e90f..a9dd182ec2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -312,6 +312,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while creating response object */ private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod) throws KeyMgtException { + //todo modify this to pass the password as well String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 579f09c606..9bef3e44fc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -798,6 +798,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here + + try { +// DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, +// "client_credentials", null, new String[] {"device_management"}, false, validityTime); +// deviceConfig.setClientId(dcrResponse.getClientId()); +// deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. + getOSGiService(JWTClientManagerService.class, null); + JWTClient jwtClient = jwtClientManagerService.getJWTClient(); +// AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(), +// apiApplicationKey.getConsumerSecret(), +// username, Constants.ApplicationInstall.SUBSCRIPTION_SCOPE); + } catch (JWTClientException e) { + String msg = "Error while generating an OAuth token for user " + username; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + + //todo call REST APIs DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, "client_credentials", null, new String[] {"device_management"}, false, validityTime); deviceConfig.setClientId(dcrResponse.getClientId()); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 1073737ef5..7bba263529 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; @@ -154,6 +155,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; + private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -387,6 +389,25 @@ public class DeviceMgtAPIUtils { return otpManagementService; } + /** + * Initializing and accessing method for APIM Consumer REST API. + * + * @return ConsumerRESTAPIServices instance + * @throws IllegalStateException if ConsumerRESTAPIServices cannot be initialized + */ + public static synchronized ConsumerRESTAPIServices getConsumerRESTAPIServices() { + if (consumerRESTAPIServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + consumerRESTAPIServices = (ConsumerRESTAPIServices) ctx.getOSGiService(ConsumerRESTAPIServices.class, null); + if (consumerRESTAPIServices == null) { + String msg = "Consumer Rest API service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return consumerRESTAPIServices; + } + public static RegistryService getRegistryService() { RegistryService registryService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From 7dfcc0e33cb346a36e537d95d6b36d7c33914663 Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 15 Jun 2023 02:50:59 +0000 Subject: [PATCH 024/157] Get token separately for REST calls Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../APIManagementProviderServiceImpl.java | 18 +- .../rest/api/ConsumerRESTAPIServices.java | 25 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 457 +++++++++++------- .../impl/DeviceManagementServiceImpl.java | 14 + 4 files changed, 331 insertions(+), 183 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 293faeabbb..2996174734 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -138,7 +138,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, null, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -147,21 +147,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); + consumerRESTAPIServices.getAllApplications(applicationInfo, null, 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); + application = consumerRESTAPIServices.createApplication(applicationInfo, null, application); addSubscriptions(application, uniqueApiList, applicationInfo); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, null, + application.getApplicationId()); Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); addSubscriptions(application, uniqueApiList, applicationInfo); } else { @@ -173,7 +174,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo, null); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -182,7 +183,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, null, + application.getApplicationId(), keyManager.getName(), keyType, validityTime); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -221,7 +223,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, null, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -273,7 +275,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); } /** diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 0eda468baa..df81bff172 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -28,36 +28,39 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) + Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(ApiApplicationInfo applicationInfo, String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(ApiApplicationInfo applicationInfo, Application application) + Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParam, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, + Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application, KeyManager keyManager) + ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, + String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index a4594d6678..dc17ff623f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -50,16 +50,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; - Request request = new Request.Builder() - .url(getAllApplicationsUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllApplicationsUrl); + if (!(applicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + applicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -67,13 +73,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllApplications(refreshedApiApplicationInfo, appName); + if (!(applicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllApplications(refreshedApiApplicationInfo, null, appName); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -90,29 +102,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; - Request request = new Request.Builder() - .url(getAllApplicationsUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + + Request.Builder builder = new Request.Builder(); + builder.url(getDetailsOfAPPUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -129,7 +153,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; @@ -143,27 +167,38 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"attributes\": " + application.getAttributes().toString() + ",\n" + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + "}"; - RequestBody requestBody = RequestBody.create(JSON, applicationInfo); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createApplication(refreshedApiApplicationInfo, application); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createApplication(refreshedApiApplicationInfo, null, application); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -180,30 +215,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; - Request request = new Request.Builder() - .url(deleteScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .delete() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(deleteScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.delete(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), Application.class); + return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return deleteApplication(refreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return deleteApplication(refreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -220,16 +266,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -237,13 +289,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllSubscriptions(rehreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -260,20 +318,25 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParams, + public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; + StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { - getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); + getAPIsURL.append(Constants.AMPERSAND).append(query.getKey()).append(Constants.EQUAL).append(query.getValue()); } Request.Builder builder = new Request.Builder(); - builder.url(getAPIsURL); - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()); + builder.url(getAPIsURL.toString()); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -286,13 +349,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllApis(rehreshedApiApplicationInfo, queryParams, headerParams); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -309,10 +378,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(ApiApplicationInfo applicationInfo, Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; + String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + @@ -322,25 +391,37 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { "}"; RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(createSubscriptionUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createSubscription(refreshedApiApplicationInfo, subscriptions); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createSubscription(refreshedApiApplicationInfo, null, subscriptions); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -357,20 +438,26 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; + String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); - RequestBody requestBody = RequestBody.create(JSON, subscriptionsList); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(createSubscriptionsUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -378,13 +465,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createSubscriptions(refreshedApiApplicationInfo, subscriptions); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -401,15 +494,16 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, KeyManager keyManager) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, + String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + - application.getApplicationId() + "/generate-keys"; + String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + + applicationId + "/generate-keys"; String keyInfo = "{\n" + - " \"keyType\": \"PRODUCTION\",\n" + - " \"keyManager\": \""+ keyManager.getName() +"\",\n" + + " \"keyType\": \"" + keyType + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + " \"grantTypesToBeSupported\": [\n" + " \"password\",\n" + " \"client_credentials\"\n" + @@ -419,30 +513,42 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"am_application_scope\",\n" + " \"default\"\n" + " ],\n" + - " \"validityTime\": 3600,\n" + + " \"validityTime\": " + validityTime + ",\n" + " \"additionalProperties\": {}\n" + "}"; RequestBody requestBody = RequestBody.create(JSON, keyInfo); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(generateApplicationKeysUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, application, keyManager); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -459,30 +565,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; - Request request = new Request.Builder() - .url(getKeyDetails) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(getKeyDetails); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getKeyDetails(refreshedApiApplicationKey, applicationId, keyMapId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -499,16 +616,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; - Request request = new Request.Builder() - .url(getAllKeyManagersUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllKeyManagersUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -516,13 +639,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllKeyManagers(refreshedApiApplicationInfo); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllKeyManagers(refreshedApiApplicationInfo, null); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 9bef3e44fc..e4ab0647ef 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; +import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; +import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -825,6 +829,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { deviceConfig.setClientId(dcrResponse.getClientId()); deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, + new String[] {"device_management"}, null, username, false, String.valueOf(validityTime), null); + + deviceConfig.setClientId(apiApplicationKey.getConsumerKey()); + deviceConfig.setClientSecret(apiApplicationKey.getConsumerSecret()); + StringBuilder scopes = new StringBuilder("device:" + type.replace(" ", "") + ":" + id); for (String topic : mqttEventTopicStructure) { if (topic.contains("${deviceId}")) { @@ -871,6 +882,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (APIManagerException e) { + String msg = "Error while calling rest Call for application key generation"; + log.error(msg, e); } return Response.status(Response.Status.OK).entity(deviceConfig).build(); From 43ef801ac3219df6de87cae66d6bd86a5c8448f8 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 15 Jun 2023 09:48:36 +0530 Subject: [PATCH 025/157] Improvements in consumer rest apis --- .../rest/api/ConsumerRESTAPIServicesImpl.java | 120 +++++++++++------- 1 file changed, 73 insertions(+), 47 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index dc17ff623f..076d735112 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -50,16 +50,17 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) + public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); builder.url(getAllApplicationsUrl); - if (!(applicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()); + + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + accessToken); @@ -73,18 +74,18 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(applicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count return getAllApplications(refreshedApiApplicationInfo, null, appName); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -105,11 +106,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getDetailsOfAPPUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -124,7 +126,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -133,9 +135,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -156,6 +158,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; String applicationInfo = "{\n" + @@ -171,7 +174,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -186,7 +189,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -195,9 +198,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createApplication(refreshedApiApplicationInfo, null, application); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -218,11 +221,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(deleteScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -237,7 +241,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -246,9 +250,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return deleteApplication(refreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -269,11 +273,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -289,7 +294,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -298,9 +303,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -322,6 +327,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -330,7 +336,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL.toString()); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -349,7 +355,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -358,9 +364,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -381,6 +387,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + @@ -394,7 +401,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -409,7 +416,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -418,9 +425,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createSubscription(refreshedApiApplicationInfo, null, subscriptions); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -442,6 +449,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -449,7 +457,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionsUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -465,7 +473,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -474,9 +482,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -498,6 +506,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; @@ -521,7 +530,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(generateApplicationKeysUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -536,7 +545,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -545,9 +554,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -568,11 +577,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -587,7 +597,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -596,9 +606,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -619,11 +629,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); builder.url(getAllKeyManagersUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -639,7 +650,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -677,4 +688,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { return applicationInfo; } + + private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { + + boolean token; + if ((!(accessToken == null) && apiApplicationInfo == null)) { + token = true; + } else if (!(apiApplicationInfo == null) && accessToken == null) { + token = false; + } else { + String msg = "Null access token or Rest Application info"; + log.error(msg); + throw new BadRequestException(msg); + } + return token; + } } From bfaeb1778f12b2f09efa82fd9dee806409c0d685 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 16 Jun 2023 08:03:11 +0530 Subject: [PATCH 026/157] Add JWT support --- .../APIManagementProviderService.java | 5 + .../APIManagementProviderServiceImpl.java | 149 ++++++++++++++++++ .../extension/api/KeyManagerServiceImpl.java | 4 +- .../extension/service/KeyMgtService.java | 3 +- .../extension/service/KeyMgtServiceImpl.java | 53 +++++-- .../impl/DeviceManagementServiceImpl.java | 42 ++--- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++ 7 files changed, 243 insertions(+), 34 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 51ac50cf08..1e561ae465 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -55,6 +55,11 @@ public interface APIManagementProviderService { boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException; + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException; + /** * Remove APIM Application. */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 2996174734..11953fa3dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -114,6 +114,138 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + try { + List uniqueApiList = new ArrayList<>(); + + Map headerParams = new HashMap<>(); + if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); + } + + for (String tag : tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(null, accessToken, queryParams, headerParams); + + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, accessToken, 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(null, accessToken, application); + addSubscriptions(application, uniqueApiList, accessToken); + } else { + if (applications.length == 1) { + Optional applicationOpt = + Arrays.stream(applications).findFirst(); + application = applicationOpt.get(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, accessToken, + application.getApplicationId()); + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + addSubscriptions(application, uniqueApiList, accessToken); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + } + + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); + if (isNewApplication) { + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(null, accessToken); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + throw new APIManagerException(msg); + } + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(null, accessToken, + application.getApplicationId(), keyManager.getName(), keyType, validityTime); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = "Couldn't find application key data from meta data mgt service. Meta key: " + + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); + log.error(msg); + throw new APIManagerException(msg); + } + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(null, accessToken, applicationId, + keyMappingId); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + } catch (APIServicesException e) { + String msg = "Error occurred while processing the response of APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (BadRequestException e) { + String msg = "Provided incorrect payload when invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (UnexpectedResponseException e) { + String msg = "Error occurred while invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -278,6 +410,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); } + private void addSubscriptions( + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, + List apiInfos, String accessToken) + throws BadRequestException, UnexpectedResponseException, APIServicesException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + List subscriptionList = new ArrayList<>(); + apiInfos.forEach(apiInfo -> { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptionList.add(subscription); + }); + consumerRESTAPIServices.createSubscriptions(null, accessToken, subscriptionList); + } + /** * {@inheritDoc} */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index dbfee32906..8a5c49e4d6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtExcepti import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnAuthorizedException; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -47,7 +48,8 @@ public class KeyManagerServiceImpl implements KeyManagerService { 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()); + dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), + dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword()); return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build(); } catch (KeyMgtException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java index f08f92d8c7..92015842ba 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java @@ -35,11 +35,12 @@ public interface KeyMgtService { * @param callBackUrl callback url of the application * @param tags api tags for api subscription of the application * @param isSaasApp if the application is a saas app + * @param password Password of the owner * @return @{@link DCRResponse} DCR Response object with client credentials * @throws KeyMgtException if any error occurs during DCR process */ DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException; + String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException; /*** * This method will handle the access token requests diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index a9dd182ec2..9de536da5e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -19,9 +19,13 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtDataHolder; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; @@ -62,7 +66,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { String subTenantUserUsername, subTenantUserPassword, keyManagerName, msg = null; public DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException { + String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException { if (owner == null) { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -90,13 +94,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { kmConfig = getKeyManagerConfig(); if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) { - OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, validityPeriod); + OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, + validityPeriod, kmConfig.getAdminPassword()); return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret()); } else { // super-tenant admin dcr and token generation OAuthApplication superTenantOauthApp = createOauthApplication( KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT, - kmConfig.getAdminUsername(), null, validityPeriod); + kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword()); String superAdminAccessToken = createAccessToken(superTenantOauthApp); // create new key manager for the tenant, under super-tenant space @@ -119,7 +124,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { // 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, password); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id @@ -311,14 +316,16 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @return @{@link OAuthApplication} OAuth application object * @throws KeyMgtException if any error occurs while creating response object */ - private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod) throws KeyMgtException { + private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, + int validityPeriod, String ownerPassword) throws KeyMgtException { //todo modify this to pass the password as well - String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod); + String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, ownerPassword); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT; String username, password; + //todo why can't we use owner details here? if (KeyMgtConstants.SUPER_TENANT.equals(MultitenantUtils.getTenantDomain(owner))) { username = kmConfig.getAdminUsername(); password = kmConfig.getAdminPassword(); @@ -327,6 +334,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { password = subTenantUserPassword; } + //todo why can't we use owner details for authentication Request request = new Request.Builder() .url(dcrEndpoint) .addHeader(KeyMgtConstants.AUTHORIZATION_HEADER, Credentials.basic(username, password)) @@ -420,27 +428,46 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @return @{@link Application} Application object * @throws KeyMgtException if any error occurs while retrieving the application */ - private Application getApplication(String applicationName, String owner) throws KeyMgtException { + private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { try { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); - APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); +// APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); + + ConsumerRESTAPIServices consumerRESTAPIServices = + KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); + //todo map Application and return //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" - } catch (APIManagementException e) { - msg = "Error while trying to retrieve the application"; - log.error(msg); - throw new KeyMgtException(msg); + } + +// catch (APIManagementException e) { +// msg = "Error while trying to retrieve the application"; +// log.error(msg); +// throw new KeyMgtException(msg); +// } + + catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { + e.printStackTrace(); + throw new KeyMgtException(""); + } catch (UnexpectedResponseException e) { + throw new KeyMgtException(""); + } catch (APIServicesException e) { + throw new KeyMgtException(""); } } - private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod) { + private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod, + String password) { JSONObject jsonObject = new JSONObject(); jsonObject.put("applicationName", clientName); jsonObject.put("username", owner); jsonObject.put("tags", tags); jsonObject.put("validityPeriod", validityPeriod); + jsonObject.put("password", password); return jsonObject.toString(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index e4ab0647ef..abcdbacc93 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -802,37 +802,40 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here - + ApiApplicationKey apiApplicationKey = null; try { -// DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, -// "client_credentials", null, new String[] {"device_management"}, false, validityTime); -// deviceConfig.setClientId(dcrResponse.getClientId()); -// deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. getOSGiService(JWTClientManagerService.class, null); JWTClient jwtClient = jwtClientManagerService.getJWTClient(); -// AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(), -// apiApplicationKey.getConsumerSecret(), -// username, Constants.ApplicationInstall.SUBSCRIPTION_SCOPE); + AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), + adminDCRResponse.getClientSecret(), + username, "appm:subscribe"); + + APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); + apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, + new String[] {"device_management"}, null, false, String.valueOf(validityTime), + accessTokenInfo.getAccessToken()); + } catch (JWTClientException e) { - String msg = "Error while generating an OAuth token for user " + username; + String msg = "Error while generating an application tokens for Tenant Admin."; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (UserStoreException e) { + String msg = "Error while getting user credentials."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } //todo call REST APIs - DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, - "client_credentials", null, new String[] {"device_management"}, false, validityTime); - deviceConfig.setClientId(dcrResponse.getClientId()); - deviceConfig.setClientSecret(dcrResponse.getClientSecret()); - - APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, username, false, String.valueOf(validityTime), null); - deviceConfig.setClientId(apiApplicationKey.getConsumerKey()); deviceConfig.setClientSecret(apiApplicationKey.getConsumerSecret()); @@ -852,7 +855,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { // add scopes for update operation /tenantDomain/deviceType/deviceId/update/operation scopes.append(" perm:topic:pub:" + tenantDomain + ":" + type + ":" + id + ":update:operation"); - TokenRequest tokenRequest = new TokenRequest(dcrResponse.getClientId(), dcrResponse.getClientSecret(), + TokenRequest tokenRequest = new TokenRequest(apiApplicationKey.getConsumerKey(), + apiApplicationKey.getConsumerSecret(), null, scopes.toString(), "client_credentials", null, null, null, null, validityTime); TokenResponse tokenResponse = keyMgtService.generateAccessToken(tokenRequest); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 7bba263529..a297bffd48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -156,6 +157,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; + private static volatile APIManagementProviderService apiManagementProviderService; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -408,6 +410,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for API management Provider Service. + * + * @return APIManagementProviderService instance + * @throws IllegalStateException if APIManagementProviderService cannot be initialized + */ + public static synchronized APIManagementProviderService getAPIManagementService() { + if (apiManagementProviderService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiManagementProviderService = (APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null); + if (apiManagementProviderService == null) { + String msg = "API Management Provider service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiManagementProviderService; + } + public static RegistryService getRegistryService() { RegistryService registryService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From da1485d04f514d38ebd840a7a5e869f11762e4cb Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 16 Jun 2023 11:58:52 +0530 Subject: [PATCH 027/157] Fix getApplication method with Rest api calls --- .../api/bean/APIMConsumer/Application.java | 9 +++-- .../extension/service/KeyMgtServiceImpl.java | 39 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java index 50fb64147d..d56de0331d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Application.java @@ -18,9 +18,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; +import org.wso2.carbon.apimgt.api.model.APIKey; import java.util.List; +import java.util.Map; /** * This class represents the Consumer Application Information. @@ -36,7 +37,7 @@ public class Application { private List groups; private int subscriptionCount; private List keys; - private JSONObject attributes; + private Map attributes; private List subscriptionScopes; private String owner; private boolean hashEnabled; @@ -113,11 +114,11 @@ public class Application { this.keys = keys; } - public JSONObject getAttributes() { + public Map getAttributes() { return attributes; } - public void setAttributes(JSONObject attributes) { + public void setAttributes(Map attributes) { this.attributes = attributes; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 9de536da5e..36b40846f1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONObject; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.Application; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; @@ -429,30 +430,40 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while retrieving the application */ private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { - try { - APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); -// APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); + try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); - //todo map Application and return - //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" - } + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; + if (applications.length == 1) { + applicationFromRestCall = applications[0]; + } else { + String msg = + "Found invalid number of applications. No of applications found from the APIM: " + applications.length; + throw new KeyMgtException(msg); + } -// catch (APIManagementException e) { -// msg = "Error while trying to retrieve the application"; -// log.error(msg); -// throw new KeyMgtException(msg); -// } + Application application = null; + application.setUUID(applicationFromRestCall.getApplicationId()); + application.setName(applicationFromRestCall.getName()); + application.setDescription(applicationFromRestCall.getDescription()); + application.setApplicationAttributes(applicationFromRestCall.getAttributes()); + application.setTokenType(applicationFromRestCall.getTokenType()); + application.setStatus(applicationFromRestCall.getStatus()); + application.setSubscriptionCount(applicationFromRestCall.getSubscriptionCount()); + application.setOwner(applicationFromRestCall.getOwner()); + application.setIsBlackListed(applicationFromRestCall.isHashEnabled()); + return application; + } catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { e.printStackTrace(); - throw new KeyMgtException(""); + msg = "Error while trying to retrieve the application"; + log.error(msg); + throw new KeyMgtException(msg); } catch (UnexpectedResponseException e) { throw new KeyMgtException(""); } catch (APIServicesException e) { From cb2fb990e700b73fcad7760ae482d14edeac800e Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Mon, 19 Jun 2023 12:00:20 +0000 Subject: [PATCH 028/157] Get ApiApplicationInfo and access token into single object Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../APIManagementProviderServiceImpl.java | 190 ++++-------------- .../rest/api/ConsumerRESTAPIServices.java | 27 ++- .../rest/api/ConsumerRESTAPIServicesImpl.java | 144 ++++++++----- .../extension/rest/api/dto/TokenInfo.java | 44 ++++ .../extension/service/KeyMgtServiceImpl.java | 6 +- 5 files changed, 188 insertions(+), 223 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 11953fa3dc..3174473b70 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManag 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.dto.TokenInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -119,131 +120,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String keyType, boolean isAllowedAllDomains, String validityTime, String accessToken) throws APIManagerException { - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - try { - List uniqueApiList = new ArrayList<>(); - - Map headerParams = new HashMap<>(); - if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - - for (String tag : tags) { - Map queryParams = new HashMap<>(); - queryParams.put("tag", tag); - - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(null, accessToken, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); - } + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(null); + tokenInfo.setAccessToken(accessToken); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, accessToken, 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(null, accessToken, application); - addSubscriptions(application, uniqueApiList, accessToken); - } else { - if (applications.length == 1) { - Optional applicationOpt = - Arrays.stream(applications).findFirst(); - application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, accessToken, - application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, accessToken); - } else { - String msg = "Found more than one application for application name: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - } - - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(null, accessToken); - KeyManager keyManager; - if (keyManagers.length == 1) { - keyManager = keyManagers[0]; - } else { - String msg = - "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; - throw new APIManagerException(msg); - } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(null, accessToken, - application.getApplicationId(), keyManager.getName(), keyType, validityTime); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { - Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); - if (metaData == null) { - String msg = "Couldn't find application key data from meta data mgt service. Meta key: " - + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " - + metaData.getMetaValue(); - log.error(msg); - throw new APIManagerException(msg); - } - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(null, accessToken, applicationId, - keyMappingId); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } - } catch (APIServicesException e) { - String msg = "Error occurred while processing the response of APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (BadRequestException e) { - String msg = "Provided incorrect payload when invoking APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (UnexpectedResponseException e) { - String msg = "Error occurred while invoking APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } + return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, null, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -254,10 +135,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throws APIManagerException { + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); + + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(applicationInfo); + tokenInfo.setAccessToken(null); + + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,isAllowedAllDomains, validityTime, tokenInfo); + } + + private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, TokenInfo tokenInfo) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -270,7 +164,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, null, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -279,24 +173,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(applicationInfo, null, applicationName); + consumerRESTAPIServices.getAllApplications(tokenInfo, 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, null, application); - addSubscriptions(application, uniqueApiList, applicationInfo); + application = consumerRESTAPIServices.createApplication(tokenInfo, application); + addSubscriptions(application, uniqueApiList, tokenInfo); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, null, - application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, applicationInfo); + addSubscriptions(application, uniqueApiList, tokenInfo); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -306,7 +199,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo, null); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -315,8 +208,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, null, - application.getApplicationId(), keyManager.getName(), keyType, validityTime); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), keyType, validityTime); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -355,7 +248,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, null, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -387,7 +280,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe * * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} * @param apiInfos {@link List} - * @param apiApplicationInfo {@link ApiApplicationInfo} + * @param tokenInfo {@link TokenInfo} * * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. @@ -395,25 +288,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, ApiApplicationInfo apiApplicationInfo) + List apiInfos, TokenInfo tokenInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - List subscriptionList = new ArrayList<>(); - apiInfos.forEach(apiInfo -> { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptionList.add(subscription); - }); - consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); - } - private void addSubscriptions( - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, String accessToken) - throws BadRequestException, UnexpectedResponseException, APIServicesException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -424,7 +301,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(null, accessToken, subscriptionList); + + consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } /** @@ -766,7 +644,7 @@ Otherwise, Generate Application Keys and return them throw new APIManagerException(errorMsg, e); } - ApiApplicationInfo applicationInfo = null; + ApiApplicationInfo applicationInfo = new ApiApplicationInfo(); applicationInfo.setClientId(apiApplicationKey.getClientId()); applicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); applicationInfo.setAccess_token(accessTokenInfo.getAccess_token()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index df81bff172..5ed98034e2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -19,7 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -28,39 +28,36 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) + Application[] getAllApplications(TokenInfo tokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) + Application createApplication(TokenInfo tokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, - Map headerParams) + APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) + Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, - List subscriptions) + Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, - String keyManager, String validityTime, String keyType) + ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) + KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 076d735112..81ed4cd4e3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -50,10 +51,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String accessToken, String appName) + public Application[] getAllApplications(TokenInfo tokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); @@ -63,7 +65,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -81,7 +83,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApplications(refreshedApiApplicationInfo, null, appName); + tokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + tokenInfo.setAccessToken(null); + return getAllApplications(tokenInfo, appName); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -103,10 +107,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); @@ -116,7 +121,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -133,7 +138,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getDetailsOfAnApplication(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -155,10 +163,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) + public Application createApplication(TokenInfo tokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; String applicationInfo = "{\n" + @@ -179,7 +188,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -196,7 +205,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createApplication(refreshedApiApplicationInfo, null, application); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createApplication(refreshedTokenInfo, application); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -218,10 +230,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); @@ -231,7 +244,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.delete(); Request request = builder.build(); @@ -248,7 +261,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return deleteApplication(refreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return deleteApplication(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -270,10 +286,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request.Builder builder = new Request.Builder(); @@ -283,7 +300,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -299,9 +316,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllSubscriptions(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -323,11 +343,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, - Map headerParams) + public APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -341,7 +361,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); @@ -360,9 +380,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllApis(refreshedTokenInfo, queryParams, headerParams); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -384,10 +407,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) + public Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + @@ -406,7 +430,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -423,7 +447,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscription(refreshedApiApplicationInfo, null, subscriptions); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createSubscription(refreshedTokenInfo, subscriptions); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -445,11 +472,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, - List subscriptions) + public Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -462,7 +489,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -480,7 +507,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createSubscriptions(refreshedTokenInfo, subscriptions); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -502,11 +532,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, - String keyManager, String validityTime, String keyType) + public ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, + String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; @@ -535,7 +566,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -550,9 +581,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return generateApplicationKeys(refreshedTokenInfo, applicationId, keyManager, validityTime, keyType); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -574,10 +608,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); @@ -587,7 +622,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -602,9 +637,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getKeyDetails(refreshedTokenInfo, applicationId, keyMapId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -626,10 +664,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) + public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); @@ -639,7 +678,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -657,7 +696,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllKeyManagers(refreshedApiApplicationInfo, null); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllKeyManagers(refreshedTokenInfo); } else { String msg = "Invalid or null access token"; log.error(msg); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java new file mode 100644 index 0000000000..72100c982b --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto; + +/** + * This holds the API application information and access token for REST APIS cals. + */ +public class TokenInfo { + + private ApiApplicationInfo apiApplicationInfo; + private String accessToken; + + public ApiApplicationInfo getApiApplicationInfo() { + return apiApplicationInfo; + } + + public void setApiApplicationInfo(ApiApplicationInfo apiApplicationInfo) { + this.apiApplicationInfo = apiApplicationInfo; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 36b40846f1..7629403290 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; @@ -431,11 +432,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { */ private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(null); + tokenInfo.setAccessToken(accessToken); try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); + consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; if (applications.length == 1) { From 342e201c4cc61057ff7191a560303b93f2962e6a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 20 Jun 2023 09:39:49 +0530 Subject: [PATCH 029/157] Add improvements to APIM application creating logic --- .../APIManagementProviderService.java | 40 +- .../APIManagementProviderServiceImpl.java | 670 +++++++++--------- .../extension/service/KeyMgtServiceImpl.java | 44 +- .../impl/DeviceManagementServiceImpl.java | 2 +- .../client/extension/util/JWTClientUtil.java | 6 +- 5 files changed, 382 insertions(+), 380 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 1e561ae465..14449cdf09 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -33,22 +33,22 @@ public interface APIManagementProviderService { */ boolean isTierLoaded(); - /** - * Generate and retreive application keys. if the application does exist then - * create it and subscribe to apis that are grouped with the tags. - * - * @param apiApplicationName name of the application. - * @param tags tags of the apis that application needs to be subscribed. - * @param keyType of the application. - * @param username to whom the application is created - * @param isAllowedAllDomains application is allowed to all the tenants - * @param validityTime validity period of the application - * @return consumerkey and secrete of the created application. - * @throws APIManagerException - */ - ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains, - String validityTime) throws APIManagerException; +// /** +// * Generate and retreive application keys. if the application does exist then +// * create it and subscribe to apis that are grouped with the tags. +// * +// * @param apiApplicationName name of the application. +// * @param tags tags of the apis that application needs to be subscribed. +// * @param keyType of the application. +// * @param username to whom the application is created +// * @param isAllowedAllDomains application is allowed to all the tenants +// * @param validityTime validity period of the application +// * @return consumerkey and secrete of the created application. +// * @throws APIManagerException +// */ +// ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], +// String keyType, String username, boolean isAllowedAllDomains, +// String validityTime) throws APIManagerException; ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -60,10 +60,10 @@ public interface APIManagementProviderService { boolean isAllowedAllDomains, String validityTime, String accessToken) throws APIManagerException; - /** - * Remove APIM Application. - */ - void removeAPIApplication(String applicationName, String username) throws APIManagerException; +// /** +// * Remove APIM Application. +// */ +// void removeAPIApplication(String applicationName, String username) throws APIManagerException; /** * To get access token for given scopes and for the given validity period diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3174473b70..730bb53c16 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -54,7 +54,6 @@ import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; -import org.wso2.carbon.apimgt.api.model.Application; import org.wso2.carbon.apimgt.api.model.SubscribedAPI; import org.wso2.carbon.apimgt.api.model.Subscriber; import org.wso2.carbon.apimgt.impl.APIAdminImpl; @@ -97,23 +96,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return false; } - @Override - public void removeAPIApplication(String applicationName, String username) throws APIManagerException { - - try { - APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" - if (application != null) { - // todo:apim - apiConsumer.removeApplication(application, username); - //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to remove api application : " + applicationName, e); - } - - - } +// @Override +// public void removeAPIApplication(String applicationName, String username) throws APIManagerException { +// +// try { +// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); +// Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +//// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" +// if (application != null) { +// // todo:apim - apiConsumer.removeApplication(application, username); +// //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" +// } +// } catch (APIManagementException e) { +// throw new APIManagerException("Failed to remove api application : " + applicationName, e); +// } +// +// +// } @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, @@ -123,8 +122,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); tokenInfo.setAccessToken(accessToken); - - return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, null, isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -136,18 +134,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); - TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(applicationInfo); tokenInfo.setAccessToken(null); - - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType,isAllowedAllDomains, validityTime, tokenInfo); } private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo) throws APIManagerException { + String keyType, + boolean isAllowedAllDomains, + String validityTime, TokenInfo tokenInfo) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -175,88 +171,45 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - boolean isNewApplication = false; + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); 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(tokenInfo, application); - addSubscriptions(application, uniqueApiList, tokenInfo); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, tokenInfo); - } else { - String msg = "Found more than one application for application name: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - } - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); - KeyManager keyManager; - if (keyManagers.length == 1) { - keyManager = keyManagers[0]; - } else { - String msg = - "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; - throw new APIManagerException(msg); - } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), keyType, validityTime); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { - String msg = "Couldn't find application key data from meta data mgt service. Meta key: " - + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " - + metaData.getMetaValue(); - log.error(msg); - throw new APIManagerException(msg); + // Todo add a comment + consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + } else { + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + addSubscriptions(application, uniqueApiList, tokenInfo); + + String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); + log.error(msg); + throw new APIManagerException(msg); + } + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); + + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); } } } catch (APIServicesException e) { @@ -271,6 +224,71 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String msg = "Error occurred while invoking APIM REST endpoints."; log.error(msg, e); throw new APIManagerException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + + + private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, + TokenInfo tokenInfo, String keyType, String validityTime) 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(); + application.setName(applicationName); + + try { + application = consumerRESTAPIServices.createApplication(tokenInfo, application); + addSubscriptions(application, uniqueApiList, tokenInfo); + + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + log.error(msg); + throw new APIManagerException(msg); + } + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), keyType, validityTime); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = + "Since meta key:" + applicationName + " already exists, meta data creating process " + + "failed."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (BadRequestException e) { + String msg = "Provided incorrect payload when invoking APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (UnexpectedResponseException e) { + String msg = "Error occurred while invoking APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (APIServicesException e) { + String msg = "Error occurred while processing the response of APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); } } @@ -305,234 +323,234 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } - /** - * {@inheritDoc} - */ - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains, String validityTime) - throws APIManagerException { - - -/* - -todo - Modify generateAndRetrieveApplicationKeys - -Check the existence of the API application. - -if Application is not exists - Create the Application - -If super tenants - Get set of tagged APIs -If the tenant domain is not super tenant - Get set of tagged APIs from super tenant space - -If new Application - Subscribed to tagged APIs -Else - Get all subscribed APIs of application - Filter out APIs and subscribed to APIs which can be subscribed - Filter -> Use set of tagged APis - Remove already subscribed APIs from the set - Subscribed to remaining APIs - -Get Application keys from application - If API keys are there return API keys - -Otherwise, Generate Application Keys and return them - - */ - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - if (StringUtils.isEmpty(username)) { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; - } - try { - APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); - int applicationId = 0; - Subscriber subscriber = null; - if (application == null) { - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - if (subscriber == null) { - // create subscriber - // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - } - //create application - application = new Application(applicationName, subscriber); - application.setTier(ApiApplicationConstants.DEFAULT_TIER); - application.setGroupId(""); - application.setTokenType("OAUTH"); - // todo:resolve:apim - apiConsumer.addApplication(application, username); - application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); - } else { - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - } - - Set subscribedAPIs = - null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); - - log.info("Already subscribed API count: " + subscribedAPIs.size()); - - // subscribe to apis. - APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; - if (tags != null && tags.length > 0) { - for (String tag : tags) { - boolean startedTenantFlow = false; - Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); - - /** - * From APIM 4.0.0, APIs published in the super tenant can only be listed by - * APIConsumer, only if the APIConsumer belongs to the super tenant. So we - * are starting tenant flow if we are not already in super tenant(child - * tenant starting to create OAuth app). - */ - if (apisWithTag == null || apisWithTag.size() == 0) { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, - true); - - try { - String superAdminUsername = PrivilegedCarbonContext - .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); - apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); - } catch (UserStoreException e) { - throw new APIManagerException("Failed to create api application for " + - "tenant: " + tenantDomain + - ". Caused by to inability to get super tenant username", e); - } - - apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - startedTenantFlow = true; - } - - Set apiTypeWrapperList = new HashSet<>(); - if (apisWithTag != null && apisWithTag.size() > 0) { - Set tempApiIds = new HashSet<>(); - for (API apiInfo : apisWithTag) { - String id = apiInfo.getId().getProviderName().replace("@", "-AT-") - + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); - boolean subscriptionExist = false; - if (subscribedAPIs.size() > 0) { - for (SubscribedAPI subscribedAPI : subscribedAPIs) { - // todo:resolve:apim -// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { -// subscriptionExist = true; -// break; -// } - } - } - if (!subscriptionExist && !tempApiIds.contains(id)) { - ApiTypeWrapper apiTypeWrapper; - if (startedTenantFlow) { - /** - * This mean APIs were not found in the child tenant, so all - * calls to get info about APIs need to be to super tenant. - */ - apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( - apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - } else { - /** - * Ideally, in all usecases of IoT server, tenant domain here - * will be carbon.super. This block is kept to make sure in - * the future, if there are some APIs published to a specific - * tenant only. - */ - apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( - apiInfo.getUuid(), tenantDomain); - } - apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); - apiTypeWrapperList.add(apiTypeWrapper); - tempApiIds.add(id); - } - } - if (startedTenantFlow) { - PrivilegedCarbonContext.endTenantFlow(); - } - - /** This is done in a redundant loop instead of doing in the same loop - * that populates apiTypeWrapperList because in a tenanted scenario, - * apiConsumerAPIPublishedTenant will belong to super tenant. So super - * tenant flow need to end before starting subscription to avoid adding - * subscriptions inside super tenant when we are trying to create an - * Oauth app for a child tenant. - */ - for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { - // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); - } - } - } - } - //end of subscription - - List applicationKeys = application.getKeys(); - if (applicationKeys != null) { - for (APIKey applicationKey : applicationKeys) { - if (keyType.equals(applicationKey.getType())) { - if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } - } - } - } - - List allowedDomains = new ArrayList<>(); - if (isAllowedAllDomains) { - allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); - } else { - allowedDomains.add(APIManagerUtil.getTenantDomain()); - } - - APIAdmin apiAdmin = new APIAdminImpl(); - String keyManagerId = null; - try { - List keyManagerConfigurations = null; // todo:resolve:apim - - // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); - if (keyManagerConfigurations != null) { - for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { - keyManagerId = keyManagerConfigurationDTO.getUuid(); - } - } - String applicationAccessTokenExpiryTime = "N/A"; - if (!StringUtils.isEmpty(validityTime)) { - applicationAccessTokenExpiryTime = validityTime; - } - String jsonString = "{\"grant_types\":\"refresh_token,access_token," + - "urn:ietf:params:oauth:grant-type:saml2-bearer," + - "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + - "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + - "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + - "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + - "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + - "\"username\":\"" + username + "\"}"; - - Map keyDetails = null; // todo:resolve:apim - apiConsumer -// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", -// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", -// jsonString, keyManagerId, tenantDomain); - - if (keyDetails != null) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); - apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); - return apiApplicationKey; - } - throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -// todo:resolve:apim - commected as it says never throw since we commented apim calls above -// cnt rm -// } catch (APIManagementException e) { - } catch (Exception e) { - throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); - } - } +// /** +// * {@inheritDoc} +// */ +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], +// String keyType, String username, boolean isAllowedAllDomains, String validityTime) +// throws APIManagerException { +// +// +///* +// +//todo - Modify generateAndRetrieveApplicationKeys +// +//Check the existence of the API application. +// +//if Application is not exists +// Create the Application +// +//If super tenants +// Get set of tagged APIs +//If the tenant domain is not super tenant +// Get set of tagged APIs from super tenant space +// +//If new Application +// Subscribed to tagged APIs +//Else +// Get all subscribed APIs of application +// Filter out APIs and subscribed to APIs which can be subscribed +// Filter -> Use set of tagged APis +// Remove already subscribed APIs from the set +// Subscribed to remaining APIs +// +//Get Application keys from application +// If API keys are there return API keys +// +//Otherwise, Generate Application Keys and return them +// +// */ +// +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// if (StringUtils.isEmpty(username)) { +// username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; +// } +// try { +// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); +// Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// int applicationId = 0; +// Subscriber subscriber = null; +// if (application == null) { +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// if (subscriber == null) { +// // create subscriber +// // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// } +// //create application +// application = new Application(applicationName, subscriber); +// application.setTier(ApiApplicationConstants.DEFAULT_TIER); +// application.setGroupId(""); +// application.setTokenType("OAUTH"); +// // todo:resolve:apim - apiConsumer.addApplication(application, username); +// application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// } else { +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// } +// +// Set subscribedAPIs = +// null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); +// +// log.info("Already subscribed API count: " + subscribedAPIs.size()); +// +// // subscribe to apis. +// APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; +// if (tags != null && tags.length > 0) { +// for (String tag : tags) { +// boolean startedTenantFlow = false; +// Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); +// +// /** +// * From APIM 4.0.0, APIs published in the super tenant can only be listed by +// * APIConsumer, only if the APIConsumer belongs to the super tenant. So we +// * are starting tenant flow if we are not already in super tenant(child +// * tenant starting to create OAuth app). +// */ +// if (apisWithTag == null || apisWithTag.size() == 0) { +// PrivilegedCarbonContext.startTenantFlow(); +// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, +// true); +// +// try { +// String superAdminUsername = PrivilegedCarbonContext +// .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); +// apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); +// } catch (UserStoreException e) { +// throw new APIManagerException("Failed to create api application for " + +// "tenant: " + tenantDomain + +// ". Caused by to inability to get super tenant username", e); +// } +// +// apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// startedTenantFlow = true; +// } +// +// Set apiTypeWrapperList = new HashSet<>(); +// if (apisWithTag != null && apisWithTag.size() > 0) { +// Set tempApiIds = new HashSet<>(); +// for (API apiInfo : apisWithTag) { +// String id = apiInfo.getId().getProviderName().replace("@", "-AT-") +// + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); +// boolean subscriptionExist = false; +// if (subscribedAPIs.size() > 0) { +// for (SubscribedAPI subscribedAPI : subscribedAPIs) { +// // todo:resolve:apim +//// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { +//// subscriptionExist = true; +//// break; +//// } +// } +// } +// if (!subscriptionExist && !tempApiIds.contains(id)) { +// ApiTypeWrapper apiTypeWrapper; +// if (startedTenantFlow) { +// /** +// * This mean APIs were not found in the child tenant, so all +// * calls to get info about APIs need to be to super tenant. +// */ +// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( +// apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// } else { +// /** +// * Ideally, in all usecases of IoT server, tenant domain here +// * will be carbon.super. This block is kept to make sure in +// * the future, if there are some APIs published to a specific +// * tenant only. +// */ +// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( +// apiInfo.getUuid(), tenantDomain); +// } +// apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); +// apiTypeWrapperList.add(apiTypeWrapper); +// tempApiIds.add(id); +// } +// } +// if (startedTenantFlow) { +// PrivilegedCarbonContext.endTenantFlow(); +// } +// +// /** This is done in a redundant loop instead of doing in the same loop +// * that populates apiTypeWrapperList because in a tenanted scenario, +// * apiConsumerAPIPublishedTenant will belong to super tenant. So super +// * tenant flow need to end before starting subscription to avoid adding +// * subscriptions inside super tenant when we are trying to create an +// * Oauth app for a child tenant. +// */ +// for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { +// // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); +// } +// } +// } +// } +// //end of subscription +// +// List applicationKeys = application.getKeys(); +// if (applicationKeys != null) { +// for (APIKey applicationKey : applicationKeys) { +// if (keyType.equals(applicationKey.getType())) { +// if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { +// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); +// apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); +// apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); +// return apiApplicationKey; +// } +// } +// } +// } +// +// List allowedDomains = new ArrayList<>(); +// if (isAllowedAllDomains) { +// allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); +// } else { +// allowedDomains.add(APIManagerUtil.getTenantDomain()); +// } +// +// APIAdmin apiAdmin = new APIAdminImpl(); +// String keyManagerId = null; +// try { +// List keyManagerConfigurations = null; // todo:resolve:apim - +// // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); +// if (keyManagerConfigurations != null) { +// for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { +// keyManagerId = keyManagerConfigurationDTO.getUuid(); +// } +// } +// String applicationAccessTokenExpiryTime = "N/A"; +// if (!StringUtils.isEmpty(validityTime)) { +// applicationAccessTokenExpiryTime = validityTime; +// } +// String jsonString = "{\"grant_types\":\"refresh_token,access_token," + +// "urn:ietf:params:oauth:grant-type:saml2-bearer," + +// "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + +// "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + +// "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + +// "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + +// "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + +// "\"username\":\"" + username + "\"}"; +// +// Map keyDetails = null; // todo:resolve:apim - apiConsumer +//// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", +//// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", +//// jsonString, keyManagerId, tenantDomain); +// +// if (keyDetails != null) { +// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); +// apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); +// apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); +// return apiApplicationKey; +// } +// throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); +//// todo:resolve:apim - commected as it says never throw since we commented apim calls above +//// cnt rm +//// } catch (APIManagementException e) { +// } catch (Exception e) { +// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); +// } +// } catch (APIManagementException e) { +// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); +// } +// } @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 7629403290..69f51fff56 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -34,11 +34,8 @@ import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.Application; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; @@ -132,8 +129,9 @@ public class KeyMgtServiceImpl implements KeyMgtService { // 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(); + + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = getApplication(clientName, owner); + String applicationUUID = application.getApplicationId(); // do app key mapping mapApplicationKeys(dcrApplication.getClientId(), dcrApplication.getClientSecret(), keyManagerName, @@ -426,11 +424,11 @@ public class KeyMgtServiceImpl implements KeyMgtService { * Retrieves an application by name and owner * * @param applicationName name of the application - * @param owner owner of the application + * @param accessToken Access Token * @return @{@link Application} Application object * @throws KeyMgtException if any error occurs while retrieving the application */ - private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { + private io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application getApplication(String applicationName, String accessToken) throws KeyMgtException { TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); @@ -440,38 +438,26 @@ public class KeyMgtServiceImpl implements KeyMgtService { KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); - - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; if (applications.length == 1) { - applicationFromRestCall = applications[0]; + return applications[0]; } else { String msg = "Found invalid number of applications. No of applications found from the APIM: " + applications.length; + log.error(msg); throw new KeyMgtException(msg); } - - Application application = null; - application.setUUID(applicationFromRestCall.getApplicationId()); - application.setName(applicationFromRestCall.getName()); - application.setDescription(applicationFromRestCall.getDescription()); - application.setApplicationAttributes(applicationFromRestCall.getAttributes()); - application.setTokenType(applicationFromRestCall.getTokenType()); - application.setStatus(applicationFromRestCall.getStatus()); - application.setSubscriptionCount(applicationFromRestCall.getSubscriptionCount()); - application.setOwner(applicationFromRestCall.getOwner()); - application.setIsBlackListed(applicationFromRestCall.isHashEnabled()); - return application; - } - - catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { - e.printStackTrace(); + } catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { msg = "Error while trying to retrieve the application"; - log.error(msg); + log.error(msg, e); throw new KeyMgtException(msg); } catch (UnexpectedResponseException e) { - throw new KeyMgtException(""); + msg = "Received invalid response for the API applications retrieving REST API call."; + log.error(msg, e); + throw new KeyMgtException(msg); } catch (APIServicesException e) { - throw new KeyMgtException(""); + msg = "Error occurred while processing the API Response."; + log.error(msg, e); + throw new KeyMgtException(msg); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index abcdbacc93..09be7963fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -802,7 +802,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here - ApiApplicationKey apiApplicationKey = null; + ApiApplicationKey apiApplicationKey; try { DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java index b223a98a66..e2e5d30bb4 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java @@ -218,8 +218,7 @@ public class JWTClientUtil { long nbf = currentTimeMillis + jwtConfig.getValidityPeriodFromCurrentTime() * 60 * 1000; String jti = jwtConfig.getJti(); if (jti == null) { - String defaultTokenId = currentTimeMillis + "" + new SecureRandom().nextInt(); - jti = defaultTokenId; + jti = currentTimeMillis + "" + new SecureRandom().nextInt(); } List aud = jwtConfig.getAudiences(); //set up the basic claims @@ -273,8 +272,7 @@ public class JWTClientUtil { JWSSigner signer = new RSASSASigner(rsaPrivateKey); SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.RS256), claimsSet.build()); signedJWT.sign(signer); - String assertion = signedJWT.serialize(); - return assertion; + return signedJWT.serialize(); } catch (KeyStoreException e) { throw new JWTClientException("Failed loading the keystore.", e); } catch (IOException e) { From c455bfe187dab810bfca35f514efff129825df17 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 21 Jun 2023 17:40:08 +0530 Subject: [PATCH 030/157] Fix consumer REST calls --- .../APIManagementProviderServiceImpl.java | 8 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 7 +- .../rest/api/bean/APIMConsumer/APIInfo.java | 203 +++--------------- .../api/bean/APIMConsumer/Subscription.java | 8 +- 4 files changed, 48 insertions(+), 178 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 730bb53c16..b124fb4e91 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -80,6 +80,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); + private static final String UNLIMITED_TIER = "Unlimited"; @Override public boolean isTierLoaded() { @@ -238,6 +239,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe 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(); application.setName(applicationName); + application.setThrottlingPolicy(UNLIMITED_TIER); try { application = consumerRESTAPIServices.createApplication(tokenInfo, application); @@ -254,7 +256,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), keyType, validityTime); + keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -317,6 +319,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Subscription subscription = new Subscription(); subscription.setApiId(apiInfo.getId()); subscription.setApplicationId(application.getApplicationId()); + subscription.setThrottlingPolicy(UNLIMITED_TIER); + subscription.setRequestedThrottlingPolicy(UNLIMITED_TIER); subscriptionList.add(subscription); }); @@ -649,7 +653,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationKey apiApplicationKey; io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { - if (username == null && password == null) { + if (username == null || password == null) { apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); } else { apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 81ed4cd4e3..293894ee71 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -176,7 +176,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"description\": \"" + application.getDescription() + "\",\n" + " \"tokenType\": \"" + application.getTokenType() + "\",\n" + " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + - " \"attributes\": " + application.getAttributes().toString() + ",\n" + + " \"attributes\": " + gson.toJson(application.getAttributes()) + ",\n" + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + "}"; RequestBody requestBody = RequestBody.create(JSON, applicationInfo); @@ -291,7 +291,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId + "&limit=1000"; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); @@ -497,8 +497,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); - return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); + return gson.fromJson(response.body().string(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java index f18647899f..3dc4b6c570 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/APIInfo.java @@ -36,31 +36,16 @@ public class APIInfo { private String context; private String version; private String provider; - private JSONObject apiDefinition; - private String wsdlUri; private String lifeCycleStatus; - private boolean isDefaultVersion; - private String type; - private Set transport; - private List operations; - private String authorizationHeader; - private String securityScheme; - private Set tags; - private List tiers; - private boolean hasThumbnail; - private String additionalProperties; - private JSONObject monetization; - private List endpointURLs; - private JSONObject businessInformation; - private List environmentList; - private List scopes; + private String thumbnailUri; private String avgRating; + private List throttlingPolicies; private JSONObject advertiseInfo; + private JSONObject businessInformation; private boolean isSubscriptionAvailable; - private List categories; - private List keyManagers = new ArrayList(); - private String createdTime; - private String lastUpdatedTime; + private String monetizationLabel; + private String gatewayVendor; + private List additionalProperties; public String getId() { return id; @@ -110,22 +95,6 @@ public class APIInfo { this.provider = provider; } - public JSONObject getApiDefinition() { - return apiDefinition; - } - - public void setApiDefinition(JSONObject apiDefinition) { - this.apiDefinition = apiDefinition; - } - - public String getWsdlUri() { - return wsdlUri; - } - - public void setWsdlUri(String wsdlUri) { - this.wsdlUri = wsdlUri; - } - public String getLifeCycleStatus() { return lifeCycleStatus; } @@ -134,100 +103,36 @@ public class APIInfo { this.lifeCycleStatus = lifeCycleStatus; } - public boolean isDefaultVersion() { - return isDefaultVersion; - } - - public void setDefaultVersion(boolean defaultVersion) { - isDefaultVersion = defaultVersion; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Set getTransport() { - return transport; - } - - public void setTransport(Set transport) { - this.transport = transport; - } - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } - - public String getAuthorizationHeader() { - return authorizationHeader; - } - - public void setAuthorizationHeader(String authorizationHeader) { - this.authorizationHeader = authorizationHeader; - } - - public String getSecurityScheme() { - return securityScheme; - } - - public void setSecurityScheme(String securityScheme) { - this.securityScheme = securityScheme; - } - - public Set getTags() { - return tags; - } - - public void setTags(Set tags) { - this.tags = tags; - } - - public List getTiers() { - return tiers; - } - - public void setTiers(List tiers) { - this.tiers = tiers; - } - - public boolean isHasThumbnail() { - return hasThumbnail; + public String getThumbnailUri() { + return thumbnailUri; } - public void setHasThumbnail(boolean hasThumbnail) { - this.hasThumbnail = hasThumbnail; + public void setThumbnailUri(String thumbnailUri) { + this.thumbnailUri = thumbnailUri; } - public String getAdditionalProperties() { - return additionalProperties; + public String getAvgRating() { + return avgRating; } - public void setAdditionalProperties(String additionalProperties) { - this.additionalProperties = additionalProperties; + public void setAvgRating(String avgRating) { + this.avgRating = avgRating; } - public JSONObject getMonetization() { - return monetization; + public List getThrottlingPolicies() { + return throttlingPolicies; } - public void setMonetization(JSONObject monetization) { - this.monetization = monetization; + public void setThrottlingPolicies(List throttlingPolicies) { + this.throttlingPolicies = throttlingPolicies; } - public List getEndpointURLs() { - return endpointURLs; + public JSONObject getAdvertiseInfo() { + return advertiseInfo; } - public void setEndpointURLs(List endpointURLs) { - this.endpointURLs = endpointURLs; + public void setAdvertiseInfo(JSONObject advertiseInfo) { + this.advertiseInfo = advertiseInfo; } public JSONObject getBusinessInformation() { @@ -238,38 +143,6 @@ public class APIInfo { this.businessInformation = businessInformation; } - public List getEnvironmentList() { - return environmentList; - } - - public void setEnvironmentList(List environmentList) { - this.environmentList = environmentList; - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; - } - - public String getAvgRating() { - return avgRating; - } - - public void setAvgRating(String avgRating) { - this.avgRating = avgRating; - } - - public JSONObject getAdvertiseInfo() { - return advertiseInfo; - } - - public void setAdvertiseInfo(JSONObject advertiseInfo) { - this.advertiseInfo = advertiseInfo; - } - public boolean isSubscriptionAvailable() { return isSubscriptionAvailable; } @@ -278,35 +151,27 @@ public class APIInfo { isSubscriptionAvailable = subscriptionAvailable; } - public List getCategories() { - return categories; - } - - public void setCategories(List categories) { - this.categories = categories; - } - - public List getKeyManagers() { - return keyManagers; + public String getMonetizationLabel() { + return monetizationLabel; } - public void setKeyManagers(List keyManagers) { - this.keyManagers = keyManagers; + public void setMonetizationLabel(String monetizationLabel) { + this.monetizationLabel = monetizationLabel; } - public String getCreatedTime() { - return createdTime; + public String getGatewayVendor() { + return gatewayVendor; } - public void setCreatedTime(String createdTime) { - this.createdTime = createdTime; + public void setGatewayVendor(String gatewayVendor) { + this.gatewayVendor = gatewayVendor; } - public String getLastUpdatedTime() { - return lastUpdatedTime; + public List getAdditionalProperties() { + return additionalProperties; } - public void setLastUpdatedTime(String lastUpdatedTime) { - this.lastUpdatedTime = lastUpdatedTime; + public void setAdditionalProperties(List additionalProperties) { + this.additionalProperties = additionalProperties; } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index 085b87785f..2ff525f5dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -18,13 +18,15 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +import org.json.JSONObject; + public class Subscription { private String subscriptionId; private String applicationId; private String apiId; private APIInfo apiInfo; - private Application applicationInfo; + private JSONObject applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -62,11 +64,11 @@ public class Subscription { this.apiInfo = apiInfo; } - public Application getApplicationInfo() { + public JSONObject getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(Application applicationInfo) { + public void setApplicationInfo(JSONObject applicationInfo) { this.applicationInfo = applicationInfo; } From 1e9b38440b35acd6bc7c5c2e090fc55106c7f8d8 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 28 Jun 2023 09:33:27 +0530 Subject: [PATCH 031/157] Improve subscription filtering logic --- .../extension/APIManagementProviderServiceImpl.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index b124fb4e91..0808f11963 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -64,14 +64,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; /** * This class represents an implementation of APIManagementProviderService. @@ -188,7 +181,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + for (Subscription subscription : subscriptions) { + uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); + } addSubscriptions(application, uniqueApiList, tokenInfo); String[] metaValues = metaData.getMetaValue().split(":"); From 5b6b11dc8c82ab4766baddc2e4886595d03953a1 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 4 Jul 2023 16:54:32 +0530 Subject: [PATCH 032/157] fixed unit tests of application-mgt --- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 7 +++++++ .../test/resources/user-test/user-mgt-registry-test.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 9c3ab8ff85..7134db16fc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -153,6 +153,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -160,6 +164,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From defb0aed04141090facf8cd80fb9efa9ff2a394c Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:35:43 +0530 Subject: [PATCH 033/157] fixed unit tests in analytics-mgt --- .../pom.xml | 2 +- .../pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 82f30811ab..59c0b53f0c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -295,7 +295,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 2e2888b88a..0089325b5d 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -211,7 +211,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon From c855b707e7d980fae0ace659f82df7c9e612b124 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:40:38 +0530 Subject: [PATCH 034/157] fixed mockito dependency issue --- .../io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index c0c72a2f65..0f030906b9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From bc66555a0489a0a8e6b26110a21604d31d456b7d Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 13:15:02 +0530 Subject: [PATCH 035/157] fixed unit tests --- .../pom.xml | 9 +- .../src/test/resources/sql/CreateH2TestDB.sql | 247 ++++++++++-------- .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 9 +- .../carbon-home/dbscripts/dm-db-h2.sql | 169 +++++++----- .../conf/datasources/data-source-config.xml | 2 +- .../pom.xml | 2 +- 7 files changed, 256 insertions(+), 184 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 6887a4f3e5..5e7d63b270 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -116,12 +116,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -254,7 +261,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index defd753f33..6c906a5c49 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -1,3 +1,51 @@ + DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO; + ALTER TABLE IF EXISTS DM_DEVICE DROP CONSTRAINT IF EXISTS fk_DM_DEVICE_DM_DEVICE_TYPE2; +-- ALTER TABLE IF EXISTS DM_DEVICE_TYPE_PLATFORM DROP CONSTRAINT IF EXISTS DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING; + ALTER TABLE IF EXISTS DM_ROLE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_ROLE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_POLICY; +-- ALTER TABLE IF EXISTS DM_GEOFENCE_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_GEOFENCE_GROUP_MAPPING_GROUP; +-- ALTER TABLE IF EXISTS DM_DEVICE_EVENT_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_EVENT_GROUP_MAPPING_GROUP; + + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_DEVICE2; + ALTER TABLE IF EXISTS DM_ENROLMENT DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_ENROLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DEVCIE_APPLIED; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE; + ALTER TABLE IF EXISTS DM_NOTIFICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_NOTIFICATION; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_DETAILS_DEVICE; + + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_OPERATION; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_OPERATION; + + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_ENROLMENT; + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_ENROLEMENT; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DM_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_ENROLMENT_DEVICE_DETAILS; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE_LARGE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_LARGE_MAPPING; +-- + ALTER TABLE IF EXISTS DM_POLICY DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY; + ALTER TABLE IF EXISTS DM_PROFILE_FEATURES DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY_FEATURES; +-- + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_POLICY_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_TYPE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_TYPE_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION; + ALTER TABLE IF EXISTS DM_ROLE_POLICY DROP CONSTRAINT IF EXISTS FK_ROLE_POLICY_POLICY; + ALTER TABLE IF EXISTS DM_USER_POLICY DROP CONSTRAINT IF EXISTS DM_POLICY_USER_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_POLICY_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_DM_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_CRITERIA_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA_PROPERTIES DROP CONSTRAINT IF EXISTS FK_POLICY_CRITERIA_PROPERTIES; + ALTER TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES DROP CONSTRAINT IF EXISTS FK_COMPLIANCE_FEATURES_STATUS; + DROP TABLE IF EXISTS DM_DEVICE_TYPE; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( ID INT AUTO_INCREMENT NOT NULL, @@ -13,24 +61,22 @@ DROP TABLE IF EXISTS DM_GROUP; CREATE TABLE IF NOT EXISTS DM_GROUP ( ID INTEGER AUTO_INCREMENT NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, - DESCRIPTION TEXT DEFAULT NULL, STATUS VARCHAR(50) DEFAULT NULL, - DATE_OF_CREATE BIGINT DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, - OWNER VARCHAR(45) DEFAULT NULL, + DESCRIPTION TEXT DEFAULT NULL, + OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); - -DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE; -CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( - ID INTEGER auto_increment NOT NULL, - SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, - CERTIFICATE BLOB DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) +DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; +CREATE TABLE IF NOT EXISTS DM_ROLE_GROUP_MAP ( + ID INTEGER AUTO_INCREMENT NOT NULL, + GROUP_ID INTEGER DEFAULT NULL, + ROLE VARCHAR(45) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_ROLE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_DEVICE; @@ -38,13 +84,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_DM_DEVICE UNIQUE (NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) ); DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES; @@ -53,8 +100,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, PROPERTY_NAME VARCHAR(100) DEFAULT 0, PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) + TENANT_ID VARCHAR(100), + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) ); DROP TABLE IF EXISTS GROUP_PROPERTIES; @@ -74,9 +121,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID) - REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + REFERENCES DM_DEVICE (ID) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_OPERATION; @@ -96,7 +143,7 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(50) NOT NULL, + OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, @@ -105,7 +152,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( TENANT_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); DROP TABLE IF EXISTS DM_DEVICE_STATUS; CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( @@ -119,7 +167,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING; CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -167,10 +215,14 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE_LARGE ( ID INTEGER NOT NULL, OPERATION_RESPONSE LONGBLOB DEFAULT NULL, OPERATION_ID INTEGER NOT NULL, + EN_OP_MAP_ID INTEGER NOT NULL, RECEIVED_TIMESTAMP TIMESTAMP NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, CONSTRAINT fk_dm_device_operation_response_large_mapping FOREIGN KEY (ID) REFERENCES DM_DEVICE_OPERATION_RESPONSE (ID) + ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_en_op_map_response_large FOREIGN KEY (EN_OP_MAP_ID) + REFERENCES DM_ENROLMENT_OP_MAPPING (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -181,30 +233,25 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID INT NOT NULL AUTO_INCREMENT , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INT NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME ) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_POLICY; CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , - PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL, DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -213,31 +260,13 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); - -DROP TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION; -CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, - ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, - POLICY_ID INT(11) NOT NULL, - FEATURE_ID INT(11) DEFAULT NULL, - IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, - PRIMARY KEY (ID), - CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION -); - - DROP TABLE IF EXISTS DM_DEVICE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , - DEVICE_ID INT(11) NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -253,29 +282,24 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , - POLICY_ID INT(11) NOT NULL , + ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME) - ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_PROFILE_FEATURES; CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL, + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -285,11 +309,26 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, + IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + DROP TABLE IF EXISTS DM_ROLE_POLICY; CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -315,11 +354,11 @@ DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -363,7 +402,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL COMMENT 'This is used to ', + CONTENT BLOB NULL, PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -376,7 +415,7 @@ DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS; CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -391,8 +430,8 @@ DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT; CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -423,7 +462,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -434,7 +473,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT FK_DM_APP_MAP_DM_ENROL + CONSTRAINT fk_dm_enrolement FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION @@ -448,15 +487,14 @@ DROP TABLE IF EXISTS DM_NOTIFICATION; CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(100) NULL, + DESCRIPTION VARCHAR(1000) NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- @@ -494,7 +532,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, + ALTITUDE DOUBLE NULL, + SPEED FLOAT NULL, + BEARING FLOAT NULL, + DISTANCE DOUBLE NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -507,6 +549,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +DROP INDEX IF EXISTS DM_DEVICE_LOCATION_GEO_hashx; +CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); DROP TABLE IF EXISTS DM_DEVICE_DETAIL; CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( @@ -527,8 +571,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT(1) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -553,15 +597,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, + ON DELETE CASCADE + ON UPDATE CASCADE , CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + ON DELETE CASCADE + ON UPDATE CASCADE ); - -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- @@ -621,22 +664,4 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID ORDER BY TENANT_ID, DEVICE_ID; -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 45b7fd07c9..8add23b3d8 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -114,6 +114,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -121,6 +125,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -342,7 +349,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 40ad63072f..df3277920d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - RECEIVED_TIMESTAMP TIMESTAMP NULL, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); - +CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , - DEVICE_ID INT(11) NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, - POLICY_ID INT(11) NOT NULL, - FEATURE_ID INT(11) DEFAULT NULL, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT(11) NOT NULL, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT(1) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -744,24 +766,6 @@ CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( STATUS INT DEFAULT 0, PRIMARY KEY (ID) ); -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -- END OF DM_EXT_DEVICE_MAPPING TABLE-- -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- @@ -773,23 +777,23 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( -- DYNAMIC TASK TABLES-- CREATE TABLE IF NOT EXISTS DYNAMIC_TASK ( - DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, - NAME VARCHAR(300) DEFAULT NULL , - CRON VARCHAR(8000) DEFAULT NULL, - IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, - TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (DYNAMIC_TASK_ID) + DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, + NAME VARCHAR(300) DEFAULT NULL , + CRON VARCHAR(8000) DEFAULT NULL, + IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, + TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (DYNAMIC_TASK_ID) ); CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( - DYNAMIC_TASK_ID INTEGER NOT NULL, - PROPERTY_NAME VARCHAR(100) DEFAULT 0, - PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100), - PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), - CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES - DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE + DYNAMIC_TASK_ID INTEGER NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), + CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES + DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); -- END OF DYNAMIC TASK TABLE-- @@ -802,5 +806,34 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); +-- END OF DM_DEVICE_SUB_TYPE TABLE-- + +-- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + +-- SUB_OPERATION_TEMPLATE TABLE-- +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, + OPERATION_DEFINITION TEXT NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) +); --- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file +-- END OF SUB_OPERATION_TEMPLATE TABLE-- diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 6476fc0aa6..f9972e1ef0 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -273,7 +273,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From da8fa5b89502858dc014244674c7df888a32c9ac Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:22:21 +0530 Subject: [PATCH 036/157] fixed unit tests --- .../pom.xml | 14 +++++++++++++- .../client/extension/service/JWTClientTest.java | 3 ++- .../resources/user-test/user-mgt-registry-test.xml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 8b646fa964..f35ea73b60 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -155,7 +155,12 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 + test + + + org.mockito + mockito-core test @@ -253,12 +258,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index d497d5e108..beb7db9962 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -43,9 +43,10 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.powermock.modules.testng.PowerMockTestCase; @PrepareForTest(JWTClientUtil.class) -public class JWTClientTest { +public class JWTClientTest extends PowerMockTestCase{ private static final Log log = LogFactory.getLog(JWTClientTest.class); @ObjectFactory diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From c286fec27bded7cfcd3152ac355e36b0aeb1333b Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:26:32 +0530 Subject: [PATCH 037/157] fixed unit tests --- .../pom.xml | 9 ++++++++- .../src/test/resources/data-source-config.xml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d23f1863cd..35621201eb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -111,6 +111,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -118,6 +122,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + @@ -175,7 +182,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From ce37fdb4be94219fd46494e6c5666386439f2e0e Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:50:32 +0530 Subject: [PATCH 038/157] fixed unit tests --- .../pom.xml | 20 +- .../pom.xml | 34 + .../pom.xml | 29 + .../src/test/resources/conf/carbon.xml | 658 ------------------ .../test/resources/repository/conf/carbon.xml | 0 5 files changed, 81 insertions(+), 660 deletions(-) delete mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 38ba36543d..7bd5e03b5b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -106,13 +106,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + - file:src/test/resources/carbon-home/repository/conf/log4j.properties - + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -207,5 +213,15 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 8b1dc93e22..16d45fccce 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -104,6 +104,21 @@ io.entgra.device.mgt.core.device.mgt.core test + + org.mockito + mockito-core + test + + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + @@ -157,6 +172,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + org.jacoco jacoco-maven-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ed434c7873..ec115c2905 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -122,6 +122,16 @@ powermock-module-testng test + + org.wso2.carbon + org.wso2.carbon.securevault + test + + + org.mockito + mockito-core + test + @@ -189,6 +199,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml deleted file mode 100644 index a5518cb720..0000000000 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - - - - ${product.name} - - - ${product.key} - - - ${product.version} - - - - - - - - - local:/${carbon.context}/services/ - - - - - - - ${default.server.role} - - - - - - - org.wso2.carbon - - - / - - - - - - - - - 15 - - - - - - - - - 0 - - - - - 9999 - - 11111 - - - - - - 10389 - - 8000 - - - - - - 10500 - - - - - - - org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory - - - - - - - - - java - - - - - - - - - - false - - - false - - - 600 - - - - false - - - - - - - - 30 - - - - - - - - - 15 - - - - - - ${carbon.home}/repository/deployment/server/ - - - 15 - - - ${carbon.home}/repository/conf/axis2/axis2.xml - - - 30000 - - - ${carbon.home}/repository/deployment/client/ - - ${carbon.home}/repository/conf/axis2/axis2_client.xml - - true - - - - - - - - - - admin - Default Administrator Role - - - user - Default User Role - - - - - - - - - - - - ${carbon.home}/repository/resources/security/wso2carbon.jks - - JKS - - wso2carbon - - wso2carbon - - wso2carbon - - - - - - ${carbon.home}/repository/resources/security/client-truststore.jks - - JKS - - wso2carbon - - - - - - - - - - - - - - - - - - - UserManager - - - false - - - - - - - ${carbon.home}/tmp/work - - - - - - true - - - 10 - - - 30 - - - - - - 100 - - - - keystore - certificate - * - - org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor - - - - - jarZip - - org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor - - - - dbs - - org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor - - - - tools - - org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor - - - - toolsAny - - org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor - - - - - - - info - org.wso2.carbon.core.transports.util.InfoProcessor - - - wsdl - org.wso2.carbon.core.transports.util.Wsdl11Processor - - - wsdl2 - org.wso2.carbon.core.transports.util.Wsdl20Processor - - - xsd - org.wso2.carbon.core.transports.util.XsdProcessor - - - - - - false - false - true - svn - http://svnrepo.example.com/repos/ - username - password - true - - - - - - - - - - - - - - - ${require.carbon.servlet} - - - - - true - - - - - - - default repository - ${p2.repo.url} - - - - - - - - true - - - - - - true - - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml new file mode 100644 index 0000000000..e69de29bb2 From f63a6ee65b88c67d53ab7661dc79a2371cdfc84a Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:54:56 +0530 Subject: [PATCH 039/157] fixed unit tests --- .../pom.xml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index a4673c3e6e..fffcfba429 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -76,12 +76,20 @@ org.apache.maven.plugins maven-surefire-plugin - - file:src/test/resources/log4j.properties - + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml + + ${basedir}/target/coverage-reports/jacoco-unit.exec + file:src/test/resources/log4j.properties + + + org.ops4j.pax.logging + @@ -255,7 +263,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From be6db5c5d54ac2c4ecf4894bcc4e90ada4171a32 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 17:06:48 +0530 Subject: [PATCH 040/157] fixed unit tests --- pom.xml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 28dfc7301b..ec8f446882 100644 --- a/pom.xml +++ b/pom.xml @@ -833,6 +833,16 @@ jaxb-api ${version.org.wso2.orbit.javax.xml.bind} + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + org.apache.axis2.transport @@ -1654,7 +1664,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 ${power.mock.version} test @@ -1741,6 +1751,11 @@ mockito-inline ${mokito.version} + + org.mockito + mockito-core + ${mokito.version} + org.ops4j.pax.logging pax-logging-api @@ -1888,7 +1903,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + 2.22.2 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -2113,7 +2128,7 @@ 0.7.8 0.7.5.201505241946 1.0b3 - 1.7.4 + 2.0.2 1.4.0.wso2v1 1.7.25 @@ -2136,7 +2151,7 @@ [1.6.0, 2.0.0) [1.2.0,1.3.0) - 4.2.0 + 2.23.4 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 From 80b42315d7fc928ce0a45cbdbc50883601102576 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:11:31 +0530 Subject: [PATCH 041/157] operation template related unit test fixes --- .../pom.xml | 7 + .../carbon-home/dbscripts/dm-db-h2.sql | 199 ++++++++++++------ .../repository/conf/cdm-config.xml | 92 +++++--- .../conf/datasources/data-source-config.xml | 2 +- 4 files changed, 207 insertions(+), 93 deletions(-) diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index c71669f41e..a4ef16008e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -119,6 +119,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -126,6 +130,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 6052156588..df3277920d 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - RECEIVED_TIMESTAMP TIMESTAMP NULL, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); - +CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , - DEVICE_ID INT(11) NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, - POLICY_ID INT(11) NOT NULL, - FEATURE_ID INT(11) DEFAULT NULL, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT(11) NOT NULL, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT(1) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -588,8 +610,7 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID), - CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) + PRIMARY KEY (ID) ); -- END OF DM_OTP_DATA TABLE -- @@ -725,52 +746,94 @@ CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING ( -- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- +-- DM_EXT_GROUP_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_GROUP_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + TRACCAR_GROUP_ID INT DEFAULT 0, + GROUP_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + STATUS INT DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_EXT_GROUP_MAPPING TABLE-- + +-- END OF DM_EXT_DEVICE_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( + ID INT NOT NULL AUTO_INCREMENT, + TRACCAR_DEVICE_ID INT DEFAULT 0, + DEVICE_ID INT NOT NULL, + TENANT_ID INT NOT NULL, + STATUS INT DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_EXT_DEVICE_MAPPING TABLE-- + +-- END OF DM_EXT_PERMISSION_MAPPING TABLE-- +CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( + TRACCAR_DEVICE_ID INT DEFAULT 0, + TRACCAR_USER_ID INT DEFAULT 0 +); +-- END OF DM_EXT_PERMISSION_MAPPING TABLE-- + +-- DYNAMIC TASK TABLES-- +CREATE TABLE IF NOT EXISTS DYNAMIC_TASK ( + DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, + NAME VARCHAR(300) DEFAULT NULL , + CRON VARCHAR(8000) DEFAULT NULL, + IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, + TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (DYNAMIC_TASK_ID) +); + +CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( + DYNAMIC_TASK_ID INTEGER NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), + CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES + DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE +); +-- END OF DYNAMIC TASK TABLE-- + -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID INT NOT NULL, + SUB_TYPE_ID VARCHAR(45) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); - -- END OF DM_DEVICE_SUB_TYPE TABLE-- +-- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, - UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -- END OF SUB_OPERATION_TEMPLATE TABLE-- - -INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES -(3,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), -(4,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 4, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml index b6c2900db7..3ce48daefe 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -31,18 +31,10 @@ 60000 true - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider - + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider @@ -50,16 +42,16 @@ https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} - org.wso2.carbon.policy.mgt + io.entgra.device.mgt.core.policy.mgt true 60000 5 @@ -90,7 +82,7 @@ device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the device-cache to improve performance. --> - false + true 600 10000 + + true + 600 + 10000 + true - false + true 86400 @@ -120,6 +114,11 @@ false + false + + DM_DB + ARCHIVAL_DB + io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTask 0 0 0 1/1 * ? * @@ -159,7 +158,7 @@ true - wss://localhost:9443 + ws://localhost:9763 2 100 20 @@ -167,5 +166,50 @@ 640 BYOD,COPE + + false + false + io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier + http://localhost:8280 + + + false + + + test_role + + /permission/admin/Login + + + + + + + + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.2.0 | © 2023 + , All Rights Reserved. + + Entgra + + repository/resources/whitelabel + favicon.png + logo.png + icon.png + default + + + + + + + + + + false + Replace with mail + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From 5b85778d271712eea79eba77089f4eec93338bd6 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:16:53 +0530 Subject: [PATCH 042/157] fixed operation template unit tests --- .../template/mock/BaseOperationTemplatePluginTest.java | 1 + .../test/resources/carbon-home/dbscripts/insert-subtypes.sql | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index c563311602..58c7e8b65f 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -144,6 +144,7 @@ public abstract class BaseOperationTemplatePluginTest { conn = ConnectionManagerUtils.getDBConnection(); stmt = conn.createStatement(); stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/dm-db-h2.sql'"); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/insert-subtypes.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql new file mode 100644 index 0000000000..ffa001a086 --- /dev/null +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql @@ -0,0 +1,3 @@ +INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES +(3,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), +(4,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 4, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'); \ No newline at end of file From effc35d52d82cf6f77aa2b7d06c7e9a1f9e02af4 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 25 May 2023 21:19:05 +0530 Subject: [PATCH 043/157] Update admin credentials in webapp-auth-config template --- .../src/main/resources/conf/webapp-authenticator-config.xml | 4 ++-- .../repository/conf/etc/webapp-authenticator-config.xml.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml index bf5d2e00e2..c3bb4569b8 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml @@ -24,8 +24,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - ${admin.username} - ${admin.password} + {{super_admin.username}} + {{super_admin.password}} 100 100 diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 index 7c3ce35486..6c51e0f2b6 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 @@ -14,8 +14,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - ${admin.username} - ${admin.password} + {{super_admin.username}} + {{super_admin.password}} 100 100 From 74e06047f1076dd9de989d7bf7f782b0bbeea980 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Tue, 13 Jun 2023 09:19:43 +0530 Subject: [PATCH 044/157] Fix class def not found in grafana component --- .../pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0089325b5d..e8197e4426 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -124,7 +124,7 @@ org.wso2.carbon.utils;version="[4.8,5)" - !io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal, + !io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.* From 7ad3a0e21be981216104a4338f25ff2e6d2c872a Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Fri, 16 Jun 2023 10:06:30 +0000 Subject: [PATCH 045/157] Add custom loggers (#136) * Fixes https://roadmap.entgra.net/issues/10117 * Added custom logs for below cases: 1. Device connectivity events 2. Policy payload change events 3. Device enrollment history events 4. App install events **1. Device connectivity logs** - logs for newly added operations and calls for pending operations Pattern : {DateTime} {LogLevel} - {ActionTag} {OperationCode} {DeviceId} {DeviceType} {TenantDomain} {TenantId} {UserName} - log_message ``` [2023-06-15 00:12:09,093] INFO - [ADD_OPERATION] [DEVICE_LOCATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:12:10,344] INFO - [PENDING_OPERATION] [DEVICE_LOCATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected [2023-06-15 00:13:49,755] INFO - [ADD_OPERATION] [DEVICE_LOCK] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:13:56,513] INFO - [ADD_OPERATION] [DEVICE_MUTE] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:14:23,839] INFO - [PENDING_OPERATION] [DEVICE_MUTE] [2023-06-15 00:15:12,549] INFO - [ADD_OPERATION] [INSTALL_APPLICATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:15:29,703] INFO - [PENDING_OPERATION] [INSTALL_APPLICATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected ``` **2. Policy payload change events** - logs for creating policy, updating policy, deleting policy, change policy priorities and apply changes to device logs Pattern : {DateTime} {LogLevel} - {ActionTag} {PolicyName} {TenantDomain} {TenantId} {Payload} {UserName} - log_message ``` [2023-06-15 00:15:53,264] INFO - [UPDATE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":0,"deviceType":"ios","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":0,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":33,"policyType":"GENERAL"}] [admin] - Policy updated [2023-06-15 00:34:38,980] INFO - [ADD_POLICY] [application management policy] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":65,"priorityId":0,"profile":{"profileId":65,"profileName":"application management policy","tenantId":0,"deviceType":"windows","createdDate":"Jun 15, 2023 12:34:38 AM","updatedDate":"Jun 15, 2023 12:34:38 AM","profileFeaturesList":[{"id":65,"featureCode":"ALLOW_ALL_TRUSTED_APPS","profileId":0,"deviceType":"windows","content":"{\"enabled\":true}","correctiveActions":[]},{"id":73,"featureCode":"RESTRICT_APP_TO_SYSTEM_VOLUME","profileId":0,"deviceType":"windows","content":"{\"enabled\":false}","correctiveActions":[]}]},"policyName":"application management policy","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":0,"policyType":"GENERAL"}] [admin] - Policy created [2023-06-15 00:35:05,420] INFO - [DELETE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":-1234,"deviceType":"ios","createdDate":"Jun 13, 2023 10:24:30 PM","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":33,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":true,"description":"test","compliance":"enforce","policyCriterias":[],"tenantId":-1234,"profileId":33,"deviceGroups":[],"policyType":"GENERAL"}] [admin] - Policy deleted [2023-06-15 00:35:12,768] INFO - [UPDATE_POLICY_PRIORITIES] [] [carbon.super] [-1234] [[{"id":65,"priorityId":1,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0},{"id":34,"priorityId":2,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0}]] [admin] - Policy priorities updated [2023-06-15 00:35:25,395] INFO - [PUBLISH_CHANGES] [] [carbon.super] [-1234] [] [admin] - Apply changes to device ``` **3. Device enrollment history events** - logs for device enrollment and dis-enrollment Pattern : {DateTime} {LogLevel} - {DeviceId} {DeviceType} {Owner} {Ownership} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:12:09,078] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device enrolled successfully [2023-06-15 00:47:36,278] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device disenrolled successfully ``` **4. App install events** - logs for app installation and uninstallation Pattern : {DateTime} {LogLevel} - {AppId} {AppName} {AppType} {SubType} {Action} {Device} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:15:12,550] INFO - [1] [Calculator] [PUBLIC] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:24,454] INFO - [2] [Sololearn] [ENTERPRISE] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:40,498] INFO - [3] [Engineering] [WEB_CLIP] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - Web app install triggered ``` * https://repository.entgra.net/proprietary/product-uem/pulls/6 Co-authored-by: prathabanKavin Co-authored-by: Pahansith Gunathilake Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/136 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../core/impl/SubscriptionManagerImpl.java | 18 +- .../operation/mgt/OperationManagerImpl.java | 38 ++- .../DeviceManagementProviderServiceImpl.java | 37 +- .../logger/AppInstallLogContext.java | 181 ++++++++++ .../logger/DeviceConnectivityLogContext.java | 150 +++++++++ .../logger/DeviceEnrolmentLogContext.java | 149 ++++++++ .../notification/logger/PolicyLogContext.java | 133 ++++++++ .../impl/EntgraAppInstallLoggerImpl.java | 318 ++++++++++++++++++ .../EntgraDeviceConnectivityLoggerImpl.java | 318 ++++++++++++++++++ .../impl/EntgraDeviceEnrolmentLoggerImpl.java | 318 ++++++++++++++++++ .../logger/impl/EntgraDeviceLoggerImpl.java | 7 - .../logger/impl/EntgraPolicyLoggerImpl.java | 318 ++++++++++++++++++ .../logger/impl/EntgraUserLoggerImpl.java | 2 - .../logger/util/MDCContextUtil.java | 102 +++++- .../impl/PolicyAdministratorPointImpl.java | 10 +- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 39 ++- 16 files changed, 2114 insertions(+), 24 deletions(-) create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index cae569bbd3..92c1a93f18 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.application.mgt.common.*; @@ -87,8 +91,8 @@ import java.util.stream.Collectors; * This is the default implementation for the Subscription Manager. */ public class SubscriptionManagerImpl implements SubscriptionManager { - - private static final Log log = LogFactory.getLog(SubscriptionManagerImpl.class); + AppInstallLogContext.Builder appInstallLogContextBuilder = new AppInstallLogContext.Builder(); + private static final EntgraLogger log = new EntgraAppInstallLoggerImpl(SubscriptionManagerImpl.class); private SubscriptionDAO subscriptionDAO; private ApplicationDAO applicationDAO; private LifecycleStateManager lifecycleStateManager; @@ -620,7 +624,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Properties properties, boolean isOperationReExecutingDisabled) throws ApplicationManagementException { - + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); //Get app subscribing info of each device SubscribingDeviceIdHolder subscribingDeviceIdHolder = getSubscribingDeviceIdHolder(devices, applicationDTO.getApplicationReleaseDTOs().get(0).getId()); @@ -670,10 +676,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, new ArrayList<>(entry.getValue()), entry.getKey(), action, properties); activityList.add(activity); + for (DeviceIdentifier identifier : deviceIdentifiers) { + log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + } } } else { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); + for (DeviceIdentifier identifier : deviceIdentifiers) { + log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + } } ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 5e5ca5c13d..92cf1818a7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -19,6 +19,23 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; import io.entgra.device.mgt.core.device.mgt.common.*; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; +import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; +import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -68,7 +85,8 @@ import java.util.concurrent.ThreadPoolExecutor; */ public class OperationManagerImpl implements OperationManager { - private static final Log log = LogFactory.getLog(OperationManagerImpl.class); + DeviceConnectivityLogContext.Builder deviceConnectivityLogContextBuilder = new DeviceConnectivityLogContext.Builder(); + private static final EntgraLogger log = new EntgraDeviceConnectivityLoggerImpl(OperationManagerImpl.class); private static final int CACHE_VALIDITY_PERIOD = 5 * 60 * 1000; private static final String NOTIFIER_TYPE_LOCAL = "LOCAL"; private static final String SYSTEM = "system"; @@ -151,6 +169,8 @@ public class OperationManagerImpl implements OperationManager { } } + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds); List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); if (!validDeviceIds.isEmpty()) { @@ -227,6 +247,10 @@ public class OperationManagerImpl implements OperationManager { activity.setActivityStatus( this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult)); } + for (DeviceIdentifier deviceId : authorizedDeviceIds) { + device = getDevice(deviceId); + log.info("Operation added", deviceConnectivityLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(deviceType).setActionTag("ADD_OPERATION").setTenantDomain(tenantDomain).setTenantId(tenantId).setUserName(initiatedBy).setOperationCode(operationCode).build()); + } return activity; } catch (OperationManagementDAOException e) { OperationManagementDAOFactory.rollbackTransaction(); @@ -673,7 +697,9 @@ public class OperationManagerImpl implements OperationManager { if (log.isDebugEnabled()) { log.debug("Device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]"); } - + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -686,16 +712,18 @@ public class OperationManagerImpl implements OperationManager { case INACTIVE: case UNREACHABLE: this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - + log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(deviceId.getId()).setDeviceType(deviceId.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } @Override public List getPendingOperations(Device device) throws OperationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -713,10 +741,10 @@ public class OperationManagerImpl implements OperationManager { this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); device.setEnrolmentInfo(enrolmentInfo); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, device, tenantId); break; } + log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(device.getDeviceIdentifier()).setDeviceType(device.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceIdentifier, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 02d6b010eb..e6a32ba4f4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -21,6 +21,30 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.lang.StringUtils; +import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.Billing; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; +import io.entgra.device.mgt.core.device.mgt.common.DeviceNotification; +import io.entgra.device.mgt.core.device.mgt.common.DevicePropertyNotification; +import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; +import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; +import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; +import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; +import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; +import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; @@ -117,7 +141,9 @@ import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, PluginInitializationListener { - private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); + DeviceEnrolmentLogContext.Builder deviceEnrolmentLogContextBuilder = new DeviceEnrolmentLogContext.Builder(); + + private static final EntgraLogger log = new EntgraDeviceEnrolmentLoggerImpl(DeviceManagementProviderServiceImpl.class); private static final String OPERATION_RESPONSE_EVENT_STREAM_DEFINITION = "org.wso2.iot.OperationResponseStream"; private final DeviceManagementPluginRepository pluginRepository; @@ -205,6 +231,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrollmentConfiguration enrollmentConfiguration = DeviceManagerUtil.getEnrollmentConfigurationEntry(); String deviceSerialNumber = null; if (enrollmentConfiguration != null) { @@ -291,6 +319,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(existingDevice.getId())).setDeviceType(String.valueOf(existingDevice.getType())).setOwner(newEnrolmentInfo.getOwner()).setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + @@ -327,6 +356,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } device.setEnrolmentInfo(enrollment); DeviceManagementDAOFactory.commitTransaction(); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(enrollment.getOwner()).setOwnership(String.valueOf(enrollment.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } else { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException("No device type registered with name - " + device.getType() @@ -515,7 +545,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } int tenantId = this.getTenantId(); - + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); Device device = this.getDevice(deviceId, false); if (device == null) { if (log.isDebugEnabled()) { @@ -549,7 +580,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } //procees to dis-enroll a device from traccar ends - + log.info("Device disenrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(device.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java new file mode 100644 index 0000000000..33cffac366 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class AppInstallLogContext extends LogContext { + private final String appId; + private final String appName; + private final String appType; + private final String subType; + private final String tenantId; + private final String tenantDomain; + private final String device; + private final String userName; + private final String action; + + private AppInstallLogContext(Builder builder) { + this.appId = builder.appId; + this.appName = builder.appName; + this.appType = builder.appType; + this.subType = builder.subType; + this.tenantId = builder.tenantId; + this.tenantDomain = builder.tenantDomain; + this.device = builder.device; + this.userName = builder.userName; + this.action = builder.action; + } + + public String getAppId() { + return appId; + } + + public String getAppName() { + return appName; + } + + public String getAppType() { + return appType; + } + + public String getSubType() { + return subType; + } + + public String getTenantId() { + return tenantId; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getDevice() { + return device; + } + + public String getUserName() { + return userName; + } + + public String getAction() { + return action; + } + + public static class Builder { + private String appId; + private String appName; + private String appType; + private String subType; + private String tenantId; + private String tenantDomain; + private String device; + private String userName; + private String action; + + public Builder() { + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getAppId() { + return appId; + } + + public Builder setAppId(String appId) { + this.appId = appId; + return this; + } + + public String getAppName() { + return appName; + } + + public Builder setAppName(String appName) { + this.appName = appName; + return this; + } + + public String getAppType() { + return appType; + } + + public Builder setAppType(String appType) { + this.appType = appType; + return this; + } + + public String getSubType() { + return subType; + } + + public Builder setSubType(String subType) { + this.subType = subType; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getTenantId() { + return tenantId; + } + + public Builder setTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public String getDevice() { + return device; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + public String getAction() { + return action; + } + + public Builder setAction(String action) { + this.action = action; + return this; + } + + public AppInstallLogContext build() { + return new AppInstallLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java new file mode 100644 index 0000000000..d110e84a43 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class DeviceConnectivityLogContext extends LogContext { + + private final String deviceId; + private final String deviceType; + private final String actionTag; + private final String operationCode; + private final String tenantId; + private final String tenantDomain; + private final String userName; + + private DeviceConnectivityLogContext(Builder builder) { + this.deviceId = builder.deviceId; + this.deviceType = builder.deviceType; + this.actionTag = builder.actionTag; + this.operationCode = builder.operationCode; + this.tenantId = builder.tenantId; + this.tenantDomain = builder.tenantDomain; + this.userName = builder.userName; + } + + public String getDeviceId() { + return deviceId; + } + + public String getDeviceType() { + return deviceType; + } + + public String getActionTag() { + return actionTag; + } + + public String getOperationCode() { + return operationCode; + } + + public String getTenantId() { + return tenantId; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getUserName() { + return userName; + } + + public static class Builder { + private String deviceId; + private String deviceType; + private String operationCode; + private String actionTag; + private String tenantId; + private String tenantDomain; + private String userName; + + public Builder() { + } + + public String getDeviceId() { + return deviceId; + } + + public Builder setDeviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public String getDeviceType() { + return deviceType; + } + + public Builder setDeviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public String getOperationCode() { + return operationCode; + } + + public Builder setOperationCode(String operationCode) { + this.operationCode = operationCode; + return this; + } + + public String getTenantId() { + return tenantId; + } + + public Builder setTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getActionTag() { + return actionTag; + } + + public Builder setActionTag(String actionTag) { + this.actionTag = actionTag; + return this; + } + + public DeviceConnectivityLogContext build() { + return new DeviceConnectivityLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java new file mode 100644 index 0000000000..b355b29671 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class DeviceEnrolmentLogContext extends LogContext { + private final String deviceId; + private final String deviceType; + private final String owner; + private final String ownership; + private final String tenantID; + private final String tenantDomain; + private final String userName; + + private DeviceEnrolmentLogContext(Builder builder) { + this.deviceId = builder.deviceId; + this.deviceType = builder.deviceType; + this.owner = builder.owner; + this.ownership = builder.ownership; + this.tenantID = builder.tenantID; + this.tenantDomain = builder.tenantDomain; + this.userName = builder.userName; + } + + public String getTenantID() { + return tenantID; + } + + public String getDeviceId() { + return deviceId; + } + + public String getOwner() { + return owner; + } + + public String getDeviceType() { + return deviceType; + } + + public String getOwnership() { + return ownership; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getUserName() { + return userName; + } + public static class Builder { + private String deviceId; + private String deviceType; + private String owner; + private String ownership; + private String tenantID; + private String tenantDomain; + private String userName; + + public Builder() { + } + + public String getDeviceType() { + return deviceType; + } + + public Builder setDeviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public String getTenantID() { + return tenantID; + } + + public Builder setTenantID(String tenantID) { + this.tenantID = tenantID; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getDeviceId() { + return deviceId; + } + + public Builder setDeviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public String getOwner() { + return owner; + } + + public Builder setOwner(String owner) { + this.owner = owner; + return this; + } + + public String getOwnership() { + return ownership; + } + + public Builder setOwnership(String ownership) { + this.ownership = ownership; + return this; + } + + public DeviceEnrolmentLogContext build() { + return new DeviceEnrolmentLogContext(this); + } + + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java new file mode 100644 index 0000000000..9dbd10a059 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class PolicyLogContext extends LogContext { + private final String policyName; + private final String payload; + private final String actionTag; + private final String userName; + private final String tenantID; + private final String tenantDomain; + + private PolicyLogContext(Builder builder) { + this.policyName = builder.policyName; + this.payload = builder.payload; + this.actionTag = builder.actionTag; + this.userName = builder.userName; + this.tenantID = builder.tenantID; + this.tenantDomain = builder.tenantDomain; + } + + public String getPolicyName() { + return policyName; + } + + public String getPayload() { + return payload; + } + + public String getActionTag() { + return actionTag; + } + + public String getUserName() { + return userName; + } + + public String getTenantID() { + return tenantID; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public static class Builder { + private String policyName; + private String payload; + private String actionTag; + private String userName; + private String tenantID; + private String tenantDomain; + + public Builder() { + } + + public String getPolicyName() { + return policyName; + } + + public Builder setPolicyName(String policyName) { + this.policyName = policyName; + return this; + } + + public String getPayload() { + return payload; + } + + public Builder setPayload(String payload) { + this.payload = payload; + return this; + } + + public String getActionTag() { + return actionTag; + } + + public Builder setActionTag(String actionTag) { + this.actionTag = actionTag; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getTenantID() { + return tenantID; + } + + public Builder setTenantID(String tenantID) { + this.tenantID = tenantID; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public PolicyLogContext build() { + return new PolicyLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java new file mode 100644 index 0000000000..81f071c2af --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraAppInstallLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraAppInstallLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java new file mode 100644 index 0000000000..aaa62bf488 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraDeviceConnectivityLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java new file mode 100644 index 0000000000..db0b7dd265 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraDeviceEnrolmentLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java index ae10ae87c2..a51987463f 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; - import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; @@ -26,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; - public class EntgraDeviceLoggerImpl implements EntgraLogger { private static Log log = null; @@ -74,7 +72,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.info(object, t); } - public void debug(String message) { log.debug(message); } @@ -114,7 +111,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.debug(object, t); } - public void error(String message) { log.error(message); } @@ -161,7 +157,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.error(object, t); } - public void warn(String message) { log.warn(message); } @@ -208,7 +203,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.warn(object, t); } - public void trace(String message) { log.trace(message); } @@ -248,7 +242,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.trace(object, t); } - public void fatal(String message) { log.fatal(message); } diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java new file mode 100644 index 0000000000..218252f260 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraPolicyLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraPolicyLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java index 6a082b013d..fa482605f6 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; - import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.UserLogContext; @@ -26,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; - public class EntgraUserLoggerImpl implements EntgraLogger { private static Log log = null; diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index 09f903188a..dc046e8eeb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -17,8 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.util; -import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; -import io.entgra.device.mgt.core.notification.logger.UserLogContext; +import io.entgra.device.mgt.core.notification.logger.*; import org.apache.log4j.MDC; public final class MDCContextUtil { @@ -62,6 +61,105 @@ public final class MDCContextUtil { } } + + public static void populatePolicyMDCContext(final PolicyLogContext mdcContext) { + if (mdcContext.getPolicyName() != null) { + MDC.put("PolicyName", mdcContext.getPolicyName()); + } + if (mdcContext.getPayload() != null) { + MDC.put("Payload", mdcContext.getPayload()); + } + if (mdcContext.getActionTag() != null) { + MDC.put("ActionTag", mdcContext.getActionTag()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantID() != null) { + MDC.put("TenantId", mdcContext.getTenantID()); + } + } + + public static void populateAppInstallMDCContext(final AppInstallLogContext mdcContext) { + if (mdcContext.getAppId() != null) { + MDC.put("AppId", mdcContext.getAppId()); + } + if (mdcContext.getAppName() != null) { + MDC.put("AppName", mdcContext.getAppName()); + } + if (mdcContext.getAppType() != null) { + MDC.put("AppType", mdcContext.getAppType()); + } + if (mdcContext.getSubType() != null) { + MDC.put("SubType", mdcContext.getSubType()); + } + if (mdcContext.getDevice() != null) { + MDC.put("Device", mdcContext.getDevice()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantId() != null) { + MDC.put("TenantId", mdcContext.getTenantId()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getAction() != null) { + MDC.put("Action", mdcContext.getAction()); + } + } + + public static void populateDeviceConnectivityMDCContext(final DeviceConnectivityLogContext mdcContext) { + if (mdcContext.getDeviceId() != null) { + MDC.put("DeviceId", mdcContext.getDeviceId()); + } + if (mdcContext.getDeviceType() != null) { + MDC.put("DeviceType", mdcContext.getDeviceType()); + } + if (mdcContext.getOperationCode() != null) { + MDC.put("OperationCode", mdcContext.getOperationCode()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantId() != null) { + MDC.put("TenantId", mdcContext.getTenantId()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getActionTag() != null) { + MDC.put("ActionTag", mdcContext.getActionTag()); + } + } + + public static void populateDeviceEnrolmentMDCContext(final DeviceEnrolmentLogContext mdcContext) { + if (mdcContext.getDeviceId() != null) { + MDC.put("DeviceId", mdcContext.getDeviceId()); + } + if (mdcContext.getDeviceType() != null) { + MDC.put("DeviceType", mdcContext.getDeviceType()); + } + if (mdcContext.getOwner() != null) { + MDC.put("Owner", mdcContext.getOwner()); + } + if (mdcContext.getOwnership() != null) { + MDC.put("Ownership", mdcContext.getOwnership()); + } + if (mdcContext.getTenantID() != null) { + MDC.put("TenantId", mdcContext.getTenantID()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + } } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index b07f311ce1..c5d661c567 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -54,7 +57,8 @@ import java.util.Set; public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { - private static final Log log = LogFactory.getLog(PolicyAdministratorPointImpl.class); + PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); + private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyAdministratorPointImpl.class); private PolicyManager policyManager; private ProfileManager profileManager; @@ -135,6 +139,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); if (log.isDebugEnabled()) { @@ -168,11 +174,13 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { properties, triggerInfo); taskManager.registerTask(taskInfo); taskManager.scheduleTask(taskInfo.getName()); + log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { if (!taskManager.isTaskScheduled(taskName)) { TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ, properties, triggerInfo); taskManager.scheduleTask(taskInfo.getName()); + log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { throw new PolicyManagementException("There is a task already running for policy changes. Please try " + "to apply " + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 5cc0dc35b8..d0534e28ac 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; @@ -48,6 +52,7 @@ import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.sql.Timestamp; @@ -55,12 +60,13 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { + PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); private final PolicyDAO policyDAO; private final ProfileDAO profileDAO; private final FeatureDAO featureDAO; private final ProfileManager profileManager; private final PolicyConfiguration policyConfiguration; - private static final Log log = LogFactory.getLog(PolicyManagerImpl.class); + private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyManagerImpl.class); public PolicyManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -72,6 +78,9 @@ public class PolicyManagerImpl implements PolicyManager { @Override public Policy addPolicy(Policy policy) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { PolicyManagementDAOFactory.beginTransaction(); if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { @@ -153,11 +162,16 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + String stringPayload = new Gson().toJson(policy); + log.info("Policy created", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("ADD_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @Override public Policy updatePolicy(Policy policy) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { // Previous policy needs to be obtained before beginning the transaction Policy previousPolicy = this.getPolicy(policy.getId()); @@ -299,6 +313,8 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + String stringPayload = new Gson().toJson(policy); + log.info("Policy updated", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("UPDATE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @@ -488,6 +504,10 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean updatePolicyPriorities(List policies) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); + String stringPayload = new Gson().toJson(policies); boolean bool; try { List existingPolicies; @@ -516,18 +536,24 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + log.info("Policy priorities updated", policyLogContextBuilder.setPayload(stringPayload).setActionTag("UPDATE_POLICY_PRIORITIES").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { try { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); PolicyManagementDAOFactory.beginTransaction(); policyDAO.deleteAllPolicyRelatedConfigs(policy.getId()); policyDAO.deletePolicy(policy.getId()); featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); + String stringPayload = new Gson().toJson(policy); + log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return true; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -548,6 +574,9 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); boolean bool; List policies = this.getPolicies(); Policy pol = null; @@ -578,6 +607,8 @@ public class PolicyManagerImpl implements PolicyManager { featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); + String stringPayload = new Gson().toJson(policy); + log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -636,6 +667,9 @@ public class PolicyManagerImpl implements PolicyManager { List deviceList = new ArrayList<>(); DeviceManagementProviderService deviceManagementService = PolicyManagementDataHolder .getInstance().getDeviceManagementService(); + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); for (DeviceIdentifier deviceIdentifier : deviceIdentifierList) { try { Device device = deviceManagementService.getDevice(deviceIdentifier, false); @@ -664,6 +698,9 @@ public class PolicyManagerImpl implements PolicyManager { } policy.setDevices(deviceList); } + String policyPayload = new Gson().toJson(policy); + String deviceListPayload = new Gson().toJson(deviceList); + log.info("Policy added to devices", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(" Policy: " + policyPayload + " DeviceList: " + deviceListPayload).setActionTag("ADD_POLICY_TO_DEVICE").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new PolicyManagementException("Error occurred while adding the policy (" From ce4276c93a34870f67882e9cc415d333a6b7696a Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Tue, 4 Apr 2023 03:01:09 +0530 Subject: [PATCH 046/157] pom.xml updated by pull --- .../org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index ce7fb6b507..e8baa01f8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -47,7 +47,7 @@ testng - org.wso2.tomcat + org. wso2.tomcat tomcat From 88356c57aa962bb86a0ed10a934bb670eac1e4c8 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Tue, 4 Apr 2023 13:52:03 +0530 Subject: [PATCH 047/157] Add hierarchical grouping feature --- .../service/api/GroupManagementService.java | 87 ++++++++++ .../admin/GroupManagementAdminService.java | 85 +++++++++- .../impl/GroupManagementServiceImpl.java | 63 +++++++ .../GroupManagementAdminServiceImpl.java | 41 +++++ .../group/mgt/DeviceGroupRoleWrapper.java | 155 ++++++++++++++++++ .../core/device/mgt/core/dao/GroupDAO.java | 30 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 100 +++++++++-- .../impl/group/PostgreSQLGroupDAOImpl.java | 42 ++++- .../core/dao/util/GroupManagementDAOUtil.java | 1 + .../GroupManagementProviderService.java | 11 ++ .../GroupManagementProviderServiceImpl.java | 84 ++++++++++ .../src/test/resources/sql/h2.sql | 1 + .../pom.xml | 2 +- .../src/test/resources/sql/CreateH2TestDB.sql | 1 + .../src/main/resources/dbscripts/cdm/h2.sql | 1 + .../main/resources/dbscripts/cdm/mssql.sql | 1 + .../main/resources/dbscripts/cdm/mysql.sql | 1 + .../main/resources/dbscripts/cdm/oracle.sql | 1 + .../resources/dbscripts/cdm/postgresql.sql | 1 + 19 files changed, 691 insertions(+), 17 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index cfe12bc3f8..be792d22c1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -26,6 +26,13 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; import javax.ws.rs.*; @@ -159,6 +166,13 @@ import java.util.List; key = "perm:groups:devices-types", roles = {"Internal/devicemgt-user"}, permissions = {"/device-mgt/groups/devices/types"} + ), + @Scope( + name = "View whether the groups has relevant device types", + description = "View whether the groups has relevant device types", + key = "perm:groups:add", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/groups/device-types"} ) } ) @@ -1206,4 +1220,77 @@ public interface GroupManagementService { required = true) List identifiers); + + @POST + @Path("/roles/share") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", + notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", + tags = "Device Group Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "Created. \n Device group has successfully been created.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL of the created group."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body."), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.") + } + ), + @ApiResponse( + code = 303, + message = "See Other. \n Source can be retrieved from the URL specified at the Location " + + "header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Group not found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while creating the group or adding devices or sharing the group.", + response = ErrorResponse.class) + }) + Response createGroupWithRoles(@ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + ); + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java index 393389340f..eb5f791ab6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -27,8 +27,16 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; -import javax.ws.rs.*; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -358,4 +366,79 @@ public interface GroupManagementAdminService { required = true) @Valid DeviceGroup group); + + + @POST + @Path("/roles/share") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", + notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", + tags = "Device Group Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "Created. \n Device group has successfully been created.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL of the created group."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body."), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.") + } + ), + @ApiResponse( + code = 303, + message = "See Other. \n Source can be retrieved from the URL specified at the Location " + + "header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Group not found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while creating the group or adding devices or sharing the group.", + response = ErrorResponse.class) + }) + Response createGroupWithRoles(@ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + + ); + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index f0122835e1..b7e9ba8271 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -18,6 +18,27 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; @@ -39,6 +60,14 @@ import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.transaction.UserTransaction; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; @@ -416,4 +445,38 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } + @POST + @Path("/roles/share") + @Override + public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { + String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + if (groups == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + groups.setOwner(owner); + groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); + try { + DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); + DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), owner.isEmpty()); + if (group != null) { + DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); + return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); + } else { + String msg = "Error occurred while retrieving newly created group."; + log.error(msg); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } catch (GroupManagementException e) { + String msg = "Error occurred while adding new group."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (GroupAlreadyExistException e) { + String msg = "Group already exists with name : " + groups.getName() + "."; + log.warn(msg); + return Response.status(Response.Status.CONFLICT).entity(msg).build(); + } catch (RoleDoesNotExistException e) { + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 5f6d8a7bae..3ff5bcdb48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -29,9 +29,25 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @@ -144,4 +160,29 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ return Response.status(Response.Status.CONFLICT).entity(msg).build(); } } + @POST + @Path("/roles/share") + @Override + public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { + String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + if (group == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + group.setOwner(owner); + group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); + try { + DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); + DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); + return Response.status(Response.Status.CREATED).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while adding new group."; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (GroupAlreadyExistException e) { + String msg = "Group already exists with name : " + group.getName() + "."; + return Response.status(Response.Status.CONFLICT).entity(msg).build(); + } catch (RoleDoesNotExistException e) { + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java new file mode 100644 index 0000000000..132730e915 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.common.group.mgt; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * Holds Device Group details and expose to external access + */ +@ApiModel(value = "DeviceGroupRoleWrapper", description = "This class carries all information related to a managed device group.") +public class DeviceGroupRoleWrapper implements Serializable { + + private static final long serialVersionUID = 1998121711L; + + @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") + private int id; + + @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", + required = true) + private String description; + + @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", + required = true) + private String name; + + private String owner; + + @ApiModelProperty(name = "status", value = "The status of group that needs updating/retrieval.") + private String status; + + @ApiModelProperty(name = "parentGroupId", value = "Group ID of parent group") + private int parentGroupId; + + @ApiModelProperty(name = "parentPath", value = "Path of parent group") + private String parentPath; + + @ApiModelProperty(name = "childrenGroups", value = "Children groups") + private List childrenGroups; + + @ApiModelProperty(name = "userRoles", value = "User roles") + private List userRoles; + +// @ApiModelProperty(name = "DeviceGroupRoleWrapper", value = "Device group role wrapper") +// private List DeviceGroupRoleWrapper; + + public DeviceGroupRoleWrapper() {} + + public DeviceGroupRoleWrapper(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + private Map groupProperties; + + public int getGroupId() { + return id; + } + + public void setGroupId(int id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public Map getGroupProperties() { + return groupProperties; + } + + public void setGroupProperties(Map groupProperties) { + this.groupProperties = groupProperties; + } + + public int getParentGroupId() { + return parentGroupId; + } + + public void setParentGroupId(int parentGroupId) { + this.parentGroupId = parentGroupId; + } + + public String getParentPath() { + return parentPath; + } + + public void setParentPath(String parentPath) { + this.parentPath = parentPath; + } + + public List getChildrenGroups() { + return childrenGroups; + } + + public void setChildrenGroups(List childrenGroups) { + this.childrenGroups = childrenGroups; + } + + public List getUserRoles() { + return userRoles; + } + + public void setUserRoles(List userRoles) { + this.userRoles = userRoles; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 16ac6f62be..8ee4b7d869 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import java.util.List; import java.util.Map; @@ -40,6 +41,21 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; + + /** + * Add properties for device group. + * Note that groupId parameter is considered seperately due to the groupId parameter passed with + * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. + * + * @param groups to be added. + * @param tenantId of the group. + * @return sql execution result. + * @throws GroupManagementDAOException + */ + int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; + + + /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -50,8 +66,22 @@ public interface GroupDAO { * @return sql execution result. * @throws GroupManagementDAOException */ + boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; + /** + * Update properties for device group. + * Note that groupId parameter is considered seperately due to the groupId parameter passed with + * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. + * + * @param groups to be updated. + * @param tenantId of the group. + * @return sql execution result. + * @throws GroupManagementDAOException + */ + + boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; + /** * Update properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 803526e593..db38b8eb90 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -49,7 +50,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; @@ -111,7 +112,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE TENANT_ID = ?"; + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; } @@ -175,11 +176,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if (deviceGroup.getStatus() == null || deviceGroup.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " - + "VALUES (?, ?, ?, ?, ?)"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + "VALUES (?, ?, ?, ?, ?, ?)"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?, ?)"; hasStatus = true; } stmt = conn.prepareStatement(sql, new String[]{"ID"}); @@ -188,8 +189,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setInt(4, tenantId); stmt.setString(5, deviceGroup.getParentPath()); + stmt.setInt(6, deviceGroup.getParentGroupId()); if (hasStatus) { - stmt.setString(6, deviceGroup.getStatus()); + stmt.setString(7, deviceGroup.getStatus()); } stmt.executeUpdate(); @@ -206,6 +208,48 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs; + int groupId = -1; + boolean hasStatus = false; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql; + if (groups.getStatus() == null || groups.getStatus().isEmpty()) { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + + "VALUES (?, ?, ?, ?, ?, ?)"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?, ?)"; + hasStatus = true; + } + stmt = conn.prepareStatement(sql, new String[]{"ID"}); + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + stmt.setInt(6, groups.getParentGroupId()); + if (hasStatus) { + stmt.setString(7, groups.getStatus()); + } + + + stmt.executeUpdate(); + rs = stmt.getGeneratedKeys(); + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } catch (SQLException e) { + throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + + groups.getName() + "'", e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + } + public boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -234,6 +278,34 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { return status; } + public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) + throws GroupManagementDAOException { + boolean status; + PreparedStatement stmt = null; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + stmt = conn.prepareStatement( + "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + + "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)"); + for (Map.Entry entry : groups.getGroupProperties().entrySet()) { + stmt.setInt(1, groupId); + stmt.setString(2, entry.getKey()); + stmt.setString(3, entry.getValue()); + stmt.setInt(4, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + status = true; + } catch (SQLException e) { + String msg = "Error occurred while adding properties for group '" + + groups.getName() + "' values : " + groups.getGroupProperties(); + throw new GroupManagementDAOException(msg, e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + public boolean updateGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -491,7 +563,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { ResultSet resultSet = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE ID = ? " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE ID = ? " + "AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -514,7 +586,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getChildrenGroups(String parentPath, int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, parentPath + "%"); @@ -539,7 +611,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getRootGroups(int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, "/"); @@ -567,7 +639,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupBuilders = new ArrayList<>(); try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH FROM DM_GROUP G " + + String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH, G.PARENT_GROUP_ID FROM DM_GROUP G " + "INNER JOIN DM_DEVICE_GROUP_MAP GM ON G.ID = GM.GROUP_ID " + "WHERE GM.DEVICE_ID = ? AND GM.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); @@ -705,7 +777,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = - "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE LOWER(GROUP_NAME) = LOWER(?) AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, groupName); @@ -876,7 +948,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP g, " + + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID P FROM DM_GROUP g, " + "(SELECT GROUP_ID FROM DM_ROLE_GROUP_MAP WHERE ROLE IN ("; int index = 0; @@ -990,7 +1062,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, username); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index f2aeaed327..eec480abd7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -49,7 +50,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if(StringUtils.isEmpty(deviceGroup.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + @@ -79,6 +80,45 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } + public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs; + int groupId = -1; + boolean hasStatus = false; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql; + if(StringUtils.isEmpty(groups.getStatus())) { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + "VALUES (?, ?, ?, ?) RETURNING ID"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + + "VALUES (?, ?, ?, ?, ?) RETURNING ID"; + hasStatus = true; + } + stmt = conn.prepareStatement(sql); + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + if(hasStatus) { + stmt.setString(6, groups.getStatus()); + } + stmt.execute(); + rs = stmt.getGeneratedKeys(); + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } catch (SQLException e) { + throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + + groups.getName() + "'", e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + } + @Override public List getDevices(int groupId, int startIndex, int rowCount, int tenantId) throws GroupManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java index acf8d4c614..42307e6b74 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java @@ -87,6 +87,7 @@ public final class GroupManagementDAOUtil { group.setOwner(resultSet.getString("OWNER")); group.setStatus(resultSet.getString("STATUS")); group.setParentPath(resultSet.getString("PARENT_PATH")); + group.setParentGroupId(resultSet.getInt("PARENT_GROUP_ID")); return group; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 1bae5b30ce..729c9f0abe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -43,6 +43,17 @@ public interface GroupManagementProviderService { void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException; + /** + * Add new device group and create default role with default permissions. + * + * @param groups to add + * @param defaultRole of the deviceGroup + * @param defaultPermissions of the default role + * @throws GroupManagementException + */ + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, + String[] defaultPermissions )throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + /** * Update existing device group. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index c605a8ebe7..2cc0be6640 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -19,6 +19,23 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -41,6 +58,11 @@ import org.wso2.carbon.user.api.UserStoreManager; import java.sql.SQLException; import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -125,6 +147,68 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } + + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) + throws GroupManagementException, GroupAlreadyExistException { + if (groups == null) { + String msg = "Received incomplete data for createGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Creating group '" + groups.getName() + "'"); + } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + GroupManagementDAOFactory.beginTransaction(); + DeviceGroup existingGroup = this.groupDAO.getGroup(groups.getName(), tenantId); + if (existingGroup == null) { + if (groups.getParentGroupId() == 0) { + groups.setParentPath(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); + } else { + DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); + if (immediateParentGroup == null) { + String msg = "Parent group with group ID '" + groups.getParentGroupId() + + "' does not exist. Hence creating of group '" + groups.getName() + + "' was not success"; + log.error(msg); + throw new GroupManagementException(msg); + } + String parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup); + groups.setParentPath(parentPath); + } + int updatedGroupID = this.groupDAO.addGroupWithRoles(groups, tenantId); + if (groups.getGroupProperties() != null && groups.getGroupProperties().size() > 0) { + this.groupDAO.addGroupPropertiesWithRoles(groups, updatedGroupID, tenantId); + } + GroupManagementDAOFactory.commitTransaction(); + } else { + throw new GroupAlreadyExistException("Group exist with name " + groups.getName()); + } + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding deviceGroup '" + groups.getName() + "' to database."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupAlreadyExistException ex) { + throw ex; + } catch (Exception e) { + String msg = "Error occurred in creating group '" + groups.getName() + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + + if (log.isDebugEnabled()) { + log.debug("DeviceGroup added: " + groups.getName()); + } + } + /** * {@inheritDoc} */ diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index d22d8f312f..4f83fa5b5e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index e8baa01f8b..ce7fb6b507 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -47,7 +47,7 @@ testng - org. wso2.tomcat + org.wso2.tomcat tomcat diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 6c906a5c49..e3ed0cd6ec 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -66,6 +66,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index df3277920d..15ffa69605 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -25,6 +25,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index c162d41e06..5b6b3b93f1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -41,6 +41,7 @@ IF NOT EXISTS(SELECT * OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 6dcc7bec44..86da197b12 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -29,6 +29,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ENGINE = InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index a6f87c9cb6..6cc55f7e74 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -52,6 +52,7 @@ CREATE TABLE DM_GROUP ( OWNER VARCHAR2(255) DEFAULT NULL, PARENT_PATH VARCHAR2(255) DEFAULT NULL, TENANT_ID NUMBER(10) DEFAULT 0, + PARENT_GROUP_ID NUMBER(10) DEFAULT 0, CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 8c601111b7..b1fc128cf9 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ; From 32e5456f215348b6ebec8136fb3e622ffa34011f Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 17:16:38 +0530 Subject: [PATCH 048/157] fixes line issues --- .../group/mgt/DeviceGroupRoleWrapper.java | 20 ++-- .../core/device/mgt/core/dao/GroupDAO.java | 92 +++++++++---------- 2 files changed, 52 insertions(+), 60 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java index 132730e915..768fe55524 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java @@ -37,12 +37,10 @@ public class DeviceGroupRoleWrapper implements Serializable { @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") private int id; - @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", - required = true) + @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", required = true) private String description; - @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", - required = true) + @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", required = true) private String name; private String owner; @@ -62,10 +60,8 @@ public class DeviceGroupRoleWrapper implements Serializable { @ApiModelProperty(name = "userRoles", value = "User roles") private List userRoles; -// @ApiModelProperty(name = "DeviceGroupRoleWrapper", value = "Device group role wrapper") -// private List DeviceGroupRoleWrapper; - - public DeviceGroupRoleWrapper() {} + public DeviceGroupRoleWrapper() { + } public DeviceGroupRoleWrapper(String name) { this.name = name; @@ -79,7 +75,7 @@ public class DeviceGroupRoleWrapper implements Serializable { this.status = status; } - private Map groupProperties; + private Map groupProperties; public int getGroupId() { return id; @@ -113,11 +109,11 @@ public class DeviceGroupRoleWrapper implements Serializable { this.owner = owner; } - public Map getGroupProperties() { + public Map getGroupProperties() { return groupProperties; } - public void setGroupProperties(Map groupProperties) { + public void setGroupProperties(Map groupProperties) { this.groupProperties = groupProperties; } @@ -152,4 +148,4 @@ public class DeviceGroupRoleWrapper implements Serializable { public void setUserRoles(List userRoles) { this.userRoles = userRoles; } -} +} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 8ee4b7d869..6072d52ee7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -31,6 +31,7 @@ import java.util.Map; * This interface represents the key operations associated with persisting group related information. */ public interface GroupDAO { + /** * Add new Device Group. * @@ -41,21 +42,18 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be added. - * @param tenantId of the group. + * @param groups to be added. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; - - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -66,7 +64,6 @@ public interface GroupDAO { * @return sql execution result. * @throws GroupManagementDAOException */ - boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; /** @@ -74,12 +71,11 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be updated. - * @param tenantId of the group. + * @param groups to be updated. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; /** @@ -97,8 +93,8 @@ public interface GroupDAO { /** * Remove properties for device group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; @@ -115,19 +111,19 @@ public interface GroupDAO { /** * Retrives all properties stored against a group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; + Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; /** * Update an existing Device Group. * * @param deviceGroup group to update. - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void updateGroup(DeviceGroup deviceGroup, int groupId, int tenantId) @@ -137,7 +133,7 @@ public interface GroupDAO { * Update existing Device Groups. * * @param deviceGroups groups to update. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during updating of groups */ void updateGroups(List deviceGroups, int tenantId) throws GroupManagementDAOException; @@ -145,8 +141,8 @@ public interface GroupDAO { /** * Delete an existing Device Group. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteGroup(int groupId, int tenantId) throws GroupManagementDAOException; @@ -155,7 +151,7 @@ public interface GroupDAO { * Delete mappings of Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of mappings of groups */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -164,7 +160,7 @@ public interface GroupDAO { * Delete existing Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of groups */ void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -172,8 +168,8 @@ public interface GroupDAO { /** * Get device group by id. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @return Device Group in tenant with specified name. * @throws GroupManagementDAOException */ @@ -183,7 +179,7 @@ public interface GroupDAO { * Get children groups by parent path. * * @param parentPath of parent group. - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of children device groups * @throws GroupManagementDAOException on error during retrieval of children groups */ @@ -192,7 +188,7 @@ public interface GroupDAO { /** * Get root groups. * - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of root device groups * @throws GroupManagementDAOException on error during retrieval of root groups */ @@ -200,6 +196,7 @@ public interface GroupDAO { /** * Get the groups of device with device id provided + * * @param deviceId * @return groups which has the device. * @throws GroupManagementDAOException @@ -210,7 +207,7 @@ public interface GroupDAO { * Get paginated list of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -250,7 +247,7 @@ public interface GroupDAO { * Get paginated count of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -260,7 +257,7 @@ public interface GroupDAO { * Check group already existed with given name. * * @param groupName of the Device Group. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return existence of group with name * @throws GroupManagementDAOException */ @@ -269,7 +266,7 @@ public interface GroupDAO { /** * Add device to a given Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -279,7 +276,7 @@ public interface GroupDAO { /** * Remove device from the Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -289,7 +286,7 @@ public interface GroupDAO { /** * Check device is belonging to a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -300,7 +297,7 @@ public interface GroupDAO { /** * Get count of devices in a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param tenantId of user's tenant. * @return device count. * @throws GroupManagementDAOException @@ -310,10 +307,10 @@ public interface GroupDAO { /** * Get paginated result of devices of a given tenant and device group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param startIndex for pagination. - * @param rowCount for pagination. - * @param tenantId of user's tenant. + * @param rowCount for pagination. + * @param tenantId of user's tenant. * @return list of device in group * @throws GroupManagementDAOException */ @@ -323,9 +320,9 @@ public interface GroupDAO { /** * Get All the devices that are in one of the given device status and belongs to given group * - * @param groupName Group name + * @param groupName Group name * @param deviceStatuses Device Statuses - * @param tenantId Tenant Id + * @param tenantId Tenant Id * @return List of devices * @throws GroupManagementDAOException if error occurred while retreving list of devices that are in one of the * given device status and belongs to the given group @@ -388,8 +385,8 @@ public interface GroupDAO { /** * Get count of all device groups which shared with a user role. * - * @param roles of the group. - * @param tenantId of user's tenant. + * @param roles of the group. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException @@ -419,27 +416,26 @@ public interface GroupDAO { /** * Get count of device groups which owned by user. * - * @param username of the owner. - * @param tenantId of user's tenant. + * @param username of the owner. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException */ int getOwnGroupsCount(String username, int tenantId, String parentPath) throws GroupManagementDAOException; - /** - * Get device Ids of devices which are assigned to groups. + components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java * Get device Ids of devices which are assigned to groups. * * @param paginationRequest Request object with offset and limit. - * @param groupNames default group names that should be omitted when checking the device - * whether they have been assigned to groups - * @throws GroupManagementDAOException Might occur while retrieving information of group - * unassigned devices + * @param groupNames default group names that should be omitted when checking the device + * whether they have been assigned to groups * @return details of devices that are unassigned to groups. + * @throws GroupManagementDAOException Might occur while retrieving information of group + * unassigned devices */ List getGroupUnassignedDevices(PaginationRequest paginationRequest, List groupNames) throws GroupManagementDAOException; -} +} \ No newline at end of file From d842fc4085ad0ba335cb907b693c18489e5dc6c0 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 17:45:27 +0530 Subject: [PATCH 049/157] remove unnecessary imports, fixes line issues --- .../mgt/core/service/GroupManagementProviderService.java | 5 ++--- .../core/service/GroupManagementProviderServiceImpl.java | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 729c9f0abe..ab4e7aa926 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -46,13 +46,12 @@ public interface GroupManagementProviderService { /** * Add new device group and create default role with default permissions. * - * @param groups to add + * @param groups to add * @param defaultRole of the deviceGroup * @param defaultPermissions of the default role * @throws GroupManagementException */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, - String[] defaultPermissions )throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; /** * Update existing device group. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 2cc0be6640..44dea24fe4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -147,9 +147,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) - throws GroupManagementException, GroupAlreadyExistException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -168,9 +166,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); if (immediateParentGroup == null) { - String msg = "Parent group with group ID '" + groups.getParentGroupId() - + "' does not exist. Hence creating of group '" + groups.getName() - + "' was not success"; + String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; log.error(msg); throw new GroupManagementException(msg); } From 13545f1c7c1ef13d5d48195c1bb5f4b53cd35a44 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 18:38:11 +0530 Subject: [PATCH 050/157] remove unnecessary code lines --- .../core/device/mgt/core/dao/GroupDAO.java | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 6072d52ee7..75a6979410 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -31,7 +31,6 @@ import java.util.Map; * This interface represents the key operations associated with persisting group related information. */ public interface GroupDAO { - /** * Add new Device Group. * @@ -47,8 +46,8 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be added. - * @param tenantId of the group. + * @param groups to be added. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ @@ -71,8 +70,8 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be updated. - * @param tenantId of the group. + * @param groups to be updated. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ @@ -93,8 +92,8 @@ public interface GroupDAO { /** * Remove properties for device group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; @@ -111,19 +110,19 @@ public interface GroupDAO { /** * Retrives all properties stored against a group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; + Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; /** * Update an existing Device Group. * * @param deviceGroup group to update. - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void updateGroup(DeviceGroup deviceGroup, int groupId, int tenantId) @@ -133,7 +132,7 @@ public interface GroupDAO { * Update existing Device Groups. * * @param deviceGroups groups to update. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during updating of groups */ void updateGroups(List deviceGroups, int tenantId) throws GroupManagementDAOException; @@ -141,8 +140,8 @@ public interface GroupDAO { /** * Delete an existing Device Group. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteGroup(int groupId, int tenantId) throws GroupManagementDAOException; @@ -151,7 +150,7 @@ public interface GroupDAO { * Delete mappings of Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of mappings of groups */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -160,7 +159,7 @@ public interface GroupDAO { * Delete existing Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of groups */ void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -168,8 +167,8 @@ public interface GroupDAO { /** * Get device group by id. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @return Device Group in tenant with specified name. * @throws GroupManagementDAOException */ @@ -179,7 +178,7 @@ public interface GroupDAO { * Get children groups by parent path. * * @param parentPath of parent group. - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of children device groups * @throws GroupManagementDAOException on error during retrieval of children groups */ @@ -188,7 +187,7 @@ public interface GroupDAO { /** * Get root groups. * - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of root device groups * @throws GroupManagementDAOException on error during retrieval of root groups */ @@ -196,7 +195,6 @@ public interface GroupDAO { /** * Get the groups of device with device id provided - * * @param deviceId * @return groups which has the device. * @throws GroupManagementDAOException @@ -207,7 +205,7 @@ public interface GroupDAO { * Get paginated list of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -247,7 +245,7 @@ public interface GroupDAO { * Get paginated count of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -257,7 +255,7 @@ public interface GroupDAO { * Check group already existed with given name. * * @param groupName of the Device Group. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return existence of group with name * @throws GroupManagementDAOException */ @@ -266,7 +264,7 @@ public interface GroupDAO { /** * Add device to a given Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -276,7 +274,7 @@ public interface GroupDAO { /** * Remove device from the Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -286,7 +284,7 @@ public interface GroupDAO { /** * Check device is belonging to a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -297,7 +295,7 @@ public interface GroupDAO { /** * Get count of devices in a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param tenantId of user's tenant. * @return device count. * @throws GroupManagementDAOException @@ -307,10 +305,10 @@ public interface GroupDAO { /** * Get paginated result of devices of a given tenant and device group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param startIndex for pagination. - * @param rowCount for pagination. - * @param tenantId of user's tenant. + * @param rowCount for pagination. + * @param tenantId of user's tenant. * @return list of device in group * @throws GroupManagementDAOException */ @@ -320,9 +318,9 @@ public interface GroupDAO { /** * Get All the devices that are in one of the given device status and belongs to given group * - * @param groupName Group name + * @param groupName Group name * @param deviceStatuses Device Statuses - * @param tenantId Tenant Id + * @param tenantId Tenant Id * @return List of devices * @throws GroupManagementDAOException if error occurred while retreving list of devices that are in one of the * given device status and belongs to the given group @@ -385,8 +383,8 @@ public interface GroupDAO { /** * Get count of all device groups which shared with a user role. * - * @param roles of the group. - * @param tenantId of user's tenant. + * @param roles of the group. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException @@ -416,22 +414,23 @@ public interface GroupDAO { /** * Get count of device groups which owned by user. * - * @param username of the owner. - * @param tenantId of user's tenant. + * @param username of the owner. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException */ int getOwnGroupsCount(String username, int tenantId, String parentPath) throws GroupManagementDAOException; + /** - components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java * Get device Ids of devices which are assigned to groups. + * Get device Ids of devices which are assigned to groups. * * @param paginationRequest Request object with offset and limit. - * @param groupNames default group names that should be omitted when checking the device - * whether they have been assigned to groups - * @return details of devices that are unassigned to groups. + * @param groupNames default group names that should be omitted when checking the device + * whether they have been assigned to groups * @throws GroupManagementDAOException Might occur while retrieving information of group - * unassigned devices + * unassigned devices + * @return details of devices that are unassigned to groups. */ List getGroupUnassignedDevices(PaginationRequest paginationRequest, From cd9d127a5e1b1616ac5d0409fe225e0c93114f33 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 11:15:23 +0530 Subject: [PATCH 051/157] remove unnecessary variable, change error msg --- .../jaxrs/service/impl/GroupManagementServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index b7e9ba8271..262e51eb9f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -449,15 +449,15 @@ public class GroupManagementServiceImpl implements GroupManagementService { @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (groups == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - groups.setOwner(owner); + groups.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), owner.isEmpty()); + DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); if (group != null) { DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); @@ -467,7 +467,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + groups.getName() + " group"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { From 7d05446a38cd6359aa5802e1f0f3c38888ea30f2 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 14:29:10 +0530 Subject: [PATCH 052/157] add error log --- .../impl/admin/GroupManagementAdminServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 3ff5bcdb48..cd53637812 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -164,21 +164,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (group == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - group.setOwner(owner); + group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); return Response.status(Response.Status.CREATED).build(); } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + group.getName() + " group"; + log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { String msg = "Group already exists with name : " + group.getName() + "."; + log.warn(msg); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); From 4a239887cb717c996b3506ad49c2668adf586ddb Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Fri, 16 Jun 2023 01:58:42 +0530 Subject: [PATCH 053/157] add try with resources --- .../core/dao/impl/AbstractGroupDAOImpl.java | 70 +++++++++---------- .../impl/group/PostgreSQLGroupDAOImpl.java | 46 ++++++------ .../GroupManagementProviderService.java | 7 ++ .../GroupManagementProviderServiceImpl.java | 15 ++-- 4 files changed, 71 insertions(+), 67 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index db38b8eb90..37a10f9c23 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -208,9 +208,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + @Override public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs; int groupId = -1; boolean hasStatus = false; try { @@ -224,29 +223,29 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { + "VALUES (?, ?, ?, ?, ?, ?, ?)"; hasStatus = true; } - stmt = conn.prepareStatement(sql, new String[]{"ID"}); - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - stmt.setInt(6, groups.getParentGroupId()); - if (hasStatus) { - stmt.setString(7, groups.getStatus()); - } - - - stmt.executeUpdate(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - groupId = rs.getInt(1); + try (PreparedStatement stmt = conn.prepareStatement(sql, new String[]{"ID"})) { + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + stmt.setInt(6, groups.getParentGroupId()); + if (hasStatus) { + stmt.setString(7, groups.getStatus()); + } + stmt.executeUpdate(); + try (ResultSet rs = stmt.getGeneratedKeys();) { + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } } - return groupId; } catch (SQLException e) { - throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + - groups.getName() + "'", e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); + String msg = "Error occurred while adding deviceGroup '" + + groups.getName() + "'"; + log.error(msg); + throw new GroupManagementDAOException(msg, e); } } @@ -281,27 +280,26 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; - PreparedStatement stmt = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - stmt = conn.prepareStatement( + try (PreparedStatement stmt = conn.prepareStatement( "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + - "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)"); - for (Map.Entry entry : groups.getGroupProperties().entrySet()) { - stmt.setInt(1, groupId); - stmt.setString(2, entry.getKey()); - stmt.setString(3, entry.getValue()); - stmt.setInt(4, tenantId); - stmt.addBatch(); + "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)")) { + for (Map.Entry entry : groups.getGroupProperties().entrySet()) { + stmt.setInt(1, groupId); + stmt.setString(2, entry.getKey()); + stmt.setString(3, entry.getValue()); + stmt.setInt(4, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + status = true; } - stmt.executeBatch(); - status = true; } catch (SQLException e) { String msg = "Error occurred while adding properties for group '" + groups.getName() + "' values : " + groups.getGroupProperties(); + log.error(msg); throw new GroupManagementDAOException(msg, e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); } return status; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index eec480abd7..6a786a0bfd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -40,6 +42,7 @@ import java.util.List; */ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { + private static final Log log = LogFactory.getLog(PostgreSQLGroupDAOImpl.class); @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { PreparedStatement stmt = null; @@ -80,15 +83,14 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } + @Override public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs; int groupId = -1; boolean hasStatus = false; try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; - if(StringUtils.isEmpty(groups.getStatus())) { + if (StringUtils.isEmpty(groups.getStatus())) { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { @@ -96,26 +98,28 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { "VALUES (?, ?, ?, ?, ?) RETURNING ID"; hasStatus = true; } - stmt = conn.prepareStatement(sql); - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - if(hasStatus) { - stmt.setString(6, groups.getStatus()); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + if (hasStatus) { + stmt.setString(6, groups.getStatus()); + } + stmt.execute(); + try (ResultSet rs = stmt.getGeneratedKeys()) { + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } } - stmt.execute(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; } catch (SQLException e) { - throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + - groups.getName() + "'", e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); + String msg = "Error occurred while adding deviceGroup '" + + groups.getName() + "'"; + log.error(msg); + throw new GroupManagementDAOException(msg, e); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index ab4e7aa926..b263ea1234 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -24,6 +24,13 @@ import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 44dea24fe4..2dd39081a3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -49,6 +49,7 @@ import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.netbeans.lib.cvsclient.commandLine.command.status; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -147,7 +148,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -179,23 +180,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } else { - throw new GroupAlreadyExistException("Group exist with name " + groups.getName()); + throw new GroupManagementException("Group exist with name " + groups.getName()); } - } catch (GroupManagementDAOException e) { + } catch (GroupManagementDAOException | GroupManagementException e) { GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while adding deviceGroup '" + groups.getName() + "' to database."; + String msg = e.getMessage(); log.error(msg, e); throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { String msg = "Error occurred while initiating transaction."; log.error(msg, e); throw new GroupManagementException(msg, e); - } catch (GroupAlreadyExistException ex) { - throw ex; - } catch (Exception e) { - String msg = "Error occurred in creating group '" + groups.getName() + "'"; - log.error(msg, e); - throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } From ae131693774e346f159e8b99ba4a98a16dc632e4 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Fri, 16 Jun 2023 09:48:52 +0530 Subject: [PATCH 054/157] add rollback --- .../mgt/core/service/GroupManagementProviderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 2dd39081a3..7c8f64768d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -167,6 +167,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); if (immediateParentGroup == null) { + GroupManagementDAOFactory.rollbackTransaction(); String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; log.error(msg); throw new GroupManagementException(msg); @@ -182,7 +183,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { throw new GroupManagementException("Group exist with name " + groups.getName()); } - } catch (GroupManagementDAOException | GroupManagementException e) { + } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); String msg = e.getMessage(); log.error(msg, e); From 4c1963a32b9dd9b14b7e1b21f9cf16e9fb8d4178 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 21 Jun 2023 13:48:19 +0530 Subject: [PATCH 055/157] [maven-release-plugin] prepare release v5.0.26 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 6 ++---- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 5 ++--- features/operation-template-mgt-plugin-feature/pom.xml | 5 ++--- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 132 files changed, 137 insertions(+), 141 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 59c0b53f0c..838561b6a7 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index a05f1959a3..abce130619 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index e8197e4426..075c39b37c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 0b495a83a8..a8220d602c 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index abf6339213..2aa9999730 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index e647b5f2dc..7fee2e5bb2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 1732b47585..68e72db692 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 37082c6fc6..757cbfadbc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 7434c58e54..8e1e32e95a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 7d4ef0501d..bcae043d9a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 2392078c2e..a28e93feb4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 53374f48c6..4588b2c460 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 0f030906b9..b4ff8dc017 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index bee1ec2744..fd85f36d34 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index c9eafdb800..6ee268bcd6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 7134db16fc..e9d33caae3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 512aef9700..9711c6d8dc 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 82a035ace6..57f9f2b74b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 0691f0648c..518d4c61da 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 35621201eb..755a7dbcc4 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 98c20d369b..9284098a0f 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 7bd5e03b5b..d97bfd8d08 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 16d45fccce..bf9d815d0c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index f984260692..3a17f1cc24 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index a50c455f80..1c73e6e36b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index c357cd7566..1a8656bd8e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 17a7c4b6ff..20904653a9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ec115c2905..8d33680a7e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 6291d849a5..97ff50cdbc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index cab0ec4896..ce27031777 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index c6914f5733..7d28fa77ee 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 09ac87fdb8..75c85b84d7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index d8323a431c..390405ef56 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index fffcfba429..922b19e1b2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 521ff65c5c..3840cd7f58 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index a9814241de..1b8a25de66 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 57ff12e288..06f017db31 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index cb1c9dba67..348fcfff2f 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 9971311788..b61f46b42d 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 819685280b..1ed1fc7ee8 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index fa60f27f1e..a72c50d97e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index f35ea73b60..ef17a87683 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 216bfb4d71..78584bb5ad 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 324934a4dd..3614aaa0cb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.26-SNAPSHOT + 5.0.26 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index cb85a7f88c..a5fe3c705e 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index a4ef16008e..8a50c339ea 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index d83ea2e190..77e08cf802 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 0eff71e8f9..a4a640a299 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 10fa65047d..00c531c249 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 52d3c6c045..de99ae8d4a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 5e7d63b270..d982303296 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 2daade26a6..5315ea8535 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 8add23b3d8..de517a3697 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 0f4e0f5f5a..9ec655ddde 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 0913807c9c..678ecb939d 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index daf623b335..67c0f7eff9 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 802b4fc403..c94144c21f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 9ea2215ea7..8b6639a9a4 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index e6c32be204..789defab64 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 456c573204..341eca5abf 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 1d07439a11..a0e6646599 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 5ed3918990..ebeea083b9 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index ce01e21a9c..287ff5b16d 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 2b70f9001d..edfdb7eab8 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 77c2cf12cb..cc85951b7f 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index a2140712f7..da419f1132 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 2e0dd266f5..c272274dc5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index fceb5e77d1..9e2ccfccfd 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index e91b0ed983..0e7b666ae5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 6eda7374a9..a6e36e35a8 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index a58b6b40ae..9218d9ce08 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 47912a8465..b046f3bde9 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index f9972e1ef0..da2f37f83c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index f5f2d2c1f3..8406a3140d 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index e7d57bd4b7..5de76a344c 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 01debfaf07..10387c44a8 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 2087a82870..dff8e55869 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 168b828243..f08e83b047 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 73abea954f..e3be4ee404 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index f13b9e3927..68350054e9 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index b0f3a595a5..da47b18dcc 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -17,14 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 636cc8c34e..e4f84c6659 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 1a2cb3b77e..093920714d 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 9c37daadae..6ed13d9ce2 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index eaa8ffa5c7..be0ded82eb 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 4877de4bbe..50795abc02 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 5617820cf5..cec153f56b 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index c21ff6fb19..6caf1a3128 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 3867d0806e..bc9d33470d 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 3acaabfd9d..8d4d88f357 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index ee3a2da42a..a421535337 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 5d58fe1956..2980c90d10 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 6ba482a99f..f82ffa6891 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 89babbcd7a..97815f9369 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 9dacdae6ba..f57f9a299b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index e37e6fbd26..4d4a4ce0ff 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index f74312e6a3..b5f933fbd7 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 810e45e3b7..31706389f4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index e02dcb8012..82fb243a6d 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 845e0f69d7..0a3cdfc6bf 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2a2c6468b1..2b5c4de3bd 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 904012948e..c2729e73ff 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 6455ab6f05..7b7fb9f736 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index cb5841a715..99869dbb9a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 230fa3700f..72be1ce3db 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index e1b4db491a..6020dcde00 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index f551b3e518..cded4f70a4 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 57b1438027..157c01609a 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 3220ebb7da..4277e38122 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 1bfe57fa69..0c6ee1ce8a 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index f4b3d3e41a..d25fa68234 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index f9f8ce9f41..ebb95d9957 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a16c219134..a0b620e134 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 7f96d0da93..9a5ef37eaa 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 97a7746320..d3de369a85 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index cf0e00a0b5..3bf3514e5e 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index f37cf1d8f3..13ce5f1747 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 7984cd5521..02d53d0dd7 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index a70cbbc67a..2d6b9ce586 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 001cc0dd34..63421e7713 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index a19947d332..da2cb6e32f 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 73986be63f..dabb999aa0 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index a75c167bfa..4a711fe135 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index ee58261e6c..fc2aa0d8ba 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 5dcab5c654..70b0166a43 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index d9b3cb564c..fc9d04a3d6 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index d60cefe7be..66617d8db4 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 90ba4c04cc..124abdc31f 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 45b132211d..97230de6c0 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index ce0141f915..c4b8dee97b 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 5aaec7c6b5..c507f7b23b 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/pom.xml b/pom.xml index ec8f446882..d954e1fcdd 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.26-SNAPSHOT + 5.0.26 WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -1794,7 +1794,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - HEAD + v5.0.26 @@ -1997,7 +1997,7 @@ 1.2.11-wso2v25 - 5.0.26-SNAPSHOT + 5.0.26 4.9.2 From 48801a3b8edf35d97c695b64c01dfb4971921044 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 21 Jun 2023 13:48:25 +0530 Subject: [PATCH 056/157] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 132 files changed, 134 insertions(+), 134 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 838561b6a7..c198c72364 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index abce130619..3cbdb071e5 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 075c39b37c..d16b2ad8c9 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index a8220d602c..110c64f553 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 2aa9999730..6482bc57da 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index 7fee2e5bb2..d2e2ca34c7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 68e72db692..5dc407ca23 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 757cbfadbc..022d3a8a51 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 8e1e32e95a..9ace7f0c33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index bcae043d9a..45c9ab231f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index a28e93feb4..82957d2b0d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 4588b2c460..201515986f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index b4ff8dc017..7e3ef60c38 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index fd85f36d34..2094510334 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 6ee268bcd6..6a8a238623 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index e9d33caae3..f9931aae6c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9711c6d8dc..2e2e67a22f 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 57f9f2b74b..b67ccf20ef 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 518d4c61da..3a7526f408 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 755a7dbcc4..d24319a34f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 9284098a0f..7833296e8a 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index d97bfd8d08..d8a79858c6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index bf9d815d0c..610f4f6cda 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 3a17f1cc24..da2c459069 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 1c73e6e36b..f238d4d5d4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 1a8656bd8e..1608581ec7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 20904653a9..c2899b36e3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 8d33680a7e..aeaed8655c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 97ff50cdbc..d1c6c2206c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index ce27031777..e18d86ef10 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 7d28fa77ee..1223822167 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 75c85b84d7..27617e89ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 390405ef56..bec50d0782 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 922b19e1b2..c00dc59b3b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 3840cd7f58..b97dba2a91 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 1b8a25de66..585aeafeaa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 06f017db31..d0ecba2064 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 348fcfff2f..7e01efb324 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index b61f46b42d..e6848b89c8 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 1ed1fc7ee8..7bf1a8fbdb 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index a72c50d97e..8bf81024df 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index ef17a87683..e5157d6a82 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 78584bb5ad..bc0478f310 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 3614aaa0cb..70ca947ed2 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.26 + 5.0.27-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index a5fe3c705e..c4dfdd014b 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 8a50c339ea..c8af2e9003 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 77e08cf802..94c29533fe 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index a4a640a299..0439397aff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 00c531c249..eac063769d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index de99ae8d4a..fbfb70849b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index d982303296..cd75cd10c5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 5315ea8535..0d6b866dea 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index de517a3697..8c1e357da7 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 9ec655ddde..91d04c4c33 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 678ecb939d..26e51edae7 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 67c0f7eff9..06997c8f17 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index c94144c21f..20edac784a 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 8b6639a9a4..f0eb908782 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 789defab64..7c15343e73 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 341eca5abf..d14ddd7d18 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index a0e6646599..b4ba0d60bf 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index ebeea083b9..8163f936a3 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 287ff5b16d..bdc00ce03d 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index edfdb7eab8..6550c0c17b 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index cc85951b7f..06b561b237 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index da419f1132..7c275e0a25 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index c272274dc5..9abdfa3735 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 9e2ccfccfd..60dcfdbe95 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 0e7b666ae5..a23d2d922d 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index a6e36e35a8..18baf3dd9d 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 9218d9ce08..685e75809d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index b046f3bde9..0faab0c2fa 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index da2f37f83c..44862e66e7 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 8406a3140d..252b96df53 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 5de76a344c..c087fc0b4a 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 10387c44a8..570f87276f 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index dff8e55869..7dd4d6fb94 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index f08e83b047..2ebf097dd7 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index e3be4ee404..c0456a9c1c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 68350054e9..b157b5afa6 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index da47b18dcc..98ac163d22 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index e4f84c6659..696558150f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 093920714d..6ed2466109 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 6ed13d9ce2..7e04260393 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index be0ded82eb..2841167689 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 50795abc02..499e95ba46 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index cec153f56b..da7eeda702 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 6caf1a3128..b434483af3 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index bc9d33470d..ad2d1c068c 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 8d4d88f357..366cffe69e 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index a421535337..7a33d7ebef 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 2980c90d10..bd44c707b0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index f82ffa6891..0798f33b74 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 97815f9369..dfbd7c1aa5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index f57f9a299b..3e3e688d59 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 4d4a4ce0ff..844427fea5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index b5f933fbd7..8648168dca 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 31706389f4..1c2f9f450a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 82fb243a6d..84e33b2daf 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 0a3cdfc6bf..8f8ec91fba 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2b5c4de3bd..406388f422 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index c2729e73ff..062cc6df3e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 7b7fb9f736..9ef814e62f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 99869dbb9a..80ed932a53 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 72be1ce3db..96c5194c45 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 6020dcde00..096683db82 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index cded4f70a4..a2d4bed8ba 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 157c01609a..13e974fbdb 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 4277e38122..c3e2fafa70 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 0c6ee1ce8a..fd4fb89fd9 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index d25fa68234..34a5aa4ccf 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index ebb95d9957..3eb94e0b04 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a0b620e134..8351d50946 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 9a5ef37eaa..02b8f172a5 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index d3de369a85..5eaac22ad1 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 3bf3514e5e..30094f7686 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 13ce5f1747..3cccf87ad1 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 02d53d0dd7..3243b26827 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 2d6b9ce586..d7e84d2782 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 63421e7713..002b18f48f 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index da2cb6e32f..8f87de9b1f 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index dabb999aa0..ee105d34b8 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 4a711fe135..53fcfbaee9 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index fc2aa0d8ba..23513d7ed8 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 70b0166a43..b6dd0dcc5c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index fc9d04a3d6..c7f0a53f58 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 66617d8db4..8350d1b2d2 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 124abdc31f..53903a27e5 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 97230de6c0..a3ead6185d 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index c4b8dee97b..f8aa63d70f 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index c507f7b23b..adbbd92316 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index d954e1fcdd..1a0eab8a0f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.26 + 5.0.27-SNAPSHOT WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -1794,7 +1794,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - v5.0.26 + HEAD @@ -1997,7 +1997,7 @@ 1.2.11-wso2v25 - 5.0.26 + 5.0.27-SNAPSHOT 4.9.2 From 566942694cd3ade245b81ac8475e16198b6e71ed Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Wed, 21 Jun 2023 23:32:48 +0530 Subject: [PATCH 057/157] Remove apim_reserved_user when fetching users --- .../jaxrs/service/impl/UserManagementServiceImpl.java | 9 +++++++++ .../mgt/core/device/mgt/api/jaxrs/util/Constants.java | 1 + 2 files changed, 10 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index 5209ace472..286c0a47aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,6 +424,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = getBasicUserInfo(username); userList.add(user); } @@ -484,6 +487,9 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } + if (commonUsers != null) { + commonUsers.remove(Constants.APIM_RESERVED_USER); + } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -658,6 +664,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 300e47b147..c9ad2e182e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; + public static final String APIM_RESERVED_USER = "apim_reserved_user"; public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; From c6cc0f9a6781708b13f72e7ffb41fd5f74279f0c Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 22 Jun 2023 19:45:11 +0530 Subject: [PATCH 058/157] Fix incorrect clear app scope --- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 46114821a2..809c856038 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -224,7 +224,7 @@ perm:admin:tenant:view perm:admin:metadata:view perm:admin:usage:view - perm:android:clear-applicatio + perm:android:clear-application perm:android:suspend-package perm:android:alternate-install From cfe7e520ab71d178bc53a1186a2a77dc76b291a5 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Tue, 20 Jun 2023 23:37:12 +0530 Subject: [PATCH 059/157] iOS user enrollment support Fixes https://roadmap.entgra.net/issues/10149 --- .../mgt/common/general/QREnrollmentDetails.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index df0719d152..fede2e3780 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -18,10 +18,21 @@ package io.entgra.device.mgt.core.device.mgt.common.general; +import java.util.Map; + public class QREnrollmentDetails { String ownershipType; String username; String enrollmentMode; + Map customValues; + + public Map getCustomValues() { + return customValues; + } + + public void setCustomValues(Map customValues) { + this.customValues = customValues; + } public String getOwnershipType() { return ownershipType; } From 8b928a4acabf2253387dece125f15ecdcd387a45 Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Sun, 25 Jun 2023 19:14:59 +0000 Subject: [PATCH 060/157] Remove unwanted check in billing logic Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../DeviceManagementProviderServiceImpl.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index e6a32ba4f4..cbcf07c9b7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -135,6 +135,18 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -1037,7 +1049,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } - long dateInDays = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); + + // Convert dateDiff to days as a decimal value + double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); + + if (dateDiffInDays % 1 >= 0.9) { + dateDiffInDays = Math.ceil(dateDiffInDays); + } + + long dateInDays = (long) dateDiffInDays; double cost = (tenantCost.getCost() / 365) * dateInDays; totalCost += cost; device.setCost(Math.round(cost * 100.0) / 100.0); @@ -1104,9 +1124,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv long difference_In_Days = (difference_In_Time / (1000 * 60 * 60 * 24)) % 365; + if (difference_In_Time % (1000 * 60 * 60 * 24) >= 0.9 * (1000 * 60 * 60 * 24)) { + difference_In_Days++; + } + for (int i = 1; i <= difference_In_Years; i++) { List allDevicesPerYear = new ArrayList<>(); - LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; Timestamp newStartDate; Timestamp newEndDate; @@ -1115,14 +1139,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv remainingDaysConsidered = true; oneYearAfterStart = startDate.toLocalDateTime(); newEndDate = endDate; - } else if (Timestamp.valueOf(oneYearAfterStart).getTime() >= endDate.getTime()) { - newEndDate = Timestamp.valueOf(oneYearAfterStart); } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } @@ -1145,7 +1167,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices.addAll(billingResponse.getDevice()); totalCost = totalCost + billingResponse.getTotalCostPerYear(); deviceCount = deviceCount + billingResponse.getDeviceCount(); - LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1); + LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1).with(LocalTime.of(00, 00, 00)); startDate = Timestamp.valueOf(nextStartDate); } From 19048ef3410991edd859d5d3a77138a056985125 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 9 Apr 2023 11:50:14 +0530 Subject: [PATCH 061/157] Add SCEP support fixes https://roadmap.entgra.net/issues/10042 --- .../mgt/core/impl/CertificateGenerator.java | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index bc98fae4a5..dfa0a2b616 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -55,10 +55,28 @@ import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.Store; -import org.jscep.message.*; +import org.jscep.message.CertRep; +import org.jscep.message.MessageDecodingException; +import org.jscep.message.MessageEncodingException; +import org.jscep.message.PkcsPkiEnvelopeDecoder; +import org.jscep.message.PkcsPkiEnvelopeEncoder; +import org.jscep.message.PkiMessage; +import org.jscep.message.PkiMessageDecoder; +import org.jscep.message.PkiMessageEncoder; import org.jscep.transaction.FailInfo; import org.jscep.transaction.Nonce; import org.jscep.transaction.TransactionId; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateDAO; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOException; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import org.wso2.carbon.certificate.mgt.core.dto.CAStatus; +import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; +import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse; +import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; +import org.wso2.carbon.certificate.mgt.core.exception.TransactionManagementException; +import org.wso2.carbon.certificate.mgt.core.util.CertificateManagementConstants; +import org.wso2.carbon.certificate.mgt.core.util.CommonUtil; +import org.wso2.carbon.certificate.mgt.core.util.Serializer; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.naming.InvalidNameException; @@ -70,12 +88,35 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; -import java.security.*; +import java.security.InvalidKeyException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.Security; +import java.security.SignatureException; import java.security.cert.Certificate; import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.*; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertificateNotYetValidException; +import java.security.cert.X509Certificate; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.X509EncodedKeySpec; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +>>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -773,6 +814,7 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); +<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -783,6 +825,10 @@ public class CertificateGenerator { } String subjectDn = joiner.toString(); X500Name issuerName = new X500Name(subjectDn); +======= + X500Name issuerName = new X500Name(certCA.getSubjectDN().getName()); + +>>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + From 1e252dd67fa34d46ba14e74fdba188e5be3e0ec8 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 19 Apr 2023 06:46:09 +0000 Subject: [PATCH 062/157] Fix issue with Nginx not recognizing the SCEP client certificate (#105) Co-authored-by: Pahansith Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/105 Co-authored-by: Pahansith Gunathilake Co-committed-by: Pahansith Gunathilake --- .../certificate/mgt/core/impl/CertificateGenerator.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index dfa0a2b616..a569b12fd3 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -116,7 +116,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; ->>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -815,6 +814,9 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); <<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +======= +>>>>>>> d34adaae96 (Fix issue with Nginx not recognizing the SCEP client certificate (#105)):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -825,10 +827,6 @@ public class CertificateGenerator { } String subjectDn = joiner.toString(); X500Name issuerName = new X500Name(subjectDn); -======= - X500Name issuerName = new X500Name(certCA.getSubjectDN().getName()); - ->>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + From a603a69f3ef79c45c2acfca79de1b5f4688ba360 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Wed, 24 May 2023 13:54:10 +0530 Subject: [PATCH 063/157] OTP for enrollment with Mutual TLS Fixes https://roadmap.entgra.net/issues/10093 --- .../mgt/common/DeviceManagementConstants.java | 2 + .../common/general/QREnrollmentDetails.java | 9 ++++ .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../mgt/common/spi/OTPManagementService.java | 6 +-- .../dao/impl/GenericOTPManagementDAOImpl.java | 12 ++++- .../mgt/service/OTPManagementServiceImpl.java | 51 +++++++++---------- .../authenticator/BasicAuthAuthenticator.java | 31 +++++++++-- .../CertificateAuthenticator.java | 9 ++++ .../OneTimeTokenAuthenticator.java | 14 ++++- 9 files changed, 98 insertions(+), 38 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java index fb4c749b82..6fd2fedde9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java @@ -134,6 +134,8 @@ public final class DeviceManagementConstants { public static final String LAST_NAME = "last-name"; public static final String TENANT_ADMIN_USERNAME = "tenant-admin-username"; public static final String TENANT_ADMIN_PASSWORD = "tenant-admin-password"; + + public static final int OTP_DEFAULT_EXPIRY_SECONDS = 3600; } public static final class EventServices { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index fede2e3780..08a334bf2f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -33,6 +33,7 @@ public class QREnrollmentDetails { public void setCustomValues(Map customValues) { this.customValues = customValues; } + int tokenExpiry; public String getOwnershipType() { return ownershipType; } @@ -45,4 +46,12 @@ public class QREnrollmentDetails { public String getEnrollmentMode() { return enrollmentMode; } public void setEnrollmentMode(String enrollmentMode) { this.enrollmentMode = enrollmentMode; } + + public int getTokenExpiry() { + return tokenExpiry; + } + + public void setTokenExpiry(int tokenExpiry) { + this.tokenExpiry = tokenExpiry; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index afb1d6b0fa..d8f49d79ec 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT + USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java index c89d311cda..e4cfa042b6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java @@ -35,7 +35,8 @@ public interface OTPManagementService { * @throws OTPManagementException if error occurred whle verifying validity of the OPT * @throws BadRequestException if found an null value for OTP */ - OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException; + OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws + OTPManagementException, BadRequestException; /** * Invalidate the OTP and send welcome mail @@ -59,8 +60,7 @@ public interface OTPManagementService { boolean hasEmailRegistered(String email, String emailDomain) throws OTPManagementException, DeviceManagementException; - OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, - int tenantId, boolean persistPin) throws OTPManagementException; + OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinData, boolean persistPin) throws OTPManagementException; OneTimePinDTO getRenewedOtpByEmailAndMailType(String email, String emailType) throws OTPManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index eaac0bf827..c11ff6ab0c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -25,7 +25,12 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.OTPManagementDAO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; +import org.wso2.carbon.device.mgt.core.otp.mgt.dao.OTPManagementDAO; +import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import java.sql.*; import java.util.Calendar; import java.util.List; @@ -51,7 +56,8 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM + "META_INFO, " + "CREATED_AT," + "TENANT_ID," - + "USERNAME) VALUES (?, ?, ?, ?, ?, ?, ?)"; + + "USERNAME, " + + "EXPIRY_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; try { Connection conn = this.getDBConnection(); Calendar calendar = Calendar.getInstance(); @@ -65,6 +71,8 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM stmt.setTimestamp(5, timestamp); stmt.setInt(6, oneTimePinDTO.getTenantId()); stmt.setString(7, oneTimePinDTO.getUsername()); + stmt.setInt(8, oneTimePinDTO.getExpiryTime() == 0 + ? DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS : oneTimePinDTO.getExpiryTime()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index 087cf3851f..ee087d3c68 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -117,7 +117,8 @@ public class OTPManagementServiceImpl implements OTPManagementService { } @Override - public OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException { + public OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws OTPManagementException, + BadRequestException { if (StringUtils.isBlank(oneTimeToken)){ String msg = "Received blank OTP to verify. OTP: " + oneTimeToken; log.error(msg); @@ -141,17 +142,19 @@ public class OTPManagementServiceImpl implements OTPManagementService { oneTimePinDTO.getCreatedAt().getTime() + oneTimePinDTO.getExpiryTime() * 1000L); if (currentTimestamp.after(expiredTimestamp)) { - String renewedOTP = UUID.randomUUID().toString(); - renewOTP(oneTimePinDTO, renewedOTP); - Gson gson = new Gson(); - Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); + if (requireRenewal) { + String renewedOTP = UUID.randomUUID().toString(); + renewOTP(oneTimePinDTO, renewedOTP); + Gson gson = new Gson(); + Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); - Properties props = new Properties(); - props.setProperty("first-name", tenant.getAdminFirstName()); - props.setProperty("otp-token", renewedOTP); - props.setProperty("email", oneTimePinDTO.getEmail()); - props.setProperty("type", oneTimePinDTO.getEmailType()); - sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); + Properties props = new Properties(); + props.setProperty("first-name", tenant.getAdminFirstName()); + props.setProperty("otp-token", renewedOTP); + props.setProperty("email", oneTimePinDTO.getEmail()); + props.setProperty("type", oneTimePinDTO.getEmailType()); + sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); + } return null; } return oneTimePinDTO; @@ -234,8 +237,14 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); - oneTimePinDTO = generateOneTimePin(emailAddress, OTPEmailTypes.DEVICE_ENROLLMENT.toString(), username, - null, tenantId, false); + + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(emailAddress); + oneTimePinData.setTenantId(tenantId); + oneTimePinData.setUsername(username); + oneTimePinData.setEmailType(OTPEmailTypes.USER_INVITE.toString()); + + oneTimePinDTO = generateOneTimePin(oneTimePinData, false); oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); @@ -269,27 +278,17 @@ public class OTPManagementServiceImpl implements OTPManagementService { /** * Create One Time Token - * @param email email - * @param emailType email type - * @param userName username - * @param metaDataObj meta data object - * @param tenantId tenant Id + * @param oneTimePinDTO Data related to the one time pin * @return {@link OneTimePinDTO} */ @Override - public OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, - int tenantId, boolean persistPin) throws OTPManagementException { + public OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinDTO, boolean persistPin) throws OTPManagementException { String otpValue = UUID.randomUUID().toString(); Gson gson = new Gson(); - String metaInfo = gson.toJson(metaDataObj); + String metaInfo = gson.toJson(oneTimePinDTO.getMetaInfo()); - OneTimePinDTO oneTimePinDTO = new OneTimePinDTO(); - oneTimePinDTO.setEmail(email); - oneTimePinDTO.setTenantId(tenantId); - oneTimePinDTO.setUsername(userName); - oneTimePinDTO.setEmailType(emailType); oneTimePinDTO.setMetaInfo(metaInfo); oneTimePinDTO.setOtpToken(otpValue); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 6545b7bbab..11395eef60 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -35,6 +35,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.nio.charset.Charset; import java.util.Base64; import java.util.Properties; +import java.util.StringTokenizer; public class BasicAuthAuthenticator implements WebappAuthenticator { @@ -50,15 +51,23 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { /* - This is done to avoid every endpoint being able to use basic auth. Add the following to - the required web.xml of the web app. + This is done to avoid every web app being able to use basic auth. Add the following to + the required web.xml of the web app. This is a global config for a web app to allow all + contexts of the web app to use basic auth basicAuth true + + Adding the basicAuthAllowList parameter allows to selectively allow some context paths in a + web app to use basic auth while all the other context remain unavailable with basic auth. + If this parameter is present, any context that requires basic auth must be specially + added as comma separated list to the param-value of basicAuthAllowList. */ - if (!isAuthenticationSupported(request)) { - return false; + if (!isAllowListedForBasicAuth(request)) { + if (!isAuthenticationSupported(request)) { + return false; + } } if (request.getCoyoteRequest() == null || request.getCoyoteRequest().getMimeHeaders() == null) { return false; @@ -75,6 +84,20 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { return false; } + private boolean isAllowListedForBasicAuth(Request request) { + String param = request.getContext().findParameter("basicAuthAllowList"); + if (param != null && !param.isEmpty()) { + //Add the nonSecured end-points to cache + String[] basicAuthAllowList = param.split(","); + for (String contexPath : basicAuthAllowList) { + if (request.getRequestURI().toString().endsWith(contexPath.trim())) { + return true; + } + } + } + return false; + } + @Override public AuthenticationInfo authenticate(Request request, Response response) { AuthenticationInfo authenticationInfo = new AuthenticationInfo(); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index 5238828dd0..c968905e78 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,21 +74,30 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { + log.info("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + log.info("clientCertificate" + certificateResponse.getSerialNumber()); + log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); + log.info("username" + authenticationInfo.getUsername()); } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { + log.info("MUTUAL_AUTH_HEADER"); Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); X509Certificate[] clientCertificate = null; if (object instanceof X509Certificate[]) { + log.info("clientCertificate"); clientCertificate = (X509Certificate[]) request. getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); } if (clientCertificate != null && clientCertificate[0] != null) { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); + log.info("clientCertificate" + certificateResponse.getSerialNumber()); + log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); + log.info("username" + authenticationInfo.getUsername()); } else { authenticationInfo.setStatus(Status.FAILURE); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java index 82e592524b..29392b63f5 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java @@ -49,8 +49,18 @@ public class OneTimeTokenAuthenticator implements WebappAuthenticator { try { OTPManagementService otpManagementService = AuthenticatorFrameworkDataHolder.getInstance() .getOtpManagementService(); - OneTimePinDTO validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER)); + OneTimePinDTO validOTP; + if (request.getRequestURI().toString().endsWith("cloud/download-url") + || request.getRequestURI().toString().endsWith("cloud/tenant")) { + validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER), true); + } else { + log.info("Validating OTP for enrollments PIN: " + request.getHeader(Constants + .HTTPHeaders.ONE_TIME_TOKEN_HEADER)); + validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER), false); + } + if (validOTP != null) { authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setTenantId(validOTP.getTenantId()); From 84563078d3d496717a0c6eb457decd6185ae6b43 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sat, 13 May 2023 12:56:56 +0530 Subject: [PATCH 064/157] Add tenant based storing and loading SCEP certificates --- .../mgt/core/dao/CertificateDAO.java | 10 +++++ .../dao/impl/AbstractCertificateDAOImpl.java | 36 +++++++++++++++++ .../mgt/core/impl/CertificateGenerator.java | 39 ++++++++++++------- .../mgt/core/impl/KeyStoreReader.java | 37 ++++++++++++++++++ .../exception/StorageManagementException.java | 32 +++++++++++++++ 5 files changed, 141 insertions(+), 13 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index de3be1856a..dcd20bbde5 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -51,6 +51,16 @@ public interface CertificateDAO { */ CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException; + /** + * Obtain a certificated stored in the database by providing the common name and the tenant ID + * + * @param serialNumber Serial number (Common name) of the certificate + * @param tenantId ID of the certificate owning tenant + * @return representation of the certificate. + * @throws CertificateManagementDAOException if fails to read the certificate from the database + */ + CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException; + /** * Get all the certificates in a paginated manner. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 45a7e7c56f..fad84f8309 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -119,6 +119,42 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ return certificateResponse; } + @Override + public CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet resultSet = null; + CertificateResponse certificateResponse = null; + try { + conn = this.getConnection(); + String query = + "SELECT CERTIFICATE, SERIAL_NUMBER, TENANT_ID, USERNAME FROM" + + " DM_DEVICE_CERTIFICATE WHERE SERIAL_NUMBER = ? AND TENANT_ID = ? "; + stmt = conn.prepareStatement(query); + stmt.setString(1, serialNumber); + stmt.setInt(2, tenantId); + resultSet = stmt.executeQuery(); + + if (resultSet.next()) { + certificateResponse = new CertificateResponse(); + byte[] certificateBytes = resultSet.getBytes("CERTIFICATE"); + certificateResponse.setCertificate(certificateBytes); + certificateResponse.setSerialNumber(resultSet.getString("SERIAL_NUMBER")); + certificateResponse.setTenantId(resultSet.getInt("TENANT_ID")); + certificateResponse.setUsername(resultSet.getString("USERNAME")); + CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse); + } + } catch (SQLException e) { + String errorMsg = + "Unable to get the read the certificate with serial" + serialNumber; + log.error(errorMsg, e); + throw new CertificateManagementDAOException(errorMsg, e); + } finally { + CertificateManagementDAOUtil.cleanupResources(stmt, resultSet); + } + return certificateResponse; + } + @Override public List searchCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index a569b12fd3..acb9796bc2 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -376,15 +376,31 @@ public class CertificateGenerator { CertificateResponse lookUpCertificate = null; KeyStoreReader keyStoreReader = new KeyStoreReader(); if (distinguishedName != null && !distinguishedName.isEmpty()) { - if (distinguishedName.contains("/CN=")) { - String[] dnSplits = distinguishedName.split("/"); - for (String dnPart : dnSplits) { - if (dnPart.contains("CN=")) { - String commonNameExtracted = dnPart.replace("CN=", ""); - lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted); - break; + if (distinguishedName.contains("CN=")) { + String[] dnSplits = null; + if (distinguishedName.contains("/")) { + dnSplits = distinguishedName.split("/"); + } else if (distinguishedName.contains(",")) { + //some older versions of nginx will forward the client certificate subject dn separated with commas + dnSplits = distinguishedName.split(","); + } + String commonNameExtracted = null; + int tenantId = 0; + if (dnSplits != null && dnSplits.length >= 1) { + for (String dnPart : dnSplits) { + if (dnPart.contains("CN=")) { + commonNameExtracted = dnPart.replace("CN=", ""); + } else if (dnPart.contains("OU=")) { + //the OU of the certificate will be like OU=tenant_ ex: OU=tenant_-1234 + //splitting by underscore to extract the tenant domain + String[] orgUnitSplits = dnPart.split("_"); + tenantId = Integer.parseInt(orgUnitSplits[1]); + } } } + + lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted, tenantId); + } else { LdapName ldapName; try { @@ -813,10 +829,6 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); -<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java -<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java -======= ->>>>>>> d34adaae96 (Fix issue with Nginx not recognizing the SCEP client certificate (#105)):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -829,8 +841,9 @@ public class CertificateGenerator { X500Name issuerName = new X500Name(subjectDn); String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); - X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + - serialNumber); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + X500Name subjectName = new X500Name("O=" + commonName + ",CN=" + + serialNumber + ", OU=tenant_"+tenantId); Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365 * 100)); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java index 56ec2bb6f5..94cab378bf 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java @@ -271,6 +271,43 @@ public class KeyStoreReader { return raPrivateKey; } + public CertificateResponse getCertificateBySerial(String serialNumber, int tenantId) throws KeystoreException { + CertificateResponse certificateResponse = null; + try { + CertificateCacheManager cacheManager = CertificateCacheManagerImpl.getInstance(); + certificateResponse = cacheManager.getCertificateBySerial(serialNumber); + if (certificateResponse == null) { + try { + CertificateManagementDAOFactory.openConnection(); + certificateResponse = certDao.retrieveCertificate(serialNumber, tenantId); + } catch (SQLException e) { + String errorMsg = "Error when making a connection to the database."; + throw new KeystoreException(errorMsg, e); + } finally { + CertificateManagementDAOFactory.closeConnection(); + } + if (certificateResponse != null && certificateResponse.getCertificate() != null) { + Certificate certificate = (Certificate) Serializer.deserialize(certificateResponse.getCertificate()); + if (certificate instanceof X509Certificate) { + X509Certificate x509cert = (X509Certificate) certificate; + String commonName = CertificateGenerator.getCommonName(x509cert); + certificateResponse.setCommonName(commonName); + cacheManager.addCertificateBySerial(serialNumber, certificateResponse); + } + } + } + } catch (CertificateManagementDAOException e) { + String errorMsg = "Error when retrieving certificate from the the database for the serial number: " + + serialNumber; + throw new KeystoreException(errorMsg, e); + + } catch (ClassNotFoundException | IOException e) { + String errorMsg = "Error when de-serializing saved certificate."; + throw new KeystoreException(errorMsg, e); + } + return certificateResponse; + } + public CertificateResponse getCertificateBySerial(String serialNumber) throws KeystoreException { CertificateResponse certificateResponse = null; try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java new file mode 100644 index 0000000000..38985716de --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java @@ -0,0 +1,32 @@ +/* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.common.exception; + +/** + * Represents the exception thrown during storing and retrieving the artifacts. + */ +public class StorageManagementException extends Exception { + public StorageManagementException(String message, Throwable ex) { + super(message, ex); + } + + public StorageManagementException(String message) { + super(message); + } +} + From 9a55a83af47ab8f35eebf04b4084947d9a1bef18 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 21 Jun 2023 06:20:17 +0530 Subject: [PATCH 065/157] Add OTP based remote session implementation --- .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../interceptor/DefaultTokenHandler.java | 99 ++++++------------- .../ui/request/interceptor/UserHandler.java | 1 + .../interceptor/util/HandlerConstants.java | 1 + .../request/interceptor/util/HandlerUtil.java | 13 +++ 5 files changed, 48 insertions(+), 68 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index d8f49d79ec..53113c5b75 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE + USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE, REMOTE_SESSION } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index 1d757b421e..a40dcafefd 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.google.gson.Gson; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; @@ -27,13 +26,22 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; +import io.entgra.ui.request.interceptor.util.HandlerConstants; +import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; +import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -55,71 +63,28 @@ public class DefaultTokenHandler extends HttpServlet { HttpSession httpSession = req.getSession(false); if (httpSession != null) { - AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY); - if (authData == null) { - HandlerUtil.sendUnAuthorizeResponse(resp); - return; + String userWithDomain = (String) httpSession.getAttribute(HandlerConstants.USERNAME_WITH_DOMAIN); + String[] userNameParts = userWithDomain.split("@"); + + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(OTPEmailTypes.REMOTE_SESSION.toString()); + oneTimePinData.setEmailType(OTPEmailTypes.REMOTE_SESSION.toString()); + oneTimePinData.setUsername(userNameParts[0]); + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); + try { + oneTimePinData.setTenantId(realmService.getTenantManager().getTenantId(userNameParts[1])); + } catch (UserStoreException e) { + throw new RuntimeException(e); } - - AuthData defaultAuthData = (AuthData) httpSession - .getAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY); - if (defaultAuthData != null) { - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultAuthData.getAccessToken())); - return; - } - - String clientId = authData.getClientId(); - String clientSecret = authData.getClientSecret(); - - String queryString = req.getQueryString(); - String scopeString = ""; - if (StringUtils.isNotEmpty(queryString)) { - scopeString = req.getParameter("scopes"); - if (scopeString != null) { - scopeString = "?scopes=" + scopeString; - } - } - - String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId - + "/" + clientSecret + "/default-token" + scopeString; - - HttpGet defaultTokenRequest = new HttpGet(tokenUrl); - defaultTokenRequest - .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); - defaultTokenRequest - .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); - - if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { - log.error("Error occurred while invoking the API to get default token data."); - HandlerUtil.handleError(resp, tokenResultResponse); - return; - } - String tokenResult = tokenResultResponse.getData(); - if (tokenResult == null) { - log.error("Invalid default token response is received."); - HandlerUtil.handleError(resp, tokenResultResponse); - return; - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - AuthData newDefaultAuthData = new AuthData(); - newDefaultAuthData.setClientId(clientId); - newDefaultAuthData.setClientSecret(clientSecret); - - String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); - newDefaultAuthData.setAccessToken(defaultToken); - newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); - newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); - httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); - - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); + oneTimePinData.setExpiryTime(DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS); + OTPManagementService otpManagementService = HandlerUtil.getOTPManagementService(); + try { + oneTimePinData = otpManagementService.generateOneTimePin(oneTimePinData, true); + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(oneTimePinData.getOtpToken())); + } catch (OTPManagementException e) { + log.error("Failed while generating remote session OTP for user " + userWithDomain, e); + HandlerUtil.handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); } } else { HandlerUtil.sendUnAuthorizeResponse(resp); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index d5e8d2bf4d..c0f6c7f6ee 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -120,6 +120,7 @@ public class UserHandler extends HttpServlet { proxyResponse.setData( jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); HandlerUtil.handleSuccess(resp, proxyResponse); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); } } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 239cf1c944..9aa9cb9fe6 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -106,4 +106,5 @@ public class HandlerConstants { public static final String IOT_REPORTING_WEBAPP_HOST_ENV_VAR = "iot.reporting.webapp.host"; public static final String USER_SCOPES = "userScopes"; public static final String HUBSPOT_CHAT_URL = "api.hubapi.com"; + public static final String USERNAME_WITH_DOMAIN = "usernameWithDomain"; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 5a05a19425..f15215067e 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -51,6 +51,9 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -70,6 +73,8 @@ public class HandlerUtil { private static boolean isLoginCacheInitialized = false; private static AuthData authData; + private static OTPManagementService otpManagementService; + /*** * * @param httpRequest - httpMethod e.g:- HttpPost, HttpGet @@ -742,4 +747,12 @@ public class HandlerUtil { public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } + + public static OTPManagementService getOTPManagementService() { + if (otpManagementService == null) { + otpManagementService = (OTPManagementService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(OTPManagementService.class, null); + } + return otpManagementService; + } } From 2dd804f1a869038dc9b3aea019f1884f5fe387ea Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 18 Jun 2023 12:22:01 +0530 Subject: [PATCH 066/157] Add the logic to save device id to certificate DB partialy fixes https://roadmap.entgra.net/issues/10145 --- .../mgt/core/bean/Certificate.java | 9 +++++ .../mgt/core/dao/CertificateDAO.java | 11 ++++++ .../dao/impl/AbstractCertificateDAOImpl.java | 34 +++++++++++++++++++ .../mgt/core/impl/CertificateGenerator.java | 27 +++++++++++++-- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java index e3e55c330f..acf63daa07 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java @@ -25,6 +25,15 @@ public class Certificate { X509Certificate certificate; int tenantId; String tenantDomain; + String deviceIdentifier; + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } public int getTenantId() { return tenantId; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index dcd20bbde5..779251761e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -41,6 +41,17 @@ public interface CertificateDAO { void addCertificate(List certificate) throws CertificateManagementDAOException; + /** + * This can be used to store a certificate in the database, where it will be stored against the serial number + * of the certificate. + * + * @param certificate Holds the certificate and relevant details. + * @throws CertificateManagementDAOException + * + */ + void addCertificate(Certificate certificate) + throws CertificateManagementDAOException; + /** * Usage is to obtain a certificate stored in the database by providing the common name. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index fad84f8309..0a8e9e3066 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -81,6 +81,40 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ } } + @Override + public void addCertificate(Certificate certificate) + throws CertificateManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + stmt = conn.prepareStatement( + "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID," + + " USERNAME, DEVICE_IDENTIFIER) VALUES (?,?,?,?,?)"); + PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. + getThreadLocalCarbonContext(); + String username = threadLocalCarbonContext.getUsername(); + // the serial number of the certificate used for its creation is set as its alias. + String serialNumber = certificate.getSerial(); + if (serialNumber == null || serialNumber.isEmpty()) { + serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber()); + } + byte[] bytes = Serializer.serialize(certificate.getCertificate()); + + stmt.setString(1, serialNumber); + stmt.setBytes(2, bytes); + stmt.setInt(3, certificate.getTenantId()); + stmt.setString(4, username); + stmt.setString(5, certificate.getDeviceIdentifier()); + stmt.executeUpdate(); + } catch (SQLException | IOException e) { + throw new CertificateManagementDAOException("Error occurred while saving the " + + "certificate. ", e); + } finally { + CertificateManagementDAOUtil.cleanupResources(stmt, null); + } + } + @Override public CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index acb9796bc2..b8109e74fc 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -727,6 +727,29 @@ public class CertificateGenerator { throw new KeystoreException(errorMsg, e); } } + public void saveCertificate(org.wso2.carbon.certificate.mgt.core.bean.Certificate + certificate) throws KeystoreException { + + if (certificate == null) { + return; + } + + try { + CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO(); + CertificateManagementDAOFactory.beginTransaction(); + certificateDAO.addCertificate(certificate); + CertificateManagementDAOFactory.commitTransaction(); + } catch (CertificateManagementDAOException e) { + String errorMsg = "Error occurred when saving the generated certificate in database"; + log.error(errorMsg); + CertificateManagementDAOFactory.rollbackTransaction(); + throw new KeystoreException(errorMsg, e); + } catch (TransactionManagementException e) { + String errorMsg = "Error occurred when saving the generated certificate in database"; + log.error(errorMsg); + throw new KeystoreException(errorMsg, e); + } + } public void saveCertInKeyStore(List certificate) throws KeystoreException { @@ -866,8 +889,8 @@ public class CertificateGenerator { List certificates = new ArrayList<>(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); certificate.setCertificate(issuedCert); - certificates.add(certificate); - saveCertInKeyStore(certificates); + certificate.setDeviceIdentifier(commonName); + saveCertificate(certificate); } catch (OperatorCreationException e) { String errorMsg = "Error creating the content signer"; From 6299d0fd83a7d52bdd1f4d2f4f5ddd7cc4d29eb2 Mon Sep 17 00:00:00 2001 From: rajitha Date: Thu, 15 Jun 2023 14:08:46 +0530 Subject: [PATCH 067/157] Add otp token --- .../DeviceManagementConfigService.java | 7 ++- .../DeviceManagementConfigServiceImpl.java | 57 ++++++++++++++++++- .../config/api/util/DeviceMgtAPIUtils.java | 17 ++++++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index eac30a6de6..729e477c00 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -139,7 +139,12 @@ public interface DeviceManagementConfigService { value = "The properties list using for query a device", required = true) @QueryParam("properties") - String properties); + String properties, + @ApiParam( + name = "withAccessToken", + value = "Whether to use access token or otp token for device configuration") + @QueryParam("withAccessToken") + boolean withAccessToken); @PUT @Path("/device/transfer") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index f387dfea32..d32ac76676 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -48,6 +48,30 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; +import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; +import org.wso2.carbon.device.mgt.common.DeviceTransferRequest; +import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; +import org.wso2.carbon.device.mgt.common.general.TenantDetail; +import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; +import org.wso2.carbon.device.mgt.core.config.keymanager.KeyManagerConfigurations; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; +import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; @@ -70,7 +94,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig @Path("/configurations") @Produces(MediaType.APPLICATION_JSON) public Response getConfiguration(@HeaderParam("token") String token, - @QueryParam("properties") String properties) { + @QueryParam("properties") String properties, + @QueryParam("withAccessToken") boolean withAccessToken) { DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); try { if (token == null || token.isEmpty()) { @@ -95,7 +120,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig deviceProps.put("token", token); DeviceConfiguration devicesConfiguration = dms.getDeviceConfiguration(deviceProps); - setAccessTokenToDeviceConfigurations(devicesConfiguration); + if (withAccessToken) setAccessTokenToDeviceConfigurations(devicesConfiguration); + else setOTPTokenToDeviceConfigurations(devicesConfiguration); return Response.status(Response.Status.OK).entity(devicesConfiguration).build(); } catch (DeviceManagementException e) { String msg = "Error occurred while retrieving configurations"; @@ -207,6 +233,33 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig } } + private void setOTPTokenToDeviceConfigurations(DeviceConfiguration deviceConfiguration) + throws DeviceManagementException { + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); + oneTimePinData.setEmailType(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); + oneTimePinData.setUsername(deviceConfiguration.getDeviceOwner()); + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + deviceConfiguration.getTenantDomain(), true); + oneTimePinData.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + PrivilegedCarbonContext.endTenantFlow(); + OTPManagementService otpManagementService = DeviceMgtAPIUtils.getOtpManagementService(); + try { + OneTimePinDTO oneTimePinDTO = otpManagementService.generateOneTimePin(oneTimePinData, true); + if (oneTimePinDTO == null) { + String msg = "Null value returned when generating OTP token for " + oneTimePinData.getOtpToken(); + log.error(msg); + throw new DeviceManagementException(msg); + } + deviceConfiguration.setAccessToken(oneTimePinDTO.getOtpToken()); + } catch (OTPManagementException ex) { + String msg = "Error occurred while generating one time pin: " + ex.getMessage(); + log.error(msg, ex); + throw new DeviceManagementException(msg, ex); + } + } + @Override @Path("/tenants") @GET diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java index 1dd6052def..fbe57c8928 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java @@ -22,6 +22,8 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -34,6 +36,8 @@ public class DeviceMgtAPIUtils { private static DeviceManagementProviderService deviceManagementProviderService = null; private static RealmService realmService = null; + private static OTPManagementService otpManagementService = null; + public static DeviceManagementProviderService getDeviceManagementService() { if (deviceManagementProviderService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -48,6 +52,19 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } + public static OTPManagementService getOtpManagementService() { + if (otpManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + otpManagementService = (OTPManagementService) ctx.getOSGiService(OTPManagementService.class, null); + if (otpManagementService == null) { + String msg = "OTP Management Service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return otpManagementService; + } + public static RealmService getRealmService() { if (realmService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From 469c4988c5aaa9da44e16b189ef8508e6b4ee363 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Fri, 23 Jun 2023 20:39:12 +0530 Subject: [PATCH 068/157] Remove unnecessary logs --- .../CertificateAuthenticator.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index c968905e78..cb9bf50215 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,31 +74,29 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { - log.info("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + if (log.isDebugEnabled()) { + log.debug("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + } CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); - log.info("clientCertificate" + certificateResponse.getSerialNumber()); - log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); - log.info("username" + authenticationInfo.getUsername()); + if (log.isDebugEnabled()) { + log.debug("Certificate Serial : " + certificateResponse.getSerialNumber() + + ", CN : " + certificateResponse.getCommonName() + + " , username" + authenticationInfo.getUsername()); + } } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { - log.info("MUTUAL_AUTH_HEADER"); Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); X509Certificate[] clientCertificate = null; if (object instanceof X509Certificate[]) { - log.info("clientCertificate"); clientCertificate = (X509Certificate[]) request. getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); } if (clientCertificate != null && clientCertificate[0] != null) { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); - log.info("clientCertificate" + certificateResponse.getSerialNumber()); - log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); - log.info("username" + authenticationInfo.getUsername()); - } else { authenticationInfo.setStatus(Status.FAILURE); authenticationInfo.setMessage("No client certificate is present"); From e979130e550981042059454a4c3625be52c6c592 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 26 Jun 2023 13:43:13 +0530 Subject: [PATCH 069/157] Fix missing imports --- .../api/service/impl/DeviceManagementConfigServiceImpl.java | 4 ++++ .../core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java | 1 + 2 files changed, 5 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index d32ac76676..de80a541d2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -21,6 +21,10 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; +import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.OTPEmailTypes; +import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index c11ff6ab0c..02373de936 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; From f9b9f76a3c858a5de7fcca2d245be007bb6864c2 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Mon, 26 Jun 2023 14:15:29 +0530 Subject: [PATCH 070/157] Fix skip app release error --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../device/mgt/core/application/mgt/core/util/APIUtil.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 9a50d0d00a..6bb2edc88e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1239,13 +1239,13 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } + if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + persistAppIconInfo(applicationReleaseDTO); + } applicationReleaseEntities.add(applicationReleaseDTO); } applicationDTO.setId(appId); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { - persistAppIconInfo(applicationReleaseDTO); - } return APIUtil.appDtoToAppResponse(applicationDTO); } } catch (LifeCycleManagementDAOException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 4b78b9e1c2..40b0762380 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -514,7 +514,6 @@ public class APIUtil { public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException { String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO .getAppHashValue() + Constants.FORWARD_SLASH; - String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); - return iconPath; + return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); } } From 5a8bcf671148b1c2eea4b8f24d6cef75b33aa705 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Sun, 25 Jun 2023 20:04:36 +0530 Subject: [PATCH 071/157] Add device enrolment log for modifyenrolment --- .../mgt/core/service/DeviceManagementProviderServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index cbcf07c9b7..31b77ebef3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -446,6 +446,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (log.isDebugEnabled()) { log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'"); } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); if (deviceManager == null) { @@ -474,6 +476,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); DeviceManagementDAOFactory.commitTransaction(); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); From 729f1fd85fbbdeef584ea667f8c1aceef2bfaa85 Mon Sep 17 00:00:00 2001 From: rajitha Date: Tue, 27 Jun 2023 13:26:05 +0530 Subject: [PATCH 072/157] Update invite link --- .../mgt/service/OTPManagementServiceImpl.java | 19 ------------------- .../email/templates/user-enrollment.vm | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index ee087d3c68..074eb8eed7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -227,9 +227,6 @@ public class OTPManagementServiceImpl implements OTPManagementService { } } } - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - OneTimePinDTO oneTimePinDTO; - List oneTimePinDTOList = new ArrayList<>(); Properties props = new Properties(); props.setProperty("enrollment-steps", enrollmentSteps.toString()); try { @@ -237,22 +234,11 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); - - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(emailAddress); - oneTimePinData.setTenantId(tenantId); - oneTimePinData.setUsername(username); - oneTimePinData.setEmailType(OTPEmailTypes.USER_INVITE.toString()); - - oneTimePinDTO = generateOneTimePin(oneTimePinData, false); - oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); props.setProperty("username", username); - props.setProperty("otp-token", oneTimePinDTO.getOtpToken()); sendMail(props, emailAddress, DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE); } - this.otpManagementDAO.addOTPData(oneTimePinDTOList); ConnectionManagerUtil.commitDBTransaction(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; @@ -266,11 +252,6 @@ public class OTPManagementServiceImpl implements OTPManagementService { String msg = "SQL Error occurred when adding OPT data to send device enrollment Invitation."; log.error(msg, e); throw new OTPManagementException(msg, e); - } catch (OTPManagementDAOException e) { - ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occurred while saving the OTP data."; - log.error(msg, e); - throw new OTPManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm index 7765bcdda2..ef5307de33 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm @@ -37,7 +37,7 @@

You have been invited to enrol your device in Entgra IoT Server. - Click here to begin device enrolment.

+ Click here to begin device enrolment.

Enrollment Steps are as below, From 0ce7cd954c8642acceafaa873f77cdec2ac9a80f Mon Sep 17 00:00:00 2001 From: Thilina Sandaruwan Date: Tue, 27 Jun 2023 08:57:23 +0000 Subject: [PATCH 073/157] HierarchicalGrouping (#153) Goals Complete hierarchical grouping task https://roadmap.entgra.net/issues/9528 and https://roadmap.entgra.net/issues/9529 Approach Fix the encountered issues Co-authored-by: ThilinaPremachandra Co-authored-by: Pahansith Gunathilake Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/153 Co-authored-by: Thilina Sandaruwan Co-committed-by: Thilina Sandaruwan --- .../core/device/mgt/core/dao/GroupDAO.java | 13 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 78 +++++++++++++++++-- .../GroupManagementProviderServiceImpl.java | 14 +++- 3 files changed, 97 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 75a6979410..777cdb922f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -211,6 +211,19 @@ public interface GroupDAO { */ List getGroups(GroupPaginationRequest paginationRequest, int tenantId) throws GroupManagementDAOException; + /** + * Get paginated list of Device Groups in tenant with specified device group ids. + * + * @param paginationRequest to filter results. + * @param deviceGroupIds of groups required. + * @param tenantId of user's tenant. + * @param isWithParentPath of user's ParentPath. + * @return List of all Device Groups in tenant. + * @throws GroupManagementDAOException + */ + List getGroups(GroupPaginationRequest paginationRequest, List deviceGroupIds, + int tenantId, boolean isWithParentPath) throws GroupManagementDAOException; + /** * Get paginated list of Device Groups in tenant with specified device group ids. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 37a10f9c23..9705c5772c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -104,7 +104,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { @Override public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId) throws GroupManagementDAOException { + int tenantId) throws GroupManagementDAOException { int deviceGroupIdsCount = deviceGroupIds.size(); if (deviceGroupIdsCount == 0) { return new ArrayList<>(); @@ -165,6 +165,73 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } + @Override + public List getGroups(GroupPaginationRequest request, List deviceGroupIds, + int tenantId, boolean isWithParentPath) throws GroupManagementDAOException { + int deviceGroupIdsCount = deviceGroupIds.size(); + if (deviceGroupIdsCount == 0) { + return new ArrayList<>(); + } + + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; + if (StringUtils.isNotBlank(request.getGroupName())) { + sql += " AND GROUP_NAME LIKE ?"; + } + if (StringUtils.isNotBlank(request.getOwner())) { + sql += " AND OWNER LIKE ?"; + } + if (StringUtils.isNotBlank(request.getParentPath())) { + if(isWithParentPath){ + sql += " AND PARENT_PATH LIKE ?"; + } + } + sql += " AND ID IN ("; + for (int i = 0; i < deviceGroupIdsCount; i++) { + sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?"; + } + sql += ")"; + if (request.getRowCount() != 0) { + sql += " LIMIT ? OFFSET ?"; + } + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIndex = 1; + stmt.setInt(paramIndex++, tenantId); + if (StringUtils.isNotBlank(request.getGroupName())) { + stmt.setString(paramIndex++, request.getGroupName() + "%"); + } + if (StringUtils.isNotBlank(request.getOwner())) { + stmt.setString(paramIndex++, request.getOwner() + "%"); + } + if (StringUtils.isNotBlank(request.getParentPath())) { + if(isWithParentPath){ + stmt.setString(paramIndex++, request.getParentPath()); + } + } + for (Integer deviceGroupId : deviceGroupIds) { + stmt.setInt(paramIndex++, deviceGroupId); + } + if (request.getRowCount() != 0) { + stmt.setInt(paramIndex++, request.getRowCount()); + stmt.setInt(paramIndex, request.getStartIndex()); + } + List deviceGroupList = new ArrayList<>(); + try (ResultSet resultSet = stmt.executeQuery()) { + while (resultSet.next()) { + deviceGroupList.add(GroupManagementDAOUtil.loadGroup(resultSet)); + } + } + return deviceGroupList; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() + + " in tenant: " + tenantId; + log.error(msg); + throw new GroupManagementDAOException(msg, e); + } + } @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { @@ -373,7 +440,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, " - + "PARENT_PATH = ? WHERE ID = ? AND TENANT_ID = ?"; + + "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)){ for (DeviceGroup deviceGroup : deviceGroups) { stmt.setString(1, deviceGroup.getDescription()); @@ -381,8 +448,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setString(4, deviceGroup.getStatus()); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getGroupId()); - stmt.setInt(7, tenantId); + stmt.setInt(6, deviceGroup.getParentGroupId()); + stmt.setInt(7, deviceGroup.getGroupId()); + stmt.setInt(8, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -1198,7 +1266,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } - @Override + @Override public List getAllDevicesOfGroup(String groupName, int tenantId) throws GroupManagementDAOException { Connection conn; List devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 7c8f64768d..9b5ab0e5ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -312,6 +312,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); + if (!newParentPath.equals(DeviceGroupConstants.HierarchicalGroup.SEPERATOR)) { + String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); + int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); + childrenGroup.setParentGroupId(latestGroupId); + } else { + childrenGroup.setParentGroupId(0); + } } } } @@ -518,7 +525,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroupsWithHierarchy(String username, GroupPaginationRequest request, - boolean requireGroupProps) throws GroupManagementException { + boolean requireGroupProps) throws GroupManagementException { if (request == null) { String msg = "Received incomplete data for retrieve groups with hierarchy"; log.error(msg); @@ -527,6 +534,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (log.isDebugEnabled()) { log.debug("Get groups with hierarchy " + request.toString()); } + boolean isWithParentPath = false; DeviceManagerUtil.validateGroupListPageSize(request); List rootGroups; try { @@ -538,7 +546,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { List allDeviceGroupIdsOfUser = getGroupIds(username); GroupManagementDAOFactory.openConnection(); - rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); + rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId, isWithParentPath); } String parentPath; List childrenGroups; @@ -1359,7 +1367,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid * @throws GroupManagementDAOException on error during population of group properties. */ private void createGroupWithChildren(DeviceGroup parentGroup, List childrenGroups, - boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { + boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { if (childrenGroups.isEmpty() || depth == counter) { return; } From da6f7158cfbd16e0172473e49b385253c0c2f972 Mon Sep 17 00:00:00 2001 From: nishan Date: Thu, 15 Jun 2023 14:12:56 +0530 Subject: [PATCH 074/157] add api for get visible roles --- .../service/api/RoleManagementService.java | 98 +++++++++++++++++++ .../impl/RoleManagementServiceImpl.java | 93 +++++++++++++++++- 2 files changed, 190 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java index f7eb730a8b..5031f1598d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java @@ -187,6 +187,104 @@ public interface RoleManagementService { defaultValue = "5") @QueryParam("limit") int limit); + @GET + @Path("/visible/{metaKey}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting the List of Visible Roles", + notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" + + "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", + tags = "Role Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.", + response = RoleList.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client already has the latest version of the " + + "requested resource."), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified resource does not exist.\n", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while fetching the list of roles" + + " assigned to the specified user.", + response = ErrorResponse.class) + }) + Response getVisibleRole( + @ApiParam( + name = "filter", + value = "Provide a character or a few characters in the role name.", + required = false) + @QueryParam("filter") String filter, + @ApiParam( + name = "user-store", + value = "The name of the UserStore you wish to get the list of roles.", + required = false) + @QueryParam("user-store") String userStoreName, + @ApiParam( + name = "If-Modified-Since", + value = "Checks if the requested variant was modified, since the specified date-time." + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", + required = false) + @HeaderParam("If-Modified-Since") String ifModifiedSince, + @ApiParam( + name = "offset", + value = "The starting pagination index for the complete list of qualified items.", + required = false, + defaultValue = "0") + @QueryParam("offset") int offset, + @ApiParam( + name = "limit", + value = "Provide how many role details you require from the starting pagination index/offset.", + required = false, + defaultValue = "5") + @QueryParam("limit") int limit, + @ApiParam( + name = "username", + value = "The username of the user.", + required = true, + defaultValue = "admin") + @QueryParam("username") String username, + @ApiParam( + name = "domain", + value = "The domain name of the user store.", + required = false) + @QueryParam("domain") String domain, + @ApiParam( + name = "metaKey", + value = "Key of the metadata", + required = true) + @PathParam("metaKey") String metaKey); + @GET @Path("/filter/{prefix}") @ApiOperation( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index c8df51825e..7f5078d8a6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,6 +17,12 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import org.apache.axis2.databinding.types.xsd._boolean; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; @@ -97,6 +103,91 @@ public class RoleManagementServiceImpl implements RoleManagementService { } } + @GET + @Path("/visible/{metaKey}") + @Override + public Response getVisibleRole( + @QueryParam("filter") String filter, + @QueryParam("user-store") String userStore, + @HeaderParam("If-Modified-Since") String ifModifiedSince, + @QueryParam("offset") int offset, @QueryParam("limit") int limit, + @QueryParam("username") String username, @QueryParam("domain") String domain, + @PathParam("metaKey") String metaKey) { + RequestValidationUtil.validatePaginationParameters(offset, limit); + if (limit == 0){ + limit = Constants.DEFAULT_PAGE_LIMIT; + } + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } + Metadata metadata; + List visibleRoles; + RoleList visibleRoleList = new RoleList(); + try { + metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); + String metaValue = metadata.getMetaValue(); + JSONParser parser = new JSONParser(); + JSONObject jsonObject = (JSONObject) parser.parse(metaValue); + boolean decision = (boolean) jsonObject.get("isUserAbleToViewAllRoles"); + if (decision) { + if(userStore == null || "".equals(userStore)){ + userStore = PRIMARY_USER_STORE; + } + try{ + visibleRoles =getRolesFromUserStore(filter, userStore); + visibleRoleList.setList(visibleRoles); + + visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); + visibleRoleList.setList(visibleRoles); + + return Response.status(Response.Status.OK).entity(visibleRoleList).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving roles from the underlying user stores"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + } else { + try{UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + if (!userStoreManager.isExistingUser(username)) { + if (log.isDebugEnabled()) { + log.debug("User by username: " + username + " does not exist for role retrieval."); + } + String msg = "User by username: " + username + " does not exist for role retrieval."; + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } + visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); + + return Response.status(Response.Status.OK).entity(visibleRoleList).build(); + }catch (UserStoreException e) { + String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + } + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting the metadata entry for metaKey:" + metaKey; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + private List getFilteredVisibleRoles(UserStoreManager userStoreManager, String username) + throws UserStoreException { + String[] roleListOfUser; + roleListOfUser = userStoreManager.getRoleListOfUser(username); + List filteredRoles = new ArrayList<>(); + for (String role : roleListOfUser) { + if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) { + filteredRoles.add(role); + } + } + return filteredRoles; + } + @GET @Path("/filter/{prefix}") @Override @@ -597,7 +688,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd); return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " + - "successfully been updated with the user list") + "successfully been updated with the user list") .build(); } catch (UserStoreException e) { String msg = "Error occurred while updating the users of the role '" + roleName + "'"; From 50beae1bf87d8dfea57bb5f23f7b83db7dbd103f Mon Sep 17 00:00:00 2001 From: nishan Date: Mon, 26 Jun 2023 07:28:53 +0530 Subject: [PATCH 075/157] Remove the user has role validation --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 6bb2edc88e..e2bfb9902c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -3614,13 +3614,6 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - if (!hasUserRole(unrestrictedRoles, userName)) { - String msg = "You are trying to restrict the visibility of the application for a role set, but " - + "in order to perform the action at least one role should be assigned to user: " - + userName; - log.error(msg); - throw new BadRequestException(msg); - } } Filter filter = new Filter(); From 1844db87d8ab85dafc75cc3a046d6c1af255b108 Mon Sep 17 00:00:00 2001 From: Nishan Sangeeth Date: Wed, 28 Jun 2023 16:00:53 +0000 Subject: [PATCH 076/157] Improve app visibility restricting functionality Co-authored-by: Nishan Sangeeth Co-committed-by: Nishan Sangeeth --- .../common/services/ApplicationManager.java | 5 ++ .../mgt/core/impl/ApplicationManagerImpl.java | 52 ++++++++++++++++++- .../application/mgt/core/util/APIUtil.java | 18 +++++++ .../application/mgt/core/util/Constants.java | 3 +- .../impl/RoleManagementServiceImpl.java | 23 ++++---- .../device/mgt/api/jaxrs/util/Constants.java | 1 + 6 files changed, 91 insertions(+), 11 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index f7655b566b..f0e2d040ff 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -29,6 +29,11 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; +<<<<<<< HEAD +======= +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +>>>>>>> 3616245ae6 (Improve app visibility restricting functionality) import org.apache.cxf.jaxrs.ext.multipart.Attachment; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index e2bfb9902c..fba517f148 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -19,6 +19,16 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import org.json.JSONObject; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; +import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; +import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; +import io.entgra.device.mgt.core.application.mgt.common.Pagination; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; import io.entgra.device.mgt.core.application.mgt.common.dto.*; import io.entgra.device.mgt.core.application.mgt.common.exception.*; @@ -57,6 +67,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; +import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -1669,6 +1680,31 @@ public class ApplicationManagerImpl implements ApplicationManager { } } + /** + * Check whether valid metaData value or not + * + * @return true or false + * @throws MetadataManagementException If it is unable to load metaData + */ + private boolean isUserAbleToViewAllRoles() throws MetadataManagementException { + List allMetadata; + allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); + if (allMetadata != null && !allMetadata.isEmpty()) { + for(Metadata metadata : allMetadata){ + if(Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())){ + String metaValue = metadata.getMetaValue(); + if (metaValue != null) { + JSONObject jsonObject; + jsonObject = new JSONObject(metaValue); + boolean isUserAbleToViewAllRoles = jsonObject.getBoolean(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); + return isUserAbleToViewAllRoles; + } + } + } + } + return false; + } + /** * Get assigned role list of the given user. * @@ -3442,7 +3478,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void validateAppCreatingRequest(T param) throws ApplicationManagementException, RequestValidatingException { + public void validateAppCreatingRequest(T param) + throws ApplicationManagementException, RequestValidatingException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); int deviceTypeId = -1; @@ -3614,6 +3651,15 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } + if (!isUserAbleToViewAllRoles()) { + if (!hasUserRole(unrestrictedRoles, userName)) { + String msg = "You are trying to restrict the visibility of the application for a role set, but " + + "in order to perform the action at least one role should be assigned to user: " + + userName; + log.error(msg); + throw new BadRequestException(msg); + } + } } Filter filter = new Filter(); @@ -3665,6 +3711,10 @@ public class ApplicationManagerImpl implements ApplicationManager { String msg = "Error occurred when validating the unrestricted roles given for the web clip"; log.error(msg, e); throw new ApplicationManagementException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while retrieving metadata list"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 40b0762380..8c3ccbc8bf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -40,6 +40,7 @@ import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -64,6 +65,7 @@ public class APIUtil { private static volatile SubscriptionManager subscriptionManager; private static volatile ReviewManager reviewManager; private static volatile AppmDataHandler appmDataHandler; + private static volatile MetadataManagementService metadataManagementService; public static SPApplicationManager getSPApplicationManager() { if (SPApplicationManager == null) { @@ -516,4 +518,20 @@ public class APIUtil { .getAppHashValue() + Constants.FORWARD_SLASH; return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); } + + public static MetadataManagementService getMetadataManagementService() { + if (metadataManagementService == null) { + synchronized (APIUtil.class) { + if (metadataManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + metadataManagementService = (MetadataManagementService) ctx.getOSGiService( + MetadataManagementService.class, null); + if (metadataManagementService == null) { + throw new IllegalStateException("Metadata Management service not initialized."); + } + } + } + } + return metadataManagementService; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index 5864242acf..efd848cdb1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -70,7 +70,8 @@ public class Constants { public static final String ANY = "ANY"; public static final String DEFAULT_PCK_NAME = "default.app.com"; public static final String ALL = "ALL"; - + public static final String SHOW_ALL_ROLES = "SHOW_ALL_ROLES"; + public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 7f5078d8a6..03a66c383e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -110,8 +110,10 @@ public class RoleManagementServiceImpl implements RoleManagementService { @QueryParam("filter") String filter, @QueryParam("user-store") String userStore, @HeaderParam("If-Modified-Since") String ifModifiedSince, - @QueryParam("offset") int offset, @QueryParam("limit") int limit, - @QueryParam("username") String username, @QueryParam("domain") String domain, + @QueryParam("offset") int offset, + @QueryParam("limit") int limit, + @QueryParam("username") String username, + @QueryParam("domain") String domain, @PathParam("metaKey") String metaKey) { RequestValidationUtil.validatePaginationParameters(offset, limit); if (limit == 0){ @@ -128,13 +130,13 @@ public class RoleManagementServiceImpl implements RoleManagementService { String metaValue = metadata.getMetaValue(); JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(metaValue); - boolean decision = (boolean) jsonObject.get("isUserAbleToViewAllRoles"); + boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { - if(userStore == null || "".equals(userStore)){ + if (userStore == null || "".equals(userStore)){ userStore = PRIMARY_USER_STORE; } - try{ - visibleRoles =getRolesFromUserStore(filter, userStore); + try { + visibleRoles = getRolesFromUserStore(filter, userStore); visibleRoleList.setList(visibleRoles); visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); @@ -148,7 +150,8 @@ public class RoleManagementServiceImpl implements RoleManagementService { new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } else { - try{UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + try { + UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { if (log.isDebugEnabled()) { log.debug("User by username: " + username + " does not exist for role retrieval."); @@ -159,7 +162,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - }catch (UserStoreException e) { + } catch (UserStoreException e) { String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; log.error(msg, e); return Response.serverError().entity( @@ -171,7 +174,9 @@ public class RoleManagementServiceImpl implements RoleManagementService { log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (ParseException e) { - throw new RuntimeException(e); + String msg = "Error occurred while parsing JSON metadata: " + e.getMessage(); + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index c9ad2e182e..02d332baf2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -38,6 +38,7 @@ public class Constants { public static final int DEFAULT_PAGE_LIMIT = 50; public static final String FORWARD_SLASH = "/"; public static final String ANDROID = "android"; + public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.uem.platform.android." + "core.polcy.AndroidPolicyPayloadValidator"; public static final String IOS = "ios"; From d90c5c459a35d8f7bae4366e19605d0ccb38fe02 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 29 Jun 2023 00:28:34 +0530 Subject: [PATCH 077/157] Remove reserved_user when fetching users --- .../api/jaxrs/service/impl/UserManagementServiceImpl.java | 5 +++-- .../device/mgt/core/device/mgt/api/jaxrs/util/Constants.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index 286c0a47aa..d0f5239fa3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,7 +424,7 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username)) { + if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { continue; } user = getBasicUserInfo(username); @@ -489,6 +489,7 @@ public class UserManagementServiceImpl implements UserManagementService { } if (commonUsers != null) { commonUsers.remove(Constants.APIM_RESERVED_USER); + commonUsers.remove(Constants.RESERVED_USER); } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { @@ -664,7 +665,7 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username)) { + if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { continue; } user = new UserInfo(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 02d332baf2..0a9b6efa26 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -31,7 +31,8 @@ public class Constants { public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; public static final String APIM_RESERVED_USER = "apim_reserved_user"; - public static final String DEFAULT_STREAM_VERSION = "1.0.0"; + public static final String RESERVED_USER = "reserved_user"; + public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; From 5d9938d7befa01f3d2fabf9ab07c6912eda15208 Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Fri, 30 Jun 2023 06:32:38 +0000 Subject: [PATCH 078/157] Add footer config template ## Purpose * Fixes https://roadmap.entgra.net/issues/10180 ## Description * cdm-config.xml.j2, cdm-config.xml templates are updated from hardcoded values to retrieve values from deployment.toml * server_name, server_version and current_year are added as variables * **Usage:** change deployment.toml values when a new version released. This will update the footer ## Related PRs * https://repository.entgra.net/proprietary/product-uem/pulls/15 Co-authored-by: prathabanKavin Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/160 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../src/main/resources/conf/cdm-config.xml | 2 +- .../templates/repository/conf/cdm-config.xml.j2 | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 3ce48daefe..c40cefc413 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -189,7 +189,7 @@ <a href='https://entgra.io' target='_blank'> Entgra </a> - IoT Server 5.2.0 | © 2023 + UEM Server 5.3.0 | © 2023 , All Rights Reserved. Entgra diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 262761caec..2152b1814f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -325,12 +325,16 @@ - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - IoT Server 5.2.0 | © 2023 - , All Rights Reserved. - + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + {% if product_conf is defined %} + {{product_conf.server_name}} {{product_conf.server_version}} | © {{product_conf.current_year}} + {% else %} + Entgra UEM Server + {% endif %} + , All Rights Reserved. + Entgra repository/resources/whitelabel From fde6de94bb49ad986a4933b016611624800d0374 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Sat, 1 Jul 2023 21:06:29 +0530 Subject: [PATCH 079/157] fix: sub tenants grouping issue --- .../admin/GroupManagementAdminServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index cd53637812..5e4d0d4789 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -44,6 +44,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupMan import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.apache.commons.lang.StringUtils; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -106,13 +107,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @DefaultValue("5") @QueryParam("limit") int limit) { try { RequestValidationUtil.validatePaginationParameters(offset, limit); + String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); GroupPaginationRequest request = new GroupPaginationRequest(offset, limit); request.setGroupName(name); request.setOwner(owner); request.setStatus(status); request.setDepth(depth); - PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); + + PaginationResult deviceGroupsResult; + if (StringUtils.isBlank(currentUser)) { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); + } else { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + } + DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); From 05811512482f6fb01884744d2b9922c598a8b663 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Sun, 2 Jul 2023 01:23:13 +0530 Subject: [PATCH 080/157] add: super-tenant admin check --- .../service/impl/admin/GroupManagementAdminServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 5e4d0d4789..636ed66062 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -113,9 +113,10 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ request.setOwner(owner); request.setStatus(status); request.setDepth(depth); + boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser)) { + if (StringUtils.isBlank(currentUser) || isAdmin) { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(null, request, requireGroupProps); } else { From b682e77d346c9a9fbabae473aa5e93eaefc71a23 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Mon, 3 Jul 2023 18:53:34 +0530 Subject: [PATCH 081/157] fix: group assigned role issue --- .../impl/GroupManagementServiceImpl.java | 22 +++++++++++++++++-- .../GroupManagementAdminServiceImpl.java | 16 +++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index 262e51eb9f..b4fb899ba8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -29,6 +29,7 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistExc import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -58,6 +59,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; import javax.naming.InitialContext; @@ -70,6 +73,7 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class GroupManagementServiceImpl implements GroupManagementService { @@ -123,8 +127,18 @@ public class GroupManagementServiceImpl implements GroupManagementService { request.setGroupName(name); request.setOwner(owner); request.setDepth(depth); - PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); + String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); + boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); + PaginationResult deviceGroupsResult; + if (hasAdminRole) { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); + } else{ + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + } DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -133,6 +147,10 @@ public class GroupManagementServiceImpl implements GroupManagementService { String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while getting user realm."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 636ed66062..35be14c7cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -43,8 +43,11 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -53,6 +56,7 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; +import java.util.Arrays; public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { @@ -113,17 +117,19 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ request.setOwner(owner); request.setStatus(status); request.setDepth(depth); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); + String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); - + boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser) || isAdmin) { + if (StringUtils.isBlank(currentUser) || isAdmin || hasAdminRole) { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(null, request, requireGroupProps); } else { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(currentUser, request, requireGroupProps); } - DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -132,6 +138,10 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while getting user realm."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } From 3dc567fcfec09465f5746f9534a8f214c23d4148 Mon Sep 17 00:00:00 2001 From: rajitha Date: Tue, 4 Jul 2023 18:37:39 +0530 Subject: [PATCH 082/157] Fix transaction initiating issue --- .../device/mgt/core/operation/mgt/OperationManagerImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 92cf1818a7..223eb95564 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -472,6 +472,7 @@ public class OperationManagerImpl implements OperationManager { int failAttempts = 0; while (true) { try { + OperationManagementDAOFactory.beginTransaction(); operationMappingDAO.updateOperationMapping(operation.getId(), device.getEnrolmentInfo().getId(), io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); OperationManagementDAOFactory.commitTransaction(); @@ -494,6 +495,11 @@ public class OperationManagerImpl implements OperationManager { } catch (InterruptedException ignore) { break; } + } catch (TransactionManagementException ex) { + log.error("Error occurred while initiating the transaction", ex); + break; + } finally { + OperationManagementDAOFactory.closeConnection(); } } } catch (Exception e) { From a1ae369fe5d92c460d272905c549e5480f49ee0a Mon Sep 17 00:00:00 2001 From: rajitha Date: Wed, 5 Jul 2023 20:01:06 +0530 Subject: [PATCH 083/157] Fix realm service unbinding issues --- .../APIApplicationManagerExtensionDataHolder.java | 13 +++++++------ .../publisher/internal/APIPublisherDataHolder.java | 13 +++++++------ .../internal/JWTClientExtensionDataHolder.java | 13 +++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index d6a3bb2fc5..e3bbebc4d0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -68,17 +68,18 @@ public class APIApplicationManagerExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index baff1848ed..bc7b8af32c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -75,17 +75,18 @@ public class APIPublisherDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java index 7d253b2333..cd3999c9bf 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java @@ -74,17 +74,18 @@ public class JWTClientExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } } From b765c8ded32dfe5e2e4e80b0bb8807d2f563e395 Mon Sep 17 00:00:00 2001 From: Thilina Sandaruwan Date: Mon, 10 Jul 2023 07:46:21 +0000 Subject: [PATCH 084/157] Grouping Improvements (#169) Purpose After deleting a role, delete relevant records from DM_ROLE_GROUP_MAP table Related tickets: https://roadmap.entgra.net/issues/9528 and https://roadmap.entgra.net/issues/9529 Co-authored-by: ThilinaPremachandra Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/169 Co-authored-by: Thilina Sandaruwan Co-committed-by: Thilina Sandaruwan --- .../impl/GroupManagementServiceImpl.java | 4 +- .../impl/RoleManagementServiceImpl.java | 13 ++++-- .../GroupManagementAdminServiceImpl.java | 4 +- .../core/device/mgt/core/dao/GroupDAO.java | 9 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 17 ++++++++ .../GroupManagementProviderService.java | 16 ++++++- .../GroupManagementProviderServiceImpl.java | 42 +++++++++++++++++-- 7 files changed, 93 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index b4fb899ba8..98ca6249d0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -489,8 +489,8 @@ public class GroupManagementServiceImpl implements GroupManagementService { log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + groups.getName() + "."; - log.warn(msg); + String msg = "Group already exists with name : " + groups.getName() + " Try with another group name."; + log.error(msg, e); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 03a66c383e..44150409ad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import org.apache.axis2.databinding.types.xsd._boolean; import org.json.simple.JSONObject; @@ -638,6 +639,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { @Consumes(MediaType.WILDCARD) @Override public Response deleteRole(@PathParam("roleName") String roleName, @QueryParam("user-store") String userStoreName) { + String roleToDelete = roleName; if (userStoreName != null && !userStoreName.isEmpty()) { roleName = userStoreName + "/" + roleName; } @@ -645,6 +647,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { try { final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (!userStoreManager.isExistingRole(roleName)) { String msg = "No role exists with the name : " + roleName ; return Response.status(404).entity(msg).build(); @@ -654,16 +657,18 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (log.isDebugEnabled()) { log.debug("Deleting the role in user store"); } - userStoreManager.deleteRole(roleName); - // Delete all authorizations for the current role before deleting - authorizationManager.clearRoleAuthorization(roleName); - + DeviceMgtAPIUtils.getGroupManagementProviderService().deleteRoleAndRoleGroupMapping(roleName, roleToDelete, tenantId, userStoreManager, authorizationManager); return Response.status(Response.Status.OK).build(); } catch (UserStoreException e) { String msg = "Error occurred while deleting the role '" + roleName + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while deleting group-role mapping records"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 35be14c7cb..d7bf236acf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -199,8 +199,8 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + group.getName() + "."; - log.warn(msg); + String msg = "Group already exists with name : " + group.getName() + " Try with another group name."; + log.error(msg, e); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 777cdb922f..ac91b7036f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -155,6 +155,15 @@ public interface GroupDAO { */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; + /** + * Delete mappings of Device Groups. + * + * @param role of Device Groups. + * @param tenantId of the role. + * @throws GroupManagementDAOException on error during deletion of mappings of groups + */ + void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException; + /** * Delete existing Device Groups. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 9705c5772c..e1fc26eb8e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -541,6 +541,23 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + @Override + public void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException { + + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql = "DELETE FROM DM_ROLE_GROUP_MAP WHERE ROLE = ? AND TENANT_ID = ?"; + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, role); + stmt.setInt(2, tenantId); + stmt.executeUpdate(); + } + } catch (SQLException e) { + String msg = "Error occurred while removing record from group-role mapping."; + log.error(msg); + throw new GroupManagementDAOException(msg, e); + } + } @Override public void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException { try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index b263ea1234..ef2338688f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -31,6 +31,8 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.UserStoreManager; import java.util.List; @@ -58,7 +60,7 @@ public interface GroupManagementProviderService { * @param defaultPermissions of the default role * @throws GroupManagementException */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException,GroupManagementException, RoleDoesNotExistException; /** * Update existing device group. @@ -80,6 +82,18 @@ public interface GroupManagementProviderService { */ boolean deleteGroup(int groupId, boolean isDeleteChildren) throws GroupManagementException; + /** + * Delete existing device group. + * + * @param role to be deleted with the userStore name. + * @param roleToDelete to delete the role. + * @param tenantId to belongs to roles. + * @param userStoreManager with details. + * @param authorizationManager with details. + * @throws GroupManagementException + */ + void deleteRoleAndRoleGroupMapping(String role, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException; + /** * Get the device group provided the device group id. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 9b5ab0e5ae..3e03301769 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -49,10 +49,12 @@ import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.netbeans.lib.cvsclient.commandLine.command.status; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; @@ -148,7 +150,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException, GroupManagementException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -181,7 +183,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } else { - throw new GroupManagementException("Group exist with name " + groups.getName()); + throw new GroupAlreadyExistException("Group already exists with name : " + groups.getName() + " Try with another group name."); } } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); @@ -359,6 +361,40 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } + /** + * {@inheritDoc} + */ + @Override + public void deleteRoleAndRoleGroupMapping(String roleName, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Delete roles"); + } + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.deleteGroupsMapping(roleToDelete, tenantId); + userStoreManager.deleteRole(roleName); + // Delete all authorizations for the current role before deleting + authorizationManager.clearRoleAuthorization(roleName); + GroupManagementDAOFactory.commitTransaction(); + } catch (UserStoreException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting the role '" + roleName + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting the role"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + /** * {@inheritDoc} */ From 087a9fe72808fc57b138cdeb78a8d17ec523ae58 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 11:43:26 +0530 Subject: [PATCH 085/157] Fix dependency importing issue --- .../pom.xml | 4 +++ .../service/api/GroupManagementService.java | 25 +++++++++++++------ .../pom.xml | 4 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index f9931aae6c..fde1c89087 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -411,6 +411,10 @@ org.wso2.carbon.ntask.core provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index be792d22c1..33d46f139b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -33,6 +33,17 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; +import io.swagger.annotations.ResponseHeader; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; import javax.validation.Valid; import javax.ws.rs.*; @@ -1286,11 +1297,11 @@ public interface GroupManagementService { "Server error occurred while creating the group or adding devices or sharing the group.", response = ErrorResponse.class) }) - Response createGroupWithRoles(@ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - ); - + Response createGroupWithRoles( + @ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + ); } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index cd75cd10c5..f93f462924 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -283,6 +283,10 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + From ef2838414a1827ebea19f485561fb8dca9c33a7b Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 12:13:53 +0530 Subject: [PATCH 086/157] Fix build failure --- .../device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 27617e89ae..0c2e5663fe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -364,7 +364,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index b97dba2a91..26f6603912 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -473,7 +473,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon.multitenancy diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 585aeafeaa..c12f494f37 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -78,7 +78,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From dc6bbdd282d7653df302c570f45957be50f7c6ba Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:05:02 +0530 Subject: [PATCH 087/157] Improve functionality and fix formatting issues --- .../mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- .../core/application/mgt/core/util/Constants.java | 3 +++ .../service/impl/RoleManagementServiceImpl.java | 12 ++++++++++-- .../mgt/core/operation/mgt/OperationManagerImpl.java | 9 ++++++++- .../service/DeviceManagementProviderServiceImpl.java | 10 +++++++++- .../service/GroupManagementProviderServiceImpl.java | 2 +- 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index fba517f148..6b4d590fa8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1250,7 +1250,7 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + if (Constants.ENTERPRISE_APP_TYPE.equals(applicationDTO.getType()) || Constants.PUBLIC_APP_TYPE.equals(applicationDTO.getType())) { persistAppIconInfo(applicationReleaseDTO); } applicationReleaseEntities.add(applicationReleaseDTO); @@ -1690,8 +1690,8 @@ public class ApplicationManagerImpl implements ApplicationManager { List allMetadata; allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); if (allMetadata != null && !allMetadata.isEmpty()) { - for(Metadata metadata : allMetadata){ - if(Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())){ + for (Metadata metadata : allMetadata) { + if (Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())) { String metaValue = metadata.getMetaValue(); if (metaValue != null) { JSONObject jsonObject; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 92c1a93f18..5fdbbfaca1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -684,7 +684,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("App %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index efd848cdb1..c3e7c49160 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -94,6 +94,9 @@ public class Constants { public static final String MSI = "MSI"; public static final String APPX = "APPX"; + public static final String ENTERPRISE_APP_TYPE = "ENTERPRISE"; + public static final String PUBLIC_APP_TYPE = "ENTERPRISE"; + private static final Map AGENT_DATA = new HashMap<>(); static { AGENT_DATA.put("android", "android-agent.apk"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 44150409ad..5c04516650 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import com.google.common.base.Strings; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -35,6 +36,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.SetReferenceTransformer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.util.StringUtils; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; @@ -57,6 +59,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; import static io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants.PRIMARY_USER_STORE; @@ -120,7 +128,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (limit == 0){ limit = Constants.DEFAULT_PAGE_LIMIT; } - if (domain != null && !domain.isEmpty()) { + if (!Strings.isNullOrEmpty(domain)) { username = domain + '/' + username; } Metadata metadata; @@ -133,7 +141,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { JSONObject jsonObject = (JSONObject) parser.parse(metaValue); boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { - if (userStore == null || "".equals(userStore)){ + if (Strings.isNullOrEmpty(userStore)){ userStore = PRIMARY_USER_STORE; } try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 223eb95564..e752475939 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -721,7 +721,14 @@ public class OperationManagerImpl implements OperationManager { DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(deviceId.getId()).setDeviceType(deviceId.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); + log.info("Device Connected", deviceConnectivityLogContextBuilder + .setDeviceId(deviceId.getId()) + .setDeviceType(deviceId.getType()) + .setActionTag("PENDING_OPERATION") + .setTenantDomain(tenantDomain) + .setTenantId(String.valueOf(tenantId)) + .setUserName(userName) + .build()); return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 31b77ebef3..eb1a60c48c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -331,7 +331,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(existingDevice.getId())).setDeviceType(String.valueOf(existingDevice.getType())).setOwner(newEnrolmentInfo.getOwner()).setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder + .setDeviceId(String.valueOf(existingDevice.getId())) + .setDeviceType(String.valueOf(existingDevice.getType())) + .setOwner(newEnrolmentInfo.getOwner()) + .setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())) + .setTenantID(String.valueOf(tenantId)) + .setTenantDomain(tenantDomain) + .setUserName(userName) + .build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 3e03301769..a35d4d74bb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -314,7 +314,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); - if (!newParentPath.equals(DeviceGroupConstants.HierarchicalGroup.SEPERATOR)) { + if (!DeviceGroupConstants.HierarchicalGroup.SEPERATOR.equals(newParentPath)) { String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); childrenGroup.setParentGroupId(latestGroupId); From 8b967cee4c8709c8b2a287a940293ddf8d1f635d Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 11 Jul 2023 15:53:09 +0530 Subject: [PATCH 088/157] Add missing ios scopes in mdm-ui-config --- .../src/main/resources/conf/mdm-ui-config.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 809c856038..b16935562d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -227,6 +227,19 @@ perm:android:clear-application perm:android:suspend-package perm:android:alternate-install + perm:ios:lock + perm:ios:location + perm:ios:ring + perm:ios:clear-passcode + perm:ios:enterprise-wipe + perm:ios:notification + perm:ios:wipe-data + perm:ios:boolean-setting + perm:ios:wallpaper + perm:ios:app-attributes + perm:ios:app-configurations + perm:mac-os:restart + perm:mac-os:shut-down device-mgt From f72166895f47811352f333f7077fea050761d141 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Tue, 11 Jul 2023 23:08:33 +0530 Subject: [PATCH 089/157] Fix class not found error in analytics component --- .../api/impl/GrafanaAPIProxyServiceImpl.java | 5 +- .../api/impl/util/GrafanaMgtAPIUtils.java | 52 +++++++++++++++++++ .../pom.xml | 2 +- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 6121f78ddd..23128fc527 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.GrafanaAPIProxyService; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.bean.ErrorResponse; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.exception.RefererNotValid; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaMgtAPIUtils; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaRequestHandlerUtil; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; @@ -49,8 +50,8 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { public Response queryDatasource(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { try { GrafanaPanelIdentifier panelIdentifier = GrafanaRequestHandlerUtil.getPanelIdentifier(headers); - GrafanaMgtDataHolder.getInstance().getGrafanaQueryService(). - buildSafeQuery(body, panelIdentifier.getDashboardId(), panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), + panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); return GrafanaRequestHandlerUtil.proxyPassPostRequest(body, requestUriInfo, panelIdentifier.getOrgId()); } catch (MaliciousQueryAttempt e) { return Response.status(Response.Status.BAD_REQUEST).entity( diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java new file mode 100644 index 0000000000..07a4293b49 --- /dev/null +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util; + +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.GrafanaQueryService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +public class GrafanaMgtAPIUtils { + + private static final Log log = LogFactory.getLog(GrafanaMgtAPIUtils.class); + private static volatile GrafanaQueryService grafanaQueryService; + + /** + * Accessing GrafanaQueryService from OSGI service context + * @return GrafanaQueryService instance + */ + public static GrafanaQueryService getGrafanaQueryService() { + if (grafanaQueryService == null) { + synchronized (GrafanaMgtAPIUtils.class) { + if (grafanaQueryService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + grafanaQueryService = + (GrafanaQueryService) ctx.getOSGiService(GrafanaQueryService.class, null); + if (grafanaQueryService == null) { + String msg = "Grafana Query service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + } + } + return grafanaQueryService; + } +} diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index d16b2ad8c9..fcf8b4bf98 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -124,7 +124,7 @@ org.wso2.carbon.utils;version="[4.8,5)" - !io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal, + !io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.* From f2243ebd0e9de22c5d8d6be2bcb50fc076168d0f Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:39:31 +0530 Subject: [PATCH 090/157] Fix formatting issue --- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 5fdbbfaca1..e4bfe93d46 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -677,7 +677,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { entry.getKey(), action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } } else { From ac3e144437d76a12dedb4c81ba5bb019a854e5a2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 13 Jul 2023 07:54:34 +0530 Subject: [PATCH 091/157] Fix OSGI service unbinding issue --- .../internal/DeviceManagementDataHolder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index a901ffeddf..3fa8fdc453 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } public TenantManager getTenantManager() { - return tenantManager; - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); } - this.tenantManager = realmService.getTenantManager(); + return tenantManager; } + + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public DeviceManagementProviderService getDeviceManagementProvider() { From b7f077e63983b2c0a88cab3e502dc18ddcd06e80 Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 1 Jun 2023 09:50:58 +0000 Subject: [PATCH 092/157] Implement service for consumer rest APIs Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../apimgt/extension/rest/api/ConsumerRESTAPIServices.java | 2 ++ .../extension/rest/api/ConsumerRESTAPIServicesImpl.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 5ed98034e2..7fddca04f2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -23,6 +23,8 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import java.util.List; import java.util.Map; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 293894ee71..a85c611f99 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -24,6 +24,10 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +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.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; From 958f4e43d6c73efd824a9ba562e7200eacb23278 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 17:13:51 +0530 Subject: [PATCH 093/157] Add Consumer REST API integration --- .../pom.xml | 8 ++++++ ...ApplicationManagerExtensionDataHolder.java | 6 ++++ ...ationManagerExtensionServiceComponent.java | 28 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 9ace7f0c33..f62fd9c2ee 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -143,6 +143,14 @@ org.wso2.carbon.apimgt.impl;version="[9.28,10)", org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", org.wso2.carbon.context;version="[4.8,5)", + 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.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index e3bbebc4d0..c8608b4fc8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -39,8 +39,11 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; +<<<<<<< HEAD private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; +======= +>>>>>>> 9fc055cd4f (Add Consumer REST API integration) private APIApplicationManagerExtensionDataHolder() { } @@ -118,6 +121,7 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } +<<<<<<< HEAD public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; @@ -134,4 +138,6 @@ public class APIApplicationManagerExtensionDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } +======= +>>>>>>> 9fc055cd4f (Add Consumer REST API integration) } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index b3dc6dbd9d..78e0867d78 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -34,6 +34,34 @@ import org.wso2.carbon.user.core.service.RealmService; @Component( name = "io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent", immediate = true) +/** + * @scr.component name="io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent" + * @scr.reference name="tenant.registryloader" + * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" + * cardinality="1..1" + * policy="dynamic" + * bind="setTenantRegistryLoader" + * unbind="unsetTenantRegistryLoader" + * @scr.reference name="tenant.indexloader" + * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" + * cardinality="1..1" + * policy="dynamic" + * bind="setIndexLoader" + * unbind="unsetIndexLoader" + * @scr.reference name="realm.service" + * immediate="true" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" + * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setConsumerRESTAPIServices" + * unbind="unsetConsumerRESTAPIServices" + */ public class APIApplicationManagerExtensionServiceComponent { private static final Log log = LogFactory.getLog(APIApplicationManagerExtensionServiceComponent.class); From 29a8dd5fdee5f547a3c1e11e09f80de75b1d27d2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 11:17:29 +0530 Subject: [PATCH 094/157] Add API app registering refactored code --- .../APIManagementProviderServiceImpl.java | 35 +++++++++++++++++++ ...ApplicationManagerExtensionDataHolder.java | 7 ---- ...ationManagerExtensionServiceComponent.java | 8 ++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0808f11963..67a6f21f16 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -41,6 +41,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App 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.bean.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -119,6 +120,40 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException { + + + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + + /* + + */ + + try { + consumerRESTAPIServices.getAllApplications(null, null, null); + } catch (APIServicesException e) { + e.printStackTrace(); + } catch (BadRequestException e) { + e.printStackTrace(); + } catch (UnexpectedResponseException e) { + e.printStackTrace(); + } + + return null; + + + } + + + /** + * {@inheritDoc} + */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index c8608b4fc8..978a46c13a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -39,12 +39,8 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; -<<<<<<< HEAD private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) - private APIApplicationManagerExtensionDataHolder() { } @@ -121,7 +117,6 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } -<<<<<<< HEAD public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; @@ -138,6 +133,4 @@ public class APIApplicationManagerExtensionDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 78e0867d78..ffb576295d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -55,12 +55,18 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" * cardinality="0..1" * policy="dynamic" * bind="setConsumerRESTAPIServices" * unbind="unsetConsumerRESTAPIServices" + * @scr.reference name="apimgt.extension.APIApplicationService" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setAPIApplicationServices" + * unbind="unsetAPIApplicationServices" */ public class APIApplicationManagerExtensionServiceComponent { From 52fd8c4b893beb686573130124c524b0f2ce63a1 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 17:03:33 +0530 Subject: [PATCH 095/157] Add Application key generating logic --- .../APIManagementProviderServiceImpl.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 67a6f21f16..238042dc24 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -126,17 +126,36 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + try { + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - /* + List uniqueApiList = new ArrayList(); + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + + for (String tag: tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + if ("carbon.super".equals(tenantDomain)) { + consumerRESTAPIServices.getAllApis(null, null, queryParams); + } else { + //call All API getting call with carbon super header param + } + + uniqueApiList.add("Test"); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); - */ - try { - consumerRESTAPIServices.getAllApplications(null, null, null); } catch (APIServicesException e) { e.printStackTrace(); } catch (BadRequestException e) { From da4f3f14563768fc75a27e9c7ac8e463e5cda21a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 7 Jun 2023 20:58:48 +0530 Subject: [PATCH 096/157] Add API integration --- .../APIManagementProviderServiceImpl.java | 61 +++++++++++++++++-- .../api/bean/APIMConsumer/Subscription.java | 2 - 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 238042dc24..f57c2fadc6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -132,28 +132,77 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - List uniqueApiList = new ArrayList(); + List uniqueApiList = new ArrayList<>(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - for (String tag: tags) { + for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); if ("carbon.super".equals(tenantDomain)) { consumerRESTAPIServices.getAllApis(null, null, queryParams); } else { //call All API getting call with carbon super header param + APIInfo[] apiInfos; + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); } + apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - uniqueApiList.add("Test"); - Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); uniqueApiList.clear(); uniqueApiList.addAll(taggedAPISet); } - consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + if (applications.length == 0) { + 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 = consumerRESTAPIServices.createApplication(null, null, application); + List subscriptions = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptions.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + } else { + if (applications.length == 1) { + Optional application = + Arrays.stream(applications).findFirst(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + application.get().getApplicationId()); + for (Subscription subscription : subscriptions) { + if (uniqueApiList.contains(subscription.getApiInfo())) { + uniqueApiList.remove(subscription.getApiInfo()); + } else { + uniqueApiList.add(subscription.getApiInfo()); + } + } + + + //duplicate code block + List subscriptionList = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.get().getApplicationId()); + subscriptionList.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + + } } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index 2ff525f5dc..11fc881c1b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; - public class Subscription { private String subscriptionId; From 2125519aa6c7e69009f3102953872b15815a5670 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Sat, 10 Jun 2023 11:43:27 +0530 Subject: [PATCH 097/157] Add todo Comments --- .../extension/APIManagementProviderServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f57c2fadc6..5df0e841d8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -242,9 +242,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, TokenInfo tokenInfo) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -311,6 +313,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe 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."; log.error(msg, e); From 8880ef99db4851afb466e878b5b20470a507663a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 12 Jun 2023 16:27:38 +0530 Subject: [PATCH 098/157] Improve APIM application key generate method --- .../APIManagementProviderServiceImpl.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 5df0e841d8..3f509b4c36 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -48,6 +48,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -314,13 +315,47 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = + "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + //todo call the API key retrieving call, return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } return null; } } catch (APIServicesException e) { From 83780c6a0c1075a3b26ba862de58c825a1b4e0b9 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 20 Jun 2023 09:39:49 +0530 Subject: [PATCH 099/157] Add improvements to APIM application creating logic --- .../application/extension/APIManagementProviderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3f509b4c36..f57d7db079 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -53,6 +53,7 @@ import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; +import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; From 8ea49320196101f01af045abde085b63267404e4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 13 Jul 2023 12:20:48 +0530 Subject: [PATCH 100/157] Fixes in JWT token generation --- .../APIManagementProviderServiceImpl.java | 9 +++++-- .../rest/api/APIApplicationServices.java | 5 ++-- .../rest/api/APIApplicationServicesImpl.java | 12 ++++----- .../rest/api/constants/Constants.java | 2 -- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../publisher/APIPublisherServiceImpl.java | 10 +++++-- .../impl/DeviceManagementServiceImpl.java | 27 ++++++++++++------- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++++++++++++++ 8 files changed, 64 insertions(+), 24 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f57d7db079..b4a1f11e14 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -800,9 +800,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForConsumerRestCalls", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + "ClientForConsumerRestCalls", + username, password, + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index 1cdceff56a..f5cc8b3ec1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -24,9 +24,10 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 9dbd5f52cc..a03f81d086 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() + public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", Constants.CLIENT_NAME); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", username); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", username); jsonObject.put("saasApp", true); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 6c3cf21c89..6ca26f74f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -27,10 +27,8 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; - public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; - public static final String GRANT_TYPE = "client_credentials password refresh_token"; public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; public static final String OAUTH_EXPIRES_IN = "expires_in"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 69f51fff56..63e42132f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response"; + msg = "Error occurred while processing the response" + e; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index fe98a8cef8..e188ae799b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,7 +90,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -403,7 +406,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 09be7963fd..67042ede8b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,6 +23,11 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; 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.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -804,11 +809,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(), - "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + + APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); + APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForJWTTokenGeneration", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" + ); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -816,11 +822,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe"); + username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + + " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + + "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + + "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, false, String.valueOf(validityTime), + new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -828,8 +837,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (UserStoreException e) { - String msg = "Error while getting user credentials."; + } catch (APIServicesException e) { + String msg = "Error while generating api Application"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index a297bffd48..f1a5db1156 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +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.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -157,6 +158,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; + private static volatile APIApplicationServices apiApplicationServices; private static volatile APIManagementProviderService apiManagementProviderService; static { @@ -410,6 +412,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for APIM API application REST API. + * + * @return APIApplicationServices instance + * @throws IllegalStateException if APIApplicationServices cannot be initialized + */ + public static synchronized APIApplicationServices getApiApplicationServices() { + if (apiApplicationServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); + if (apiApplicationServices == null) { + String msg = "API application service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiApplicationServices; + } + /** * Initializing and accessing method for API management Provider Service. * From 8215186061bf218455696af408152092ec43cc94 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 26 Jul 2023 07:29:08 +0530 Subject: [PATCH 101/157] Revert "Fixes in JWT token generation and sync with upstream apim420 branch" This reverts commit d567209c11918bb6f2762629da78a50dcb335ee0, reversing changes made to 437c0e642d7e6dc009310640c68813d5c58679da. --- .../pom.xml | 4 +- .../api/impl/GrafanaAPIProxyServiceImpl.java | 5 +- .../api/impl/util/GrafanaMgtAPIUtils.java | 52 -- .../pom.xml | 2 +- .../pom.xml | 4 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 10 +- .../APIManagementProviderServiceImpl.java | 160 +---- ...ApplicationManagerExtensionDataHolder.java | 14 +- ...ationManagerExtensionServiceComponent.java | 34 - .../pom.xml | 2 +- .../rest/api/APIApplicationServices.java | 5 +- .../rest/api/APIApplicationServicesImpl.java | 12 +- .../rest/api/ConsumerRESTAPIServices.java | 2 - .../rest/api/ConsumerRESTAPIServicesImpl.java | 4 - .../api/bean/APIMConsumer/Subscription.java | 2 + .../rest/api/constants/Constants.java | 2 + .../pom.xml | 2 +- .../pom.xml | 2 +- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../pom.xml | 4 +- .../publisher/APIPublisherServiceImpl.java | 10 +- .../internal/APIPublisherDataHolder.java | 13 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../common/services/ApplicationManager.java | 5 - .../pom.xml | 13 +- .../mgt/core/impl/ApplicationManagerImpl.java | 63 +- .../core/impl/SubscriptionManagerImpl.java | 38 +- .../application/mgt/core/util/APIUtil.java | 21 +- .../application/mgt/core/util/Constants.java | 6 +- .../user-test/user-mgt-registry-test.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 11 +- .../mgt/core/bean/Certificate.java | 9 - .../mgt/core/dao/CertificateDAO.java | 21 - .../dao/impl/AbstractCertificateDAOImpl.java | 70 -- .../mgt/core/impl/CertificateGenerator.java | 106 +-- .../mgt/core/impl/KeyStoreReader.java | 37 - .../src/test/resources/data-source-config.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 22 +- .../pom.xml | 36 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 31 +- .../src/test/resources/conf/carbon.xml | 658 ++++++++++++++++++ .../test/resources/repository/conf/carbon.xml | 0 .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 4 +- .../service/api/GroupManagementService.java | 98 --- .../service/api/RoleManagementService.java | 98 --- .../admin/GroupManagementAdminService.java | 85 +-- .../impl/DeviceManagementServiceImpl.java | 27 +- .../impl/GroupManagementServiceImpl.java | 85 +-- .../impl/RoleManagementServiceImpl.java | 119 +--- .../impl/UserManagementServiceImpl.java | 10 - .../GroupManagementAdminServiceImpl.java | 67 +- .../device/mgt/api/jaxrs/util/Constants.java | 5 +- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 - .../pom.xml | 2 +- .../mgt/common/DeviceManagementConstants.java | 2 - .../common/general/QREnrollmentDetails.java | 20 - .../group/mgt/DeviceGroupRoleWrapper.java | 151 ---- .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../mgt/common/spi/OTPManagementService.java | 6 +- .../pom.xml | 18 +- .../DeviceManagementConfigService.java | 7 +- .../DeviceManagementConfigServiceImpl.java | 61 +- .../config/api/util/DeviceMgtAPIUtils.java | 17 - .../pom.xml | 4 +- .../core/device/mgt/core/dao/GroupDAO.java | 49 +- .../core/dao/impl/AbstractGroupDAOImpl.java | 193 +---- .../impl/group/PostgreSQLGroupDAOImpl.java | 46 +- .../core/dao/util/GroupManagementDAOUtil.java | 1 - .../internal/DeviceManagementDataHolder.java | 16 +- .../operation/mgt/OperationManagerImpl.java | 51 +- .../dao/impl/GenericOTPManagementDAOImpl.java | 13 +- .../mgt/service/OTPManagementServiceImpl.java | 54 +- .../DeviceManagementProviderServiceImpl.java | 84 +-- .../GroupManagementProviderService.java | 31 - .../GroupManagementProviderServiceImpl.java | 126 +--- .../src/test/resources/sql/h2.sql | 1 - .../pom.xml | 4 +- .../pom.xml | 2 +- .../exception/StorageManagementException.java | 32 - components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 16 +- .../JWTClientExtensionDataHolder.java | 13 +- .../extension/service/JWTClientTest.java | 3 +- .../user-test/user-mgt-registry-test.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../logger/AppInstallLogContext.java | 181 ----- .../logger/DeviceConnectivityLogContext.java | 150 ---- .../logger/DeviceEnrolmentLogContext.java | 149 ---- .../notification/logger/PolicyLogContext.java | 133 ---- .../impl/EntgraAppInstallLoggerImpl.java | 318 --------- .../EntgraDeviceConnectivityLoggerImpl.java | 318 --------- .../impl/EntgraDeviceEnrolmentLoggerImpl.java | 318 --------- .../logger/impl/EntgraDeviceLoggerImpl.java | 7 + .../logger/impl/EntgraPolicyLoggerImpl.java | 318 --------- .../logger/impl/EntgraUserLoggerImpl.java | 2 + .../logger/util/MDCContextUtil.java | 102 +-- components/logger/pom.xml | 2 +- .../pom.xml | 9 +- .../mock/BaseOperationTemplatePluginTest.java | 1 - .../carbon-home/dbscripts/dm-db-h2.sql | 199 ++---- .../carbon-home/dbscripts/insert-subtypes.sql | 3 - .../repository/conf/cdm-config.xml | 92 +-- .../conf/datasources/data-source-config.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 15 +- .../impl/PolicyAdministratorPointImpl.java | 10 +- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 39 +- .../src/test/resources/sql/CreateH2TestDB.sql | 248 +++---- .../user-test/user-mgt-registry-test.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../pom.xml | 11 +- .../carbon-home/dbscripts/dm-db-h2.sql | 169 ++--- .../conf/datasources/data-source-config.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- .../interceptor/DefaultTokenHandler.java | 99 ++- .../ui/request/interceptor/UserHandler.java | 1 - .../interceptor/util/HandlerConstants.java | 1 - .../request/interceptor/util/HandlerUtil.java | 13 - components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 4 +- .../authenticator/BasicAuthAuthenticator.java | 31 +- .../CertificateAuthenticator.java | 9 +- .../OneTimeTokenAuthenticator.java | 14 +- .../webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 6 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../src/main/resources/conf/cdm-config.xml | 2 +- .../src/main/resources/conf/mdm-ui-config.xml | 15 +- .../repository/conf/cdm-config.xml.j2 | 16 +- .../src/main/resources/dbscripts/cdm/h2.sql | 1 - .../main/resources/dbscripts/cdm/mssql.sql | 1 - .../main/resources/dbscripts/cdm/mysql.sql | 1 - .../main/resources/dbscripts/cdm/oracle.sql | 1 - .../resources/dbscripts/cdm/postgresql.sql | 1 - .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 5 +- .../pom.xml | 5 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../email/templates/user-enrollment.vm | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../conf/webapp-authenticator-config.xml | 4 +- .../etc/webapp-authenticator-config.xml.j2 | 4 +- .../webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 27 +- 234 files changed, 1377 insertions(+), 5036 deletions(-) delete mode 100644 components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml delete mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java delete mode 100644 components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index c198c72364..82f30811ab 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -295,7 +295,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 23128fc527..6121f78ddd 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -22,7 +22,6 @@ import com.google.gson.JsonObject; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.GrafanaAPIProxyService; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.bean.ErrorResponse; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.exception.RefererNotValid; -import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaMgtAPIUtils; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaRequestHandlerUtil; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; @@ -50,8 +49,8 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { public Response queryDatasource(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { try { GrafanaPanelIdentifier panelIdentifier = GrafanaRequestHandlerUtil.getPanelIdentifier(headers); - GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), - panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + GrafanaMgtDataHolder.getInstance().getGrafanaQueryService(). + buildSafeQuery(body, panelIdentifier.getDashboardId(), panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); return GrafanaRequestHandlerUtil.proxyPassPostRequest(body, requestUriInfo, panelIdentifier.getOrgId()); } catch (MaliciousQueryAttempt e) { return Response.status(Response.Status.BAD_REQUEST).entity( diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java deleted file mode 100644 index 07a4293b49..0000000000 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util; - -import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.GrafanaQueryService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -public class GrafanaMgtAPIUtils { - - private static final Log log = LogFactory.getLog(GrafanaMgtAPIUtils.class); - private static volatile GrafanaQueryService grafanaQueryService; - - /** - * Accessing GrafanaQueryService from OSGI service context - * @return GrafanaQueryService instance - */ - public static GrafanaQueryService getGrafanaQueryService() { - if (grafanaQueryService == null) { - synchronized (GrafanaMgtAPIUtils.class) { - if (grafanaQueryService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - grafanaQueryService = - (GrafanaQueryService) ctx.getOSGiService(GrafanaQueryService.class, null); - if (grafanaQueryService == null) { - String msg = "Grafana Query service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - } - } - return grafanaQueryService; - } -} diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 3cbdb071e5..a05f1959a3 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index fcf8b4bf98..2e2888b88a 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -211,7 +211,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito org.wso2.carbon diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 110c64f553..0b495a83a8 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 6482bc57da..abf6339213 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index d2e2ca34c7..e647b5f2dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 5dc407ca23..1732b47585 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 022d3a8a51..37082c6fc6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index f62fd9c2ee..7434c58e54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -143,14 +143,6 @@ org.wso2.carbon.apimgt.impl;version="[9.28,10)", org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", org.wso2.carbon.context;version="[4.8,5)", - 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.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index b4a1f11e14..0808f11963 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -41,19 +41,16 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App 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.bean.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; -import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; @@ -122,108 +119,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException { - - APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); - - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - try { - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, null, applicationName); - - List uniqueApiList = new ArrayList<>(); - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - - for (String tag : tags) { - Map queryParams = new HashMap<>(); - queryParams.put("tag", tag); - if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams); - } else { - //call All API getting call with carbon super header param - APIInfo[] apiInfos; - if (!"carbon.super".equals(tenantDomain)) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); - } - - if (applications.length == 0) { - 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 = consumerRESTAPIServices.createApplication(null, null, application); - List subscriptions = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptions.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); - } else { - if (applications.length == 1) { - Optional application = - Arrays.stream(applications).findFirst(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, - application.get().getApplicationId()); - for (Subscription subscription : subscriptions) { - if (uniqueApiList.contains(subscription.getApiInfo())) { - uniqueApiList.remove(subscription.getApiInfo()); - } else { - uniqueApiList.add(subscription.getApiInfo()); - } - } - - - //duplicate code block - List subscriptionList = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.get().getApplicationId()); - subscriptionList.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); - } else { - String msg = "Found more than one application for application name: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - - } - - - } catch (APIServicesException e) { - e.printStackTrace(); - } catch (BadRequestException e) { - e.printStackTrace(); - } catch (UnexpectedResponseException e) { - e.printStackTrace(); - } - - return null; - - - } - - - /** - * {@inheritDoc} - */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -244,11 +139,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, TokenInfo tokenInfo) throws APIManagerException { - ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -315,50 +208,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } } - - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { - Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); - if (metaData == null) { - String msg = - "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - //todo call the API key retrieving call, return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - return null; - } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); @@ -800,14 +649,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForConsumerRestCalls", - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( - "ClientForConsumerRestCalls", - username, password, - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 978a46c13a..d6a3bb2fc5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -41,6 +41,7 @@ public class APIApplicationManagerExtensionDataHolder { private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; + private APIApplicationManagerExtensionDataHolder() { } @@ -67,18 +68,17 @@ public class APIApplicationManagerExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index ffb576295d..b3dc6dbd9d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -34,40 +34,6 @@ import org.wso2.carbon.user.core.service.RealmService; @Component( name = "io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent", immediate = true) -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent" - * @scr.reference name="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - * @scr.reference name="tenant.indexloader" - * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setIndexLoader" - * unbind="unsetIndexLoader" - * @scr.reference name="realm.service" - * immediate="true" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" - * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" - * cardinality="0..1" - * policy="dynamic" - * bind="setConsumerRESTAPIServices" - * unbind="unsetConsumerRESTAPIServices" - * @scr.reference name="apimgt.extension.APIApplicationService" - * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" - * cardinality="0..1" - * policy="dynamic" - * bind="setAPIApplicationServices" - * unbind="unsetAPIApplicationServices" - */ public class APIApplicationManagerExtensionServiceComponent { private static final Log log = LogFactory.getLog(APIApplicationManagerExtensionServiceComponent.class); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 45c9ab231f..7d4ef0501d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index f5cc8b3ec1..1cdceff56a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -24,10 +24,9 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) - throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index a03f81d086..9dbd5f52cc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + public APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", clientName); - jsonObject.put("grantType", grantType); + jsonObject.put("clientName", Constants.CLIENT_NAME); + jsonObject.put("grantType", Constants.GRANT_TYPE); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", clientName); - jsonObject.put("grantType", grantType); + jsonObject.put("clientName", username); + jsonObject.put("grantType", Constants.GRANT_TYPE); jsonObject.put("owner", username); jsonObject.put("saasApp", true); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 7fddca04f2..5ed98034e2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -23,8 +23,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import java.util.List; import java.util.Map; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index a85c611f99..293894ee71 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -24,10 +24,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -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.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java index 11fc881c1b..2ff525f5dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/Subscription.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +import org.json.JSONObject; + public class Subscription { private String subscriptionId; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 6ca26f74f0..6c3cf21c89 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -27,8 +27,10 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; + public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; + public static final String GRANT_TYPE = "client_credentials password refresh_token"; public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; public static final String OAUTH_EXPIRES_IN = "expires_in"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 82957d2b0d..2392078c2e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 201515986f..53374f48c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 63e42132f0..69f51fff56 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response" + e; + msg = "Error occurred while processing the response"; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 7e3ef60c38..c0c72a2f65 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index e188ae799b..fe98a8cef8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,10 +90,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForPublisherRestCalls", - "client_credentials password refresh_token" - ); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -406,10 +403,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForPublisherRestCalls", - "client_credentials password refresh_token" - ); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index bc7b8af32c..baff1848ed 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -75,18 +75,17 @@ public class APIPublisherDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2094510334..bee1ec2744 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 6a8a238623..c9eafdb800 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index f0e2d040ff..f7655b566b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -29,11 +29,6 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; -<<<<<<< HEAD -======= -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; ->>>>>>> 3616245ae6 (Improve app visibility restricting functionality) import org.apache.cxf.jaxrs.ext.multipart.Attachment; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index fde1c89087..9c3ab8ff85 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -153,10 +153,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - src/test/resources/testng.xml @@ -164,9 +160,6 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties - - org.ops4j.pax.logging - @@ -411,10 +404,6 @@ org.wso2.carbon.ntask.core provided - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.notification.logger - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 6b4d590fa8..9a50d0d00a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -19,16 +19,6 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.*; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import org.json.JSONObject; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.Pagination; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; import io.entgra.device.mgt.core.application.mgt.common.dto.*; import io.entgra.device.mgt.core.application.mgt.common.exception.*; @@ -67,7 +57,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; -import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -1250,13 +1239,13 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } - if (Constants.ENTERPRISE_APP_TYPE.equals(applicationDTO.getType()) || Constants.PUBLIC_APP_TYPE.equals(applicationDTO.getType())) { - persistAppIconInfo(applicationReleaseDTO); - } applicationReleaseEntities.add(applicationReleaseDTO); } applicationDTO.setId(appId); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); + if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + persistAppIconInfo(applicationReleaseDTO); + } return APIUtil.appDtoToAppResponse(applicationDTO); } } catch (LifeCycleManagementDAOException e) { @@ -1680,31 +1669,6 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - /** - * Check whether valid metaData value or not - * - * @return true or false - * @throws MetadataManagementException If it is unable to load metaData - */ - private boolean isUserAbleToViewAllRoles() throws MetadataManagementException { - List allMetadata; - allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); - if (allMetadata != null && !allMetadata.isEmpty()) { - for (Metadata metadata : allMetadata) { - if (Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())) { - String metaValue = metadata.getMetaValue(); - if (metaValue != null) { - JSONObject jsonObject; - jsonObject = new JSONObject(metaValue); - boolean isUserAbleToViewAllRoles = jsonObject.getBoolean(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); - return isUserAbleToViewAllRoles; - } - } - } - } - return false; - } - /** * Get assigned role list of the given user. * @@ -3478,8 +3442,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void validateAppCreatingRequest(T param) - throws ApplicationManagementException, RequestValidatingException { + public void validateAppCreatingRequest(T param) throws ApplicationManagementException, RequestValidatingException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); int deviceTypeId = -1; @@ -3651,14 +3614,12 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - if (!isUserAbleToViewAllRoles()) { - if (!hasUserRole(unrestrictedRoles, userName)) { - String msg = "You are trying to restrict the visibility of the application for a role set, but " - + "in order to perform the action at least one role should be assigned to user: " - + userName; - log.error(msg); - throw new BadRequestException(msg); - } + if (!hasUserRole(unrestrictedRoles, userName)) { + String msg = "You are trying to restrict the visibility of the application for a role set, but " + + "in order to perform the action at least one role should be assigned to user: " + + userName; + log.error(msg); + throw new BadRequestException(msg); } } @@ -3711,10 +3672,6 @@ public class ApplicationManagerImpl implements ApplicationManager { String msg = "Error occurred when validating the unrestricted roles given for the web clip"; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } catch (MetadataManagementException e) { - String msg = "Error occurred while retrieving metadata list"; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index e4bfe93d46..cae569bbd3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -19,10 +19,6 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.application.mgt.common.*; @@ -91,8 +87,8 @@ import java.util.stream.Collectors; * This is the default implementation for the Subscription Manager. */ public class SubscriptionManagerImpl implements SubscriptionManager { - AppInstallLogContext.Builder appInstallLogContextBuilder = new AppInstallLogContext.Builder(); - private static final EntgraLogger log = new EntgraAppInstallLoggerImpl(SubscriptionManagerImpl.class); + + private static final Log log = LogFactory.getLog(SubscriptionManagerImpl.class); private SubscriptionDAO subscriptionDAO; private ApplicationDAO applicationDAO; private LifecycleStateManager lifecycleStateManager; @@ -624,9 +620,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Properties properties, boolean isOperationReExecutingDisabled) throws ApplicationManagementException { - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + //Get app subscribing info of each device SubscribingDeviceIdHolder subscribingDeviceIdHolder = getSubscribingDeviceIdHolder(devices, applicationDTO.getApplicationReleaseDTOs().get(0).getId()); @@ -676,36 +670,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, new ArrayList<>(entry.getValue()), entry.getKey(), action, properties); activityList.add(activity); - for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder - .setAppId(String.valueOf(applicationDTO.getId())) - .setAppName(applicationDTO.getName()) - .setAppType(applicationDTO.getType()) - .setSubType(subType) - .setTenantId(tenantId) - .setTenantDomain(tenantDomain) - .setDevice(String.valueOf(identifier)) - .setUserName(username) - .setAction(action) - .build()); - } } } else { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); - for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("App %s triggered", action), appInstallLogContextBuilder - .setAppId(String.valueOf(applicationDTO.getId())) - .setAppName(applicationDTO.getName()) - .setAppType(applicationDTO.getType()) - .setSubType(subType) - .setTenantId(tenantId) - .setTenantDomain(tenantDomain) - .setDevice(String.valueOf(identifier)) - .setUserName(username) - .setAction(action) - .build()); - } } ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 8c3ccbc8bf..4b78b9e1c2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -40,7 +40,6 @@ import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,7 +64,6 @@ public class APIUtil { private static volatile SubscriptionManager subscriptionManager; private static volatile ReviewManager reviewManager; private static volatile AppmDataHandler appmDataHandler; - private static volatile MetadataManagementService metadataManagementService; public static SPApplicationManager getSPApplicationManager() { if (SPApplicationManager == null) { @@ -516,22 +514,7 @@ public class APIUtil { public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException { String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO .getAppHashValue() + Constants.FORWARD_SLASH; - return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); - } - - public static MetadataManagementService getMetadataManagementService() { - if (metadataManagementService == null) { - synchronized (APIUtil.class) { - if (metadataManagementService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - metadataManagementService = (MetadataManagementService) ctx.getOSGiService( - MetadataManagementService.class, null); - if (metadataManagementService == null) { - throw new IllegalStateException("Metadata Management service not initialized."); - } - } - } - } - return metadataManagementService; + String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); + return iconPath; } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index c3e7c49160..5864242acf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -70,8 +70,7 @@ public class Constants { public static final String ANY = "ANY"; public static final String DEFAULT_PCK_NAME = "default.app.com"; public static final String ALL = "ALL"; - public static final String SHOW_ALL_ROLES = "SHOW_ALL_ROLES"; - public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; + public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; @@ -94,9 +93,6 @@ public class Constants { public static final String MSI = "MSI"; public static final String APPX = "APPX"; - public static final String ENTERPRISE_APP_TYPE = "ENTERPRISE"; - public static final String PUBLIC_APP_TYPE = "ENTERPRISE"; - private static final Map AGENT_DATA = new HashMap<>(); static { AGENT_DATA.put("android", "android-agent.apk"); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 2e2e67a22f..512aef9700 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index b67ccf20ef..82a035ace6 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 3a7526f408..0691f0648c 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d24319a34f..d23f1863cd 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -111,10 +111,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - src/test/resources/testng.xml @@ -122,9 +118,6 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties - - org.ops4j.pax.logging - @@ -182,7 +175,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java index acf63daa07..e3e55c330f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java @@ -25,15 +25,6 @@ public class Certificate { X509Certificate certificate; int tenantId; String tenantDomain; - String deviceIdentifier; - - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } public int getTenantId() { return tenantId; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index 779251761e..de3be1856a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -41,17 +41,6 @@ public interface CertificateDAO { void addCertificate(List certificate) throws CertificateManagementDAOException; - /** - * This can be used to store a certificate in the database, where it will be stored against the serial number - * of the certificate. - * - * @param certificate Holds the certificate and relevant details. - * @throws CertificateManagementDAOException - * - */ - void addCertificate(Certificate certificate) - throws CertificateManagementDAOException; - /** * Usage is to obtain a certificate stored in the database by providing the common name. * @@ -62,16 +51,6 @@ public interface CertificateDAO { */ CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException; - /** - * Obtain a certificated stored in the database by providing the common name and the tenant ID - * - * @param serialNumber Serial number (Common name) of the certificate - * @param tenantId ID of the certificate owning tenant - * @return representation of the certificate. - * @throws CertificateManagementDAOException if fails to read the certificate from the database - */ - CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException; - /** * Get all the certificates in a paginated manner. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 0a8e9e3066..45a7e7c56f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -81,40 +81,6 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ } } - @Override - public void addCertificate(Certificate certificate) - throws CertificateManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - stmt = conn.prepareStatement( - "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID," + - " USERNAME, DEVICE_IDENTIFIER) VALUES (?,?,?,?,?)"); - PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. - getThreadLocalCarbonContext(); - String username = threadLocalCarbonContext.getUsername(); - // the serial number of the certificate used for its creation is set as its alias. - String serialNumber = certificate.getSerial(); - if (serialNumber == null || serialNumber.isEmpty()) { - serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber()); - } - byte[] bytes = Serializer.serialize(certificate.getCertificate()); - - stmt.setString(1, serialNumber); - stmt.setBytes(2, bytes); - stmt.setInt(3, certificate.getTenantId()); - stmt.setString(4, username); - stmt.setString(5, certificate.getDeviceIdentifier()); - stmt.executeUpdate(); - } catch (SQLException | IOException e) { - throw new CertificateManagementDAOException("Error occurred while saving the " + - "certificate. ", e); - } finally { - CertificateManagementDAOUtil.cleanupResources(stmt, null); - } - } - @Override public CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException { @@ -153,42 +119,6 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ return certificateResponse; } - @Override - public CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet resultSet = null; - CertificateResponse certificateResponse = null; - try { - conn = this.getConnection(); - String query = - "SELECT CERTIFICATE, SERIAL_NUMBER, TENANT_ID, USERNAME FROM" - + " DM_DEVICE_CERTIFICATE WHERE SERIAL_NUMBER = ? AND TENANT_ID = ? "; - stmt = conn.prepareStatement(query); - stmt.setString(1, serialNumber); - stmt.setInt(2, tenantId); - resultSet = stmt.executeQuery(); - - if (resultSet.next()) { - certificateResponse = new CertificateResponse(); - byte[] certificateBytes = resultSet.getBytes("CERTIFICATE"); - certificateResponse.setCertificate(certificateBytes); - certificateResponse.setSerialNumber(resultSet.getString("SERIAL_NUMBER")); - certificateResponse.setTenantId(resultSet.getInt("TENANT_ID")); - certificateResponse.setUsername(resultSet.getString("USERNAME")); - CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse); - } - } catch (SQLException e) { - String errorMsg = - "Unable to get the read the certificate with serial" + serialNumber; - log.error(errorMsg, e); - throw new CertificateManagementDAOException(errorMsg, e); - } finally { - CertificateManagementDAOUtil.cleanupResources(stmt, resultSet); - } - return certificateResponse; - } - @Override public List searchCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index b8109e74fc..bc98fae4a5 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -55,28 +55,10 @@ import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.Store; -import org.jscep.message.CertRep; -import org.jscep.message.MessageDecodingException; -import org.jscep.message.MessageEncodingException; -import org.jscep.message.PkcsPkiEnvelopeDecoder; -import org.jscep.message.PkcsPkiEnvelopeEncoder; -import org.jscep.message.PkiMessage; -import org.jscep.message.PkiMessageDecoder; -import org.jscep.message.PkiMessageEncoder; +import org.jscep.message.*; import org.jscep.transaction.FailInfo; import org.jscep.transaction.Nonce; import org.jscep.transaction.TransactionId; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateDAO; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOException; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import org.wso2.carbon.certificate.mgt.core.dto.CAStatus; -import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; -import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse; -import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; -import org.wso2.carbon.certificate.mgt.core.exception.TransactionManagementException; -import org.wso2.carbon.certificate.mgt.core.util.CertificateManagementConstants; -import org.wso2.carbon.certificate.mgt.core.util.CommonUtil; -import org.wso2.carbon.certificate.mgt.core.util.Serializer; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.naming.InvalidNameException; @@ -88,34 +70,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.Security; -import java.security.SignatureException; +import java.security.*; import java.security.cert.Certificate; import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.*; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateFactory; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.X509Certificate; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -376,31 +336,15 @@ public class CertificateGenerator { CertificateResponse lookUpCertificate = null; KeyStoreReader keyStoreReader = new KeyStoreReader(); if (distinguishedName != null && !distinguishedName.isEmpty()) { - if (distinguishedName.contains("CN=")) { - String[] dnSplits = null; - if (distinguishedName.contains("/")) { - dnSplits = distinguishedName.split("/"); - } else if (distinguishedName.contains(",")) { - //some older versions of nginx will forward the client certificate subject dn separated with commas - dnSplits = distinguishedName.split(","); - } - String commonNameExtracted = null; - int tenantId = 0; - if (dnSplits != null && dnSplits.length >= 1) { - for (String dnPart : dnSplits) { - if (dnPart.contains("CN=")) { - commonNameExtracted = dnPart.replace("CN=", ""); - } else if (dnPart.contains("OU=")) { - //the OU of the certificate will be like OU=tenant_ ex: OU=tenant_-1234 - //splitting by underscore to extract the tenant domain - String[] orgUnitSplits = dnPart.split("_"); - tenantId = Integer.parseInt(orgUnitSplits[1]); - } + if (distinguishedName.contains("/CN=")) { + String[] dnSplits = distinguishedName.split("/"); + for (String dnPart : dnSplits) { + if (dnPart.contains("CN=")) { + String commonNameExtracted = dnPart.replace("CN=", ""); + lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted); + break; } } - - lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted, tenantId); - } else { LdapName ldapName; try { @@ -727,29 +671,6 @@ public class CertificateGenerator { throw new KeystoreException(errorMsg, e); } } - public void saveCertificate(org.wso2.carbon.certificate.mgt.core.bean.Certificate - certificate) throws KeystoreException { - - if (certificate == null) { - return; - } - - try { - CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO(); - CertificateManagementDAOFactory.beginTransaction(); - certificateDAO.addCertificate(certificate); - CertificateManagementDAOFactory.commitTransaction(); - } catch (CertificateManagementDAOException e) { - String errorMsg = "Error occurred when saving the generated certificate in database"; - log.error(errorMsg); - CertificateManagementDAOFactory.rollbackTransaction(); - throw new KeystoreException(errorMsg, e); - } catch (TransactionManagementException e) { - String errorMsg = "Error occurred when saving the generated certificate in database"; - log.error(errorMsg); - throw new KeystoreException(errorMsg, e); - } - } public void saveCertInKeyStore(List certificate) throws KeystoreException { @@ -864,9 +785,8 @@ public class CertificateGenerator { X500Name issuerName = new X500Name(subjectDn); String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - X500Name subjectName = new X500Name("O=" + commonName + ",CN=" + - serialNumber + ", OU=tenant_"+tenantId); + X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + + serialNumber); Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365 * 100)); @@ -889,8 +809,8 @@ public class CertificateGenerator { List certificates = new ArrayList<>(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); certificate.setCertificate(issuedCert); - certificate.setDeviceIdentifier(commonName); - saveCertificate(certificate); + certificates.add(certificate); + saveCertInKeyStore(certificates); } catch (OperatorCreationException e) { String errorMsg = "Error creating the content signer"; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java index 94cab378bf..56ec2bb6f5 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java @@ -271,43 +271,6 @@ public class KeyStoreReader { return raPrivateKey; } - public CertificateResponse getCertificateBySerial(String serialNumber, int tenantId) throws KeystoreException { - CertificateResponse certificateResponse = null; - try { - CertificateCacheManager cacheManager = CertificateCacheManagerImpl.getInstance(); - certificateResponse = cacheManager.getCertificateBySerial(serialNumber); - if (certificateResponse == null) { - try { - CertificateManagementDAOFactory.openConnection(); - certificateResponse = certDao.retrieveCertificate(serialNumber, tenantId); - } catch (SQLException e) { - String errorMsg = "Error when making a connection to the database."; - throw new KeystoreException(errorMsg, e); - } finally { - CertificateManagementDAOFactory.closeConnection(); - } - if (certificateResponse != null && certificateResponse.getCertificate() != null) { - Certificate certificate = (Certificate) Serializer.deserialize(certificateResponse.getCertificate()); - if (certificate instanceof X509Certificate) { - X509Certificate x509cert = (X509Certificate) certificate; - String commonName = CertificateGenerator.getCommonName(x509cert); - certificateResponse.setCommonName(commonName); - cacheManager.addCertificateBySerial(serialNumber, certificateResponse); - } - } - } - } catch (CertificateManagementDAOException e) { - String errorMsg = "Error when retrieving certificate from the the database for the serial number: " + - serialNumber; - throw new KeystoreException(errorMsg, e); - - } catch (ClassNotFoundException | IOException e) { - String errorMsg = "Error when de-serializing saved certificate."; - throw new KeystoreException(errorMsg, e); - } - return certificateResponse; - } - public CertificateResponse getCertificateBySerial(String serialNumber) throws KeystoreException { CertificateResponse certificateResponse = null; try { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml index 533fd82959..27b6dfeaeb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true org.h2.Driver wso2carbon wso2carbon diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 7833296e8a..98c20d369b 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index d8a79858c6..38ba36543d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -106,19 +106,13 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - file:src/test/resources/log4j.properties + file:src/test/resources/carbon-home/repository/conf/log4j.properties + src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -213,15 +207,5 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - com.sun.xml.bind - jaxb-core - test - - - com.sun.xml.bind - jaxb-impl - test - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 610f4f6cda..8b1dc93e22 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -104,21 +104,6 @@ io.entgra.device.mgt.core.device.mgt.core test - - org.mockito - mockito-core - test - - - com.sun.xml.bind - jaxb-core - test - - - com.sun.xml.bind - jaxb-impl - test - @@ -172,25 +157,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - org.ops4j.pax.logging - - - org.jacoco jacoco-maven-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index da2c459069..f984260692 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index f238d4d5d4..a50c455f80 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 1608581ec7..c357cd7566 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index c2899b36e3..17a7c4b6ff 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index aeaed8655c..ed434c7873 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -122,16 +122,6 @@ powermock-module-testng test - - org.wso2.carbon - org.wso2.carbon.securevault - test - - - org.mockito - mockito-core - test - @@ -199,25 +189,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - org.ops4j.pax.logging - - - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml new file mode 100644 index 0000000000..a5518cb720 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml @@ -0,0 +1,658 @@ + + + + + + + + + ${product.name} + + + ${product.key} + + + ${product.version} + + + + + + + + + local:/${carbon.context}/services/ + + + + + + + ${default.server.role} + + + + + + + org.wso2.carbon + + + / + + + + + + + + + 15 + + + + + + + + + 0 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 10500 + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + + + + + + + + 30 + + + + + + + + + 15 + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + + + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + ${p2.repo.url} + + + + + + + + true + + + + + + true + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index d1c6c2206c..6291d849a5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index e18d86ef10..cab0ec4896 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 1223822167..c6914f5733 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 0c2e5663fe..09ac87fdb8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -364,7 +364,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index 33d46f139b..cfe12bc3f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -26,24 +26,6 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import javax.validation.Valid; import javax.ws.rs.*; @@ -177,13 +159,6 @@ import java.util.List; key = "perm:groups:devices-types", roles = {"Internal/devicemgt-user"}, permissions = {"/device-mgt/groups/devices/types"} - ), - @Scope( - name = "View whether the groups has relevant device types", - description = "View whether the groups has relevant device types", - key = "perm:groups:add", - roles = {"Internal/devicemgt-user"}, - permissions = {"/device-mgt/groups/device-types"} ) } ) @@ -1231,77 +1206,4 @@ public interface GroupManagementService { required = true) List identifiers); - - @POST - @Path("/roles/share") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = HTTPConstants.HEADER_POST, - value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", - notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", - tags = "Device Group Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "Created. \n Device group has successfully been created.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the created group."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body."), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests.") - } - ), - @ApiResponse( - code = 303, - message = "See Other. \n Source can be retrieved from the URL specified at the Location " + - "header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Group not found.", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while creating the group or adding devices or sharing the group.", - response = ErrorResponse.class) - }) - Response createGroupWithRoles( - @ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - ); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java index 5031f1598d..f7eb730a8b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java @@ -187,104 +187,6 @@ public interface RoleManagementService { defaultValue = "5") @QueryParam("limit") int limit); - @GET - @Path("/visible/{metaKey}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting the List of Visible Roles", - notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" + - "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", - tags = "Role Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.", - response = RoleList.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the " + - "requested resource."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist.\n", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the list of roles" + - " assigned to the specified user.", - response = ErrorResponse.class) - }) - Response getVisibleRole( - @ApiParam( - name = "filter", - value = "Provide a character or a few characters in the role name.", - required = false) - @QueryParam("filter") String filter, - @ApiParam( - name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", - required = false) - @QueryParam("user-store") String userStoreName, - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time." + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - required = false, - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many role details you require from the starting pagination index/offset.", - required = false, - defaultValue = "5") - @QueryParam("limit") int limit, - @ApiParam( - name = "username", - value = "The username of the user.", - required = true, - defaultValue = "admin") - @QueryParam("username") String username, - @ApiParam( - name = "domain", - value = "The domain name of the user store.", - required = false) - @QueryParam("domain") String domain, - @ApiParam( - name = "metaKey", - value = "Key of the metadata", - required = true) - @PathParam("metaKey") String metaKey); - @GET @Path("/filter/{prefix}") @ApiOperation( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java index eb5f791ab6..393389340f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -27,16 +27,8 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -366,79 +358,4 @@ public interface GroupManagementAdminService { required = true) @Valid DeviceGroup group); - - - @POST - @Path("/roles/share") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = HTTPConstants.HEADER_POST, - value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", - notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", - tags = "Device Group Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "Created. \n Device group has successfully been created.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the created group."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body."), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests.") - } - ), - @ApiResponse( - code = 303, - message = "See Other. \n Source can be retrieved from the URL specified at the Location " + - "header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Group not found.", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while creating the group or adding devices or sharing the group.", - response = ErrorResponse.class) - }) - Response createGroupWithRoles(@ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - - ); - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 67042ede8b..09be7963fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,11 +23,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; 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.extension.rest.api.APIApplicationServices; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -809,12 +804,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - - APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); - APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForJWTTokenGeneration", - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" - ); + DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -822,14 +816,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + - " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + - "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + - "perm:users:send-invitation"); + username, "appm:subscribe"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), + new String[] {"device_management"}, null, false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -837,8 +828,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (APIServicesException e) { - String msg = "Error while generating api Application"; + } catch (UserStoreException e) { + String msg = "Error while getting user credentials."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index 98ca6249d0..f0122835e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -18,28 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; @@ -59,21 +37,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.transaction.UserTransaction; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class GroupManagementServiceImpl implements GroupManagementService { @@ -127,18 +94,8 @@ public class GroupManagementServiceImpl implements GroupManagementService { request.setGroupName(name); request.setOwner(owner); request.setDepth(depth); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); - String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); - boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); - PaginationResult deviceGroupsResult; - if (hasAdminRole) { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); - } else{ - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); - } + PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -147,10 +104,6 @@ public class GroupManagementServiceImpl implements GroupManagementService { String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while getting user realm."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } @@ -463,38 +416,4 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } - @POST - @Path("/roles/share") - @Override - public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { - if (groups == null) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - groups.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); - try { - DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); - if (group != null) { - DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); - return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); - } else { - String msg = "Error occurred while retrieving newly created group."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (GroupManagementException e) { - String msg = "Error occurred while adding " + groups.getName() + " group"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + groups.getName() + " Try with another group name."; - log.error(msg, e); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } catch (RoleDoesNotExistException e) { - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); - } - } - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 5c04516650..c8df51825e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,14 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import com.google.common.base.Strings; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import org.apache.axis2.databinding.types.xsd._boolean; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; @@ -36,7 +28,6 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.SetReferenceTransformer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.util.StringUtils; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; @@ -59,12 +50,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import java.util.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; import static io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants.PRIMARY_USER_STORE; @@ -112,96 +97,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { } } - @GET - @Path("/visible/{metaKey}") - @Override - public Response getVisibleRole( - @QueryParam("filter") String filter, - @QueryParam("user-store") String userStore, - @HeaderParam("If-Modified-Since") String ifModifiedSince, - @QueryParam("offset") int offset, - @QueryParam("limit") int limit, - @QueryParam("username") String username, - @QueryParam("domain") String domain, - @PathParam("metaKey") String metaKey) { - RequestValidationUtil.validatePaginationParameters(offset, limit); - if (limit == 0){ - limit = Constants.DEFAULT_PAGE_LIMIT; - } - if (!Strings.isNullOrEmpty(domain)) { - username = domain + '/' + username; - } - Metadata metadata; - List visibleRoles; - RoleList visibleRoleList = new RoleList(); - try { - metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); - String metaValue = metadata.getMetaValue(); - JSONParser parser = new JSONParser(); - JSONObject jsonObject = (JSONObject) parser.parse(metaValue); - boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); - if (decision) { - if (Strings.isNullOrEmpty(userStore)){ - userStore = PRIMARY_USER_STORE; - } - try { - visibleRoles = getRolesFromUserStore(filter, userStore); - visibleRoleList.setList(visibleRoles); - - visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); - visibleRoleList.setList(visibleRoles); - - return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while retrieving roles from the underlying user stores"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } - } else { - try { - UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - if (!userStoreManager.isExistingUser(username)) { - if (log.isDebugEnabled()) { - log.debug("User by username: " + username + " does not exist for role retrieval."); - } - String msg = "User by username: " + username + " does not exist for role retrieval."; - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); - - return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } - } - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting the metadata entry for metaKey:" + metaKey; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ParseException e) { - String msg = "Error occurred while parsing JSON metadata: " + e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - private List getFilteredVisibleRoles(UserStoreManager userStoreManager, String username) - throws UserStoreException { - String[] roleListOfUser; - roleListOfUser = userStoreManager.getRoleListOfUser(username); - List filteredRoles = new ArrayList<>(); - for (String role : roleListOfUser) { - if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) { - filteredRoles.add(role); - } - } - return filteredRoles; - } - @GET @Path("/filter/{prefix}") @Override @@ -647,7 +542,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { @Consumes(MediaType.WILDCARD) @Override public Response deleteRole(@PathParam("roleName") String roleName, @QueryParam("user-store") String userStoreName) { - String roleToDelete = roleName; if (userStoreName != null && !userStoreName.isEmpty()) { roleName = userStoreName + "/" + roleName; } @@ -655,7 +549,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { try { final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (!userStoreManager.isExistingRole(roleName)) { String msg = "No role exists with the name : " + roleName ; return Response.status(404).entity(msg).build(); @@ -665,18 +558,16 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (log.isDebugEnabled()) { log.debug("Deleting the role in user store"); } - DeviceMgtAPIUtils.getGroupManagementProviderService().deleteRoleAndRoleGroupMapping(roleName, roleToDelete, tenantId, userStoreManager, authorizationManager); + userStoreManager.deleteRole(roleName); + // Delete all authorizations for the current role before deleting + authorizationManager.clearRoleAuthorization(roleName); + return Response.status(Response.Status.OK).build(); } catch (UserStoreException e) { String msg = "Error occurred while deleting the role '" + roleName + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (GroupManagementException e) { - String msg = "Error occurred while deleting group-role mapping records"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } @@ -706,7 +597,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd); return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " + - "successfully been updated with the user list") + "successfully been updated with the user list") .build(); } catch (UserStoreException e) { String msg = "Error occurred while updating the users of the role '" + roleName + "'"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index d0f5239fa3..5209ace472 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,9 +424,6 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { - continue; - } user = getBasicUserInfo(username); userList.add(user); } @@ -487,10 +484,6 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } - if (commonUsers != null) { - commonUsers.remove(Constants.APIM_RESERVED_USER); - commonUsers.remove(Constants.RESERVED_USER); - } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -665,9 +658,6 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { - continue; - } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index d7bf236acf..5f6d8a7bae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -29,34 +29,13 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; -import java.util.Arrays; public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { @@ -111,25 +90,13 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @DefaultValue("5") @QueryParam("limit") int limit) { try { RequestValidationUtil.validatePaginationParameters(offset, limit); - String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); GroupPaginationRequest request = new GroupPaginationRequest(offset, limit); request.setGroupName(name); request.setOwner(owner); request.setStatus(status); request.setDepth(depth); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); - String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); - boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); - boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); - PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser) || isAdmin || hasAdminRole) { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); - } else { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); - } + PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -138,10 +105,6 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while getting user realm."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } @@ -181,30 +144,4 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ return Response.status(Response.Status.CONFLICT).entity(msg).build(); } } - @POST - @Path("/roles/share") - @Override - public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { - if (group == null) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); - try { - DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); - return Response.status(Response.Status.CREATED).build(); - } catch (GroupManagementException e) { - String msg = "Error occurred while adding " + group.getName() + " group"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + group.getName() + " Try with another group name."; - log.error(msg, e); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } catch (RoleDoesNotExistException e) { - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); - } - } - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 0a9b6efa26..300e47b147 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,16 +30,13 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; - public static final String APIM_RESERVED_USER = "apim_reserved_user"; - public static final String RESERVED_USER = "reserved_user"; - public static final String DEFAULT_STREAM_VERSION = "1.0.0"; + public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static final int DEFAULT_PAGE_LIMIT = 50; public static final String FORWARD_SLASH = "/"; public static final String ANDROID = "android"; - public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.uem.platform.android." + "core.polcy.AndroidPolicyPayloadValidator"; public static final String IOS = "ios"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index f1a5db1156..a297bffd48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; -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.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -158,7 +157,6 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; - private static volatile APIApplicationServices apiApplicationServices; private static volatile APIManagementProviderService apiManagementProviderService; static { @@ -412,25 +410,6 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } - /** - * Initializing and accessing method for APIM API application REST API. - * - * @return APIApplicationServices instance - * @throws IllegalStateException if APIApplicationServices cannot be initialized - */ - public static synchronized APIApplicationServices getApiApplicationServices() { - if (apiApplicationServices == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); - if (apiApplicationServices == null) { - String msg = "API application service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - return apiApplicationServices; - } - /** * Initializing and accessing method for API management Provider Service. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index bec50d0782..d8323a431c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java index 6fd2fedde9..fb4c749b82 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java @@ -134,8 +134,6 @@ public final class DeviceManagementConstants { public static final String LAST_NAME = "last-name"; public static final String TENANT_ADMIN_USERNAME = "tenant-admin-username"; public static final String TENANT_ADMIN_PASSWORD = "tenant-admin-password"; - - public static final int OTP_DEFAULT_EXPIRY_SECONDS = 3600; } public static final class EventServices { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index 08a334bf2f..df0719d152 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -18,22 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.common.general; -import java.util.Map; - public class QREnrollmentDetails { String ownershipType; String username; String enrollmentMode; - Map customValues; - - public Map getCustomValues() { - return customValues; - } - - public void setCustomValues(Map customValues) { - this.customValues = customValues; - } - int tokenExpiry; public String getOwnershipType() { return ownershipType; } @@ -46,12 +34,4 @@ public class QREnrollmentDetails { public String getEnrollmentMode() { return enrollmentMode; } public void setEnrollmentMode(String enrollmentMode) { this.enrollmentMode = enrollmentMode; } - - public int getTokenExpiry() { - return tokenExpiry; - } - - public void setTokenExpiry(int tokenExpiry) { - this.tokenExpiry = tokenExpiry; - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java deleted file mode 100644 index 768fe55524..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.device.mgt.common.group.mgt; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * Holds Device Group details and expose to external access - */ -@ApiModel(value = "DeviceGroupRoleWrapper", description = "This class carries all information related to a managed device group.") -public class DeviceGroupRoleWrapper implements Serializable { - - private static final long serialVersionUID = 1998121711L; - - @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") - private int id; - - @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", required = true) - private String description; - - @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", required = true) - private String name; - - private String owner; - - @ApiModelProperty(name = "status", value = "The status of group that needs updating/retrieval.") - private String status; - - @ApiModelProperty(name = "parentGroupId", value = "Group ID of parent group") - private int parentGroupId; - - @ApiModelProperty(name = "parentPath", value = "Path of parent group") - private String parentPath; - - @ApiModelProperty(name = "childrenGroups", value = "Children groups") - private List childrenGroups; - - @ApiModelProperty(name = "userRoles", value = "User roles") - private List userRoles; - - public DeviceGroupRoleWrapper() { - } - - public DeviceGroupRoleWrapper(String name) { - this.name = name; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - private Map groupProperties; - - public int getGroupId() { - return id; - } - - public void setGroupId(int id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public Map getGroupProperties() { - return groupProperties; - } - - public void setGroupProperties(Map groupProperties) { - this.groupProperties = groupProperties; - } - - public int getParentGroupId() { - return parentGroupId; - } - - public void setParentGroupId(int parentGroupId) { - this.parentGroupId = parentGroupId; - } - - public String getParentPath() { - return parentPath; - } - - public void setParentPath(String parentPath) { - this.parentPath = parentPath; - } - - public List getChildrenGroups() { - return childrenGroups; - } - - public void setChildrenGroups(List childrenGroups) { - this.childrenGroups = childrenGroups; - } - - public List getUserRoles() { - return userRoles; - } - - public void setUserRoles(List userRoles) { - this.userRoles = userRoles; - } -} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index 53113c5b75..afb1d6b0fa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE, REMOTE_SESSION + USER_VERIFY, DEVICE_ENROLLMENT } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java index e4cfa042b6..c89d311cda 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java @@ -35,8 +35,7 @@ public interface OTPManagementService { * @throws OTPManagementException if error occurred whle verifying validity of the OPT * @throws BadRequestException if found an null value for OTP */ - OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws - OTPManagementException, BadRequestException; + OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException; /** * Invalidate the OTP and send welcome mail @@ -60,7 +59,8 @@ public interface OTPManagementService { boolean hasEmailRegistered(String email, String emailDomain) throws OTPManagementException, DeviceManagementException; - OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinData, boolean persistPin) throws OTPManagementException; + OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, + int tenantId, boolean persistPin) throws OTPManagementException; OneTimePinDTO getRenewedOtpByEmailAndMailType(String email, String emailType) throws OTPManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index c00dc59b3b..a4673c3e6e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -76,20 +76,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - - src/test/resources/testng.xml - - ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties - - org.ops4j.pax.logging - + + src/test/resources/testng.xml + @@ -263,7 +255,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index 729e477c00..eac30a6de6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -139,12 +139,7 @@ public interface DeviceManagementConfigService { value = "The properties list using for query a device", required = true) @QueryParam("properties") - String properties, - @ApiParam( - name = "withAccessToken", - value = "Whether to use access token or otp token for device configuration") - @QueryParam("withAccessToken") - boolean withAccessToken); + String properties); @PUT @Path("/device/transfer") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index de80a541d2..f387dfea32 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -21,10 +21,6 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; -import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.OTPEmailTypes; -import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; @@ -52,30 +48,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; -import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; -import org.wso2.carbon.device.mgt.common.DeviceTransferRequest; -import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; -import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; -import org.wso2.carbon.device.mgt.common.general.TenantDetail; -import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; -import org.wso2.carbon.device.mgt.core.config.keymanager.KeyManagerConfigurations; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; -import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; @@ -98,8 +70,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig @Path("/configurations") @Produces(MediaType.APPLICATION_JSON) public Response getConfiguration(@HeaderParam("token") String token, - @QueryParam("properties") String properties, - @QueryParam("withAccessToken") boolean withAccessToken) { + @QueryParam("properties") String properties) { DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); try { if (token == null || token.isEmpty()) { @@ -124,8 +95,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig deviceProps.put("token", token); DeviceConfiguration devicesConfiguration = dms.getDeviceConfiguration(deviceProps); - if (withAccessToken) setAccessTokenToDeviceConfigurations(devicesConfiguration); - else setOTPTokenToDeviceConfigurations(devicesConfiguration); + setAccessTokenToDeviceConfigurations(devicesConfiguration); return Response.status(Response.Status.OK).entity(devicesConfiguration).build(); } catch (DeviceManagementException e) { String msg = "Error occurred while retrieving configurations"; @@ -237,33 +207,6 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig } } - private void setOTPTokenToDeviceConfigurations(DeviceConfiguration deviceConfiguration) - throws DeviceManagementException { - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); - oneTimePinData.setEmailType(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); - oneTimePinData.setUsername(deviceConfiguration.getDeviceOwner()); - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - deviceConfiguration.getTenantDomain(), true); - oneTimePinData.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - PrivilegedCarbonContext.endTenantFlow(); - OTPManagementService otpManagementService = DeviceMgtAPIUtils.getOtpManagementService(); - try { - OneTimePinDTO oneTimePinDTO = otpManagementService.generateOneTimePin(oneTimePinData, true); - if (oneTimePinDTO == null) { - String msg = "Null value returned when generating OTP token for " + oneTimePinData.getOtpToken(); - log.error(msg); - throw new DeviceManagementException(msg); - } - deviceConfiguration.setAccessToken(oneTimePinDTO.getOtpToken()); - } catch (OTPManagementException ex) { - String msg = "Error occurred while generating one time pin: " + ex.getMessage(); - log.error(msg, ex); - throw new DeviceManagementException(msg, ex); - } - } - @Override @Path("/tenants") @GET diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java index fbe57c8928..1dd6052def 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java @@ -22,8 +22,6 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -36,8 +34,6 @@ public class DeviceMgtAPIUtils { private static DeviceManagementProviderService deviceManagementProviderService = null; private static RealmService realmService = null; - private static OTPManagementService otpManagementService = null; - public static DeviceManagementProviderService getDeviceManagementService() { if (deviceManagementProviderService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -52,19 +48,6 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } - public static OTPManagementService getOtpManagementService() { - if (otpManagementService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - otpManagementService = (OTPManagementService) ctx.getOSGiService(OTPManagementService.class, null); - if (otpManagementService == null) { - String msg = "OTP Management Service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - return otpManagementService; - } - public static RealmService getRealmService() { if (realmService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 26f6603912..521ff65c5c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -473,7 +473,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito org.wso2.carbon.multitenancy diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index ac91b7036f..16ac6f62be 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -22,7 +22,6 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import java.util.List; import java.util.Map; @@ -41,18 +40,6 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; - /** - * Add properties for device group. - * Note that groupId parameter is considered seperately due to the groupId parameter passed with - * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. - * - * @param groups to be added. - * @param tenantId of the group. - * @return sql execution result. - * @throws GroupManagementDAOException - */ - int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -65,18 +52,6 @@ public interface GroupDAO { */ boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; - /** - * Update properties for device group. - * Note that groupId parameter is considered seperately due to the groupId parameter passed with - * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. - * - * @param groups to be updated. - * @param tenantId of the group. - * @return sql execution result. - * @throws GroupManagementDAOException - */ - boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; - /** * Update properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -155,15 +130,6 @@ public interface GroupDAO { */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; - /** - * Delete mappings of Device Groups. - * - * @param role of Device Groups. - * @param tenantId of the role. - * @throws GroupManagementDAOException on error during deletion of mappings of groups - */ - void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException; - /** * Delete existing Device Groups. * @@ -220,19 +186,6 @@ public interface GroupDAO { */ List getGroups(GroupPaginationRequest paginationRequest, int tenantId) throws GroupManagementDAOException; - /** - * Get paginated list of Device Groups in tenant with specified device group ids. - * - * @param paginationRequest to filter results. - * @param deviceGroupIds of groups required. - * @param tenantId of user's tenant. - * @param isWithParentPath of user's ParentPath. - * @return List of all Device Groups in tenant. - * @throws GroupManagementDAOException - */ - List getGroups(GroupPaginationRequest paginationRequest, List deviceGroupIds, - int tenantId, boolean isWithParentPath) throws GroupManagementDAOException; - /** * Get paginated list of Device Groups in tenant with specified device group ids. * @@ -459,4 +412,4 @@ public interface GroupDAO { List groupNames) throws GroupManagementDAOException; -} \ No newline at end of file +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index e1fc26eb8e..803526e593 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -50,7 +49,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; @@ -104,7 +103,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { @Override public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId) throws GroupManagementDAOException { + int tenantId) throws GroupManagementDAOException { int deviceGroupIdsCount = deviceGroupIds.size(); if (deviceGroupIdsCount == 0) { return new ArrayList<>(); @@ -112,7 +111,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; } @@ -165,73 +164,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } - @Override - public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId, boolean isWithParentPath) throws GroupManagementDAOException { - int deviceGroupIdsCount = deviceGroupIds.size(); - if (deviceGroupIdsCount == 0) { - return new ArrayList<>(); - } - - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; - if (StringUtils.isNotBlank(request.getGroupName())) { - sql += " AND GROUP_NAME LIKE ?"; - } - if (StringUtils.isNotBlank(request.getOwner())) { - sql += " AND OWNER LIKE ?"; - } - if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ - sql += " AND PARENT_PATH LIKE ?"; - } - } - sql += " AND ID IN ("; - for (int i = 0; i < deviceGroupIdsCount; i++) { - sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?"; - } - sql += ")"; - if (request.getRowCount() != 0) { - sql += " LIMIT ? OFFSET ?"; - } - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIndex = 1; - stmt.setInt(paramIndex++, tenantId); - if (StringUtils.isNotBlank(request.getGroupName())) { - stmt.setString(paramIndex++, request.getGroupName() + "%"); - } - if (StringUtils.isNotBlank(request.getOwner())) { - stmt.setString(paramIndex++, request.getOwner() + "%"); - } - if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ - stmt.setString(paramIndex++, request.getParentPath()); - } - } - for (Integer deviceGroupId : deviceGroupIds) { - stmt.setInt(paramIndex++, deviceGroupId); - } - if (request.getRowCount() != 0) { - stmt.setInt(paramIndex++, request.getRowCount()); - stmt.setInt(paramIndex, request.getStartIndex()); - } - List deviceGroupList = new ArrayList<>(); - try (ResultSet resultSet = stmt.executeQuery()) { - while (resultSet.next()) { - deviceGroupList.add(GroupManagementDAOUtil.loadGroup(resultSet)); - } - } - return deviceGroupList; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() - + " in tenant: " + tenantId; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { @@ -243,11 +175,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if (deviceGroup.getStatus() == null || deviceGroup.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " - + "VALUES (?, ?, ?, ?, ?, ?)"; + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + "VALUES (?, ?, ?, ?, ?)"; } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " - + "VALUES (?, ?, ?, ?, ?, ?, ?)"; + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?)"; hasStatus = true; } stmt = conn.prepareStatement(sql, new String[]{"ID"}); @@ -256,9 +188,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setInt(4, tenantId); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getParentGroupId()); if (hasStatus) { - stmt.setString(7, deviceGroup.getStatus()); + stmt.setString(6, deviceGroup.getStatus()); } stmt.executeUpdate(); @@ -275,47 +206,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } - @Override - public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - int groupId = -1; - boolean hasStatus = false; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql; - if (groups.getStatus() == null || groups.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " - + "VALUES (?, ?, ?, ?, ?, ?)"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " - + "VALUES (?, ?, ?, ?, ?, ?, ?)"; - hasStatus = true; - } - try (PreparedStatement stmt = conn.prepareStatement(sql, new String[]{"ID"})) { - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - stmt.setInt(6, groups.getParentGroupId()); - if (hasStatus) { - stmt.setString(7, groups.getStatus()); - } - stmt.executeUpdate(); - try (ResultSet rs = stmt.getGeneratedKeys();) { - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding deviceGroup '" + - groups.getName() + "'"; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } - public boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -344,33 +234,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { return status; } - public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) - throws GroupManagementDAOException { - boolean status; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement( - "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + - "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)")) { - for (Map.Entry entry : groups.getGroupProperties().entrySet()) { - stmt.setInt(1, groupId); - stmt.setString(2, entry.getKey()); - stmt.setString(3, entry.getValue()); - stmt.setInt(4, tenantId); - stmt.addBatch(); - } - stmt.executeBatch(); - status = true; - } - } catch (SQLException e) { - String msg = "Error occurred while adding properties for group '" + - groups.getName() + "' values : " + groups.getGroupProperties(); - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - return status; - } - public boolean updateGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -440,7 +303,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, " - + "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?"; + + "PARENT_PATH = ? WHERE ID = ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)){ for (DeviceGroup deviceGroup : deviceGroups) { stmt.setString(1, deviceGroup.getDescription()); @@ -448,9 +311,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setString(4, deviceGroup.getStatus()); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getParentGroupId()); - stmt.setInt(7, deviceGroup.getGroupId()); - stmt.setInt(8, tenantId); + stmt.setInt(6, deviceGroup.getGroupId()); + stmt.setInt(7, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -541,23 +403,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } - @Override - public void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException { - - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "DELETE FROM DM_ROLE_GROUP_MAP WHERE ROLE = ? AND TENANT_ID = ?"; - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, role); - stmt.setInt(2, tenantId); - stmt.executeUpdate(); - } - } catch (SQLException e) { - String msg = "Error occurred while removing record from group-role mapping."; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } @Override public void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException { try { @@ -646,7 +491,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { ResultSet resultSet = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE ID = ? " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE ID = ? " + "AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -669,7 +514,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getChildrenGroups(String parentPath, int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, parentPath + "%"); @@ -694,7 +539,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getRootGroups(int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, "/"); @@ -722,7 +567,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupBuilders = new ArrayList<>(); try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH, G.PARENT_GROUP_ID FROM DM_GROUP G " + + String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH FROM DM_GROUP G " + "INNER JOIN DM_DEVICE_GROUP_MAP GM ON G.ID = GM.GROUP_ID " + "WHERE GM.DEVICE_ID = ? AND GM.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); @@ -860,7 +705,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = - "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE LOWER(GROUP_NAME) = LOWER(?) AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, groupName); @@ -1031,7 +876,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID P FROM DM_GROUP g, " + + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP g, " + "(SELECT GROUP_ID FROM DM_ROLE_GROUP_MAP WHERE ROLE IN ("; int index = 0; @@ -1145,7 +990,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, username); @@ -1283,7 +1128,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } - @Override + @Override public List getAllDevicesOfGroup(String groupName, int tenantId) throws GroupManagementDAOException { Connection conn; List devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index 6a786a0bfd..f2aeaed327 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -42,7 +39,6 @@ import java.util.List; */ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { - private static final Log log = LogFactory.getLog(PostgreSQLGroupDAOImpl.class); @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { PreparedStatement stmt = null; @@ -53,7 +49,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if(StringUtils.isEmpty(deviceGroup.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + @@ -83,46 +79,6 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } - @Override - public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - int groupId = -1; - boolean hasStatus = false; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql; - if (StringUtils.isEmpty(groups.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + - "VALUES (?, ?, ?, ?) RETURNING ID"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + - "VALUES (?, ?, ?, ?, ?) RETURNING ID"; - hasStatus = true; - } - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - if (hasStatus) { - stmt.setString(6, groups.getStatus()); - } - stmt.execute(); - try (ResultSet rs = stmt.getGeneratedKeys()) { - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding deviceGroup '" + - groups.getName() + "'"; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } - @Override public List getDevices(int groupId, int startIndex, int rowCount, int tenantId) throws GroupManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java index 42307e6b74..acf8d4c614 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java @@ -87,7 +87,6 @@ public final class GroupManagementDAOUtil { group.setOwner(resultSet.getString("OWNER")); group.setStatus(resultSet.getString("STATUS")); group.setParentPath(resultSet.getString("PARENT_PATH")); - group.setParentGroupId(resultSet.getInt("PARENT_GROUP_ID")); return group; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index 3fa8fdc453..a901ffeddf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } - return tenantManager; } + return tenantManager; + } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public DeviceManagementProviderService getDeviceManagementProvider() { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index e752475939..5e5ca5c13d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -19,23 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; import io.entgra.device.mgt.core.device.mgt.common.*; -import com.google.gson.Gson; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -85,8 +68,7 @@ import java.util.concurrent.ThreadPoolExecutor; */ public class OperationManagerImpl implements OperationManager { - DeviceConnectivityLogContext.Builder deviceConnectivityLogContextBuilder = new DeviceConnectivityLogContext.Builder(); - private static final EntgraLogger log = new EntgraDeviceConnectivityLoggerImpl(OperationManagerImpl.class); + private static final Log log = LogFactory.getLog(OperationManagerImpl.class); private static final int CACHE_VALIDITY_PERIOD = 5 * 60 * 1000; private static final String NOTIFIER_TYPE_LOCAL = "LOCAL"; private static final String SYSTEM = "system"; @@ -169,8 +151,6 @@ public class OperationManagerImpl implements OperationManager { } } - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds); List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); if (!validDeviceIds.isEmpty()) { @@ -247,10 +227,6 @@ public class OperationManagerImpl implements OperationManager { activity.setActivityStatus( this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult)); } - for (DeviceIdentifier deviceId : authorizedDeviceIds) { - device = getDevice(deviceId); - log.info("Operation added", deviceConnectivityLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(deviceType).setActionTag("ADD_OPERATION").setTenantDomain(tenantDomain).setTenantId(tenantId).setUserName(initiatedBy).setOperationCode(operationCode).build()); - } return activity; } catch (OperationManagementDAOException e) { OperationManagementDAOFactory.rollbackTransaction(); @@ -472,7 +448,6 @@ public class OperationManagerImpl implements OperationManager { int failAttempts = 0; while (true) { try { - OperationManagementDAOFactory.beginTransaction(); operationMappingDAO.updateOperationMapping(operation.getId(), device.getEnrolmentInfo().getId(), io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); OperationManagementDAOFactory.commitTransaction(); @@ -495,11 +470,6 @@ public class OperationManagerImpl implements OperationManager { } catch (InterruptedException ignore) { break; } - } catch (TransactionManagementException ex) { - log.error("Error occurred while initiating the transaction", ex); - break; - } finally { - OperationManagementDAOFactory.closeConnection(); } } } catch (Exception e) { @@ -703,9 +673,7 @@ public class OperationManagerImpl implements OperationManager { if (log.isDebugEnabled()) { log.debug("Device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]"); } - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -718,25 +686,16 @@ public class OperationManagerImpl implements OperationManager { case INACTIVE: case UNREACHABLE: this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder - .setDeviceId(deviceId.getId()) - .setDeviceType(deviceId.getType()) - .setActionTag("PENDING_OPERATION") - .setTenantDomain(tenantDomain) - .setTenantId(String.valueOf(tenantId)) - .setUserName(userName) - .build()); + return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } @Override public List getPendingOperations(Device device) throws OperationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -754,10 +713,10 @@ public class OperationManagerImpl implements OperationManager { this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); device.setEnrolmentInfo(enrolmentInfo); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, device, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(device.getDeviceIdentifier()).setDeviceType(device.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceIdentifier, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index 02373de936..eaac0bf827 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; @@ -26,12 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.OTPManagementDAO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; -import org.wso2.carbon.device.mgt.core.otp.mgt.dao.OTPManagementDAO; -import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; + import java.sql.*; import java.util.Calendar; import java.util.List; @@ -57,8 +51,7 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM + "META_INFO, " + "CREATED_AT," + "TENANT_ID," - + "USERNAME, " - + "EXPIRY_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + + "USERNAME) VALUES (?, ?, ?, ?, ?, ?, ?)"; try { Connection conn = this.getDBConnection(); Calendar calendar = Calendar.getInstance(); @@ -72,8 +65,6 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM stmt.setTimestamp(5, timestamp); stmt.setInt(6, oneTimePinDTO.getTenantId()); stmt.setString(7, oneTimePinDTO.getUsername()); - stmt.setInt(8, oneTimePinDTO.getExpiryTime() == 0 - ? DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS : oneTimePinDTO.getExpiryTime()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index 074eb8eed7..087cf3851f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -117,8 +117,7 @@ public class OTPManagementServiceImpl implements OTPManagementService { } @Override - public OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws OTPManagementException, - BadRequestException { + public OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException { if (StringUtils.isBlank(oneTimeToken)){ String msg = "Received blank OTP to verify. OTP: " + oneTimeToken; log.error(msg); @@ -142,19 +141,17 @@ public class OTPManagementServiceImpl implements OTPManagementService { oneTimePinDTO.getCreatedAt().getTime() + oneTimePinDTO.getExpiryTime() * 1000L); if (currentTimestamp.after(expiredTimestamp)) { - if (requireRenewal) { - String renewedOTP = UUID.randomUUID().toString(); - renewOTP(oneTimePinDTO, renewedOTP); - Gson gson = new Gson(); - Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); + String renewedOTP = UUID.randomUUID().toString(); + renewOTP(oneTimePinDTO, renewedOTP); + Gson gson = new Gson(); + Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); - Properties props = new Properties(); - props.setProperty("first-name", tenant.getAdminFirstName()); - props.setProperty("otp-token", renewedOTP); - props.setProperty("email", oneTimePinDTO.getEmail()); - props.setProperty("type", oneTimePinDTO.getEmailType()); - sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); - } + Properties props = new Properties(); + props.setProperty("first-name", tenant.getAdminFirstName()); + props.setProperty("otp-token", renewedOTP); + props.setProperty("email", oneTimePinDTO.getEmail()); + props.setProperty("type", oneTimePinDTO.getEmailType()); + sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); return null; } return oneTimePinDTO; @@ -227,6 +224,9 @@ public class OTPManagementServiceImpl implements OTPManagementService { } } } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + OneTimePinDTO oneTimePinDTO; + List oneTimePinDTOList = new ArrayList<>(); Properties props = new Properties(); props.setProperty("enrollment-steps", enrollmentSteps.toString()); try { @@ -234,11 +234,16 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); + oneTimePinDTO = generateOneTimePin(emailAddress, OTPEmailTypes.DEVICE_ENROLLMENT.toString(), username, + null, tenantId, false); + oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); props.setProperty("username", username); + props.setProperty("otp-token", oneTimePinDTO.getOtpToken()); sendMail(props, emailAddress, DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE); } + this.otpManagementDAO.addOTPData(oneTimePinDTOList); ConnectionManagerUtil.commitDBTransaction(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; @@ -252,6 +257,11 @@ public class OTPManagementServiceImpl implements OTPManagementService { String msg = "SQL Error occurred when adding OPT data to send device enrollment Invitation."; log.error(msg, e); throw new OTPManagementException(msg, e); + } catch (OTPManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occurred while saving the OTP data."; + log.error(msg, e); + throw new OTPManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -259,17 +269,27 @@ public class OTPManagementServiceImpl implements OTPManagementService { /** * Create One Time Token - * @param oneTimePinDTO Data related to the one time pin + * @param email email + * @param emailType email type + * @param userName username + * @param metaDataObj meta data object + * @param tenantId tenant Id * @return {@link OneTimePinDTO} */ @Override - public OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinDTO, boolean persistPin) throws OTPManagementException { + public OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, + int tenantId, boolean persistPin) throws OTPManagementException { String otpValue = UUID.randomUUID().toString(); Gson gson = new Gson(); - String metaInfo = gson.toJson(oneTimePinDTO.getMetaInfo()); + String metaInfo = gson.toJson(metaDataObj); + OneTimePinDTO oneTimePinDTO = new OneTimePinDTO(); + oneTimePinDTO.setEmail(email); + oneTimePinDTO.setTenantId(tenantId); + oneTimePinDTO.setUsername(userName); + oneTimePinDTO.setEmailType(emailType); oneTimePinDTO.setMetaInfo(metaInfo); oneTimePinDTO.setOtpToken(otpValue); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index eb1a60c48c..02d6b010eb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -21,30 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.lang.StringUtils; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Billing; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; -import io.entgra.device.mgt.core.device.mgt.common.DeviceNotification; -import io.entgra.device.mgt.core.device.mgt.common.DevicePropertyNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; @@ -135,27 +111,13 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; -import java.time.LocalTime; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, PluginInitializationListener { - DeviceEnrolmentLogContext.Builder deviceEnrolmentLogContextBuilder = new DeviceEnrolmentLogContext.Builder(); - - private static final EntgraLogger log = new EntgraDeviceEnrolmentLoggerImpl(DeviceManagementProviderServiceImpl.class); + private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); private static final String OPERATION_RESPONSE_EVENT_STREAM_DEFINITION = "org.wso2.iot.OperationResponseStream"; private final DeviceManagementPluginRepository pluginRepository; @@ -243,8 +205,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrollmentConfiguration enrollmentConfiguration = DeviceManagerUtil.getEnrollmentConfigurationEntry(); String deviceSerialNumber = null; if (enrollmentConfiguration != null) { @@ -331,15 +291,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder - .setDeviceId(String.valueOf(existingDevice.getId())) - .setDeviceType(String.valueOf(existingDevice.getType())) - .setOwner(newEnrolmentInfo.getOwner()) - .setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())) - .setTenantID(String.valueOf(tenantId)) - .setTenantDomain(tenantDomain) - .setUserName(userName) - .build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + @@ -376,7 +327,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } device.setEnrolmentInfo(enrollment); DeviceManagementDAOFactory.commitTransaction(); - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(enrollment.getOwner()).setOwnership(String.valueOf(enrollment.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } else { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException("No device type registered with name - " + device.getType() @@ -454,8 +404,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (log.isDebugEnabled()) { log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'"); } - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); if (deviceManager == null) { @@ -484,7 +432,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); DeviceManagementDAOFactory.commitTransaction(); - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -568,8 +515,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } int tenantId = this.getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + Device device = this.getDevice(deviceId, false); if (device == null) { if (log.isDebugEnabled()) { @@ -603,7 +549,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } //procees to dis-enroll a device from traccar ends - log.info("Device disenrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(device.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + @@ -1060,15 +1006,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } - - // Convert dateDiff to days as a decimal value - double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); - - if (dateDiffInDays % 1 >= 0.9) { - dateDiffInDays = Math.ceil(dateDiffInDays); - } - - long dateInDays = (long) dateDiffInDays; + long dateInDays = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); double cost = (tenantCost.getCost() / 365) * dateInDays; totalCost += cost; device.setCost(Math.round(cost * 100.0) / 100.0); @@ -1135,13 +1073,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv long difference_In_Days = (difference_In_Time / (1000 * 60 * 60 * 24)) % 365; - if (difference_In_Time % (1000 * 60 * 60 * 24) >= 0.9 * (1000 * 60 * 60 * 24)) { - difference_In_Days++; - } - for (int i = 1; i <= difference_In_Years; i++) { List allDevicesPerYear = new ArrayList<>(); - LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); Timestamp newStartDate; Timestamp newEndDate; @@ -1150,12 +1084,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv remainingDaysConsidered = true; oneYearAfterStart = startDate.toLocalDateTime(); newEndDate = endDate; + } else if (Timestamp.valueOf(oneYearAfterStart).getTime() >= endDate.getTime()) { + newEndDate = Timestamp.valueOf(oneYearAfterStart); } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); newEndDate = Timestamp.valueOf(oneYearAfterStart); } } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); newEndDate = Timestamp.valueOf(oneYearAfterStart); } @@ -1178,7 +1114,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices.addAll(billingResponse.getDevice()); totalCost = totalCost + billingResponse.getTotalCostPerYear(); deviceCount = deviceCount + billingResponse.getDeviceCount(); - LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1).with(LocalTime.of(00, 00, 00)); + LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1); startDate = Timestamp.valueOf(nextStartDate); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index ef2338688f..1bae5b30ce 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -24,15 +24,6 @@ import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.wso2.carbon.user.api.AuthorizationManager; -import org.wso2.carbon.user.api.UserStoreManager; import java.util.List; @@ -52,16 +43,6 @@ public interface GroupManagementProviderService { void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException; - /** - * Add new device group and create default role with default permissions. - * - * @param groups to add - * @param defaultRole of the deviceGroup - * @param defaultPermissions of the default role - * @throws GroupManagementException - */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException,GroupManagementException, RoleDoesNotExistException; - /** * Update existing device group. * @@ -82,18 +63,6 @@ public interface GroupManagementProviderService { */ boolean deleteGroup(int groupId, boolean isDeleteChildren) throws GroupManagementException; - /** - * Delete existing device group. - * - * @param role to be deleted with the userStore name. - * @param roleToDelete to delete the role. - * @param tenantId to belongs to roles. - * @param userStoreManager with details. - * @param authorizationManager with details. - * @throws GroupManagementException - */ - void deleteRoleAndRoleGroupMapping(String role, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException; - /** * Get the device group provided the device group id. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index a35d4d74bb..c605a8ebe7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -19,23 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -52,20 +35,12 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import java.sql.SQLException; import java.util.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -150,59 +125,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException, GroupManagementException { - if (groups == null) { - String msg = "Received incomplete data for createGroup"; - log.error(msg); - throw new GroupManagementException(msg); - } - if (log.isDebugEnabled()) { - log.debug("Creating group '" + groups.getName() + "'"); - } - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - try { - GroupManagementDAOFactory.beginTransaction(); - DeviceGroup existingGroup = this.groupDAO.getGroup(groups.getName(), tenantId); - if (existingGroup == null) { - if (groups.getParentGroupId() == 0) { - groups.setParentPath(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); - } else { - DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); - if (immediateParentGroup == null) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; - log.error(msg); - throw new GroupManagementException(msg); - } - String parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup); - groups.setParentPath(parentPath); - } - int updatedGroupID = this.groupDAO.addGroupWithRoles(groups, tenantId); - if (groups.getGroupProperties() != null && groups.getGroupProperties().size() > 0) { - this.groupDAO.addGroupPropertiesWithRoles(groups, updatedGroupID, tenantId); - } - GroupManagementDAOFactory.commitTransaction(); - } else { - throw new GroupAlreadyExistException("Group already exists with name : " + groups.getName() + " Try with another group name."); - } - } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = e.getMessage(); - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (TransactionManagementException e) { - String msg = "Error occurred while initiating transaction."; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); - } - - if (log.isDebugEnabled()) { - log.debug("DeviceGroup added: " + groups.getName()); - } - } - /** * {@inheritDoc} */ @@ -314,13 +236,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); - if (!DeviceGroupConstants.HierarchicalGroup.SEPERATOR.equals(newParentPath)) { - String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); - int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); - childrenGroup.setParentGroupId(latestGroupId); - } else { - childrenGroup.setParentGroupId(0); - } } } } @@ -361,40 +276,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - /** - * {@inheritDoc} - */ - @Override - public void deleteRoleAndRoleGroupMapping(String roleName, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException { - if (log.isDebugEnabled()) { - log.debug("Delete roles"); - } - try { - GroupManagementDAOFactory.beginTransaction(); - groupDAO.deleteGroupsMapping(roleToDelete, tenantId); - userStoreManager.deleteRole(roleName); - // Delete all authorizations for the current role before deleting - authorizationManager.clearRoleAuthorization(roleName); - GroupManagementDAOFactory.commitTransaction(); - } catch (UserStoreException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while deleting the role '" + roleName + "'"; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (TransactionManagementException e) { - String msg = "Error occurred while initiating transaction."; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while deleting the role"; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); - } - } - /** * {@inheritDoc} */ @@ -561,7 +442,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroupsWithHierarchy(String username, GroupPaginationRequest request, - boolean requireGroupProps) throws GroupManagementException { + boolean requireGroupProps) throws GroupManagementException { if (request == null) { String msg = "Received incomplete data for retrieve groups with hierarchy"; log.error(msg); @@ -570,7 +451,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (log.isDebugEnabled()) { log.debug("Get groups with hierarchy " + request.toString()); } - boolean isWithParentPath = false; DeviceManagerUtil.validateGroupListPageSize(request); List rootGroups; try { @@ -582,7 +462,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { List allDeviceGroupIdsOfUser = getGroupIds(username); GroupManagementDAOFactory.openConnection(); - rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId, isWithParentPath); + rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); } String parentPath; List childrenGroups; @@ -1403,7 +1283,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid * @throws GroupManagementDAOException on error during population of group properties. */ private void createGroupWithChildren(DeviceGroup parentGroup, List childrenGroups, - boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { + boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { if (childrenGroups.isEmpty() || depth == counter) { return; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 4f83fa5b5e..d22d8f312f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -16,7 +16,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index c12f494f37..a9814241de 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -78,7 +78,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index d0ecba2064..57ff12e288 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java deleted file mode 100644 index 38985716de..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.core.common.exception; - -/** - * Represents the exception thrown during storing and retrieving the artifacts. - */ -public class StorageManagementException extends Exception { - public StorageManagementException(String message, Throwable ex) { - super(message, ex); - } - - public StorageManagementException(String message) { - super(message); - } -} - diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7e01efb324..cb1c9dba67 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index e6848b89c8..9971311788 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 7bf1a8fbdb..819685280b 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 8bf81024df..fa60f27f1e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index e5157d6a82..8b646fa964 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -155,12 +155,7 @@ org.powermock - powermock-api-mockito2 - test - - - org.mockito - mockito-core + powermock-api-mockito test @@ -258,19 +253,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/log4j.properties src/test/resources/testng.xml - - org.ops4j.pax.logging - diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java index cd3999c9bf..7d253b2333 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java @@ -74,18 +74,17 @@ public class JWTClientExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index beb7db9962..d497d5e108 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -43,10 +43,9 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.powermock.modules.testng.PowerMockTestCase; @PrepareForTest(JWTClientUtil.class) -public class JWTClientTest extends PowerMockTestCase{ +public class JWTClientTest { private static final Log log = LogFactory.getLog(JWTClientTest.class); @ObjectFactory diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index bc0478f310..216bfb4d71 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 70ca947ed2..324934a4dd 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java deleted file mode 100644 index 33cffac366..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class AppInstallLogContext extends LogContext { - private final String appId; - private final String appName; - private final String appType; - private final String subType; - private final String tenantId; - private final String tenantDomain; - private final String device; - private final String userName; - private final String action; - - private AppInstallLogContext(Builder builder) { - this.appId = builder.appId; - this.appName = builder.appName; - this.appType = builder.appType; - this.subType = builder.subType; - this.tenantId = builder.tenantId; - this.tenantDomain = builder.tenantDomain; - this.device = builder.device; - this.userName = builder.userName; - this.action = builder.action; - } - - public String getAppId() { - return appId; - } - - public String getAppName() { - return appName; - } - - public String getAppType() { - return appType; - } - - public String getSubType() { - return subType; - } - - public String getTenantId() { - return tenantId; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getDevice() { - return device; - } - - public String getUserName() { - return userName; - } - - public String getAction() { - return action; - } - - public static class Builder { - private String appId; - private String appName; - private String appType; - private String subType; - private String tenantId; - private String tenantDomain; - private String device; - private String userName; - private String action; - - public Builder() { - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getAppId() { - return appId; - } - - public Builder setAppId(String appId) { - this.appId = appId; - return this; - } - - public String getAppName() { - return appName; - } - - public Builder setAppName(String appName) { - this.appName = appName; - return this; - } - - public String getAppType() { - return appType; - } - - public Builder setAppType(String appType) { - this.appType = appType; - return this; - } - - public String getSubType() { - return subType; - } - - public Builder setSubType(String subType) { - this.subType = subType; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getTenantId() { - return tenantId; - } - - public Builder setTenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - public String getDevice() { - return device; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - public String getAction() { - return action; - } - - public Builder setAction(String action) { - this.action = action; - return this; - } - - public AppInstallLogContext build() { - return new AppInstallLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java deleted file mode 100644 index d110e84a43..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class DeviceConnectivityLogContext extends LogContext { - - private final String deviceId; - private final String deviceType; - private final String actionTag; - private final String operationCode; - private final String tenantId; - private final String tenantDomain; - private final String userName; - - private DeviceConnectivityLogContext(Builder builder) { - this.deviceId = builder.deviceId; - this.deviceType = builder.deviceType; - this.actionTag = builder.actionTag; - this.operationCode = builder.operationCode; - this.tenantId = builder.tenantId; - this.tenantDomain = builder.tenantDomain; - this.userName = builder.userName; - } - - public String getDeviceId() { - return deviceId; - } - - public String getDeviceType() { - return deviceType; - } - - public String getActionTag() { - return actionTag; - } - - public String getOperationCode() { - return operationCode; - } - - public String getTenantId() { - return tenantId; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getUserName() { - return userName; - } - - public static class Builder { - private String deviceId; - private String deviceType; - private String operationCode; - private String actionTag; - private String tenantId; - private String tenantDomain; - private String userName; - - public Builder() { - } - - public String getDeviceId() { - return deviceId; - } - - public Builder setDeviceId(String deviceId) { - this.deviceId = deviceId; - return this; - } - - public String getDeviceType() { - return deviceType; - } - - public Builder setDeviceType(String deviceType) { - this.deviceType = deviceType; - return this; - } - - public String getOperationCode() { - return operationCode; - } - - public Builder setOperationCode(String operationCode) { - this.operationCode = operationCode; - return this; - } - - public String getTenantId() { - return tenantId; - } - - public Builder setTenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getActionTag() { - return actionTag; - } - - public Builder setActionTag(String actionTag) { - this.actionTag = actionTag; - return this; - } - - public DeviceConnectivityLogContext build() { - return new DeviceConnectivityLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java deleted file mode 100644 index b355b29671..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class DeviceEnrolmentLogContext extends LogContext { - private final String deviceId; - private final String deviceType; - private final String owner; - private final String ownership; - private final String tenantID; - private final String tenantDomain; - private final String userName; - - private DeviceEnrolmentLogContext(Builder builder) { - this.deviceId = builder.deviceId; - this.deviceType = builder.deviceType; - this.owner = builder.owner; - this.ownership = builder.ownership; - this.tenantID = builder.tenantID; - this.tenantDomain = builder.tenantDomain; - this.userName = builder.userName; - } - - public String getTenantID() { - return tenantID; - } - - public String getDeviceId() { - return deviceId; - } - - public String getOwner() { - return owner; - } - - public String getDeviceType() { - return deviceType; - } - - public String getOwnership() { - return ownership; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getUserName() { - return userName; - } - public static class Builder { - private String deviceId; - private String deviceType; - private String owner; - private String ownership; - private String tenantID; - private String tenantDomain; - private String userName; - - public Builder() { - } - - public String getDeviceType() { - return deviceType; - } - - public Builder setDeviceType(String deviceType) { - this.deviceType = deviceType; - return this; - } - - public String getTenantID() { - return tenantID; - } - - public Builder setTenantID(String tenantID) { - this.tenantID = tenantID; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getDeviceId() { - return deviceId; - } - - public Builder setDeviceId(String deviceId) { - this.deviceId = deviceId; - return this; - } - - public String getOwner() { - return owner; - } - - public Builder setOwner(String owner) { - this.owner = owner; - return this; - } - - public String getOwnership() { - return ownership; - } - - public Builder setOwnership(String ownership) { - this.ownership = ownership; - return this; - } - - public DeviceEnrolmentLogContext build() { - return new DeviceEnrolmentLogContext(this); - } - - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java deleted file mode 100644 index 9dbd10a059..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class PolicyLogContext extends LogContext { - private final String policyName; - private final String payload; - private final String actionTag; - private final String userName; - private final String tenantID; - private final String tenantDomain; - - private PolicyLogContext(Builder builder) { - this.policyName = builder.policyName; - this.payload = builder.payload; - this.actionTag = builder.actionTag; - this.userName = builder.userName; - this.tenantID = builder.tenantID; - this.tenantDomain = builder.tenantDomain; - } - - public String getPolicyName() { - return policyName; - } - - public String getPayload() { - return payload; - } - - public String getActionTag() { - return actionTag; - } - - public String getUserName() { - return userName; - } - - public String getTenantID() { - return tenantID; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public static class Builder { - private String policyName; - private String payload; - private String actionTag; - private String userName; - private String tenantID; - private String tenantDomain; - - public Builder() { - } - - public String getPolicyName() { - return policyName; - } - - public Builder setPolicyName(String policyName) { - this.policyName = policyName; - return this; - } - - public String getPayload() { - return payload; - } - - public Builder setPayload(String payload) { - this.payload = payload; - return this; - } - - public String getActionTag() { - return actionTag; - } - - public Builder setActionTag(String actionTag) { - this.actionTag = actionTag; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getTenantID() { - return tenantID; - } - - public Builder setTenantID(String tenantID) { - this.tenantID = tenantID; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public PolicyLogContext build() { - return new PolicyLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java deleted file mode 100644 index 81f071c2af..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.entgra.device.mgt.core.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraAppInstallLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraAppInstallLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java deleted file mode 100644 index aaa62bf488..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.entgra.device.mgt.core.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraDeviceConnectivityLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java deleted file mode 100644 index db0b7dd265..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.entgra.device.mgt.core.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraDeviceEnrolmentLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java index a51987463f..ae10ae87c2 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; + import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; @@ -25,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; + public class EntgraDeviceLoggerImpl implements EntgraLogger { private static Log log = null; @@ -72,6 +74,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.info(object, t); } + public void debug(String message) { log.debug(message); } @@ -111,6 +114,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.debug(object, t); } + public void error(String message) { log.error(message); } @@ -157,6 +161,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.error(object, t); } + public void warn(String message) { log.warn(message); } @@ -203,6 +208,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.warn(object, t); } + public void trace(String message) { log.trace(message); } @@ -242,6 +248,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.trace(object, t); } + public void fatal(String message) { log.fatal(message); } diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java deleted file mode 100644 index 218252f260..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.entgra.device.mgt.core.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraPolicyLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraPolicyLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java index fa482605f6..6a082b013d 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; + import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.UserLogContext; @@ -25,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; + public class EntgraUserLoggerImpl implements EntgraLogger { private static Log log = null; diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index dc046e8eeb..09f903188a 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -17,7 +17,8 @@ */ package io.entgra.device.mgt.core.notification.logger.util; -import io.entgra.device.mgt.core.notification.logger.*; +import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; +import io.entgra.device.mgt.core.notification.logger.UserLogContext; import org.apache.log4j.MDC; public final class MDCContextUtil { @@ -61,105 +62,6 @@ public final class MDCContextUtil { } } - - public static void populatePolicyMDCContext(final PolicyLogContext mdcContext) { - if (mdcContext.getPolicyName() != null) { - MDC.put("PolicyName", mdcContext.getPolicyName()); - } - if (mdcContext.getPayload() != null) { - MDC.put("Payload", mdcContext.getPayload()); - } - if (mdcContext.getActionTag() != null) { - MDC.put("ActionTag", mdcContext.getActionTag()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantID() != null) { - MDC.put("TenantId", mdcContext.getTenantID()); - } - } - - public static void populateAppInstallMDCContext(final AppInstallLogContext mdcContext) { - if (mdcContext.getAppId() != null) { - MDC.put("AppId", mdcContext.getAppId()); - } - if (mdcContext.getAppName() != null) { - MDC.put("AppName", mdcContext.getAppName()); - } - if (mdcContext.getAppType() != null) { - MDC.put("AppType", mdcContext.getAppType()); - } - if (mdcContext.getSubType() != null) { - MDC.put("SubType", mdcContext.getSubType()); - } - if (mdcContext.getDevice() != null) { - MDC.put("Device", mdcContext.getDevice()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantId() != null) { - MDC.put("TenantId", mdcContext.getTenantId()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getAction() != null) { - MDC.put("Action", mdcContext.getAction()); - } - } - - public static void populateDeviceConnectivityMDCContext(final DeviceConnectivityLogContext mdcContext) { - if (mdcContext.getDeviceId() != null) { - MDC.put("DeviceId", mdcContext.getDeviceId()); - } - if (mdcContext.getDeviceType() != null) { - MDC.put("DeviceType", mdcContext.getDeviceType()); - } - if (mdcContext.getOperationCode() != null) { - MDC.put("OperationCode", mdcContext.getOperationCode()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantId() != null) { - MDC.put("TenantId", mdcContext.getTenantId()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getActionTag() != null) { - MDC.put("ActionTag", mdcContext.getActionTag()); - } - } - - public static void populateDeviceEnrolmentMDCContext(final DeviceEnrolmentLogContext mdcContext) { - if (mdcContext.getDeviceId() != null) { - MDC.put("DeviceId", mdcContext.getDeviceId()); - } - if (mdcContext.getDeviceType() != null) { - MDC.put("DeviceType", mdcContext.getDeviceType()); - } - if (mdcContext.getOwner() != null) { - MDC.put("Owner", mdcContext.getOwner()); - } - if (mdcContext.getOwnership() != null) { - MDC.put("Ownership", mdcContext.getOwnership()); - } - if (mdcContext.getTenantID() != null) { - MDC.put("TenantId", mdcContext.getTenantID()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - } } diff --git a/components/logger/pom.xml b/components/logger/pom.xml index c4dfdd014b..cb85a7f88c 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index c8af2e9003..c71669f41e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -119,10 +119,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -130,9 +126,6 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index 58c7e8b65f..c563311602 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -144,7 +144,6 @@ public abstract class BaseOperationTemplatePluginTest { conn = ConnectionManagerUtils.getDBConnection(); stmt = conn.createStatement(); stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/dm-db-h2.sql'"); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/carbon-home/dbscripts/insert-subtypes.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index df3277920d..6052156588 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT NULL, + PARENT_PATH VARCHAR(255) DEFAULT '/', TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT DEFAULT NULL, + DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP BIGINT NOT NULL, - RECEIVED_TIMESTAMP BIGINT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,19 +108,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); -CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ENROLMENT_ID INTEGER NOT NULL, - DEVICE_ID INTEGER NOT NULL, - STATUS VARCHAR(50) DEFAULT NULL, - UPDATE_TIME TIMESTAMP DEFAULT NULL, - CHANGED_BY VARCHAR(255) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE -); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -188,17 +176,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT NULL , + TENANT_ID INT(11) NOT NULL , + PROFILE_ID INT(11) NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -209,11 +197,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT , + DEVICE_ID INT(11) NOT NULL , + ENROLMENT_ID INT(11) NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,9 +216,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , + ID INT(11) NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -240,11 +228,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT NOT NULL , + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -255,11 +243,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, + ID INT(11) NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT DEFAULT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + FEATURE_ID INT(11) DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -270,9 +258,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -296,11 +284,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -353,7 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -368,7 +356,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -397,7 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -417,16 +405,6 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- -CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ICON_PATH VARCHAR(150) DEFAULT NULL, - PACKAGE_NAME VARCHAR(150) NOT NULL, - VERSION VARCHAR(50) DEFAULT '1.1.0', - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - TENANT_ID INTEGER NOT NULL, - PRIMARY KEY (ID) -); - -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -447,7 +425,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1500) NULL, + VALUE_FIELD VARCHAR(1000) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -476,7 +454,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -513,8 +491,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + PLUGGED_IN INT(1) NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -541,7 +519,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT NOT NULL, + TIMESTAMP BIGINT(15) NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -610,7 +588,8 @@ CREATE TABLE IF NOT EXISTS DM_OTP_DATA ( CREATED_AT TIMESTAMP NOT NULL, EXPIRY_TIME INT NOT NULL DEFAULT 3600, IS_EXPIRED BOOLEAN DEFAULT false, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) ); -- END OF DM_OTP_DATA TABLE -- @@ -746,94 +725,52 @@ CREATE TABLE IF NOT EXISTS DM_GEOFENCE_EVENT_MAPPING ( -- END OF DM_GEOFENCE_GROUP_MAPPING TABLE-- --- DM_EXT_GROUP_MAPPING TABLE-- -CREATE TABLE IF NOT EXISTS DM_EXT_GROUP_MAPPING ( - ID INT NOT NULL AUTO_INCREMENT, - TRACCAR_GROUP_ID INT DEFAULT 0, - GROUP_ID INT NOT NULL, - TENANT_ID INT NOT NULL, - STATUS INT DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_EXT_GROUP_MAPPING TABLE-- - --- END OF DM_EXT_DEVICE_MAPPING TABLE-- -CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( - ID INT NOT NULL AUTO_INCREMENT, - TRACCAR_DEVICE_ID INT DEFAULT 0, - DEVICE_ID INT NOT NULL, - TENANT_ID INT NOT NULL, - STATUS INT DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_EXT_DEVICE_MAPPING TABLE-- - --- END OF DM_EXT_PERMISSION_MAPPING TABLE-- -CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( - TRACCAR_DEVICE_ID INT DEFAULT 0, - TRACCAR_USER_ID INT DEFAULT 0 -); --- END OF DM_EXT_PERMISSION_MAPPING TABLE-- - --- DYNAMIC TASK TABLES-- -CREATE TABLE IF NOT EXISTS DYNAMIC_TASK ( - DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, - NAME VARCHAR(300) DEFAULT NULL , - CRON VARCHAR(8000) DEFAULT NULL, - IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, - TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (DYNAMIC_TASK_ID) -); - -CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( - DYNAMIC_TASK_ID INTEGER NOT NULL, - PROPERTY_NAME VARCHAR(100) DEFAULT 0, - PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100), - PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), - CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES - DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE -); --- END OF DYNAMIC TASK TABLE-- - -- DM_DEVICE_SUB_TYPE TABLE-- CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, - SUB_TYPE_ID VARCHAR(45) NOT NULL, + SUB_TYPE_ID INT NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); --- END OF DM_DEVICE_SUB_TYPE TABLE-- --- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( - ID INT NOT NULL AUTO_INCREMENT, - DEVICE_NAME VARCHAR(100) NOT NULL, - IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, - TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, - TRACCAR_USENAME VARCHAR(100) NULL, - STATUS VARCHAR(100) NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +-- END OF DM_DEVICE_SUB_TYPE TABLE-- -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, +CREATE TABLE SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE VARCHAR(100) NOT NULL, - SUB_TYPE_ID INT NOT NULL, + OPERATION_CODE varchar(100) NOT NULL, + SUB_TYPE_ID int NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, + UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), --- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + -- END OF SUB_OPERATION_TEMPLATE TABLE-- + +INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES +(3,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), +(4,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 4, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql deleted file mode 100644 index ffa001a086..0000000000 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES -(3,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), -(4,-1234,'METER','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 4, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'); \ No newline at end of file diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 3ce48daefe..b6c2900db7 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -31,10 +31,18 @@ 60000 true - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + @@ -42,16 +50,16 @@ https://localhost:9443 - ${admin.username} - ${admin.username} + admin + admin https://localhost:9443 - ${admin.username} - ${admin.username} + admin + admin - io.entgra.device.mgt.core.policy.mgt + org.wso2.carbon.policy.mgt true 60000 5 @@ -82,7 +90,7 @@ device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the device-cache to improve performance. --> - true + false 600 10000 - - true - 600 - 10000 - true - true + false 86400 @@ -114,11 +120,6 @@ false - false - - DM_DB - ARCHIVAL_DB - io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTask 0 0 0 1/1 * ? * @@ -158,7 +159,7 @@ true - ws://localhost:9763 + wss://localhost:9443 2 100 20 @@ -166,50 +167,5 @@ 640 BYOD,COPE - - false - false - io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier - http://localhost:8280 - - - false - - - test_role - - /permission/admin/Login - - - - - - - - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - IoT Server 5.2.0 | © 2023 - , All Rights Reserved. - - Entgra - - repository/resources/whitelabel - favicon.png - logo.png - icon.png - default - - - - - - - - - - false - Replace with mail - diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index 2e591b07c9..ad8165fc67 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true org.h2.Driver wso2carbon wso2carbon diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 94c29533fe..d83ea2e190 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 0439397aff..0eff71e8f9 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index eac063769d..10fa65047d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index fbfb70849b..52d3c6c045 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index f93f462924..6887a4f3e5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -116,19 +116,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/log4j.properties src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -261,7 +254,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test @@ -283,10 +276,6 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.notification.logger - diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index c5d661c567..b07f311ce1 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -57,8 +54,7 @@ import java.util.Set; public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { - PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); - private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyAdministratorPointImpl.class); + private static final Log log = LogFactory.getLog(PolicyAdministratorPointImpl.class); private PolicyManager policyManager; private ProfileManager profileManager; @@ -139,8 +135,6 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); if (log.isDebugEnabled()) { @@ -174,13 +168,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { properties, triggerInfo); taskManager.registerTask(taskInfo); taskManager.scheduleTask(taskInfo.getName()); - log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { if (!taskManager.isTaskScheduled(taskName)) { TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ, properties, triggerInfo); taskManager.scheduleTask(taskInfo.getName()); - log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { throw new PolicyManagementException("There is a task already running for policy changes. Please try " + "to apply " + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index d0534e28ac..5cc0dc35b8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import com.google.gson.Gson; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; @@ -52,7 +48,6 @@ import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.sql.Timestamp; @@ -60,13 +55,12 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { - PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); private final PolicyDAO policyDAO; private final ProfileDAO profileDAO; private final FeatureDAO featureDAO; private final ProfileManager profileManager; private final PolicyConfiguration policyConfiguration; - private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyManagerImpl.class); + private static final Log log = LogFactory.getLog(PolicyManagerImpl.class); public PolicyManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -78,9 +72,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public Policy addPolicy(Policy policy) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { PolicyManagementDAOFactory.beginTransaction(); if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { @@ -162,16 +153,11 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - String stringPayload = new Gson().toJson(policy); - log.info("Policy created", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("ADD_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @Override public Policy updatePolicy(Policy policy) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { // Previous policy needs to be obtained before beginning the transaction Policy previousPolicy = this.getPolicy(policy.getId()); @@ -313,8 +299,6 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - String stringPayload = new Gson().toJson(policy); - log.info("Policy updated", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("UPDATE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @@ -504,10 +488,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean updatePolicyPriorities(List policies) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - String stringPayload = new Gson().toJson(policies); boolean bool; try { List existingPolicies; @@ -536,24 +516,18 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - log.info("Policy priorities updated", policyLogContextBuilder.setPayload(stringPayload).setActionTag("UPDATE_POLICY_PRIORITIES").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { try { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); PolicyManagementDAOFactory.beginTransaction(); policyDAO.deleteAllPolicyRelatedConfigs(policy.getId()); policyDAO.deletePolicy(policy.getId()); featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); - String stringPayload = new Gson().toJson(policy); - log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return true; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -574,9 +548,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); boolean bool; List policies = this.getPolicies(); Policy pol = null; @@ -607,8 +578,6 @@ public class PolicyManagerImpl implements PolicyManager { featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); - String stringPayload = new Gson().toJson(policy); - log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -667,9 +636,6 @@ public class PolicyManagerImpl implements PolicyManager { List deviceList = new ArrayList<>(); DeviceManagementProviderService deviceManagementService = PolicyManagementDataHolder .getInstance().getDeviceManagementService(); - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); for (DeviceIdentifier deviceIdentifier : deviceIdentifierList) { try { Device device = deviceManagementService.getDevice(deviceIdentifier, false); @@ -698,9 +664,6 @@ public class PolicyManagerImpl implements PolicyManager { } policy.setDevices(deviceList); } - String policyPayload = new Gson().toJson(policy); - String deviceListPayload = new Gson().toJson(deviceList); - log.info("Policy added to devices", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(" Policy: " + policyPayload + " DeviceList: " + deviceListPayload).setActionTag("ADD_POLICY_TO_DEVICE").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new PolicyManagementException("Error occurred while adding the policy (" diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index e3ed0cd6ec..defd753f33 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -1,51 +1,3 @@ - DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO; - ALTER TABLE IF EXISTS DM_DEVICE DROP CONSTRAINT IF EXISTS fk_DM_DEVICE_DM_DEVICE_TYPE2; --- ALTER TABLE IF EXISTS DM_DEVICE_TYPE_PLATFORM DROP CONSTRAINT IF EXISTS DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING; - ALTER TABLE IF EXISTS DM_ROLE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_ROLE_GROUP_MAP_DM_GROUP2; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_GROUP2; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_POLICY; --- ALTER TABLE IF EXISTS DM_GEOFENCE_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_GEOFENCE_GROUP_MAPPING_GROUP; --- ALTER TABLE IF EXISTS DM_DEVICE_EVENT_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_EVENT_GROUP_MAPPING_GROUP; - - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_DEVICE2; - ALTER TABLE IF EXISTS DM_ENROLMENT DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_ENROLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_DEVICE_POLICY; - ALTER TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DEVCIE_APPLIED; - ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE; - ALTER TABLE IF EXISTS DM_NOTIFICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_NOTIFICATION; - ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_DETAILS_DEVICE; - - ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_OPERATION; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_OPERATION; - - ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_ENROLMENT; - ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_ENROLLMENT; - ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_ENROLEMENT; - ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE_ENROLLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DM_ENROLLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_ENROLMENT_DEVICE_DETAILS; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE_LARGE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_LARGE_MAPPING; --- - ALTER TABLE IF EXISTS DM_POLICY DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY; - ALTER TABLE IF EXISTS DM_PROFILE_FEATURES DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY_FEATURES; --- - ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_POLICY_DEVICE_POLICY; - ALTER TABLE IF EXISTS DM_DEVICE_TYPE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_TYPE_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION; - ALTER TABLE IF EXISTS DM_ROLE_POLICY DROP CONSTRAINT IF EXISTS FK_ROLE_POLICY_POLICY; - ALTER TABLE IF EXISTS DM_USER_POLICY DROP CONSTRAINT IF EXISTS DM_POLICY_USER_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_POLICY_POLICY_CRITERIA; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_DM_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_CRITERIA_POLICY_CRITERIA; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA_PROPERTIES DROP CONSTRAINT IF EXISTS FK_POLICY_CRITERIA_PROPERTIES; - ALTER TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES DROP CONSTRAINT IF EXISTS FK_COMPLIANCE_FEATURES_STATUS; - DROP TABLE IF EXISTS DM_DEVICE_TYPE; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( ID INT AUTO_INCREMENT NOT NULL, @@ -61,23 +13,24 @@ DROP TABLE IF EXISTS DM_GROUP; CREATE TABLE IF NOT EXISTS DM_GROUP ( ID INTEGER AUTO_INCREMENT NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, - STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, - OWNER VARCHAR(255) DEFAULT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + DATE_OF_CREATE BIGINT DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, + OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); -DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; -CREATE TABLE IF NOT EXISTS DM_ROLE_GROUP_MAP ( - ID INTEGER AUTO_INCREMENT NOT NULL, - GROUP_ID INTEGER DEFAULT NULL, - ROLE VARCHAR(45) DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_ROLE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE + +DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE; +CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( + ID INTEGER auto_increment NOT NULL, + SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, + CERTIFICATE BLOB DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + USERNAME VARCHAR(500) DEFAULT NULL, + PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_DEVICE; @@ -85,14 +38,13 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT DEFAULT NULL, + DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) - REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT uk_DM_DEVICE UNIQUE (NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, TENANT_ID) + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES; @@ -101,8 +53,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, PROPERTY_NAME VARCHAR(100) DEFAULT 0, PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100), - PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) + TENANT_ID VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) ); DROP TABLE IF EXISTS GROUP_PROPERTIES; @@ -122,9 +74,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID) - REFERENCES DM_DEVICE (ID) ON DELETE CASCADE ON UPDATE CASCADE, + REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE + REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_OPERATION; @@ -144,7 +96,7 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(255) NOT NULL, + OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, @@ -153,8 +105,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( TENANT_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_DEVICE_STATUS; CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( @@ -168,7 +119,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE + DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING; CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -216,14 +167,10 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE_LARGE ( ID INTEGER NOT NULL, OPERATION_RESPONSE LONGBLOB DEFAULT NULL, OPERATION_ID INTEGER NOT NULL, - EN_OP_MAP_ID INTEGER NOT NULL, RECEIVED_TIMESTAMP TIMESTAMP NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, CONSTRAINT fk_dm_device_operation_response_large_mapping FOREIGN KEY (ID) REFERENCES DM_DEVICE_OPERATION_RESPONSE (ID) - ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_en_op_map_response_large FOREIGN KEY (EN_OP_MAP_ID) - REFERENCES DM_ENROLMENT_OP_MAPPING (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); @@ -234,25 +181,30 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ID INT NOT NULL AUTO_INCREMENT , PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INT NOT NULL , - DEVICE_TYPE VARCHAR(300) NOT NULL , + DEVICE_TYPE VARCHAR(20) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) + PRIMARY KEY (ID) , + CONSTRAINT DM_PROFILE_DEVICE_TYPE + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) + ON DELETE NO ACTION + ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_POLICY; CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , + PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL, DESCRIPTION VARCHAR(1000) NULL, - PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT NULL , + TENANT_ID INT(11) NOT NULL , + PROFILE_ID INT(11) NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -261,13 +213,31 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); + +DROP TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION; +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT(11) NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + FEATURE_ID INT(11) DEFAULT NULL, + IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + + DROP TABLE IF EXISTS DM_DEVICE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT , + DEVICE_ID INT(11) NOT NULL , + ENROLMENT_ID INT(11) NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -283,24 +253,29 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , - DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(20) NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) REFERENCES DM_POLICY (ID ) ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME) + ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_PROFILE_FEATURES; CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT NOT NULL , + DEVICE_TYPE VARCHAR(20) NOT NULL, + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -310,26 +285,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); -CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, - ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT DEFAULT NULL, - IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, - PRIMARY KEY (ID), - CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION -); - DROP TABLE IF EXISTS DM_ROLE_POLICY; CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -355,11 +315,11 @@ DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -403,7 +363,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL, + CONTENT BLOB NULL COMMENT 'This is used to ', PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -416,7 +376,7 @@ DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS; CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -431,8 +391,8 @@ DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT; CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(20) NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -463,7 +423,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -474,7 +434,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_enrolement + CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION @@ -488,14 +448,15 @@ DROP TABLE IF EXISTS DM_NOTIFICATION; CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NULL, + OPERATION_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(1000) NULL, - LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + DESCRIPTION VARCHAR(100) NULL, PRIMARY KEY (NOTIFICATION_ID), CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- @@ -533,11 +494,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, - ALTITUDE DOUBLE NULL, - SPEED FLOAT NULL, - BEARING FLOAT NULL, - DISTANCE DOUBLE NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -550,8 +507,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -DROP INDEX IF EXISTS DM_DEVICE_LOCATION_GEO_hashx; -CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); DROP TABLE IF EXISTS DM_DEVICE_DETAIL; CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( @@ -572,8 +527,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + PLUGGED_IN INT(1) NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -598,14 +553,15 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE CASCADE - ON UPDATE CASCADE , + ON DELETE NO ACTION + ON UPDATE NO ACTION, CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) - ON DELETE CASCADE - ON UPDATE CASCADE + ON DELETE NO ACTION + ON UPDATE NO ACTION ); + -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- @@ -665,4 +621,22 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID ORDER BY TENANT_ID, DEVICE_ID; +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + -- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 0d6b866dea..2daade26a6 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 8c1e357da7..45b7fd07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -114,10 +114,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -125,9 +121,6 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -349,7 +342,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index df3277920d..40ad63072f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT NULL, + PARENT_PATH VARCHAR(255) DEFAULT '/', TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT DEFAULT NULL, + DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP BIGINT NOT NULL, - RECEIVED_TIMESTAMP BIGINT NULL, + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,19 +108,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); -CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ENROLMENT_ID INTEGER NOT NULL, - DEVICE_ID INTEGER NOT NULL, - STATUS VARCHAR(50) DEFAULT NULL, - UPDATE_TIME TIMESTAMP DEFAULT NULL, - CHANGED_BY VARCHAR(255) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE -); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -188,17 +176,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT NULL , + TENANT_ID INT(11) NOT NULL , + PROFILE_ID INT(11) NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -209,11 +197,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT , + DEVICE_ID INT(11) NOT NULL , + ENROLMENT_ID INT(11) NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,9 +216,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , + ID INT(11) NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -240,11 +228,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + ID INT(11) NOT NULL AUTO_INCREMENT, + PROFILE_ID INT(11) NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT NOT NULL , + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -255,11 +243,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, + ID INT(11) NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT DEFAULT NULL, + CORRECTIVE_POLICY_ID INT(11) DEFAULT NULL, + POLICY_ID INT(11) NOT NULL, + FEATURE_ID INT(11) DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -270,9 +258,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -296,11 +284,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -353,7 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -368,7 +356,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -397,7 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -417,16 +405,6 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- -CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ICON_PATH VARCHAR(150) DEFAULT NULL, - PACKAGE_NAME VARCHAR(150) NOT NULL, - VERSION VARCHAR(50) DEFAULT '1.1.0', - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - TENANT_ID INTEGER NOT NULL, - PRIMARY KEY (ID) -); - -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -447,7 +425,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1500) NULL, + VALUE_FIELD VARCHAR(1000) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -476,7 +454,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -513,8 +491,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + PLUGGED_IN INT(1) NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -541,7 +519,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT NOT NULL, + TIMESTAMP BIGINT(15) NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -766,6 +744,24 @@ CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( STATUS INT DEFAULT 0, PRIMARY KEY (ID) ); +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + -- END OF DM_EXT_DEVICE_MAPPING TABLE-- -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- @@ -777,23 +773,23 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( -- DYNAMIC TASK TABLES-- CREATE TABLE IF NOT EXISTS DYNAMIC_TASK ( - DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, - NAME VARCHAR(300) DEFAULT NULL , - CRON VARCHAR(8000) DEFAULT NULL, - IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, - TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (DYNAMIC_TASK_ID) + DYNAMIC_TASK_ID INTEGER AUTO_INCREMENT NOT NULL, + NAME VARCHAR(300) DEFAULT NULL , + CRON VARCHAR(8000) DEFAULT NULL, + IS_ENABLED BOOLEAN NOT NULL DEFAULT FALSE, + TASK_CLASS_NAME VARCHAR(8000) DEFAULT NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (DYNAMIC_TASK_ID) ); CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( - DYNAMIC_TASK_ID INTEGER NOT NULL, - PROPERTY_NAME VARCHAR(100) DEFAULT 0, - PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100), - PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), - CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES - DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE + DYNAMIC_TASK_ID INTEGER NOT NULL, + PROPERTY_NAME VARCHAR(100) DEFAULT 0, + PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, + TENANT_ID VARCHAR(100), + PRIMARY KEY (DYNAMIC_TASK_ID, PROPERTY_NAME, TENANT_ID), + CONSTRAINT FK_DYNAMIC_TASK_TASK_PROPERTIES FOREIGN KEY (DYNAMIC_TASK_ID) REFERENCES + DYNAMIC_TASK (DYNAMIC_TASK_ID) ON DELETE CASCADE ON UPDATE CASCADE ); -- END OF DYNAMIC TASK TABLE-- @@ -806,34 +802,5 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); --- END OF DM_DEVICE_SUB_TYPE TABLE-- - --- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( - ID INT NOT NULL AUTO_INCREMENT, - DEVICE_NAME VARCHAR(100) NOT NULL, - IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, - TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, - TRACCAR_USENAME VARCHAR(100) NULL, - STATUS VARCHAR(100) NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- - --- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, - OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE VARCHAR(100) NOT NULL, - SUB_TYPE_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), --- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), - CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) -); --- END OF SUB_OPERATION_TEMPLATE TABLE-- +-- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index 2e591b07c9..ad8165fc67 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true org.h2.Driver wso2carbon wso2carbon diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 91d04c4c33..0f4e0f5f5a 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 26e51edae7..0913807c9c 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 06997c8f17..daf623b335 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 20edac784a..802b4fc403 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index f0eb908782..9ea2215ea7 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 7c15343e73..e6c32be204 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index d14ddd7d18..456c573204 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index b4ba0d60bf..1d07439a11 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 8163f936a3..5ed3918990 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index bdc00ce03d..ce01e21a9c 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 6550c0c17b..2b70f9001d 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 06b561b237..77c2cf12cb 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 7c275e0a25..a2140712f7 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 9abdfa3735..2e0dd266f5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 60dcfdbe95..fceb5e77d1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index a23d2d922d..e91b0ed983 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 18baf3dd9d..6eda7374a9 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 685e75809d..a58b6b40ae 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index a40dcafefd..1d757b421e 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.google.gson.Gson; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; @@ -26,22 +27,13 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; -import io.entgra.ui.request.interceptor.util.HandlerConstants; -import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; -import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.core.service.RealmService; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -63,28 +55,71 @@ public class DefaultTokenHandler extends HttpServlet { HttpSession httpSession = req.getSession(false); if (httpSession != null) { - String userWithDomain = (String) httpSession.getAttribute(HandlerConstants.USERNAME_WITH_DOMAIN); - String[] userNameParts = userWithDomain.split("@"); - - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(OTPEmailTypes.REMOTE_SESSION.toString()); - oneTimePinData.setEmailType(OTPEmailTypes.REMOTE_SESSION.toString()); - oneTimePinData.setUsername(userNameParts[0]); - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); - try { - oneTimePinData.setTenantId(realmService.getTenantManager().getTenantId(userNameParts[1])); - } catch (UserStoreException e) { - throw new RuntimeException(e); + AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY); + if (authData == null) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; } - oneTimePinData.setExpiryTime(DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS); - OTPManagementService otpManagementService = HandlerUtil.getOTPManagementService(); - try { - oneTimePinData = otpManagementService.generateOneTimePin(oneTimePinData, true); - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(oneTimePinData.getOtpToken())); - } catch (OTPManagementException e) { - log.error("Failed while generating remote session OTP for user " + userWithDomain, e); - HandlerUtil.handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); + + AuthData defaultAuthData = (AuthData) httpSession + .getAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY); + if (defaultAuthData != null) { + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultAuthData.getAccessToken())); + return; + } + + String clientId = authData.getClientId(); + String clientSecret = authData.getClientSecret(); + + String queryString = req.getQueryString(); + String scopeString = ""; + if (StringUtils.isNotEmpty(queryString)) { + scopeString = req.getParameter("scopes"); + if (scopeString != null) { + scopeString = "?scopes=" + scopeString; + } + } + + String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId + + "/" + clientSecret + "/default-token" + scopeString; + + HttpGet defaultTokenRequest = new HttpGet(tokenUrl); + defaultTokenRequest + .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); + defaultTokenRequest + .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); + ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); + + if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { + log.error("Error occurred while invoking the API to get default token data."); + HandlerUtil.handleError(resp, tokenResultResponse); + return; + } + String tokenResult = tokenResultResponse.getData(); + if (tokenResult == null) { + log.error("Invalid default token response is received."); + HandlerUtil.handleError(resp, tokenResultResponse); + return; + } + + JsonParser jsonParser = new JsonParser(); + JsonElement jTokenResult = jsonParser.parse(tokenResult); + if (jTokenResult.isJsonObject()) { + JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); + AuthData newDefaultAuthData = new AuthData(); + newDefaultAuthData.setClientId(clientId); + newDefaultAuthData.setClientSecret(clientSecret); + + String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); + newDefaultAuthData.setAccessToken(defaultToken); + newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); + newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); + httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); + + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); } } else { HandlerUtil.sendUnAuthorizeResponse(resp); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index c0f6c7f6ee..d5e8d2bf4d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -120,7 +120,6 @@ public class UserHandler extends HttpServlet { proxyResponse.setData( jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); } } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 9aa9cb9fe6..239cf1c944 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -106,5 +106,4 @@ public class HandlerConstants { public static final String IOT_REPORTING_WEBAPP_HOST_ENV_VAR = "iot.reporting.webapp.host"; public static final String USER_SCOPES = "userScopes"; public static final String HUBSPOT_CHAT_URL = "api.hubapi.com"; - public static final String USERNAME_WITH_DOMAIN = "usernameWithDomain"; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index f15215067e..5a05a19425 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -51,9 +51,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -73,8 +70,6 @@ public class HandlerUtil { private static boolean isLoginCacheInitialized = false; private static AuthData authData; - private static OTPManagementService otpManagementService; - /*** * * @param httpRequest - httpMethod e.g:- HttpPost, HttpGet @@ -747,12 +742,4 @@ public class HandlerUtil { public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } - - public static OTPManagementService getOTPManagementService() { - if (otpManagementService == null) { - otpManagementService = (OTPManagementService) PrivilegedCarbonContext - .getThreadLocalCarbonContext().getOSGiService(OTPManagementService.class, null); - } - return otpManagementService; - } } diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 0faab0c2fa..47912a8465 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 44862e66e7..6476fc0aa6 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -273,7 +273,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 11395eef60..6545b7bbab 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -35,7 +35,6 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.nio.charset.Charset; import java.util.Base64; import java.util.Properties; -import java.util.StringTokenizer; public class BasicAuthAuthenticator implements WebappAuthenticator { @@ -51,23 +50,15 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { /* - This is done to avoid every web app being able to use basic auth. Add the following to - the required web.xml of the web app. This is a global config for a web app to allow all - contexts of the web app to use basic auth + This is done to avoid every endpoint being able to use basic auth. Add the following to + the required web.xml of the web app. basicAuth true - - Adding the basicAuthAllowList parameter allows to selectively allow some context paths in a - web app to use basic auth while all the other context remain unavailable with basic auth. - If this parameter is present, any context that requires basic auth must be specially - added as comma separated list to the param-value of basicAuthAllowList. */ - if (!isAllowListedForBasicAuth(request)) { - if (!isAuthenticationSupported(request)) { - return false; - } + if (!isAuthenticationSupported(request)) { + return false; } if (request.getCoyoteRequest() == null || request.getCoyoteRequest().getMimeHeaders() == null) { return false; @@ -84,20 +75,6 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { return false; } - private boolean isAllowListedForBasicAuth(Request request) { - String param = request.getContext().findParameter("basicAuthAllowList"); - if (param != null && !param.isEmpty()) { - //Add the nonSecured end-points to cache - String[] basicAuthAllowList = param.split(","); - for (String contexPath : basicAuthAllowList) { - if (request.getRequestURI().toString().endsWith(contexPath.trim())) { - return true; - } - } - } - return false; - } - @Override public AuthenticationInfo authenticate(Request request, Response response) { AuthenticationInfo authenticationInfo = new AuthenticationInfo(); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index cb9bf50215..5238828dd0 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,17 +74,9 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { - if (log.isDebugEnabled()) { - log.debug("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); - } CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); authenticationInfo = checkCertificateResponse(certificateResponse); - if (log.isDebugEnabled()) { - log.debug("Certificate Serial : " + certificateResponse.getSerialNumber() - + ", CN : " + certificateResponse.getCommonName() - + " , username" + authenticationInfo.getUsername()); - } } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); @@ -97,6 +89,7 @@ public class CertificateAuthenticator implements WebappAuthenticator { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); authenticationInfo = checkCertificateResponse(certificateResponse); + } else { authenticationInfo.setStatus(Status.FAILURE); authenticationInfo.setMessage("No client certificate is present"); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java index 29392b63f5..82e592524b 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java @@ -49,18 +49,8 @@ public class OneTimeTokenAuthenticator implements WebappAuthenticator { try { OTPManagementService otpManagementService = AuthenticatorFrameworkDataHolder.getInstance() .getOtpManagementService(); - OneTimePinDTO validOTP; - if (request.getRequestURI().toString().endsWith("cloud/download-url") - || request.getRequestURI().toString().endsWith("cloud/tenant")) { - validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER), true); - } else { - log.info("Validating OTP for enrollments PIN: " + request.getHeader(Constants - .HTTPHeaders.ONE_TIME_TOKEN_HEADER)); - validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER), false); - } - + OneTimePinDTO validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER)); if (validOTP != null) { authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setTenantId(validOTP.getTenantId()); diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 252b96df53..f5f2d2c1f3 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index c087fc0b4a..e7d57bd4b7 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 570f87276f..01debfaf07 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 7dd4d6fb94..2087a82870 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 2ebf097dd7..168b828243 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index c0456a9c1c..73abea954f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index b157b5afa6..f13b9e3927 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 98ac163d22..b0f3a595a5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -17,12 +17,14 @@ ~ under the License. --> - + io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 696558150f..636cc8c34e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 6ed2466109..1a2cb3b77e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 7e04260393..9c37daadae 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 2841167689..eaa8ffa5c7 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 499e95ba46..4877de4bbe 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index da7eeda702..5617820cf5 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index b434483af3..c21ff6fb19 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index ad2d1c068c..3867d0806e 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 366cffe69e..3acaabfd9d 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 7a33d7ebef..ee3a2da42a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index bd44c707b0..5d58fe1956 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 0798f33b74..6ba482a99f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index dfbd7c1aa5..89babbcd7a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 3e3e688d59..9dacdae6ba 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 844427fea5..e37e6fbd26 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 8648168dca..f74312e6a3 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 1c2f9f450a..810e45e3b7 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 84e33b2daf..e02dcb8012 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 8f8ec91fba..845e0f69d7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 406388f422..2a2c6468b1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index c40cefc413..3ce48daefe 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -189,7 +189,7 @@ <a href='https://entgra.io' target='_blank'> Entgra </a> - UEM Server 5.3.0 | © 2023 + IoT Server 5.2.0 | © 2023 , All Rights Reserved. Entgra diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index b16935562d..46114821a2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -224,22 +224,9 @@ perm:admin:tenant:view perm:admin:metadata:view perm:admin:usage:view - perm:android:clear-application + perm:android:clear-applicatio perm:android:suspend-package perm:android:alternate-install - perm:ios:lock - perm:ios:location - perm:ios:ring - perm:ios:clear-passcode - perm:ios:enterprise-wipe - perm:ios:notification - perm:ios:wipe-data - perm:ios:boolean-setting - perm:ios:wallpaper - perm:ios:app-attributes - perm:ios:app-configurations - perm:mac-os:restart - perm:mac-os:shut-down device-mgt diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 2152b1814f..262761caec 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -325,16 +325,12 @@ - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - {% if product_conf is defined %} - {{product_conf.server_name}} {{product_conf.server_version}} | © {{product_conf.current_year}} - {% else %} - Entgra UEM Server - {% endif %} - , All Rights Reserved. - + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.2.0 | © 2023 + , All Rights Reserved. + Entgra repository/resources/whitelabel diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 15ffa69605..df3277920d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -25,7 +25,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 5b6b3b93f1..c162d41e06 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -41,7 +41,6 @@ IF NOT EXISTS(SELECT * OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 86da197b12..6dcc7bec44 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -29,7 +29,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ENGINE = InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 6cc55f7e74..a6f87c9cb6 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -52,7 +52,6 @@ CREATE TABLE DM_GROUP ( OWNER VARCHAR2(255) DEFAULT NULL, PARENT_PATH VARCHAR2(255) DEFAULT NULL, TENANT_ID NUMBER(10) DEFAULT 0, - PARENT_GROUP_ID NUMBER(10) DEFAULT 0, CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index b1fc128cf9..8c601111b7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -23,7 +23,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 062cc6df3e..904012948e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 9ef814e62f..6455ab6f05 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 80ed932a53..cb5841a715 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 96c5194c45..230fa3700f 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 096683db82..e1b4db491a 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index a2d4bed8ba..f551b3e518 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 13e974fbdb..57b1438027 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index c3e2fafa70..3220ebb7da 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index fd4fb89fd9..1bfe57fa69 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 34a5aa4ccf..f4b3d3e41a 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 3eb94e0b04..f9f8ce9f41 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -17,12 +17,13 @@ ~ under the License. --> - + io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 8351d50946..a16c219134 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -17,12 +17,13 @@ ~ under the License. --> - + io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 02b8f172a5..7f96d0da93 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 5eaac22ad1..97a7746320 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 30094f7686..cf0e00a0b5 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 3cccf87ad1..f37cf1d8f3 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 3243b26827..7984cd5521 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index d7e84d2782..a70cbbc67a 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 002b18f48f..001cc0dd34 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 8f87de9b1f..a19947d332 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index ee105d34b8..73986be63f 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm index ef5307de33..7765bcdda2 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm @@ -37,7 +37,7 @@

You have been invited to enrol your device in Entgra IoT Server. - Click here to begin device enrolment.

+ Click here to begin device enrolment.

Enrollment Steps are as below, diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 53fcfbaee9..a75c167bfa 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 23513d7ed8..ee58261e6c 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index b6dd0dcc5c..5dcab5c654 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index c7f0a53f58..d9b3cb564c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 8350d1b2d2..d60cefe7be 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 53903a27e5..90ba4c04cc 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index a3ead6185d..45b132211d 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index f8aa63d70f..ce0141f915 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml index c3bb4569b8..bf5d2e00e2 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml @@ -24,8 +24,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - {{super_admin.username}} - {{super_admin.password}} + ${admin.username} + ${admin.password} 100 100 diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 index 6c51e0f2b6..7c3ce35486 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 @@ -14,8 +14,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - {{super_admin.username}} - {{super_admin.password}} + ${admin.username} + ${admin.password} 100 100 diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index adbbd92316..5aaec7c6b5 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 1a0eab8a0f..28dfc7301b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -833,16 +833,6 @@ jaxb-api ${version.org.wso2.orbit.javax.xml.bind} - - com.sun.xml.bind - jaxb-core - 2.3.0.1 - - - com.sun.xml.bind - jaxb-impl - 2.3.1 - org.apache.axis2.transport @@ -1664,7 +1654,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito ${power.mock.version} test @@ -1751,11 +1741,6 @@ mockito-inline ${mokito.version} - - org.mockito - mockito-core - ${mokito.version} - org.ops4j.pax.logging pax-logging-api @@ -1903,7 +1888,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 2.22.0 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -1997,7 +1982,7 @@ 1.2.11-wso2v25 - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.9.2 @@ -2128,7 +2113,7 @@ 0.7.8 0.7.5.201505241946 1.0b3 - 2.0.2 + 1.7.4 1.4.0.wso2v1 1.7.25 @@ -2151,7 +2136,7 @@ [1.6.0, 2.0.0) [1.2.0,1.3.0) - 2.23.4 + 4.2.0 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 From 7dfcb418f4828cf1e7f260f9a1c7304b38574556 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Jul 2023 08:35:23 +0530 Subject: [PATCH 102/157] Fix jwt token generation --- .../APIManagementProviderServiceImpl.java | 9 +++++-- .../rest/api/APIApplicationServices.java | 5 ++-- .../rest/api/APIApplicationServicesImpl.java | 12 ++++----- .../rest/api/constants/Constants.java | 2 -- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../publisher/APIPublisherServiceImpl.java | 10 +++++-- .../impl/DeviceManagementServiceImpl.java | 26 ++++++++++++------- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++++++++++++++ .../jwt/client/extension/JWTClient.java | 4 ++- 9 files changed, 66 insertions(+), 25 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0808f11963..8c12ac45ec 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -649,9 +649,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForConsumerRestCalls", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + "ClientForConsumerRestCalls", + username, password, + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index 1cdceff56a..f5cc8b3ec1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -24,9 +24,10 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index 9dbd5f52cc..a03f81d086 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() + public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", Constants.CLIENT_NAME); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", username); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", username); jsonObject.put("saasApp", true); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java index 6c3cf21c89..6ca26f74f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/constants/Constants.java @@ -27,10 +27,8 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; - public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; - public static final String GRANT_TYPE = "client_credentials password refresh_token"; public static final String REFRESH_TOKEN_GRANT_TYPE_PARAM_NAME = "refresh_token"; public static final String OAUTH_EXPIRES_IN = "expires_in"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 69f51fff56..63e42132f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response"; + msg = "Error occurred while processing the response" + e; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index fe98a8cef8..e188ae799b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,7 +90,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -403,7 +406,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 09be7963fd..6f84458c44 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,6 +23,11 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; 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.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -804,11 +809,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(), - "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); + APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForJWTTokenGeneration", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" + ); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -816,11 +821,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe"); + username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + + " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + + "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + + "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, false, String.valueOf(validityTime), + new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -828,8 +836,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (UserStoreException e) { - String msg = "Error while getting user credentials."; + } catch (APIServicesException e) { + String msg = "Error while generating api Application"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index a297bffd48..db613f8a28 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +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.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -156,6 +157,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; + private static volatile APIApplicationServices apiApplicationServices; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; private static volatile APIManagementProviderService apiManagementProviderService; @@ -410,6 +412,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for APIM API application REST API. + * + * @return APIApplicationServices instance + * @throws IllegalStateException if APIApplicationServices cannot be initialized + */ + public static synchronized APIApplicationServices getApiApplicationServices() { + if (apiApplicationServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); + if (apiApplicationServices == null) { + String msg = "API application service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiApplicationServices; + } + /** * Initializing and accessing method for API management Provider Service. * diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java index a2ae303414..2675314524 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java @@ -138,7 +138,9 @@ public class JWTClient { if (jwtConfig == null) { return null; } - URL tokenEndpoint = new URL(jwtConfig.getTokenEndpoint()); +// todo: +// URL tokenEndpoint = new URL(jwtConfig.getTokenEndpoint()); + URL tokenEndpoint = new URL("https://localhost:9443/oauth2/token"); HttpClient httpClient = JWTClientUtil.getHttpClient(tokenEndpoint.getProtocol()); HttpPost postMethod = new HttpPost(tokenEndpoint.toString()); postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs)); From 2d296a3453f9317e5f432450f651b0062f753875 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Jul 2023 12:44:40 +0530 Subject: [PATCH 103/157] Implement map application keys using dcr response --- .../APIManagementProviderServiceImpl.java | 9 ++- .../rest/api/ConsumerRESTAPIServices.java | 3 + .../rest/api/ConsumerRESTAPIServicesImpl.java | 67 ++++++++++++++++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 8c12ac45ec..3c62275186 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -250,8 +250,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg); throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), validityTime, keyType); + + ApiApplicationInfo applicationInfo = getApplicationInfo(null, null); + tokenInfo.setApiApplicationInfo(applicationInfo); + + ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, + keyManager.getName(), keyType); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 5ed98034e2..8ab2c1f0ad 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -55,6 +55,9 @@ public interface ConsumerRESTAPIServices { ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 293894ee71..572756dff7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -606,6 +606,71 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + + application.getApplicationId() + "/map-keys"; + + String payload = "{\n" + + " \"consumerKey\": \"" + apiApplicationInfo.getClientId() + "\",\n" + + " \"consumerSecret\": \"" + apiApplicationInfo.getClientSecret() + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + + " \"keyType\": \"" + keyType + "\"\n" + + "}"; + RequestBody requestBody = RequestBody.create(JSON, payload); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!token) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + tokenInfo.getAccessToken()); + } + builder.post(requestBody); + Request request = builder.build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + if (!token) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return mapApplicationKeys(refreshedTokenInfo, application, keyManager, keyType); + } else { + String msg = "Invalid access token. Unauthorized request"; + log.error(msg); + throw new APIServicesException(msg); + } + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { @@ -733,7 +798,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { boolean token; - if ((!(accessToken == null) && apiApplicationInfo == null)) { + if ((!(accessToken == null))) { token = true; } else if (!(apiApplicationInfo == null) && accessToken == null) { token = false; From a17c5c27abba5c62aef747ffa4ab34c129a4f367 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 2 Aug 2023 07:56:01 +0530 Subject: [PATCH 104/157] Fix test case failure --- .../device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index bf43ea4cde..38fe9896c3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -507,7 +507,6 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger - provided org.wso2.orbit.javax.xml.bind From f117e40fc908be937c0ef8ecc6321bfc861a3209 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Sun, 6 Aug 2023 23:38:02 +0530 Subject: [PATCH 105/157] Fix SSO related issues --- .../APIManagementProviderServiceImpl.java | 15 +++++++-------- .../ui/request/interceptor/SsoLoginHandler.java | 2 +- .../interceptor/util/HandlerConstants.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3c62275186..3a3bf5f941 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -65,6 +65,7 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.*; +import java.util.stream.Collectors; /** * This class represents an implementation of APIManagementProviderService. @@ -143,31 +144,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - List uniqueApiList = new ArrayList<>(); - Map headerParams = new HashMap<>(); if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } + Map uniqueApiSet = new HashMap<>(); for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); + Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); } + List uniqueApiList = new ArrayList<>(uniqueApiSet.values()); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (applications.length == 0) { - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + validityTime); } else { if (applications.length == 1) { Optional applicationOpt = diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index de037d8bc1..52dc03b79c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -222,7 +222,7 @@ public class SsoLoginHandler extends HttpServlet { } // Update the grant types of the application - String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + applicationId + "/keys/" + + String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + HandlerConstants.PRODUCTION_KEY; HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 9aa9cb9fe6..c6058102b6 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -26,7 +26,7 @@ public class HandlerConstants { public static final String INTERNAL_TOKEN_ENDPOINT = "/token"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; - public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v2/applications/"; + public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v3/applications"; public static final String IDENTITY_APP_MGT_ENDPOINT = "/services/IdentityApplicationManagementService.IdentityApplicationManagementServiceHttpsSoap11Endpoint"; public static final String LOGIN_PAGE = "/login"; public static final String SSO_LOGIN_CALLBACK = "/ssoLoginCallback"; @@ -77,7 +77,7 @@ public class HandlerConstants { public static final String OTP_HEADER = "one-time-token"; - public static final String AX_PREFIX = "ax2251:"; + public static final String AX_PREFIX = "ax2245:"; public static final String PAYLOADS_DIR = "repository/resources/payloads"; public static final String SOAP_ACTION_HEADER = "SOAPAction"; public static final String REFERER_HEADER = "Referer"; From da1f9d2437b160b95953577ce8c395b2a93e7efa Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 9 Aug 2023 07:34:00 +0530 Subject: [PATCH 106/157] Fix admin user details getting issue --- .../io.entgra.device.mgt.core.ui.request.interceptor/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 3fcfeea3b9..b9fe8f9195 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -335,10 +335,6 @@ javax.websocket javax.websocket-api - - xerces.wso2 - xercesImpl - org.json.wso2 json From 7e65d9f9801dd792bfcc08437747ecd53c6c1868 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 12 Sep 2023 00:02:07 +0530 Subject: [PATCH 107/157] Fix access token validating issue --- .../APIManagementProviderServiceImpl.java | 61 ++++--- .../request/interceptor/SsoLoginHandler.java | 153 +++++++++++------- .../ui/request/interceptor/UserHandler.java | 4 +- .../authenticator/OAuthAuthenticator.java | 2 +- 4 files changed, 124 insertions(+), 96 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3a3bf5f941..f4bd1cb588 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -111,13 +111,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException { + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException { TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); tokenInfo.setAccessToken(accessToken); - return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -127,12 +127,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String validityTime, String password) 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); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); } private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, @@ -149,7 +148,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe headerParams.put("X-WSO2-Tenant", "carbon.super"); } - Map uniqueApiSet = new HashMap<>(); + Map uniqueApiSet = new HashMap<>(); for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); @@ -162,8 +161,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); @@ -171,8 +168,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); - application = applicationOpt.get(); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = + applicationOpt.get(); + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { // Todo add a comment @@ -183,7 +182,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe for (Subscription subscription : subscriptions) { uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); } - addSubscriptions(application, uniqueApiList, tokenInfo); + + if (!uniqueApiList.isEmpty()) { + addSubscriptions(application, uniqueApiList, tokenInfo); + } String[] metaValues = metaData.getMetaValue().split(":"); if (metaValues.length != 2) { @@ -200,7 +202,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); return apiApplicationKey; } - } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -250,11 +251,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } - ApiApplicationInfo applicationInfo = getApplicationInfo(null, null); - tokenInfo.setApiApplicationInfo(applicationInfo); - - ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, - keyManager.getName(), keyType); + tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); +// ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, +// keyManager.getName(), keyType); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); @@ -294,16 +295,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } /** - * * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. * * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} - * @param apiInfos {@link List} - * @param tokenInfo {@link TokenInfo} - * - * @throws BadRequestException if incorrect data provided to call subscribing REST API. + * @param apiInfos {@link List} + * @param tokenInfo {@link TokenInfo} + * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. - * @throws APIServicesException if error occurred while invoking the subscribing REST API. + * @throws APIServicesException if error occurred while invoking the subscribing REST API. */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, @@ -323,7 +322,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } // /** @@ -557,7 +556,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, - String validityPeriod, String username) throws APIManagerException { + String validityPeriod, String username) throws APIManagerException { try { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); ApiApplicationKey clientCredentials = getClientCredentials(tenantDomain, tags, applicationName, tokenType, @@ -605,17 +604,17 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe /** * Get Client credentials of application belongs to tenant admin * - * @param tenantDomain Tenant Domain - * @param tags Tags + * @param tenantDomain Tenant Domain + * @param tags Tags * @param applicationName Application Name - * @param tokenType Token Type - * @param validityPeriod Validity Period + * @param tokenType Token Type + * @param validityPeriod Validity Period * @return {@link ApiApplicationKey} * @throws APIManagerException if error occurred while generating access token - * @throws UserStoreException if error occurred while getting admin username. + * @throws UserStoreException if error occurred while getting admin username. */ private ApiApplicationKey getClientCredentials(String tenantDomain, String[] tags, String applicationName, - String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { + String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { APIRegistrationProfile registrationProfile = new APIRegistrationProfile(); registrationProfile.setAllowedToAllDomains(false); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 52dc03b79c..78a95c019f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; +import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.LoginException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.text.StrSubstitutor; @@ -139,6 +140,8 @@ public class SsoLoginHandler extends HttpServlet { log.error("Error while creating the document builder."); } catch (SAXException e) { log.error("Error while parsing xml file.", e); + } catch (LoginException e) { + log.error("SSO Login is failed. Application: " + applicationName, e); } } @@ -149,7 +152,7 @@ public class SsoLoginHandler extends HttpServlet { * @param req {@link HttpServletRequest} * @param resp {@link HttpServletResponse} */ - private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { + private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) throws LoginException { try { JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); @@ -166,10 +169,6 @@ public class SsoLoginHandler extends HttpServlet { ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); - if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, clientAppResponse); - } - if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { JsonParser jsonParser = new JsonParser(); JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); @@ -188,71 +187,101 @@ public class SsoLoginHandler extends HttpServlet { // cache the oauth app credentials oAuthApp = new OAuthApp(applicationName, adminUsername, clientId, clientSecret, encodedClientApp); loginCache.addOAuthAppToCache(oAuthAppCacheKey, oAuthApp); + } else if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { + String msg = "Unauthorized attempt to register the client application. " + + "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); + log.error(msg); + HandlerUtil.handleError(resp, clientAppResponse); + throw new LoginException(msg); + } else { + String msg = "Failed the process while registering the client application. " + + "Application Name: " + applicationName + ". Response Code: " + + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); + log.error(msg); + HandlerUtil.handleError(resp, null); + throw new LoginException(msg); } // Get the details of the registered application - String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + - "?query=" + applicationName; - HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); - getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + - getAccessToken(resp, encodedClientApp)); - - ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); - - if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, getApplicationResponse); - return; - } - - if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { - JsonParser jsonParser = new JsonParser(); - JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); - if (jAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); - JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); - JsonObject app; - for (JsonElement appJson : appList) { - app = appJson.getAsJsonObject(); - if (app.get("name").getAsString().equals(applicationName)) { - applicationId = app.get("applicationId").getAsString(); - break; - } - } - } - } +// String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + +// "?query=" + applicationName; +// HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); +// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + +// getAccessToken(resp, encodedClientApp)); +// +// ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); +// +// if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { +// JsonParser jsonParser = new JsonParser(); +// JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); +// if (jAppResult.isJsonObject()) { +// JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); +// JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); +// JsonObject app; +// for (JsonElement appJson : appList) { +// app = appJson.getAsJsonObject(); +// if (app.get("name").getAsString().equals(applicationName)) { +// applicationId = app.get("applicationId").getAsString(); +// break; +// } +// } +// } +// } else if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { +// String msg = "Unauthorized attempt to get registered application data. " + +// "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, getApplicationResponse); +// throw new LoginException(msg); +// } else { +// String msg = "Failed the process while getting the data of registered application. " + +// "Application Name: " + applicationName + ". Response Code: " +// + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, null); +// throw new LoginException(msg); +// } // Update the grant types of the application - String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + - HandlerConstants.PRODUCTION_KEY; - HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); - updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + - getAccessToken(resp, encodedClientApp)); - updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); - - ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); - - // Update app as a SaaS app - this.updateSaasApp(applicationId); - - if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); - return; - } - - if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_OK) { - return; - } - HandlerUtil.handleError(resp, null); +// String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + +// HandlerConstants.PRODUCTION_KEY; +// HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); +// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + +// getAccessToken(resp, encodedClientApp)); +// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); +// updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); +// +// ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); +// +// // Update app as a SaaS app +// this.updateSaasApp(applicationId); +// +// if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { +// String msg = "Unauthorized attempt to update the grant types of the application. " + +// "Application ID: " + applicationId + ". Response message: " +// + updateApplicationGrantTypesEndpointResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); +// throw new LoginException(msg); +// } else if (updateApplicationGrantTypesEndpointResponse.getCode() != HttpStatus.SC_OK) { +// String msg = "Failed the process while updating the grant types of the application. " + +// "Application ID: " + applicationId + ". Response Code: " +// + updateApplicationGrantTypesEndpointResponse.getCode() + ", Response message: " +// + updateApplicationGrantTypesEndpointResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, null); +// throw new LoginException(msg); +// } } catch (IOException e) { - log.error("Error occurred while sending the response into the socket. ", e); + throw new LoginException("Error occurred while sending the response into the socket.", e); } catch (JsonSyntaxException e) { - log.error("Error occurred while parsing the response. ", e); - } catch (ParserConfigurationException e) { - log.error("Error while creating the document builder."); - } catch (SAXException e) { - log.error("Error while parsing xml file.", e); + throw new LoginException("Error occurred while parsing the response.", e); } +// catch (ParserConfigurationException e) { +// throw new LoginException("Error while creating the document builder.", e); +// } +// catch (SAXException e) { +// throw new LoginException("Error while parsing xml file.", e); +// } } /** diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index c0f6c7f6ee..ac423d215c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -73,7 +73,7 @@ public class UserHandler extends HttpServlet { } String accessToken = authData.getAccessToken(); - String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); +// String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); @@ -82,7 +82,7 @@ public class UserHandler extends HttpServlet { String adminPassword = dmc.getKeyManagerConfigurations().getAdminPassword(); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())); - StringEntity tokenEPPayload = new StringEntity("token=" + accessTokenWithoutPrefix, + StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED); tokenEndpoint.setEntity(tokenEPPayload); ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java index f973ae7dae..9678bff1eb 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java @@ -74,7 +74,7 @@ public class OAuthAuthenticator implements WebappAuthenticator { } try { String bearerToken = getBearerToken(request); - bearerToken = bearerToken.substring(bearerToken.indexOf("_")+1); +// bearerToken = bearerToken.substring(bearerToken.indexOf("_")+1); String resource = requestUri + ":" + requestMethod; OAuthValidationResponse oAuthValidationResponse = this.tokenValidator.validateToken(bearerToken, resource); authenticationInfo = Utils.setAuthenticationInfo(oAuthValidationResponse, authenticationInfo); From 907d4b03161f2421bab546494240fab3dd5ce351 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 13 Sep 2023 12:20:37 +0530 Subject: [PATCH 108/157] Implement method for updateGrantType rest call --- .../rest/api/ConsumerRESTAPIServices.java | 4 ++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 69 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 8ab2c1f0ad..957fcfdaa7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -61,6 +61,10 @@ public interface ConsumerRESTAPIServices { ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + String supportedGrantTypes, String callbackUrl) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 572756dff7..55f3c7003f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -727,6 +727,75 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + String supportedGrantTypes, String callbackUrl) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); + String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; + + Request.Builder builder = new Request.Builder(); + builder.url(getKeyDetails); + if (!token) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + tokenInfo.getAccessToken()); + } + + String payload = "{\n" + + " \"keyMappingId\": \"" + keyMapId + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + + " \"supportedGrantTypes\": [\n" + + " \"" + supportedGrantTypes + "\"\n" + + " ],\n" + + " \"callbackUrl\": \"" + callbackUrl + "\",\n" + + " \"additionalProperties\": {}\n" + + "}"; + RequestBody requestBody = RequestBody.create(JSON, payload); + + builder.put(requestBody); + Request request = builder.build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + if (!token) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return updateGrantType(refreshedTokenInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); + } else { + String msg = "Invalid access token. Unauthorized request"; + log.error(msg); + throw new APIServicesException(msg); + } + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request"; + log.error(msg); + throw new BadRequestException(msg); + } else { + String msg = "Response : " + response.code() + response.body(); + throw new UnexpectedResponseException(msg); + } + } catch (IOException e) { + String msg = "Error occurred while processing the response"; + log.error(msg, e); + throw new APIServicesException(msg, e); + } + } + @Override public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { From 5848d68c63abe5bae39fd8f313c4f978da5278fa Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 14 Sep 2023 11:23:29 +0530 Subject: [PATCH 109/157] Add app updating intial changes --- .../APIManagementProviderServiceImpl.java | 29 ++++++++++++++----- .../ApplicationGrantTypeUpdater.java | 26 +++++++++++++++++ .../extension/exception/KeyMgtException.java | 4 +++ .../extension/service/KeyMgtServiceImpl.java | 12 ++++---- 4 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationGrantTypeUpdater.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f4bd1cb588..3cf328e6b1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -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 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()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationGrantTypeUpdater.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationGrantTypeUpdater.java new file mode 100644 index 0000000000..b7d5e2e8b9 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/bean/APIMConsumer/ApplicationGrantTypeUpdater.java @@ -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 supportedGrantTypes; + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java index 5aa4d6e6aa..0faf78683c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java @@ -28,5 +28,9 @@ public class KeyMgtException extends Exception { public KeyMgtException(String errorMessage) { super(errorMessage); } + + public KeyMgtException(String errorMessage, Exception e) { + super(errorMessage, e); + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 63e42132f0..11e472809a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -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); } } From bb879f52cefd6ec4d62de9b11ed4739052a5b659 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 14 Sep 2023 13:30:36 +0530 Subject: [PATCH 110/157] Fix grant type update method --- .../rest/api/ConsumerRESTAPIServices.java | 2 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index 957fcfdaa7..e8342b18d5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -62,7 +62,7 @@ public interface ConsumerRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException; KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index 55f3c7003f..e5608d5cbc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -729,7 +729,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); @@ -746,16 +746,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + tokenInfo.getAccessToken()); } - String payload = "{\n" + - " \"keyMappingId\": \"" + keyMapId + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"supportedGrantTypes\": [\n" + - " \"" + supportedGrantTypes + "\"\n" + - " ],\n" + - " \"callbackUrl\": \"" + callbackUrl + "\",\n" + - " \"additionalProperties\": {}\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, payload); + JSONArray supportedGrantTypeList = new JSONArray(); + for (String string : supportedGrantTypes) { + supportedGrantTypeList.put(string); + } + + JSONObject payload = new JSONObject(); + payload.put("keyMappingId", keyMapId); + payload.put("keyManager", keyManager); + payload.put("supportedGrantTypes", supportedGrantTypeList); + payload.put("callbackUrl", (callbackUrl != null ? callbackUrl : "")); + payload.put("additionalProperties", new JSONObject()); + + RequestBody requestBody = RequestBody.create(JSON, payload.toString()); builder.put(requestBody); Request request = builder.build(); From 088642e7ce9b9d3edd16d735b8743d97981a2bd4 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 19 Sep 2023 13:22:28 +0530 Subject: [PATCH 111/157] Improve API app registration --- ...ApiApplicationRegistrationServiceImpl.java | 21 ++++++- .../api/util/RegistrationProfile.java | 21 +++++++ .../APIManagementProviderService.java | 10 +++- .../APIManagementProviderServiceImpl.java | 56 +++++++++++++------ .../keymgt/extension/api/DCRRequest.java | 21 +++++++ .../extension/api/KeyManagerServiceImpl.java | 3 +- .../extension/service/KeyMgtService.java | 5 +- .../extension/service/KeyMgtServiceImpl.java | 23 +++++--- .../application/mgt/core/util/OAuthUtils.java | 2 +- .../impl/DeviceManagementServiceImpl.java | 5 +- 10 files changed, 133 insertions(+), 34 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 133a5d1a9c..e3ce294a21 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -24,6 +24,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.api.util.Registrat import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -65,7 +66,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -108,10 +109,23 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { + ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; + if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { + applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); + applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); + + } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { + return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + + " request does not contain supported grant types to update grant types of the " + + "application." + ).build(); + } + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); + registrationProfile.isAllowedToAllDomains(), validityPeriod, + registrationProfile.getPassword(), applicationGrantTypeUpdater, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -123,7 +137,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), - registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); + registrationProfile.isAllowedToAllDomains(), validityPeriod, + registrationProfile.getPassword(), null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java index 3e3eb30a03..921b27f434 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java @@ -22,6 +22,7 @@ import org.codehaus.jackson.annotate.JsonIgnoreProperties; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; /** * DTO class to be used when registering an ApiM application. @@ -43,6 +44,10 @@ public class RegistrationProfile { @XmlElement(required = false) private String validityPeriod; + private String callbackUrl; + + private ArrayList supportedGrantTypes; + public String getApplicationName() { return applicationName; } @@ -90,4 +95,20 @@ public class RegistrationProfile { public void setPassword(String password) { this.password = password; } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 14449cdf09..1b81b29ce3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; /** @@ -53,12 +55,16 @@ public interface APIManagementProviderService { ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException; + String validityTime, String password, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException; ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException; + String validityTime, TokenInfo tokenInfo, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException; // /** // * Remove APIM Application. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3cf328e6b1..6b5ecc63ca 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,7 +24,11 @@ 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.*; +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.ApplicationGrantTypeUpdater; +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.KeyManager; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; 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; @@ -106,35 +110,42 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // // } - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException { - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setApiApplicationInfo(null); - tokenInfo.setAccessToken(accessToken); - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); - } +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, +// boolean isAllowedAllDomains, +// String validityTime, String accessToken) throws APIManagerException { +// TokenInfo tokenInfo = new TokenInfo(); +// tokenInfo.setApiApplicationInfo(null); +// tokenInfo.setAccessToken(accessToken); +// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, +// tokenInfo, null, false); +// } @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) + String validityTime, String password, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + 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); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, + tokenInfo, applicationGrantTypeUpdater, isMappingRequired); } - private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo) throws APIManagerException { + String validityTime, TokenInfo tokenInfo, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -160,7 +171,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime); + validityTime, applicationGrantTypeUpdater, isMappingRequired); } else { if (applications.length == 1) { Optional applicationOpt = @@ -173,7 +184,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (metaData == null) { // Todo add a comment consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + validityTime, applicationGrantTypeUpdater, isMappingRequired); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { @@ -265,6 +277,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } +// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, +// String supportedGrantTypes, String callbackUrl) + if (applicationGrantTypeUpdater != null) { + applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), + applicationKey.getKeyMappingId(), keyManager.getName(), + applicationGrantTypeUpdater.getSupportedGrantTypes(), + applicationGrantTypeUpdater.getCallbackUrl()); + } // ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, @@ -651,7 +671,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(), registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java index 8f492c2234..9235087a77 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java @@ -22,6 +22,7 @@ import org.codehaus.jackson.annotate.JsonIgnoreProperties; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; @XmlRootElement @@ -45,6 +46,10 @@ public class DCRRequest { @XmlElement private int validityPeriod; + private String callbackUrl; + + private ArrayList supportedGrantTypes; + public String getApplicationName() { return applicationName; } @@ -104,4 +109,20 @@ public class DCRRequest { public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 8a5c49e4d6..54cb0e98e1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -49,7 +49,8 @@ public class KeyManagerServiceImpl implements KeyManagerService { //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(), dcrRequest.getPassword()); + dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword(), + dcrRequest.getSupportedGrantTypes(), dcrRequest.getCallbackUrl()); return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build(); } catch (KeyMgtException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java index 92015842ba..b1ecb3c77b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java @@ -24,6 +24,8 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; +import java.util.List; + public interface KeyMgtService { /*** @@ -40,7 +42,8 @@ public interface KeyMgtService { * @throws KeyMgtException if any error occurs during DCR process */ DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException; + String[] tags, boolean isSaasApp, int validityPeriod, String password, + List supportedGrantTypes, String callbackUrl) throws KeyMgtException; /*** * This method will handle the access token requests diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 11e472809a..f1d3c73641 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -65,7 +65,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { String subTenantUserUsername, subTenantUserPassword, keyManagerName, msg = null; public DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException { + String[] tags, boolean isSaasApp, int validityPeriod, + String password, List supportedGrantTypes, String callbackUrl) throws KeyMgtException { if (owner == null) { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -94,13 +95,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) { OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, - validityPeriod, kmConfig.getAdminPassword()); + validityPeriod, kmConfig.getAdminPassword(), supportedGrantTypes, callbackUrl); return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret()); } else { // super-tenant admin dcr and token generation + //todo lasantha null passed in last two params OAuthApplication superTenantOauthApp = createOauthApplication( KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT, - kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword()); + kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword(), null, null); String superAdminAccessToken = createAccessToken(superTenantOauthApp); // create new key manager for the tenant, under super-tenant space @@ -123,7 +125,10 @@ public class KeyMgtServiceImpl implements KeyMgtService { // DCR for the requesting user //todo lasantha -> need to pass password of user - OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, password); + //todo lasantha null passed in last two params + + OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, + password, null, null); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id @@ -317,9 +322,11 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while creating response object */ private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, - int validityPeriod, String ownerPassword) throws KeyMgtException { + int validityPeriod, String ownerPassword, + List supportedGrantTypes, String callbackUrl) throws KeyMgtException { //todo modify this to pass the password as well - String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, ownerPassword); + String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, + ownerPassword, supportedGrantTypes, callbackUrl); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT; @@ -462,13 +469,15 @@ public class KeyMgtServiceImpl implements KeyMgtService { } private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod, - String password) { + String password, List supportedGrantTypes, String callbackUrl) { JSONObject jsonObject = new JSONObject(); jsonObject.put("applicationName", clientName); jsonObject.put("username", owner); jsonObject.put("tags", tags); jsonObject.put("validityPeriod", validityPeriod); jsonObject.put("password", password); + jsonObject.put("supportedGrantTypes", supportedGrantTypes); + jsonObject.put("callbackUrl", callbackUrl); return jsonObject.toString(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index c5975cb500..35dced984a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -66,7 +66,7 @@ public class OAuthUtils { registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 0f5a000d17..5905831436 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplic import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; @@ -827,9 +828,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), - accessTokenInfo.getAccessToken()); + tokenInfo, null, true); } catch (JWTClientException e) { String msg = "Error while generating an application tokens for Tenant Admin."; From 500fa0df982fcafe04290ef0f3bfd7e596b379f3 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 20 Sep 2023 09:30:16 +0530 Subject: [PATCH 112/157] Add improvements to app registering logic --- ...ApiApplicationRegistrationServiceImpl.java | 30 +++++----- .../APIManagementProviderService.java | 23 ++++--- .../APIManagementProviderServiceImpl.java | 60 +++++++++++-------- .../application/mgt/core/util/OAuthUtils.java | 2 +- .../impl/DeviceManagementServiceImpl.java | 8 +-- 5 files changed, 69 insertions(+), 54 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index e3ce294a21..8b2562d656 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -66,7 +66,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -109,23 +109,24 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { - ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; - if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { - applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); - applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); - - } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { - return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + - " request does not contain supported grant types to update grant types of the " + - "application." - ).build(); - } +// ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; +// if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { +// applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); +// applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); +// +// } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { +// return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + +// " request does not contain supported grant types to update grant types of the " + +// "application." +// ).build(); +// } ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), validityPeriod, - registrationProfile.getPassword(), applicationGrantTypeUpdater, false); + registrationProfile.getPassword(), null, registrationProfile.getSupportedGrantTypes(), + registrationProfile.getCallbackUrl(), false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -138,7 +139,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), registrationProfile.isAllowedToAllDomains(), validityPeriod, - registrationProfile.getPassword(), null, false); + registrationProfile.getPassword(), null, registrationProfile.getSupportedGrantTypes(), + registrationProfile.getCallbackUrl(), false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 1b81b29ce3..3aa1835f78 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -24,6 +24,8 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import java.util.ArrayList; + /** * This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM. */ @@ -52,18 +54,21 @@ public interface APIManagementProviderService { // String keyType, String username, boolean isAllowedAllDomains, // String validityTime) throws APIManagerException; - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, - boolean isMappingRequired) throws APIManagerException; +// ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, String username, +// boolean isAllowedAllDomains, +// String validityTime, String password, +// ArrayList supportedGrantTypes, +// String callbackUrl, +// boolean isMappingRequired) throws APIManagerException; ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, + String keyType, String username, boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + String validityTime, + String password, String accessToken, + ArrayList supportedGrantTypes, + String callbackUrl, boolean isMappingRequired) throws APIManagerException; // /** diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6b5ecc63ca..6d0d4b4f1d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -120,32 +120,44 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // tokenInfo.setAccessToken(accessToken); // return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, // tokenInfo, null, false); +// } + +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, String username, +// boolean isAllowedAllDomains, +// String validityTime, String password, +// ArrayList 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 public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + String validityTime, + String password, String accessToken, + ArrayList 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, applicationGrantTypeUpdater, isMappingRequired); - } - - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, - boolean isMappingRequired) throws APIManagerException { + if (StringUtils.isEmpty(accessToken)) { + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); + tokenInfo.setApiApplicationInfo(applicationInfo); + } else { + tokenInfo.setAccessToken(accessToken); + } ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -171,7 +183,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime, applicationGrantTypeUpdater, isMappingRequired); + validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { if (applications.length == 1) { Optional applicationOpt = @@ -185,7 +197,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // Todo add a comment consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime, applicationGrantTypeUpdater, isMappingRequired); + validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { @@ -239,7 +251,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, TokenInfo tokenInfo, String keyType, String validityTime, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + ArrayList supportedGrantTypes, String callbackUrl, boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -264,9 +276,7 @@ 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 @@ -279,11 +289,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } // ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, // String supportedGrantTypes, String callbackUrl) - if (applicationGrantTypeUpdater != null) { + if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), - applicationKey.getKeyMappingId(), keyManager.getName(), - applicationGrantTypeUpdater.getSupportedGrantTypes(), - applicationGrantTypeUpdater.getCallbackUrl()); + applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } @@ -671,7 +679,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(), registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index 35dced984a..96e4c40fd1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -66,7 +66,7 @@ public class OAuthUtils { registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 5905831436..f7f46b7df1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -828,11 +828,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); +// TokenInfo tokenInfo = new TokenInfo(); +// tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), - tokenInfo, null, true); + new String[] {"device_management"}, "PRODUCTION", null, false, String.valueOf(validityTime), + null, accessTokenInfo.getAccessToken(), null, null,true); } catch (JWTClientException e) { String msg = "Error while generating an application tokens for Tenant Admin."; From ac0ba0070789cef72c53d2f240551b0715b02f23 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 20 Sep 2023 09:37:58 +0530 Subject: [PATCH 113/157] Remove unnecessary sources --- ...ApiApplicationRegistrationServiceImpl.java | 13 - .../APIManagementProviderService.java | 32 -- .../APIManagementProviderServiceImpl.java | 306 +----------------- 3 files changed, 7 insertions(+), 344 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 8b2562d656..2dd6e523f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -24,7 +24,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.api.util.Registrat import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -109,18 +108,6 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { -// ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; -// if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { -// applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); -// applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); -// -// } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { -// return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + -// " request does not contain supported grant types to update grant types of the " + -// "application." -// ).build(); -// } - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 3aa1835f78..589923a920 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -20,8 +20,6 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import java.util.ArrayList; @@ -37,31 +35,6 @@ public interface APIManagementProviderService { */ boolean isTierLoaded(); -// /** -// * Generate and retreive application keys. if the application does exist then -// * create it and subscribe to apis that are grouped with the tags. -// * -// * @param apiApplicationName name of the application. -// * @param tags tags of the apis that application needs to be subscribed. -// * @param keyType of the application. -// * @param username to whom the application is created -// * @param isAllowedAllDomains application is allowed to all the tenants -// * @param validityTime validity period of the application -// * @return consumerkey and secrete of the created application. -// * @throws APIManagerException -// */ -// ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], -// String keyType, String username, boolean isAllowedAllDomains, -// String validityTime) throws APIManagerException; - -// ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, String username, -// boolean isAllowedAllDomains, -// String validityTime, String password, -// ArrayList supportedGrantTypes, -// String callbackUrl, -// boolean isMappingRequired) throws APIManagerException; - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, @@ -71,11 +44,6 @@ public interface APIManagementProviderService { String callbackUrl, boolean isMappingRequired) throws APIManagerException; -// /** -// * Remove APIM Application. -// */ -// void removeAPIApplication(String applicationName, String username) throws APIManagerException; - /** * To get access token for given scopes and for the given validity period * @param scopes Scopes diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6d0d4b4f1d..0f0791170b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -19,13 +19,10 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.bean.APIRegistrationProfile; -import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; 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.APIInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; 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.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; @@ -48,16 +45,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIAdmin; -import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; -import org.wso2.carbon.apimgt.api.model.API; -import org.wso2.carbon.apimgt.api.model.APIKey; -import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; -import org.wso2.carbon.apimgt.api.model.SubscribedAPI; -import org.wso2.carbon.apimgt.api.model.Subscriber; -import org.wso2.carbon.apimgt.impl.APIAdminImpl; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; @@ -65,8 +53,13 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; /** * This class represents an implementation of APIManagementProviderService. @@ -92,54 +85,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return false; } -// @Override -// public void removeAPIApplication(String applicationName, String username) throws APIManagerException { -// -// try { -// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); -// Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -//// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" -// if (application != null) { -// // todo:apim - apiConsumer.removeApplication(application, username); -// //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" -// } -// } catch (APIManagementException e) { -// throw new APIManagerException("Failed to remove api application : " + applicationName, e); -// } -// -// -// } - -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, -// boolean isAllowedAllDomains, -// String validityTime, String accessToken) throws APIManagerException { -// TokenInfo tokenInfo = new TokenInfo(); -// tokenInfo.setApiApplicationInfo(null); -// tokenInfo.setAccessToken(accessToken); -// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, -// tokenInfo, null, false); -// } - -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, String username, -// boolean isAllowedAllDomains, -// String validityTime, String password, -// ArrayList 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 public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -287,19 +232,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } -// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, -// String supportedGrantTypes, String callbackUrl) if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } - -// ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, -// keyManager.getName(), keyType); -// ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), -// keyManager.getName(), validityTime, keyType); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -368,235 +305,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } -// /** -// * {@inheritDoc} -// */ -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], -// String keyType, String username, boolean isAllowedAllDomains, String validityTime) -// throws APIManagerException { -// -// -///* -// -//todo - Modify generateAndRetrieveApplicationKeys -// -//Check the existence of the API application. -// -//if Application is not exists -// Create the Application -// -//If super tenants -// Get set of tagged APIs -//If the tenant domain is not super tenant -// Get set of tagged APIs from super tenant space -// -//If new Application -// Subscribed to tagged APIs -//Else -// Get all subscribed APIs of application -// Filter out APIs and subscribed to APIs which can be subscribed -// Filter -> Use set of tagged APis -// Remove already subscribed APIs from the set -// Subscribed to remaining APIs -// -//Get Application keys from application -// If API keys are there return API keys -// -//Otherwise, Generate Application Keys and return them -// -// */ -// -// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); -// if (StringUtils.isEmpty(username)) { -// username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; -// } -// try { -// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); -// Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// int applicationId = 0; -// Subscriber subscriber = null; -// if (application == null) { -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// if (subscriber == null) { -// // create subscriber -// // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// } -// //create application -// application = new Application(applicationName, subscriber); -// application.setTier(ApiApplicationConstants.DEFAULT_TIER); -// application.setGroupId(""); -// application.setTokenType("OAUTH"); -// // todo:resolve:apim - apiConsumer.addApplication(application, username); -// application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// } else { -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// } -// -// Set subscribedAPIs = -// null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); -// -// log.info("Already subscribed API count: " + subscribedAPIs.size()); -// -// // subscribe to apis. -// APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; -// if (tags != null && tags.length > 0) { -// for (String tag : tags) { -// boolean startedTenantFlow = false; -// Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); -// -// /** -// * From APIM 4.0.0, APIs published in the super tenant can only be listed by -// * APIConsumer, only if the APIConsumer belongs to the super tenant. So we -// * are starting tenant flow if we are not already in super tenant(child -// * tenant starting to create OAuth app). -// */ -// if (apisWithTag == null || apisWithTag.size() == 0) { -// PrivilegedCarbonContext.startTenantFlow(); -// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, -// true); -// -// try { -// String superAdminUsername = PrivilegedCarbonContext -// .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); -// apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); -// } catch (UserStoreException e) { -// throw new APIManagerException("Failed to create api application for " + -// "tenant: " + tenantDomain + -// ". Caused by to inability to get super tenant username", e); -// } -// -// apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// startedTenantFlow = true; -// } -// -// Set apiTypeWrapperList = new HashSet<>(); -// if (apisWithTag != null && apisWithTag.size() > 0) { -// Set tempApiIds = new HashSet<>(); -// for (API apiInfo : apisWithTag) { -// String id = apiInfo.getId().getProviderName().replace("@", "-AT-") -// + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); -// boolean subscriptionExist = false; -// if (subscribedAPIs.size() > 0) { -// for (SubscribedAPI subscribedAPI : subscribedAPIs) { -// // todo:resolve:apim -//// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { -//// subscriptionExist = true; -//// break; -//// } -// } -// } -// if (!subscriptionExist && !tempApiIds.contains(id)) { -// ApiTypeWrapper apiTypeWrapper; -// if (startedTenantFlow) { -// /** -// * This mean APIs were not found in the child tenant, so all -// * calls to get info about APIs need to be to super tenant. -// */ -// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( -// apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// } else { -// /** -// * Ideally, in all usecases of IoT server, tenant domain here -// * will be carbon.super. This block is kept to make sure in -// * the future, if there are some APIs published to a specific -// * tenant only. -// */ -// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( -// apiInfo.getUuid(), tenantDomain); -// } -// apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); -// apiTypeWrapperList.add(apiTypeWrapper); -// tempApiIds.add(id); -// } -// } -// if (startedTenantFlow) { -// PrivilegedCarbonContext.endTenantFlow(); -// } -// -// /** This is done in a redundant loop instead of doing in the same loop -// * that populates apiTypeWrapperList because in a tenanted scenario, -// * apiConsumerAPIPublishedTenant will belong to super tenant. So super -// * tenant flow need to end before starting subscription to avoid adding -// * subscriptions inside super tenant when we are trying to create an -// * Oauth app for a child tenant. -// */ -// for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { -// // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); -// } -// } -// } -// } -// //end of subscription -// -// List applicationKeys = application.getKeys(); -// if (applicationKeys != null) { -// for (APIKey applicationKey : applicationKeys) { -// if (keyType.equals(applicationKey.getType())) { -// if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { -// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); -// apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); -// apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); -// return apiApplicationKey; -// } -// } -// } -// } -// -// List allowedDomains = new ArrayList<>(); -// if (isAllowedAllDomains) { -// allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); -// } else { -// allowedDomains.add(APIManagerUtil.getTenantDomain()); -// } -// -// APIAdmin apiAdmin = new APIAdminImpl(); -// String keyManagerId = null; -// try { -// List keyManagerConfigurations = null; // todo:resolve:apim - -// // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); -// if (keyManagerConfigurations != null) { -// for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { -// keyManagerId = keyManagerConfigurationDTO.getUuid(); -// } -// } -// String applicationAccessTokenExpiryTime = "N/A"; -// if (!StringUtils.isEmpty(validityTime)) { -// applicationAccessTokenExpiryTime = validityTime; -// } -// String jsonString = "{\"grant_types\":\"refresh_token,access_token," + -// "urn:ietf:params:oauth:grant-type:saml2-bearer," + -// "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + -// "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + -// "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + -// "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + -// "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + -// "\"username\":\"" + username + "\"}"; -// -// Map keyDetails = null; // todo:resolve:apim - apiConsumer -//// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", -//// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", -//// jsonString, keyManagerId, tenantDomain); -// -// if (keyDetails != null) { -// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); -// apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); -// apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); -// return apiApplicationKey; -// } -// throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -//// todo:resolve:apim - commected as it says never throw since we commented apim calls above -//// cnt rm -//// } catch (APIManagementException e) { -// } catch (Exception e) { -// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); -// } -// } catch (APIManagementException e) { -// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); -// } -// } - @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, String validityPeriod, String username) throws APIManagerException { From cc6bbf1435de1db1d20c5bc5cc2313bb52e58630 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 21 Sep 2023 01:56:53 +0530 Subject: [PATCH 114/157] Improvements in App registration --- .../APIManagementProviderServiceImpl.java | 66 +- .../rest/api/APIApplicationServices.java | 2 +- .../rest/api/APIApplicationServicesImpl.java | 2 +- .../rest/api/ConsumerRESTAPIServices.java | 30 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 588 ++++++------------ .../extension/rest/api/dto/TokenInfo.java | 44 -- .../extension/service/KeyMgtServiceImpl.java | 9 +- .../impl/DeviceManagementServiceImpl.java | 3 - 8 files changed, 247 insertions(+), 497 deletions(-) delete mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0f0791170b..837a1b902c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -26,7 +26,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.API 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.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -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; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -96,12 +95,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isMappingRequired) throws APIManagerException { - TokenInfo tokenInfo = new TokenInfo(); + ApiApplicationInfo apiApplicationInfo = new ApiApplicationInfo(); if (StringUtils.isEmpty(accessToken)) { - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); - tokenInfo.setApiApplicationInfo(applicationInfo); + apiApplicationInfo = getApplicationInfo(username, password); } else { - tokenInfo.setAccessToken(accessToken); + apiApplicationInfo.setAccess_token(accessToken); } ConsumerRESTAPIServices consumerRESTAPIServices = @@ -118,16 +116,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationInfo, queryParams, headerParams); Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); } List uniqueApiList = new ArrayList<>(uniqueApiSet.values()); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationInfo, applicationName); if (applications.length == 0) { - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + return handleNewAPIApplication(applicationName, uniqueApiList, apiApplicationInfo, keyType, validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { if (applications.length == 1) { @@ -140,17 +138,17 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { // Todo add a comment - consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + consumerRESTAPIServices.deleteApplication(apiApplicationInfo, application.getApplicationId()); + return handleNewAPIApplication(applicationName, uniqueApiList, apiApplicationInfo, keyType, validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); } if (!uniqueApiList.isEmpty()) { - addSubscriptions(application, uniqueApiList, tokenInfo); + addSubscriptions(application, uniqueApiList, apiApplicationInfo); } String[] metaValues = metaData.getMetaValue().split(":"); @@ -162,7 +160,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(apiApplicationInfo, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -195,7 +193,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, - TokenInfo tokenInfo, String keyType, String validityTime, + ApiApplicationInfo apiApplicationInfo, String keyType, String validityTime, ArrayList supportedGrantTypes, String callbackUrl, boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = @@ -205,10 +203,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application.setThrottlingPolicy(UNLIMITED_TIER); try { - application = consumerRESTAPIServices.createApplication(tokenInfo, application); - addSubscriptions(application, uniqueApiList, tokenInfo); + application = consumerRESTAPIServices.createApplication(apiApplicationInfo, application); + addSubscriptions(application, uniqueApiList, apiApplicationInfo); - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(apiApplicationInfo); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -219,21 +217,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } - tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); ApplicationKey applicationKey; - 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 // it is a requirement then we have to call the method with enabling the flag. - applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, - keyManager.getName(), keyType); + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() + .getApiApplicationServices(); + + APIApplicationKey apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForMapping", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + + apiApplicationInfo.setClientId(apiApplicationKey.getClientId()); + apiApplicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); + + applicationKey = consumerRESTAPIServices.mapApplicationKeys(apiApplicationInfo, application, + keyManager.getName(), keyType); } else { - applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + applicationKey = consumerRESTAPIServices.generateApplicationKeys(apiApplicationInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { - applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), + applicationKey = consumerRESTAPIServices.updateGrantType(apiApplicationInfo, application.getApplicationId(), applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } @@ -277,16 +283,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe /** * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. * - * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} - * @param apiInfos {@link List} - * @param tokenInfo {@link TokenInfo} + * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} + * @param apiInfos {@link List} + * @param apiApplicationInfo {@link ApiApplicationInfo} * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. * @throws APIServicesException if error occurred while invoking the subscribing REST API. */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, TokenInfo tokenInfo) + List apiInfos, ApiApplicationInfo apiApplicationInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { ConsumerRESTAPIServices consumerRESTAPIServices = @@ -302,7 +308,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); } @Override @@ -407,7 +413,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "ClientForConsumerRestCalls", "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentialsWithUser( "ClientForConsumerRestCalls", username, password, "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java index f5cc8b3ec1..7b14f48800 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServices.java @@ -27,7 +27,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + APIApplicationKey createAndRetrieveApplicationCredentialsWithUser(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java index a03f81d086..68ea575e02 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/APIApplicationServicesImpl.java @@ -75,7 +75,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + public APIApplicationKey createAndRetrieveApplicationCredentialsWithUser(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java index e8342b18d5..2cb3cf692c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServices.java @@ -19,7 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; 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.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -28,43 +28,45 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(TokenInfo tokenInfo, String appName) + + Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(TokenInfo tokenInfo, Application application) + Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) + Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) + ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyManager, + String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + ApplicationKey mapApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, String keyManager, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + ApplicationKey updateGrantType(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId, String keyManager, List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java index e5608d5cbc..998331cc0d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/ConsumerRESTAPIServicesImpl.java @@ -23,7 +23,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; @@ -51,22 +50,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(TokenInfo tokenInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); builder.url(getAllApplicationsUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -76,21 +68,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - tokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - tokenInfo.setAccessToken(null); - return getAllApplications(tokenInfo, appName); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllApplications(refreshedApiApplicationInfo, appName); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -107,22 +91,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getDetailsOfAPPUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -131,22 +108,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getDetailsOfAnApplication(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -163,33 +131,38 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(TokenInfo tokenInfo, Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; - String applicationInfo = "{\n" + - " \"name\": \"" + application.getName() + "\",\n" + - " \"throttlingPolicy\": \"" + application.getThrottlingPolicy() + "\",\n" + - " \"description\": \"" + application.getDescription() + "\",\n" + - " \"tokenType\": \"" + application.getTokenType() + "\",\n" + - " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + - " \"attributes\": " + gson.toJson(application.getAttributes()) + ",\n" + - " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, applicationInfo); + JSONArray groups = new JSONArray(); + JSONArray subscriptionScope = new JSONArray(); + + if (application.getGroups() != null && application.getSubscriptionScopes() != null) { + for (String string : application.getGroups()) { + groups.put(string); + } + for (Scopes string : application.getSubscriptionScopes()) { + subscriptionScope.put(string); + } + } + + JSONObject applicationInfo = new JSONObject(); + applicationInfo.put("name", application.getName()); + applicationInfo.put("throttlingPolicy", application.getThrottlingPolicy()); + applicationInfo.put("description", application.getDescription()); + applicationInfo.put("tokenType", application.getTokenType()); + applicationInfo.put("groups", groups); + applicationInfo.put("attributes", new JSONObject()); + applicationInfo.put("subscriptionScopes", subscriptionScope); + + RequestBody requestBody = RequestBody.create(JSON, applicationInfo.toString()); Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -198,22 +171,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createApplication(refreshedTokenInfo, application); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createApplication(refreshedApiApplicationInfo, application); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -230,22 +194,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) + public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(deleteScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.delete(); Request request = builder.build(); @@ -254,22 +211,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return deleteApplication(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return deleteApplication(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -286,22 +234,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId + "&limit=1000"; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -311,22 +252,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllSubscriptions(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllSubscriptions(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -343,11 +275,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) + public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -356,13 +286,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL.toString()); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -375,22 +301,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllApis(refreshedTokenInfo, queryParams, headerParams); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllApis(refreshedApiApplicationInfo, queryParams, headerParams); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -407,31 +324,24 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; - String subscriptionObject = "{\n" + - " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + - " \"apiId\": \"" + subscriptions.getApiId() + "\",\n" + - " \"throttlingPolicy\": \"" + subscriptions.getThrottlingPolicy() + "\",\n" + - " \"requestedThrottlingPolicy\": \"" + subscriptions.getRequestedThrottlingPolicy() + "\"\n" + - "}"; + JSONObject subscriptionObject = new JSONObject(); + subscriptionObject.put("applicationId", subscriptions.getApplicationId()); + subscriptionObject.put("apiId", subscriptions.getApiId()); + subscriptionObject.put("throttlingPolicy", subscriptions.getThrottlingPolicy()); + subscriptionObject.put("requestedThrottlingPolicy", subscriptions.getRequestedThrottlingPolicy()); - RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); + RequestBody requestBody = RequestBody.create(JSON, subscriptionObject.toString()); Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + builder.post(requestBody); Request request = builder.build(); @@ -440,22 +350,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createSubscription(refreshedTokenInfo, subscriptions); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createSubscription(refreshedApiApplicationInfo, subscriptions); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -472,11 +373,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -484,13 +383,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionsUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + builder.post(requestBody); Request request = builder.build(); @@ -499,22 +394,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createSubscriptions(refreshedTokenInfo, subscriptions); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createSubscriptions(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -531,42 +416,36 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; - String keyInfo = "{\n" + - " \"keyType\": \"" + keyType + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"grantTypesToBeSupported\": [\n" + - " \"password\",\n" + - " \"client_credentials\"\n" + - " ],\n" + - " \"callbackUrl\": \"\",\n" + - " \"scopes\": [\n" + - " \"am_application_scope\",\n" + - " \"default\"\n" + - " ],\n" + - " \"validityTime\": " + validityTime + ",\n" + - " \"additionalProperties\": {}\n" + - "}"; - - RequestBody requestBody = RequestBody.create(JSON, keyInfo); + JSONArray grantTypesToBeSupported = new JSONArray(); + grantTypesToBeSupported.put("password"); + grantTypesToBeSupported.put("client_credentials"); + + JSONArray scopes = new JSONArray(); + scopes.put("am_application_scope"); + scopes.put("default"); + + JSONObject keyInfo = new JSONObject(); + keyInfo.put("keyType", keyType); + keyInfo.put("keyManager", keyManager); + keyInfo.put("grantTypesToBeSupported", grantTypesToBeSupported); + keyInfo.put("callbackUrl", ""); + keyInfo.put("scopes", scopes); + keyInfo.put("validityTime", 3600); + keyInfo.put("additionalProperties", new JSONObject()); + + RequestBody requestBody = RequestBody.create(JSON, keyInfo.toString()); Request.Builder builder = new Request.Builder(); builder.url(generateApplicationKeysUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -575,22 +454,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return generateApplicationKeys(refreshedTokenInfo, applicationId, keyManager, validityTime, keyType); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return generateApplicationKeys(refreshedApiApplicationInfo, applicationId, keyManager, validityTime, keyType); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -607,31 +477,24 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + public ApplicationKey mapApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, String keyManager, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + application.getApplicationId() + "/map-keys"; - String payload = "{\n" + - " \"consumerKey\": \"" + apiApplicationInfo.getClientId() + "\",\n" + - " \"consumerSecret\": \"" + apiApplicationInfo.getClientSecret() + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"keyType\": \"" + keyType + "\"\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, payload); + JSONObject payload = new JSONObject(); + payload.put("consumerKey", apiApplicationInfo.getClientId()); + payload.put("consumerSecret", apiApplicationInfo.getClientSecret()); + payload.put("keyManager", keyManager); + payload.put("keyType", keyType); + + RequestBody requestBody = RequestBody.create(JSON, payload.toString()); Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -640,22 +503,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return mapApplicationKeys(refreshedTokenInfo, application, keyManager, keyType); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return mapApplicationKeys(refreshedApiApplicationInfo, application, keyManager, keyType); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -672,22 +526,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -696,22 +543,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getKeyDetails(refreshedTokenInfo, applicationId, keyMapId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getKeyDetails(refreshedApiApplicationInfo, applicationId, keyMapId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -728,23 +566,16 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + public ApplicationKey updateGrantType(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId, String keyManager, List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); JSONArray supportedGrantTypeList = new JSONArray(); for (String string : supportedGrantTypes) { @@ -768,22 +599,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return updateGrantType(refreshedTokenInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return updateGrantType(refreshedApiApplicationInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -800,22 +622,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); builder.url(getAllKeyManagersUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -825,22 +640,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllKeyManagers(refreshedTokenInfo); - } else { - String msg = "Invalid or null access token"; - log.error(msg); - throw new BadRequestException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllKeyManagers(refreshedApiApplicationInfo); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -856,29 +662,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } - private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo refreshedApplicationInfo, AccessTokenInfo refreshedToken) { + private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo apiApplicationInfo, AccessTokenInfo refreshedToken) { - ApiApplicationInfo applicationInfo = null; - applicationInfo.setClientId(refreshedApplicationInfo.getClientId()); - applicationInfo.setClientSecret(refreshedApplicationInfo.getClientSecret()); + ApiApplicationInfo applicationInfo = new ApiApplicationInfo(); + applicationInfo.setClientId(apiApplicationInfo.getClientId()); + applicationInfo.setClientSecret(apiApplicationInfo.getClientSecret()); applicationInfo.setAccess_token(refreshedToken.getAccess_token()); applicationInfo.setRefresh_token(refreshedToken.getRefresh_token()); - return applicationInfo; } - - private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { - - boolean token; - if ((!(accessToken == null))) { - token = true; - } else if (!(apiApplicationInfo == null) && accessToken == null) { - token = false; - } else { - String msg = "Null access token or Rest Application info"; - log.error(msg); - throw new BadRequestException(msg); - } - return token; - } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java deleted file mode 100644 index 72100c982b..0000000000 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/dto/TokenInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.entgra.device.mgt.core.apimgt.extension.rest.api.dto; - -/** - * This holds the API application information and access token for REST APIS cals. - */ -public class TokenInfo { - - private ApiApplicationInfo apiApplicationInfo; - private String accessToken; - - public ApiApplicationInfo getApiApplicationInfo() { - return apiApplicationInfo; - } - - public void setApiApplicationInfo(ApiApplicationInfo apiApplicationInfo) { - this.apiApplicationInfo = apiApplicationInfo; - } - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } -} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index f1d3c73641..5afd9dbc65 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -20,7 +20,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; @@ -437,14 +437,13 @@ public class KeyMgtServiceImpl implements KeyMgtService { */ private io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application getApplication(String applicationName, String accessToken) throws KeyMgtException { - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setApiApplicationInfo(null); - tokenInfo.setAccessToken(accessToken); + ApiApplicationInfo apiApplicationInfo = new ApiApplicationInfo(); + apiApplicationInfo.setAccess_token(accessToken); try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationInfo, applicationName); if (applications.length == 1) { return applications[0]; } else { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index f7f46b7df1..3ba6e390f5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -27,7 +27,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplic import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServicesImpl; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; @@ -828,8 +827,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); -// TokenInfo tokenInfo = new TokenInfo(); -// tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, new String[] {"device_management"}, "PRODUCTION", null, false, String.valueOf(validityTime), null, accessTokenInfo.getAccessToken(), null, null,true); From 144170c4c9a443b7982c1a5dbf959d0d65e736ee Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 27 Sep 2023 15:10:51 +0530 Subject: [PATCH 115/157] Fix sso loging app creation payload --- .../ui/request/interceptor/LoginHandler.java | 3 +- .../request/interceptor/SsoLoginHandler.java | 236 +++++++++--------- .../interceptor/util/HandlerConstants.java | 1 + .../request/interceptor/util/HandlerUtil.java | 12 +- 4 files changed, 131 insertions(+), 121 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index b058322933..9aa6eec0ad 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -86,7 +86,8 @@ public class LoginHandler extends HttpServlet { apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() .encodeToString((username + HandlerConstants.COLON + password).getBytes())); apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, + username, password, null, null)); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 78a95c019f..29ccff3519 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -38,7 +38,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.json.JSONArray; -import org.json.JSONObject; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; @@ -157,6 +156,8 @@ public class SsoLoginHandler extends HttpServlet { JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); + JsonArray supportedGrantTypes = constructAppGrantTypeUpdateArray(); + String callbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; // Register the client application HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); @@ -165,7 +166,8 @@ public class SsoLoginHandler extends HttpServlet { apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedAdminCredentials); apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword)); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, + callbackUrl, supportedGrantTypes)); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); @@ -325,21 +327,17 @@ public class SsoLoginHandler extends HttpServlet { /*** * Generates payload for application grant_type update payload * - * @return {@link StringEntity} of the payload to update application grant type + * @return {@link JsonArray} of the payload to update application grant type */ - private StringEntity constructAppGrantTypeUpdatePayload() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("supportedGrantTypes", - new JSONArray(new Object[]{ - HandlerConstants.CODE_GRANT_TYPE, - HandlerConstants.REFRESH_TOKEN_GRANT_TYPE, - HandlerConstants.PASSWORD_GRANT_TYPE, - HandlerConstants.JWT_BEARER_GRANT_TYPE - }) - ); - jsonObject.put(HandlerConstants.CALLBACK_URL_KEY, iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK); - String payload = jsonObject.toString(); - return new StringEntity(payload, ContentType.APPLICATION_JSON); + private JsonArray constructAppGrantTypeUpdateArray() { + JsonArray jsonArray = new JsonArray(); + + jsonArray.add( HandlerConstants.CODE_GRANT_TYPE); + jsonArray.add( HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); + jsonArray.add( HandlerConstants.PASSWORD_GRANT_TYPE); + jsonArray.add( HandlerConstants.JWT_BEARER_GRANT_TYPE); + + return jsonArray; } /*** @@ -390,107 +388,107 @@ public class SsoLoginHandler extends HttpServlet { return jTokenResultAsJsonObject.get("access_token").getAsString(); } - /*** - * Updates Application - * - * @param appName - Application name - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml - */ - private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { - File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); - String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; - - HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); - getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); - getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); - - String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); - - Map data = new HashMap<>(); - appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + - HandlerConstants.PRODUCTION_KEY; - data.put("applicationName", appName); - requestBodyString = StrSubstitutor.replace(requestBodyString, data); - getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); - - ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); - - Document doc = DocumentBuilderFactory.newInstance() - .newDocumentBuilder() - .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); - NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); - NodeList childNodeList; - String nodeName; - - data.clear(); - data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); - data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); - data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); - data.put("saasApp", "true"); - - for (int i = 0; i < nodeList.getLength(); i++) { - childNodeList = nodeList.item(i).getChildNodes(); - for (int j = 0; j < childNodeList.getLength(); j++) { - if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { - NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); - for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { - nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { - data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); - } - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { - data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); - } - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { - data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); - } - } - } - } - } - - nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); - for (int i = 0; i < nodeList.getLength(); i++) { - childNodeList = nodeList.item(i).getChildNodes(); - for (int j = 0; j < childNodeList.getLength(); j++) { - switch (childNodeList.item(j).getNodeName()) { - case HandlerConstants.AX_PREFIX + "tenantDomain": - data.put("tenantDomain", childNodeList.item(j).getTextContent()); - break; - case HandlerConstants.AX_PREFIX + "userName": - data.put("userName", childNodeList.item(j).getTextContent()); - break; - case HandlerConstants.AX_PREFIX + "userStoreDomain": - data.put("userStoreDomain", childNodeList.item(j).getTextContent()); - break; - } - } - } - - nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); - for (int k = 0; k < nodeList.getLength(); k++) { - childNodeList = nodeList.item(k).getChildNodes(); - for (int l = 0; l < childNodeList.getLength(); l++) { - if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { - data.put("displayName", childNodeList.item(l).getTextContent()); - } - } - } - - File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); - String docStr = HandlerUtil.xmlToString(appUpdateRequest); - requestBodyString = StrSubstitutor.replace(docStr, data); - - HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); - updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); - updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); - updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); - - HandlerUtil.execute(updateApplicationEndpoint); - } +// /*** +// * Updates Application +// * +// * @param appName - Application name +// * @throws IOException IO exception throws if an error occurred when invoking token endpoint +// * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml +// */ +// private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { +// File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); +// String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; +// +// HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); +// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + +// encodedAdminCredentials); +// getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); +// getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); +// +// String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); +// +// Map data = new HashMap<>(); +// appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + +// HandlerConstants.PRODUCTION_KEY; +// data.put("applicationName", appName); +// requestBodyString = StrSubstitutor.replace(requestBodyString, data); +// getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); +// +// ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); +// +// Document doc = DocumentBuilderFactory.newInstance() +// .newDocumentBuilder() +// .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); +// NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); +// NodeList childNodeList; +// String nodeName; +// +// data.clear(); +// data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); +// data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); +// data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); +// data.put("saasApp", "true"); +// +// for (int i = 0; i < nodeList.getLength(); i++) { +// childNodeList = nodeList.item(i).getChildNodes(); +// for (int j = 0; j < childNodeList.getLength(); j++) { +// if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { +// NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); +// for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { +// nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { +// data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { +// data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { +// data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// } +// } +// } +// } +// +// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); +// for (int i = 0; i < nodeList.getLength(); i++) { +// childNodeList = nodeList.item(i).getChildNodes(); +// for (int j = 0; j < childNodeList.getLength(); j++) { +// switch (childNodeList.item(j).getNodeName()) { +// case HandlerConstants.AX_PREFIX + "tenantDomain": +// data.put("tenantDomain", childNodeList.item(j).getTextContent()); +// break; +// case HandlerConstants.AX_PREFIX + "userName": +// data.put("userName", childNodeList.item(j).getTextContent()); +// break; +// case HandlerConstants.AX_PREFIX + "userStoreDomain": +// data.put("userStoreDomain", childNodeList.item(j).getTextContent()); +// break; +// } +// } +// } +// +// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); +// for (int k = 0; k < nodeList.getLength(); k++) { +// childNodeList = nodeList.item(k).getChildNodes(); +// for (int l = 0; l < childNodeList.getLength(); l++) { +// if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { +// data.put("displayName", childNodeList.item(l).getTextContent()); +// } +// } +// } +// +// File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); +// String docStr = HandlerUtil.xmlToString(appUpdateRequest); +// requestBodyString = StrSubstitutor.replace(docStr, data); +// +// HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); +// updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + +// encodedAdminCredentials); +// updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); +// updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); +// updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); +// +// HandlerUtil.execute(updateApplicationEndpoint); +// } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index c6058102b6..0b56bbc578 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -43,6 +43,7 @@ public class HandlerConstants { public static final String SESSION_DEFAULT_AUTH_DATA_KEY = "defaultAuthInfo"; public static final String UI_CONFIG_KEY = "ui-config"; public static final String CALLBACK_URL_KEY = "callbackUrl"; + public static final String GRANT_TYPE_KEY = "supportedGrantTypes"; public static final String IS_ALLOWED_TO_ALL_DOMAINS_KEY = "isAllowedToAllDomains"; public static final String JSESSIONID_KEY = "JSESSIONID"; public static final String COMMON_AUTH_ID_KEY = "commonAuthId"; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index cd2f1f8fe0..2257d9e6d0 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -461,15 +461,25 @@ public class HandlerUtil { * @param tags - tags which are retrieved by reading app manager configuration * @param username - username provided from login form or admin username * @param password - password provided from login form or admin password + * @param callbackUrl - callback url + * @param supportedGrantTypes - supported grant types * @return {@link StringEntity} of the payload to create the client application */ - public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password) { + public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password, + String callbackUrl, JsonArray supportedGrantTypes) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(HandlerConstants.APP_NAME_KEY, appName); jsonObject.addProperty(HandlerConstants.USERNAME, username); jsonObject.addProperty(HandlerConstants.PASSWORD, password); jsonObject.addProperty(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); jsonObject.add(HandlerConstants.TAGS_KEY, tags); + if (callbackUrl != null) { + jsonObject.addProperty(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); + } + if (supportedGrantTypes != null) { + jsonObject.add(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); + + } String payload = jsonObject.toString(); return new StringEntity(payload, ContentType.APPLICATION_JSON); } From e128a2479f248c0886fa2e1298492018faaa4b4f Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 27 Sep 2023 15:37:35 +0530 Subject: [PATCH 116/157] Clear unused method --- .../request/interceptor/SsoLoginHandler.java | 188 +----------------- 1 file changed, 4 insertions(+), 184 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 29ccff3519..d063079e74 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -203,87 +203,11 @@ public class SsoLoginHandler extends HttpServlet { HandlerUtil.handleError(resp, null); throw new LoginException(msg); } - - // Get the details of the registered application -// String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + -// "?query=" + applicationName; -// HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); -// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + -// getAccessToken(resp, encodedClientApp)); -// -// ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); -// -// if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { -// JsonParser jsonParser = new JsonParser(); -// JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); -// if (jAppResult.isJsonObject()) { -// JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); -// JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); -// JsonObject app; -// for (JsonElement appJson : appList) { -// app = appJson.getAsJsonObject(); -// if (app.get("name").getAsString().equals(applicationName)) { -// applicationId = app.get("applicationId").getAsString(); -// break; -// } -// } -// } -// } else if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { -// String msg = "Unauthorized attempt to get registered application data. " + -// "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, getApplicationResponse); -// throw new LoginException(msg); -// } else { -// String msg = "Failed the process while getting the data of registered application. " + -// "Application Name: " + applicationName + ". Response Code: " -// + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, null); -// throw new LoginException(msg); -// } - - // Update the grant types of the application -// String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + -// HandlerConstants.PRODUCTION_KEY; -// HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); -// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + -// getAccessToken(resp, encodedClientApp)); -// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); -// updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); -// -// ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); -// -// // Update app as a SaaS app -// this.updateSaasApp(applicationId); -// -// if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { -// String msg = "Unauthorized attempt to update the grant types of the application. " + -// "Application ID: " + applicationId + ". Response message: " -// + updateApplicationGrantTypesEndpointResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); -// throw new LoginException(msg); -// } else if (updateApplicationGrantTypesEndpointResponse.getCode() != HttpStatus.SC_OK) { -// String msg = "Failed the process while updating the grant types of the application. " + -// "Application ID: " + applicationId + ". Response Code: " -// + updateApplicationGrantTypesEndpointResponse.getCode() + ", Response message: " -// + updateApplicationGrantTypesEndpointResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, null); -// throw new LoginException(msg); -// } } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket.", e); } catch (JsonSyntaxException e) { throw new LoginException("Error occurred while parsing the response.", e); } -// catch (ParserConfigurationException e) { -// throw new LoginException("Error while creating the document builder.", e); -// } -// catch (SAXException e) { -// throw new LoginException("Error while parsing xml file.", e); -// } } /** @@ -332,10 +256,10 @@ public class SsoLoginHandler extends HttpServlet { private JsonArray constructAppGrantTypeUpdateArray() { JsonArray jsonArray = new JsonArray(); - jsonArray.add( HandlerConstants.CODE_GRANT_TYPE); - jsonArray.add( HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); - jsonArray.add( HandlerConstants.PASSWORD_GRANT_TYPE); - jsonArray.add( HandlerConstants.JWT_BEARER_GRANT_TYPE); + jsonArray.add(HandlerConstants.CODE_GRANT_TYPE); + jsonArray.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); + jsonArray.add(HandlerConstants.PASSWORD_GRANT_TYPE); + jsonArray.add(HandlerConstants.JWT_BEARER_GRANT_TYPE); return jsonArray; } @@ -387,108 +311,4 @@ public class SsoLoginHandler extends HttpServlet { JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); return jTokenResultAsJsonObject.get("access_token").getAsString(); } - -// /*** -// * Updates Application -// * -// * @param appName - Application name -// * @throws IOException IO exception throws if an error occurred when invoking token endpoint -// * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml -// */ -// private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { -// File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); -// String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; -// -// HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); -// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + -// encodedAdminCredentials); -// getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); -// getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); -// -// String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); -// -// Map data = new HashMap<>(); -// appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + -// HandlerConstants.PRODUCTION_KEY; -// data.put("applicationName", appName); -// requestBodyString = StrSubstitutor.replace(requestBodyString, data); -// getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); -// -// ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); -// -// Document doc = DocumentBuilderFactory.newInstance() -// .newDocumentBuilder() -// .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); -// NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); -// NodeList childNodeList; -// String nodeName; -// -// data.clear(); -// data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); -// data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); -// data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); -// data.put("saasApp", "true"); -// -// for (int i = 0; i < nodeList.getLength(); i++) { -// childNodeList = nodeList.item(i).getChildNodes(); -// for (int j = 0; j < childNodeList.getLength(); j++) { -// if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { -// NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); -// for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { -// nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { -// data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { -// data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { -// data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// } -// } -// } -// } -// -// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); -// for (int i = 0; i < nodeList.getLength(); i++) { -// childNodeList = nodeList.item(i).getChildNodes(); -// for (int j = 0; j < childNodeList.getLength(); j++) { -// switch (childNodeList.item(j).getNodeName()) { -// case HandlerConstants.AX_PREFIX + "tenantDomain": -// data.put("tenantDomain", childNodeList.item(j).getTextContent()); -// break; -// case HandlerConstants.AX_PREFIX + "userName": -// data.put("userName", childNodeList.item(j).getTextContent()); -// break; -// case HandlerConstants.AX_PREFIX + "userStoreDomain": -// data.put("userStoreDomain", childNodeList.item(j).getTextContent()); -// break; -// } -// } -// } -// -// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); -// for (int k = 0; k < nodeList.getLength(); k++) { -// childNodeList = nodeList.item(k).getChildNodes(); -// for (int l = 0; l < childNodeList.getLength(); l++) { -// if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { -// data.put("displayName", childNodeList.item(l).getTextContent()); -// } -// } -// } -// -// File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); -// String docStr = HandlerUtil.xmlToString(appUpdateRequest); -// requestBodyString = StrSubstitutor.replace(docStr, data); -// -// HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); -// updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + -// encodedAdminCredentials); -// updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); -// updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); -// updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); -// -// HandlerUtil.execute(updateApplicationEndpoint); -// } } From b9b2c97841e2e8ca8875c6cccaa54b6c8de155bd Mon Sep 17 00:00:00 2001 From: nishan Date: Wed, 18 Oct 2023 07:08:39 +0530 Subject: [PATCH 117/157] Added query for set foreign key --- .../src/test/resources/sql/h2.sql | 4 +++- .../src/main/resources/dbscripts/cdm/h2.sql | 5 ++++- .../src/main/resources/dbscripts/cdm/mssql.sql | 4 +++- .../src/main/resources/dbscripts/cdm/mysql.sql | 4 +++- .../src/main/resources/dbscripts/cdm/oracle.sql | 4 +++- .../src/main/resources/dbscripts/cdm/postgresql.sql | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql index 0fb769e406..952fe1a099 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql @@ -39,5 +39,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ON DELETE NO ACTION ON UPDATE NO ACTION ); \ No newline at end of file diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index b1f68e0570..0547f9ca79 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -15,7 +15,10 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) + ); CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 7090ca20ff..a00068c5f9 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -25,7 +25,9 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, -PRIMARY KEY (ID) +PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ); IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE')) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 5e33d6b2b4..8107b71583 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -19,7 +19,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) )ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 035f31d31d..043663a706 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -30,7 +30,9 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 1b9393885c..3bad8667e2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -843,6 +843,8 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) + REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ) From 944c304a689151e7a84e4a9399add196a3b5f5f0 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 24 Oct 2023 16:13:08 +0530 Subject: [PATCH 118/157] user store role mapping feature --- .../pom.xml | 223 ++++++++++++++++++ .../role/mapper/UserStoreRoleMapper.java | 122 ++++++++++ .../UserStoreRoleMappingConfigManager.java | 76 ++++++ .../role/mapper/bean/RoleMapping.java | 58 +++++ .../bean/UserStoreRoleMappingConfig.java | 45 ++++ .../UserStoreRoleMapperException.java | 26 ++ .../UserStoreRoleMappingDataHolder.java | 85 +++++++ .../UserStoreRoleMappingServiceComponent.java | 112 +++++++++ components/device-mgt-extensions/pom.xml | 1 + .../pom.xml | 105 +++++++++ .../src/main/resources/build.properties | 19 ++ .../conf/user-store-role-mapping-config.xml | 38 +++ .../src/main/resources/p2.inf | 2 + features/device-mgt-extensions/pom.xml | 1 + pom.xml | 5 + 15 files changed, 918 insertions(+) create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMappingConfigManager.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/RoleMapping.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/exception/UserStoreRoleMapperException.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java create mode 100644 features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml create mode 100644 features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/build.properties create mode 100644 features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml create mode 100644 features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/p2.inf diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml new file mode 100644 index 0000000000..902f176763 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -0,0 +1,223 @@ + + + + + + + device-mgt-extensions + io.entgra.device.mgt.core + 5.0.31-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper + bundle + Entgra IoT - User store role mapping Module + Entgra IoT - User store role mapping Module + http://entgra.io + + + + + org.apache.felix + maven-scr-plugin + + + maven-compiler-plugin + + 1.8 + 1.8 + + 2.3.2 + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${io.entgra.device.mgt.core.version} + IOT - User store role mapping Module + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal + + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.apache.commons.logging, + org.apache.axis2.*;version="${axis2.osgi.version.range}", + org.wso2.carbon.core, + org.wso2.carbon.utils.*, + javax.xml.bind;resolution:=optional, + javax.xml.bind.annotation, + javax.xml.parsers, + org.w3c.dom, + org.wso2.carbon, + org.wso2.carbon.context, + org.wso2.carbon.user.api, + org.wso2.carbon.user.core.common, + org.wso2.carbon.user.core.service, + org.wso2.carbon.user.mgt.common + + + !io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal, + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.*;version="${project.version}" + + + + + + org.jacoco + jacoco-maven-plugin + + ${basedir}/target/coverage-reports/jacoco-unit.exec + + + + jacoco-initialize + + prepare-agent + + + + jacoco-site + test + + report + + + ${basedir}/target/coverage-reports/jacoco-unit.exec + ${basedir}/target/coverage-reports/site + + + + + + + + + + + + + + + + + + + + + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon + org.wso2.carbon.utils + provided + + + org.wso2.carbon + org.wso2.carbon.user.api + provided + + + org.wso2.carbon + org.wso2.carbon.user.core + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.user.mgt + provided + + + org.mockito + mockito-inline + test + + + org.testng + testng + test + + + org.wso2.orbit.com.h2database + h2 + test + + + org.apache.httpcomponents.wso2 + httpcore + test + + + org.wso2.apache.httpcomponents + httpclient + test + + + org.wso2.carbon + org.wso2.carbon.securevault + + test + + + org.wso2.securevault + org.wso2.securevault + test + + + xerces.wso2 + xercesImpl + test + + + org.apache.axis2.wso2 + axis2 + test + + + org.wso2.carbon + org.wso2.carbon.queuing + test + + + javax.xml.bind + jaxb-api + test + + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java new file mode 100644 index 0000000000..9419631b5b --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper; + +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean.RoleMapping; +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean.UserStoreRoleMappingConfig; +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +public class UserStoreRoleMapper implements ServerStartupObserver { + private static final Log log = LogFactory.getLog(UserStoreRoleMapper.class); + @Override + public void completingServerStartup() { + + } + + @Override + public void completedServerStartup() { + Runnable periodicTask = new Runnable() { + public void run() { + updateRoleMapping(); + log.info("UserStoreRoleMapper executed...."); + } + }; + + ScheduledExecutorService executor = + Executors.newSingleThreadScheduledExecutor(); + + executor.scheduleAtFixedRate(periodicTask,30, 60, TimeUnit.SECONDS); + } + + private void updateRoleMapping() { + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId( + MultitenantConstants.SUPER_TENANT_ID); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + + UserStoreRoleMappingConfig config = UserStoreRoleMappingDataHolder.getInstance() + .getUserStoreRoleMappingConfigManager().getUserStoreRoleMappingConfig(); + + List roleMappings = config.getMappings(); + + if (!roleMappings.isEmpty()) { + UserStoreManager userStoreManager = + UserStoreRoleMappingDataHolder.getInstance().getRealmService() + .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager(); + + for (RoleMapping mapping : roleMappings) { + String[] users = userStoreManager.getUserListOfRole(mapping.getSecondaryRole()); + if (users != null && users.length > 0) { + List primaryRoles = mapping.getInternalRoles(); + for (String role : primaryRoles) { + if (userStoreManager.isExistingRole(role)) { + String[] existingUsers = userStoreManager.getUserListOfRole(role); + List existingUserList = new ArrayList<>(Arrays.asList(existingUsers)); + List newUserList = new ArrayList<>(); + for (String user: users) { + if (existingUserList.contains(user)) { + // if contains, remove from existing list + existingUserList.remove(user); + } else { + // new user + newUserList.add(user); + } + } + + List deleteUserList = new ArrayList<>(); + if (!existingUserList.isEmpty()) { + String domain = mapping.getSecondaryRole().substring(0,mapping.getSecondaryRole().indexOf("/")); + for (String user : existingUserList) { + if (user.startsWith(domain.toUpperCase())) { + deleteUserList.add(user); + } + } + } + + // update user list of given role + if (!newUserList.isEmpty() || !deleteUserList.isEmpty()) { + userStoreManager.updateUserListOfRole(role, deleteUserList.toArray(new String[0]), newUserList.toArray(new String[0])); + log.info("update user role mapping executed....."); + } + } + } + } + } + } + } catch (Exception e) { + log.error("Error while getting user store...", e); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMappingConfigManager.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMappingConfigManager.java new file mode 100644 index 0000000000..1c4b5eac16 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMappingConfigManager.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper; + +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean.UserStoreRoleMappingConfig; +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.exception.UserStoreRoleMapperException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; + +public class UserStoreRoleMappingConfigManager { + + private static final Log log = LogFactory.getLog(UserStoreRoleMappingConfigManager.class); + private static final String USERSTORE_ROLE_MAPPING_CONFIG_PATH = CarbonUtils.getCarbonConfigDirPath() + + File.separator + "user-store-role-mapping-config.xml"; + + private final UserStoreRoleMappingConfig userStoreRoleMappingConfig; + + public UserStoreRoleMappingConfigManager() throws UserStoreRoleMapperException { + try { + File UserStoreRoleMappingConfig = new File(USERSTORE_ROLE_MAPPING_CONFIG_PATH); + Document doc = convertToDocument(UserStoreRoleMappingConfig); + JAXBContext smsContext = JAXBContext.newInstance(UserStoreRoleMappingConfig.class); + Unmarshaller unmarshaller = smsContext.createUnmarshaller(); + this.userStoreRoleMappingConfig = (UserStoreRoleMappingConfig) unmarshaller.unmarshal(doc); + } catch (JAXBException e) { + String msg = "Error occurred while initializing config '" + USERSTORE_ROLE_MAPPING_CONFIG_PATH + "'"; + log.error(msg, e); + throw new UserStoreRoleMapperException(msg, e); + } + } + + private static Document convertToDocument(File file) throws UserStoreRoleMapperException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + + try { + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + factory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true); + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + return docBuilder.parse(file); + } catch (Exception e) { + throw new UserStoreRoleMapperException("Error occurred while parsing " + USERSTORE_ROLE_MAPPING_CONFIG_PATH + + " file, while converting to a org.w3c.dom.Document", e); + } + } + + public UserStoreRoleMappingConfig getUserStoreRoleMappingConfig() { + return this.userStoreRoleMappingConfig; + } + +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/RoleMapping.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/RoleMapping.java new file mode 100644 index 0000000000..604c58b4a2 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/RoleMapping.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement( + name = "mapping" +) +public class RoleMapping { + private String secondaryRole; + + private List internalRoles; + + @XmlAttribute( + name = "secondaryRole" + ) + public String getSecondaryRole() { + return secondaryRole; + } + + public void setSecondaryRole(String secondaryRole) { + this.secondaryRole = secondaryRole; + } + + @XmlElementWrapper( + name = "internalRoles" + ) + @XmlElement( + name = "role" + ) + public List getInternalRoles() { + return internalRoles; + } + + public void setInternalRoles(List internalRoles) { + this.internalRoles = internalRoles; + } +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java new file mode 100644 index 0000000000..47c9164c7f --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement( + name = "UserStoreRoleMappingConfig" +) +public class UserStoreRoleMappingConfig { + + private List mappings; + + @XmlElementWrapper( + name = "mappings" + ) + @XmlElement( + name = "mapping" + ) + public List getMappings() { + return mappings; + } + + public void setMappings(List mappings) { + this.mappings = mappings; + } +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/exception/UserStoreRoleMapperException.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/exception/UserStoreRoleMapperException.java new file mode 100644 index 0000000000..72d56d202a --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/exception/UserStoreRoleMapperException.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.exception; + +public class UserStoreRoleMapperException extends Exception { + + public UserStoreRoleMapperException(String msg, Exception e) { + super(msg, e); + } +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java new file mode 100644 index 0000000000..46fd7aea2e --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal; + +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMappingConfigManager; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.ConfigurationContextService; + +public class UserStoreRoleMappingDataHolder { + + private ConfigurationContextService configurationContextService; + private RealmService realmService; + private UserStoreRoleMappingConfigManager userStoreRoleMappingConfigManager; + + private static final UserStoreRoleMappingDataHolder thisInstance = new UserStoreRoleMappingDataHolder(); + + private UserStoreRoleMappingDataHolder() {} + + public static UserStoreRoleMappingDataHolder getInstance() { + return thisInstance; + } + + public ConfigurationContextService getConfigurationContextService() { + return configurationContextService; + } + + public void setConfigurationContextService(ConfigurationContextService configurationContextService) { + this.configurationContextService = configurationContextService; + } + + public UserStoreManager getUserStoreManager() throws UserStoreException { + if (realmService == null) { + String msg = "Realm service has not initialized."; + throw new IllegalStateException(msg); + } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + return realmService.getTenantUserRealm(tenantId).getUserStoreManager(); + } + + public UserRealm getUserRealm() throws UserStoreException { + UserRealm realm; + if (realmService == null) { + throw new IllegalStateException("Realm service not initialized"); + } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + realm = realmService.getTenantUserRealm(tenantId); + return realm; + } + + public RealmService getRealmService() { + return realmService; + } + + public void setRealmService(RealmService realmService) { + this.realmService = realmService; + } + + public UserStoreRoleMappingConfigManager getUserStoreRoleMappingConfigManager() { + return userStoreRoleMappingConfigManager; + } + + public void setUserStoreRoleMappingConfigManager(UserStoreRoleMappingConfigManager userStoreRoleMappingConfigManager) { + this.userStoreRoleMappingConfigManager = userStoreRoleMappingConfigManager; + } +} diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java new file mode 100644 index 0000000000..7e9fb49535 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal; + +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMapper; +import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMappingConfigManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingServiceComponent" + * immediate="true" + * @scr.reference name="user.realmservice.default" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" + * @scr.reference name="config.context.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" + * cardinality="0..1" + * policy="dynamic" + * bind="setConfigurationContextService" + * unbind="unsetConfigurationContextService" + */ +public class UserStoreRoleMappingServiceComponent { + + private static final Log log = LogFactory.getLog(UserStoreRoleMappingServiceComponent.class); + + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Role Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); + UserStoreRoleMapper mapper = new UserStoreRoleMapper(); + bundleContext.registerService(ServerStartupObserver.class.getName(), mapper, null); + UserStoreRoleMappingDataHolder.getInstance().setUserStoreRoleMappingConfigManager(new UserStoreRoleMappingConfigManager()); + if (log.isDebugEnabled()) { + log.debug("Role Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Role Management Service Component", e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Role Manager Service Component"); + } + } + + protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { + if (log.isDebugEnabled()) { + log.debug("Setting ConfigurationContextService"); + } + + UserStoreRoleMappingDataHolder.getInstance().setConfigurationContextService(configurationContextService); + } + + protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { + if (log.isDebugEnabled()) { + log.debug("Un-setting ConfigurationContextService"); + } + UserStoreRoleMappingDataHolder.getInstance().setConfigurationContextService(null); + } + + /** + * Sets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void setRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Setting Realm Service"); + } + UserStoreRoleMappingDataHolder.getInstance().setRealmService(realmService); + } + + /** + * Unsets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void unsetRealmService(RealmService realmService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Realm Service"); + } + UserStoreRoleMappingDataHolder.getInstance().setRealmService(null); + } +} diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 5dbed0b826..814cfe0181 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -43,6 +43,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.logger io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager io.entgra.device.mgt.core.device.mgt.extensions.stateengine + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml new file mode 100644 index 0000000000..d06c47c7a8 --- /dev/null +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -0,0 +1,105 @@ + + + + + + + io.entgra.device.mgt.core + device-mgt-extensions-feature + 5.0.31-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.feature + pom + Entgra IoT - User store role mapper feature + http://entgra.io + + This feature contains the core bundles required for user store role mapping functionality + + + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + + org.eclipse.equinox.p2.type.group:true + + + + + + io.entgra.device.mgt.core:io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper:${io.entgra.device.mgt.core.version} + + + + + + + + + diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/build.properties b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/build.properties new file mode 100644 index 0000000000..89aee3ff76 --- /dev/null +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/build.properties @@ -0,0 +1,19 @@ +# +# Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +# +# Entgra (Pvt) Ltd. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +custom = true diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml new file mode 100644 index 0000000000..00e63a3fca --- /dev/null +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml @@ -0,0 +1,38 @@ + + + + + + + branch_css + lb_03 + ld_03_01 + ld_03_02 + + + + + branch_css + lb_05 + ld_05_01 + ld_05_02 + + + + \ No newline at end of file diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/p2.inf b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/p2.inf new file mode 100644 index 0000000000..31d07a5e20 --- /dev/null +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/p2.inf @@ -0,0 +1,2 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper_${feature.version}/conf/user-store-role-mapping-config.xml,target:${installFolder}/../../../repository/conf/user-store-role-mapping-config.xml,overwrite:true);\ diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 36516f0fe8..e941289b7d 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -41,6 +41,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature io.entgra.device.mgt.core.device.mgt.extensions.logger.feature io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper diff --git a/pom.xml b/pom.xml index eeee195f4a..627b0479fe 100644 --- a/pom.xml +++ b/pom.xml @@ -1631,6 +1631,11 @@ io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager ${io.entgra.device.mgt.core.version} + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper + ${io.entgra.device.mgt.core.version} + io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.extensions.logger From 53c48d87ca926957b5e166f2caf185d8bbc2dacc Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 24 Oct 2023 16:14:14 +0530 Subject: [PATCH 119/157] user store role mapping feature --- .../main/resources/conf/user-store-role-mapping-config.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml index 00e63a3fca..dabe881afb 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml @@ -18,7 +18,7 @@ --> - + branch_css lb_03 @@ -26,7 +26,7 @@ ld_03_02 - + branch_css lb_05 From 3d159c0111d1502a4c81ffecab7e1956bc4f6b8a Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 24 Oct 2023 16:24:04 +0530 Subject: [PATCH 120/157] user store role mapping feature --- .../role/mapper/UserStoreRoleMapper.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java index 9419631b5b..9636fa442e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java @@ -75,38 +75,40 @@ public class UserStoreRoleMapper implements ServerStartupObserver { .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager(); for (RoleMapping mapping : roleMappings) { - String[] users = userStoreManager.getUserListOfRole(mapping.getSecondaryRole()); - if (users != null && users.length > 0) { - List primaryRoles = mapping.getInternalRoles(); - for (String role : primaryRoles) { - if (userStoreManager.isExistingRole(role)) { - String[] existingUsers = userStoreManager.getUserListOfRole(role); - List existingUserList = new ArrayList<>(Arrays.asList(existingUsers)); - List newUserList = new ArrayList<>(); - for (String user: users) { - if (existingUserList.contains(user)) { - // if contains, remove from existing list - existingUserList.remove(user); - } else { - // new user - newUserList.add(user); + if (userStoreManager.isExistingRole(mapping.getSecondaryRole())) { + String[] users = userStoreManager.getUserListOfRole(mapping.getSecondaryRole()); + if (users != null && users.length > 0) { + List primaryRoles = mapping.getInternalRoles(); + for (String role : primaryRoles) { + if (userStoreManager.isExistingRole(role)) { + String[] existingUsers = userStoreManager.getUserListOfRole(role); + List existingUserList = new ArrayList<>(Arrays.asList(existingUsers)); + List newUserList = new ArrayList<>(); + for (String user : users) { + if (existingUserList.contains(user)) { + // if contains, remove from existing list + existingUserList.remove(user); + } else { + // new user + newUserList.add(user); + } } - } - List deleteUserList = new ArrayList<>(); - if (!existingUserList.isEmpty()) { - String domain = mapping.getSecondaryRole().substring(0,mapping.getSecondaryRole().indexOf("/")); - for (String user : existingUserList) { - if (user.startsWith(domain.toUpperCase())) { - deleteUserList.add(user); + List deleteUserList = new ArrayList<>(); + if (!existingUserList.isEmpty()) { + String domain = mapping.getSecondaryRole().substring(0, mapping.getSecondaryRole().indexOf("/")); + for (String user : existingUserList) { + if (user.startsWith(domain.toUpperCase())) { + deleteUserList.add(user); + } } } - } - // update user list of given role - if (!newUserList.isEmpty() || !deleteUserList.isEmpty()) { - userStoreManager.updateUserListOfRole(role, deleteUserList.toArray(new String[0]), newUserList.toArray(new String[0])); - log.info("update user role mapping executed....."); + // update user list of given role + if (!newUserList.isEmpty() || !deleteUserList.isEmpty()) { + userStoreManager.updateUserListOfRole(role, deleteUserList.toArray(new String[0]), newUserList.toArray(new String[0])); + log.info("update user role mapping executed....."); + } } } } From cb5d672583c4138faa6296e3b865c318db6c4f28 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 24 Oct 2023 16:32:53 +0530 Subject: [PATCH 121/157] user store role mapping feature --- .../extensions/userstore/role/mapper/UserStoreRoleMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java index 9636fa442e..40b3beb4cc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java @@ -116,7 +116,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver { } } } catch (Exception e) { - log.error("Error while getting user store...", e); + log.error("Error while getting user store..." + e.getMessage()); } finally { PrivilegedCarbonContext.endTenantFlow(); } From d67acc3d506197931931ce4e3a18965dd091c063 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 24 Oct 2023 17:21:51 +0530 Subject: [PATCH 122/157] introduce configs and added heart beat logic --- .../pom.xml | 9 +++- .../role/mapper/UserStoreRoleMapper.java | 41 +++++++++++++------ .../bean/UserStoreRoleMappingConfig.java | 38 +++++++++++++++++ .../UserStoreRoleMappingDataHolder.java | 11 ++++- .../UserStoreRoleMappingServiceComponent.java | 23 +++++++++++ .../conf/user-store-role-mapping-config.xml | 13 +++--- 6 files changed, 112 insertions(+), 23 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 902f176763..40ac6610bd 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -75,7 +75,9 @@ org.wso2.carbon.user.api, org.wso2.carbon.user.core.common, org.wso2.carbon.user.core.service, - org.wso2.carbon.user.mgt.common + org.wso2.carbon.user.mgt.common, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception !io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal, @@ -219,5 +221,10 @@ jaxb-api test + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon + provided + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java index 40b3beb4cc..59e3d352c7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/UserStoreRoleMapper.java @@ -20,10 +20,12 @@ package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper; import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean.RoleMapping; import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.bean.UserStoreRoleMappingConfig; import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingDataHolder; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; @@ -36,6 +38,8 @@ import java.util.concurrent.TimeUnit; public class UserStoreRoleMapper implements ServerStartupObserver { private static final Log log = LogFactory.getLog(UserStoreRoleMapper.class); + + private UserStoreRoleMappingConfig config = null; @Override public void completingServerStartup() { @@ -43,17 +47,31 @@ public class UserStoreRoleMapper implements ServerStartupObserver { @Override public void completedServerStartup() { - Runnable periodicTask = new Runnable() { - public void run() { - updateRoleMapping(); - log.info("UserStoreRoleMapper executed...."); - } - }; - ScheduledExecutorService executor = - Executors.newSingleThreadScheduledExecutor(); + config = UserStoreRoleMappingDataHolder.getInstance() + .getUserStoreRoleMappingConfigManager().getUserStoreRoleMappingConfig(); + + try { + if ((config.isEnabled() && + UserStoreRoleMappingDataHolder.getInstance().getHeartBeatService().isTaskPartitioningEnabled() && + UserStoreRoleMappingDataHolder.getInstance().getHeartBeatService().isQualifiedToExecuteTask()) + || (config.isEnabled() && + !UserStoreRoleMappingDataHolder.getInstance().getHeartBeatService().isTaskPartitioningEnabled())) { + Runnable periodicTask = new Runnable() { + public void run() { + updateRoleMapping(); + log.info("UserStoreRoleMapper executed...."); + } + }; - executor.scheduleAtFixedRate(periodicTask,30, 60, TimeUnit.SECONDS); + ScheduledExecutorService executor = + Executors.newSingleThreadScheduledExecutor(); + + executor.scheduleAtFixedRate(periodicTask, config.getInitialDelayInSeconds(), config.getPeriodInSeconds(), TimeUnit.SECONDS); + } + } catch (HeartBeatManagementException e) { + log.error("Error while accessing heart beat service " + e.getMessage()); + } } private void updateRoleMapping() { @@ -64,9 +82,6 @@ public class UserStoreRoleMapper implements ServerStartupObserver { PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - UserStoreRoleMappingConfig config = UserStoreRoleMappingDataHolder.getInstance() - .getUserStoreRoleMappingConfigManager().getUserStoreRoleMappingConfig(); - List roleMappings = config.getMappings(); if (!roleMappings.isEmpty()) { @@ -115,7 +130,7 @@ public class UserStoreRoleMapper implements ServerStartupObserver { } } } - } catch (Exception e) { + } catch (UserStoreException e) { log.error("Error while getting user store..." + e.getMessage()); } finally { PrivilegedCarbonContext.endTenantFlow(); diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java index 47c9164c7f..58e287a9ee 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/bean/UserStoreRoleMappingConfig.java @@ -27,8 +27,24 @@ import java.util.List; ) public class UserStoreRoleMappingConfig { + private boolean enabled; private List mappings; + private long initialDelayInSeconds; + + private long periodInSeconds; + + @XmlElement( + name = "enabled" + ) + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + @XmlElementWrapper( name = "mappings" ) @@ -42,4 +58,26 @@ public class UserStoreRoleMappingConfig { public void setMappings(List mappings) { this.mappings = mappings; } + + @XmlElement( + name = "initialDelayInSeconds" + ) + public long getInitialDelayInSeconds() { + return initialDelayInSeconds; + } + + public void setInitialDelayInSeconds(long initialDelayInSeconds) { + this.initialDelayInSeconds = initialDelayInSeconds; + } + + @XmlElement( + name = "periodInSeconds" + ) + public long getPeriodInSeconds() { + return periodInSeconds; + } + + public void setPeriodInSeconds(long periodInSeconds) { + this.periodInSeconds = periodInSeconds; + } } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java index 46fd7aea2e..71d3c32edd 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingDataHolder.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal; import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMappingConfigManager; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; @@ -31,7 +32,7 @@ public class UserStoreRoleMappingDataHolder { private ConfigurationContextService configurationContextService; private RealmService realmService; private UserStoreRoleMappingConfigManager userStoreRoleMappingConfigManager; - + private HeartBeatManagementService heartBeatService; private static final UserStoreRoleMappingDataHolder thisInstance = new UserStoreRoleMappingDataHolder(); private UserStoreRoleMappingDataHolder() {} @@ -82,4 +83,12 @@ public class UserStoreRoleMappingDataHolder { public void setUserStoreRoleMappingConfigManager(UserStoreRoleMappingConfigManager userStoreRoleMappingConfigManager) { this.userStoreRoleMappingConfigManager = userStoreRoleMappingConfigManager; } + + public HeartBeatManagementService getHeartBeatService() { + return heartBeatService; + } + + public void setHeartBeatService(HeartBeatManagementService heartBeatService) { + this.heartBeatService = heartBeatService; + } } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java index 7e9fb49535..2471c18403 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.in import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMapper; import io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.UserStoreRoleMappingConfigManager; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -43,6 +44,12 @@ import org.wso2.carbon.utils.ConfigurationContextService; * policy="dynamic" * bind="setConfigurationContextService" * unbind="unsetConfigurationContextService" + * @scr.reference name="entgra.heart.beat.service" + * interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService" + * cardinality="0..1" + * policy="dynamic" + * bind="setHeartBeatService" + * unbind="unsetHeartBeatService" */ public class UserStoreRoleMappingServiceComponent { @@ -109,4 +116,20 @@ public class UserStoreRoleMappingServiceComponent { } UserStoreRoleMappingDataHolder.getInstance().setRealmService(null); } + + @SuppressWarnings("unused") + protected void setHeartBeatService(HeartBeatManagementService heartBeatService) { + if (log.isDebugEnabled()) { + log.debug("Setting heart beat service"); + } + UserStoreRoleMappingDataHolder.getInstance().setHeartBeatService(heartBeatService); + } + + @SuppressWarnings("unused") + protected void unsetHeartBeatService(HeartBeatManagementService heartBeatManagementService) { + if (log.isDebugEnabled()) { + log.debug("Removing heart beat service"); + } + UserStoreRoleMappingDataHolder.getInstance().setHeartBeatService(null); + } } diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml index dabe881afb..16316f47ad 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/resources/conf/user-store-role-mapping-config.xml @@ -17,21 +17,18 @@ ~ under the License. --> + false + 30 + 3600 - branch_css - lb_03 - ld_03_01 - ld_03_02 + Internal/branch_css - branch_css - lb_05 - ld_05_01 - ld_05_02 + Internal/branch_css From 29132ba84d1ec8e6198b074ef4894e1c86481158 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 24 Oct 2023 18:43:01 +0530 Subject: [PATCH 123/157] Fix permission updating issue --- .../apimgt/webapp/publisher/APIPublisherServiceImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index f163859572..e419bb3751 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -732,16 +732,15 @@ public class APIPublisherServiceImpl implements APIPublisherService { } private void updatePermissions(String role, List permissions) throws UserStoreException { + if (role == null || permissions == null) return; AuthorizationManager authorizationManager = APIPublisherDataHolder.getInstance().getUserRealm() .getAuthorizationManager(); if (log.isDebugEnabled()) { log.debug("Updating the role '" + role + "'"); } - if (permissions != null && !permissions.isEmpty()) { - authorizationManager.clearRoleAuthorization(role); - for (String permission : permissions) { - authorizationManager.authorizeRole(role, permission, CarbonConstants.UI_PERMISSION_ACTION); - } + authorizationManager.clearRoleAuthorization(role); + for (String permission : permissions) { + authorizationManager.authorizeRole(role, permission, CarbonConstants.UI_PERMISSION_ACTION); } } From 0f1f236c91bbd72bfd44f7170119d271dbfd1cc4 Mon Sep 17 00:00:00 2001 From: shamalka Date: Tue, 24 Oct 2023 20:50:39 +0530 Subject: [PATCH 124/157] Add storeVisibilityEnabled to device types --- .../mgt/common/type/mgt/DeviceTypeMetaDefinition.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java index 7cbd12fa32..e89fe58ab2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java @@ -42,6 +42,8 @@ public class DeviceTypeMetaDefinition { private boolean longLivedToken = false; + private boolean storeVisibilityEnabled = true; + public String getDescription() { return description; } @@ -122,4 +124,12 @@ public class DeviceTypeMetaDefinition { public void setLongLivedToken(boolean longLivedToken) { this.longLivedToken = longLivedToken; } + + public boolean isStoreVisibilityEnabled() { + return storeVisibilityEnabled; + } + + public void setStoreVisibilityEnabled(boolean storeVisibilityEnabled) { + this.storeVisibilityEnabled = storeVisibilityEnabled; + } } From d8a2f72d8f8f7275f336e959df0f1f9d087b73b4 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 25 Oct 2023 09:58:53 +0530 Subject: [PATCH 125/157] Add resource refreshing logic --- .../core/apimgt/webapp/publisher/APIPublisherServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index e419bb3751..db7e58a32b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -741,6 +741,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { authorizationManager.clearRoleAuthorization(role); for (String permission : permissions) { authorizationManager.authorizeRole(role, permission, CarbonConstants.UI_PERMISSION_ACTION); + authorizationManager.refreshAllowedRolesForResource(permission); } } From 548aba7da99eced86bf5ad7d352193ac6ee58aa8 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 25 Oct 2023 08:35:24 +0000 Subject: [PATCH 126/157] revert b9b2c97841e2e8ca8875c6cccaa54b6c8de155bd revert Added query for set foreign key --- .../src/test/resources/sql/h2.sql | 4 +--- .../src/main/resources/dbscripts/cdm/h2.sql | 5 +---- .../src/main/resources/dbscripts/cdm/mssql.sql | 4 +--- .../src/main/resources/dbscripts/cdm/mysql.sql | 4 +--- .../src/main/resources/dbscripts/cdm/oracle.sql | 4 +--- .../src/main/resources/dbscripts/cdm/postgresql.sql | 4 +--- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql index 952fe1a099..bee98d7dbf 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/sql/h2.sql @@ -39,7 +39,5 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) ON DELETE NO ACTION ON UPDATE NO ACTION + PRIMARY KEY (ID) ); \ No newline at end of file diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 0547f9ca79..b1f68e0570 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -15,10 +15,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) - + PRIMARY KEY (ID) ); CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index a00068c5f9..7090ca20ff 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -25,9 +25,7 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, -PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) +PRIMARY KEY (ID) ); IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE')) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 8107b71583..5e33d6b2b4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -19,9 +19,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( TENANT_ID INTEGER DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR(500) DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) + PRIMARY KEY (ID) )ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS DM_GROUP ( diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 043663a706..035f31d31d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -30,9 +30,7 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) + PRIMARY KEY (ID) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 3bad8667e2..1b9393885c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -843,8 +843,6 @@ CREATE TABLE DM_DEVICE_CERTIFICATE ( TENANT_ID NUMBER(10) DEFAULT 0, DEVICE_IDENTIFIER VARCHAR(300), USERNAME VARCHAR2(500) DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_CERTIFICATE FOREIGN KEY (DEVICE_IDENTIFIER) - REFERENCES DM_DEVICE (DEVICE_IDENTIFICATION) + PRIMARY KEY (ID) ) From 0e769a8dd919511f8a661f6f86d70093f4fb597e Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 25 Oct 2023 15:28:43 +0530 Subject: [PATCH 127/157] [maven-release-plugin] prepare release v5.0.31 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 134 files changed, 136 insertions(+), 136 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 649a3a26e3..397e8b20a5 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 72b6963702..b8d7dcc76e 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 059a9bc268..293ffd4e01 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 7bc9db7e86..3eec78426f 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index bc9ce9529f..a3f3df3e97 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index e117cb7d5a..cedb0e1cfb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index c446adc7ce..83c4cc0437 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 07c7081238..2d70e3a3df 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 1b5b4157f1..6b5a7102df 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 5a0dcfd826..dadb5e19fb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 104c678198..b72b51383b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 2b2272de5f..e4336c9f4b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index c6ebef438f..cbd012cce6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index fb96006ff6..db01f07c0a 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 25ca18c81b..91dfa14c20 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 5a713e5f5e..208af35a8b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index b2feff02a1..8208d45738 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index f9406c6ebd..d986fb2005 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 45bf67757a..745f1d7ffc 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index fc26b8fab2..f5b9f04db8 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 78b9bcf6ae..950cf2f7d9 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 54328884f0..deceaed5c3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index e724331237..bcd4efc913 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index f294a54405..dfca53637e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 510c445c39..d281dfb472 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 88b203d3e2..285d2b51de 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 976477a4f8..cc30173892 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 9a60f537f4..36d6dd60f3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 7c500e97b0..1f3811e6e6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index e499a0e780..3f65875b42 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 40ac6610bd..645ef9d3aa 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 814cfe0181..81fc6f6fd5 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 48128f3dd7..040b9183b0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 6deb7e2a38..acc091f029 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 9518c5392b..b476fe32c0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 82c807c7e3..048b85d03d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index aae8132819..380c718954 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index a7f333af0a..ddcff84c68 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 1113b75870..33d7ae7b7f 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 8983ad2349..f6e448933c 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 5bf8605825..fcd6923252 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 87d89e8e68..98462af662 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 2777b27949..ae73a858ed 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 8855272bb3..7bf75380b5 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 9382abf2cb..e83c967180 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.31-SNAPSHOT + 5.0.31 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 6ade814e79..01332dec86 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index da557dab90..f3273467f8 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 16ed95de0b..f72bec2068 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index e1d5ba34d7..671108ec20 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 780e2b5bfb..5e9e29f856 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 730b185024..3aad7e8a45 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 732e28e4da..29ae758231 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 36e73567d0..0f55841089 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index ad2c4fca02..2946fdf1ea 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 19bacdf54d..14bb5c69ef 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 3fc9ee0375..9db92bbaaa 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 1410aaa765..6db90da755 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index ff891a074c..30a14dc35d 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 83a3462056..cc3815dac5 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index a14fb2023b..053c60551a 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index ebc0ec502c..2fa2e3de34 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 283d376978..c0ed783687 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 632fabe6c2..9a01ac1e5c 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 3b1cbd62c7..ad9c960ed9 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 784635f0ed..fe05c25d4d 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index f30347a9d3..c2f41f54e9 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 00911ea4e6..8ab914268c 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index ed91dae32d..140e6246f4 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index ab314cd805..8fdfd756b4 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 911f695989..c113978551 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index abbf64776e..2a85bc1612 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 6e588df279..d4d7839aa3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 5a5ef82b68..c9a5b3e512 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index fdd1b290cf..3dd9a4f8bb 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index f9aa06177a..97896b9a13 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index d5856bf8a4..170f7eddb1 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 195d9d610e..718cce9b5a 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 907c8e8c75..b203dfdaa7 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index f7eaeaeef9..cf5045e088 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index eb37dae2fe..58ea2ed3a8 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index c910b2774c..88436b5879 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 9ac48cd779..ea0c8676de 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 85d4212606..770abeb559 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 8764cf8b6a..51da86ee44 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index db886b2065..51f77427f5 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 911772e59a..c45e84fa9d 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index b64abe8da0..db4c467c03 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 1155b808c2..06d4169e5e 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 625d8eb508..fa8436dcf7 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 208ef8b477..066e63e6d5 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index f2f4d90c60..af82be9065 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 8bfc5f955b..3be3ac3f53 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 8572d7620f..96e8f8a6d5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index da6c048c03..6489ae99cc 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index d239526692..e63118e867 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index f1219c71a1..1a864570bd 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 14157aa28d..6f164ab960 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 8d1e07c7b5..9c31fc3e59 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 179376353c..e4f5853437 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index d06c47c7a8..2a41cd86b2 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index e941289b7d..ca685467ae 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 72eebca9e7..afd7af975b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index dffbb06221..d89928ad5d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 143c78e64e..d6044d9b75 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 450ab4bf92..1135587b45 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index fcbb28f3c4..8fec18ee09 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index cc168cb5af..15d9ce4a9e 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 1907ddfd2f..02906e0a60 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 4d2ab7d267..3e7699f12f 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index a9d93aa465..36a1c0d0ea 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 6bd87998f4..517f3fd9d8 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 30aec98c84..0146c42f41 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index bedf8aac4b..b9537c4b50 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 40efafd38e..6cc3ae32b2 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a3791b2afd..68d344530c 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index b60be2da33..784bf97c17 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index e4a31fa307..3b579c270f 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 9e70fb34d3..e7650f4231 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 3d388bd0b6..492970c02a 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 883aa53cb6..6c4dbd7cc4 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index fca80b6ce9..a1a5e20dc5 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 0eb9211c99..ce8eecc346 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 6007c3d4af..8728869ec9 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index a088484df3..d244072894 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index da352d88c5..5342d0a4f9 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 2403e63301..66731268fb 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 6f8e76a66e..9145edaece 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index de86b62306..21be1e21d8 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index f5209b00b5..3286ffef1d 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 014bf54fd9..32a6e53172 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 0c614753c6..964cc6f6c5 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 5d45e37d10..caee31ebf5 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.31-SNAPSHOT + 5.0.31 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index ca35efa3ed..b25c1afc63 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31-SNAPSHOT + 5.0.31 ../../pom.xml diff --git a/pom.xml b/pom.xml index 627b0479fe..c20d8c17bf 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.31-SNAPSHOT + 5.0.31 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1884,7 +1884,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - HEAD + v5.0.31 @@ -2089,7 +2089,7 @@ 1.2.11.wso2v10 - 5.0.31-SNAPSHOT + 5.0.31 4.7.35 From 6b948c9989d9fda793c6444a1a3b02f870b1541d Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 25 Oct 2023 15:28:51 +0530 Subject: [PATCH 128/157] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 134 files changed, 136 insertions(+), 136 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 397e8b20a5..fd676b35a4 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index b8d7dcc76e..2899a5b950 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 293ffd4e01..0f9c44a295 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 3eec78426f..57d2528979 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index a3f3df3e97..b64fbba6c4 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index cedb0e1cfb..766c954dae 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 83c4cc0437..ddc4161167 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 2d70e3a3df..9d5818f314 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 6b5a7102df..858acad319 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index dadb5e19fb..e65b4e8636 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index b72b51383b..6a69e4d51f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index e4336c9f4b..c1c289a699 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index cbd012cce6..07385d104f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index db01f07c0a..2ff7fe6fea 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 91dfa14c20..db830205d0 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 208af35a8b..83146e9da2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 8208d45738..690e7d0f5c 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index d986fb2005..fa8d78029e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 745f1d7ffc..e902db93cd 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index f5b9f04db8..73450a139c 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 950cf2f7d9..357ca9a65e 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index deceaed5c3..b740a970e1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index bcd4efc913..41dba7760d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index dfca53637e..bc37947d52 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index d281dfb472..536fd8008b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 285d2b51de..e232e0c35d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index cc30173892..cff241f967 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 36d6dd60f3..b64598accd 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 1f3811e6e6..a93c5be96b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 3f65875b42..8e0241d4a7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 645ef9d3aa..d207e49a81 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 81fc6f6fd5..0c0bbab66d 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 040b9183b0..1f59e29836 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index acc091f029..19c8479b6d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index b476fe32c0..09928ad20a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 048b85d03d..e05ba43b6c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 380c718954..28fad52730 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index ddcff84c68..358f41cf05 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 33d7ae7b7f..7f5dce145e 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index f6e448933c..0d7d7e9799 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index fcd6923252..ef42f13e42 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 98462af662..179df09ea3 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index ae73a858ed..c3f21bd9c7 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 7bf75380b5..f7e3ba2ab5 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index e83c967180..35eca267eb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.31 + 5.0.32-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 01332dec86..077e8ea5d1 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index f3273467f8..45ed95f3c5 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index f72bec2068..47fc30fbc7 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 671108ec20..f03f1f75f8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 5e9e29f856..afdfa4c281 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 3aad7e8a45..a3bcd42250 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 29ae758231..28baf9639a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 0f55841089..3c53c5fb4e 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 2946fdf1ea..eab3ba6c19 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 14bb5c69ef..90fe81295b 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 9db92bbaaa..536ad2c6d6 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 6db90da755..a9601027df 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 30a14dc35d..6bfb639310 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index cc3815dac5..6d37a0779e 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 053c60551a..3163580710 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 2fa2e3de34..34a44fe13a 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index c0ed783687..337b71b193 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 9a01ac1e5c..57185312c7 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index ad9c960ed9..57959f08f0 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index fe05c25d4d..702cdb44f7 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index c2f41f54e9..604f05780f 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 8ab914268c..5b2a0aad69 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 140e6246f4..2e59d66fe1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 8fdfd756b4..5edc3639b3 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index c113978551..bcaee05959 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 2a85bc1612..505d5fc780 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index d4d7839aa3..85d53a4015 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index c9a5b3e512..44f5284c47 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 3dd9a4f8bb..4105b4a860 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 97896b9a13..fc70dacffe 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 170f7eddb1..988a78862b 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 718cce9b5a..da76e639bb 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index b203dfdaa7..1c7202163a 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index cf5045e088..5357a9cb84 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 58ea2ed3a8..91c4aa355d 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 88436b5879..47f34e3b85 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index ea0c8676de..47e95adaa3 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 770abeb559..064c378248 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 51da86ee44..11a6e19252 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 51f77427f5..17053a76ba 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index c45e84fa9d..c1644c3752 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index db4c467c03..8d2091e4a5 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 06d4169e5e..031d219c41 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index fa8436dcf7..c8806ac96c 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 066e63e6d5..c1aa0551c3 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index af82be9065..8515af2950 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 3be3ac3f53..ee570e8f80 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 96e8f8a6d5..d5c0e68089 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 6489ae99cc..b30fa580b2 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index e63118e867..3b9047b9b4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 1a864570bd..c956b415ff 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 6f164ab960..29c0e5855d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 9c31fc3e59..0156cfd604 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index e4f5853437..38530519d1 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 2a41cd86b2..6d11422d9e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index ca685467ae..c7ceead24f 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index afd7af975b..40a2173ae4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index d89928ad5d..f99531fee4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index d6044d9b75..84f52b673d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 1135587b45..7e42f904d1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 8fec18ee09..b8d34017cf 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 15d9ce4a9e..6f9b9f9b85 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 02906e0a60..b92ad9882b 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 3e7699f12f..4a87b249da 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 36a1c0d0ea..2ab8490d40 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 517f3fd9d8..833a928979 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 0146c42f41..923eb42aa1 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index b9537c4b50..b711ecb589 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 6cc3ae32b2..e03eedf1b9 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 68d344530c..5f2b3aad0b 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 784bf97c17..fdbc51491d 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 3b579c270f..9dcd8d63ad 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index e7650f4231..08e4626d41 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 492970c02a..fa3f764580 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 6c4dbd7cc4..d54478c608 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index a1a5e20dc5..c914d3339b 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index ce8eecc346..921a902e5d 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 8728869ec9..4522cca175 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index d244072894..6764706510 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 5342d0a4f9..5fdf88c14f 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 66731268fb..ab0d07e928 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 9145edaece..3f86fa9f64 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 21be1e21d8..4e94cf999b 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 3286ffef1d..13762bd6b6 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 32a6e53172..93ad132316 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 964cc6f6c5..f5f3004e70 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index caee31ebf5..4181721142 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.31 + 5.0.32-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index b25c1afc63..9cfcd17dc2 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.31 + 5.0.32-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index c20d8c17bf..6401ed4885 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.31 + 5.0.32-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1884,7 +1884,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - v5.0.31 + HEAD @@ -2089,7 +2089,7 @@ 1.2.11.wso2v10 - 5.0.31 + 5.0.32-SNAPSHOT 4.7.35 From 2a6cdab90500974903d4efff64071516bc5f4a76 Mon Sep 17 00:00:00 2001 From: Arshana Date: Wed, 25 Oct 2023 18:16:25 +0530 Subject: [PATCH 129/157] Add missing scope dm:devices:status:change --- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 28114158a9..416c0711f3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -197,6 +197,7 @@ and:enterprise:view dm:sign-csr dm:admin:devices:view + dm:devices:status:change rm:roles:add rm:users:add rm:roles:update From 3cd6b01f4a954b0c2561a42f35b140e9e0596ccc Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 27 Oct 2023 00:46:26 +0530 Subject: [PATCH 130/157] Add certificate search by partial serial number --- .../mgt/core/dao/impl/GenericCertificateDAOImpl.java | 8 ++++---- .../mgt/core/dao/impl/OracleCertificateDAOImpl.java | 8 ++++---- .../core/dao/impl/PostgreSQLCertificateDAOImpl.java | 10 +++++----- .../mgt/core/dao/impl/SQLServerCertificateDAOImpl.java | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java index 7655e46005..3703101fd2 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java @@ -63,7 +63,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { "WHERE TENANT_ID = ?"; if (StringUtils.isNotEmpty(serialNumber)) { - sql += " AND SERIAL_NUMBER = ?"; + sql += " AND SERIAL_NUMBER LIKE ?"; } if (StringUtils.isNotEmpty(deviceIdentifier)) { @@ -79,7 +79,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 2; if (StringUtils.isNotEmpty(serialNumber)) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (StringUtils.isNotEmpty(deviceIdentifier)) { @@ -124,7 +124,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { "WHERE TENANT_ID = ? "; if (StringUtils.isNotEmpty(serialNumber)) { - query += "AND SERIAL_NUMBER = ? "; + query += "AND SERIAL_NUMBER LIKE ? "; isCertificateSerialNumberProvided = true; } @@ -144,7 +144,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 1; stmt.setInt(paramIdx++, tenantId); if (isCertificateSerialNumberProvided) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { stmt.setString(paramIdx++, deviceIdentifier); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java index 9231a0d746..31c4779dc5 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java @@ -63,7 +63,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { "FROM DM_DEVICE_CERTIFICATE " + "WHERE TENANT_ID = ? "; if (StringUtils.isNotEmpty(serialNumber)) { - query += "AND SERIAL_NUMBER = ? "; + query += "AND SERIAL_NUMBER LIKE ? "; isCertificateSerialNumberProvided = true; } @@ -83,7 +83,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 1; stmt.setInt(paramIdx++, tenantId); if (isCertificateSerialNumberProvided) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber+ "%"); } if (isCertificateDeviceIdentifierProvided) { stmt.setString(paramIdx++, deviceIdentifier); @@ -136,7 +136,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { "WHERE TENANT_ID = ?"; if (StringUtils.isNotEmpty(serialNumber)) { - sql += " AND SERIAL_NUMBER = ?"; + sql += " AND SERIAL_NUMBER LIKE ?"; } if (StringUtils.isNotEmpty(deviceIdentifier)) { @@ -152,7 +152,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 2; if (StringUtils.isNotEmpty(serialNumber)) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (StringUtils.isNotEmpty(deviceIdentifier)) { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java index e31e005f0b..55fd124a95 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java @@ -63,7 +63,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { "FROM DM_DEVICE_CERTIFICATE " + "WHERE TENANT_ID = ? "; if (StringUtils.isNotEmpty(serialNumber)) { - query += "AND SERIAL_NUMBER = ? "; + query += "AND SERIAL_NUMBER LIKE ? "; isCertificateSerialNumberProvided = true; } @@ -83,7 +83,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 1; stmt.setInt(paramIdx++, tenantId); if (isCertificateSerialNumberProvided) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { stmt.setString(paramIdx++, deviceIdentifier); @@ -136,7 +136,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { "WHERE TENANT_ID = ?"; if (StringUtils.isNotEmpty(serialNumber)) { - sql += " AND SERIAL_NUMBER = ?"; + sql += " AND SERIAL_NUMBER LIKE ?"; } if (StringUtils.isNotEmpty(deviceIdentifier)) { @@ -144,7 +144,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(username)) { - sql += " AND USERNAME ILIKE ?"; + sql += " AND USERNAME LIKE ?"; } try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -152,7 +152,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 2; if (StringUtils.isNotEmpty(serialNumber)) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (StringUtils.isNotEmpty(deviceIdentifier)) { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java index 6e0908a286..6734fcd997 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java @@ -63,7 +63,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { "FROM DM_DEVICE_CERTIFICATE " + "WHERE TENANT_ID = ? "; if (StringUtils.isNotEmpty(serialNumber)) { - query += "AND SERIAL_NUMBER = ? "; + query += "AND SERIAL_NUMBER LIKE ? "; isCertificateSerialNumberProvided = true; } @@ -83,7 +83,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 1; stmt.setInt(paramIdx++, tenantId); if (isCertificateSerialNumberProvided) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { stmt.setString(paramIdx++, deviceIdentifier); @@ -136,7 +136,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { "WHERE TENANT_ID = ?"; if (StringUtils.isNotEmpty(serialNumber)) { - sql += " AND SERIAL_NUMBER = ?"; + sql += " AND SERIAL_NUMBER LIKE ?"; } if (StringUtils.isNotEmpty(deviceIdentifier)) { @@ -152,7 +152,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 2; if (StringUtils.isNotEmpty(serialNumber)) { - stmt.setString(paramIdx++, serialNumber); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (StringUtils.isNotEmpty(deviceIdentifier)) { From caff091ff2b2a55147f0a17749cb5e1d635cf029 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Sun, 29 Oct 2023 17:05:19 +0530 Subject: [PATCH 131/157] Update tryit mail templates --- .../templates/share-product-download-url.vm | 2011 ++++++++++++++++- .../resources/email/templates/user-verify.vm | 461 +++- .../resources/email/templates/user-welcome.vm | 970 +++++++- 3 files changed, 3292 insertions(+), 150 deletions(-) diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/share-product-download-url.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/share-product-download-url.vm index befc2b3241..be994a117f 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/share-product-download-url.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/share-product-download-url.vm @@ -16,46 +16,1981 @@ under the License. *# - Experience Entgra IoT Server + Experience Entgra UEM Server - - Entgra IoT Server - - -

-
-
-
- entgra -
-
-
-

- Hi $first-name, -

-

- Thank you very much for your interest in the Entgra IoT server. Please click - here to download the latest release of the Entgra IoT server.

- -

- If you need assistance, please contact us through Entgra - contact us -

- -

- Regards, -

- -

- Entgra IoT Administrator -

-
-
-
- + + + + + + + + Entgra UEM Server + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+
+

Hi $first-name,

+

+

Welcome to your free Entgra UEM trial. Please download the product here.

+
+

To make the best use of your evaluation, here's a quick introduction to the key capabilities of our product.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+

Getting started

+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Self-guided enrollment

+
+
+ + + + + + +
+
+

Wizard-based, simple, and clear directions for the best mode of enrollment suited for your requirements.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Guided UI tour

+

+
+
+ + + + + + +
+
+

Guided walkthrough of Entgra UEM for quick navigation of available
features and functionalities.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Live chat

+

+
+
+ + + + + + +
+
+

Instant access to our support team to get answers to your questions.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+

Remote administration

+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Zero-touch enrollment

+
+
+ + + + + + +
+
+

Enroll, administer, and manage your entire device fleet remotely. Find out how to do so here.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Hierarchical grouping

+
+
+ + + + + + +
+
+

Create groups and subgroups in a hierarchical manner via our enhanced UI functionality.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Trigger operations simultaneously in a device group

+
+
+ + + + + + +
+
+

Enforce one or more operations on individual devices of an entire device group at once.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Enforceable policies for device administration

+
+
+ + + + + + + + +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Geofencing and alerts

+

+
+
+ + + + + + + + +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+

UI, analytics, reporting, and real-time processing

+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Reporting UI capabilities +

+

real-time event processing

+
+
+ + + + + + +
+
+

Demonstrative reporting UI
with a set of pre-built reports useful for EMM administration. Enables real-time complex event processing and an

+

in-house solution for batch processing so that you can create customized reports.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Grafana-based dashboards

+

+
+
+ + + + + + +
+
+

Analytics capabilities and dashboards showing useful information on devices, users, applications, operations, and policies.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Live feed

+
+
+ + + + + + +
+
+

Live feed is now available remotely for system administrators to access and track device data remotely, plus perform troubleshooting in real-time.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Per-tenant theming

+
+
+ + + + + + +
+
+

Customize your branding assets such as logos, favicons, app title/footer, etc. for a unified, personalized experience.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+

Security, privacy, and compliance

+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

GDPR compliance

+
+
+ + + + + + +
+
+

Compliant with GDPR.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Consent management

+
+
+ + + + + + +
+
+

Requires the consent of authoritative parties when signing in to the platform and enrolling devices. Cookie and privacy policies in the device management console for consent.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Device protection and security

+
+
+ + + + + + +
+
+

Fetch the device location and/or lock the device remotely. Configure devices in a manner that they become locked when passcode fail attempts exceed the limit. Offline unenrollment is possible via a special admin PIN code per device.

+
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+
+

Additional data protection

+
+
+ + + + + + +
+
+

Use enterprise-wipe to delete the enterprise portion of a device in case of device loss or theft. Clear app data of corporate apps remotely. Lock-in
devices to a given WiFi network to ensure adherence to data protection compliance regulations.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+

More resources

+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+ + +
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+ +
+ + + Blog + + +
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + +
+ + +
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+
+

That’s Entgra UEM in a nutshell. Reach out to us at evaluations@entgra.io if you have any questions.

+


Thanks for taking the time to explore Entgra UEM’s capabilities.

+


Entgra team

+
+
+ + + + + + +
+ + + + + + +
+ &#160; +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ +
+ + + + + + +
+
+

Follow Entgra on social media

+
+
+ + + + + + +
+
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + LinkedIn + +
+ + + + + + + + +
+ + X + +
+ + + + + + + + +
+ + YouTube + +
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ + + ]]> - + \ No newline at end of file diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-verify.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-verify.vm index bccc1cc0e0..c053cd889b 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-verify.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-verify.vm @@ -16,47 +16,430 @@ under the License. *# - Verify email to register with Entgra IoTS + Verify Email to Register with Entgra UEM Server - - Entgra IoT Server - - -
-
-
-
- entgra -
-
-
-

- Hi $first-name, -

-

- Congratulations!!! Thank you for registering with Entgra. Please click on the - following link to complete your registration with us. Click here. -

- -

- If you need further assistance, please contact your administrator. -

- -

- Regards, -

- -

- Entgra IoT Administrator -

-
-
-
- + + + + + + + + Entgra UEM Server + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+
+

Hi $first-name,

+


Thanks for your interest in Entgra. Please click here to complete your registration.

+


Once you verify your email address, you can check out all the features of our product.

+


Do get in touch with your administrator for any assistance at evaluations@entgra.io

+


Best wishes,
Entgra team

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ +
+ + + + + + +
+
+

Follow Entgra on social media

+
+
+ + + + + + +
+
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + LinkedIn + +
+ + + + + + + + +
+ + X + +
+ + + + + + + + +
+ + YouTube + +
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ + + ]]> -
+ \ No newline at end of file diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-welcome.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-welcome.vm index 7560594911..e8302f9ca9 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-welcome.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-welcome.vm @@ -19,80 +19,904 @@ Welcome to Entgra Evaluation Cloud - - Entgra IoT Server - - -
-
-
-
- entgra -
-
-
-

- Hi $first-name, -

-
-

- Welcome to Entgra Evaluation Cloud!! Entgra server support offers managing Android, iOS and Windows - devices along with a wide range of features that support cooperate (COPE) or personal device (BYOD) - enrollments. -

-
-
-

Access different portals

-

Your log-in credentials to any of our portals(endpoint-mgt, store, publisher) are,

-

Username: $portal-username

-

Password: password provided at registration for an evaluation account.

-

Endpoint management portal URL: $base-url-https/endpoint-mgt/

-

- This is the portal used to send operations and policies to devices and overall management of - the server. -

-

Application store portal URL: $base-url-https/store

-

- This is an in-house corporate app store where you can host all your corporate applications. - Users may browse apps and install them to their devices if the administrator has made the apps - publicly visible to users. Administrator can install, uninstall and update apps in the user - device or device groups. -

-

Application publishing portal URL: $base-url-https/publisher

-

- The portal for publishing new applications for internal use. This is the developer view of the - enterprise application store that comes with the product. -

-
-
-

Enroll a device

-

- Please find here a set of videos on how to enroll and onboard devices to our Cloud platform. - [Cloud Enrollment Guide] - When enrolling a device, Make sure to use the following log-in format: -

-

Organisation: $tenant-domain

-

Username: $agent-username

-

Password: password provided at registration.

-
-
-

- If you have any further questions, please reach out to us using your registered mail to - bizdev-group@entgra.io. Looking forward to working with you. -

-

- Best Regards, -

-

- Entgra Cloud Team -

-
-
+ + + + + + + + Entgra UEM Server + + + + + + + + + + + +
+ +
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+
+

Hi $first-name,

+

+

Thanks for registering for a free 14-day Entgra Cloud trial.

+

Entgra enables you to manage Android, iOS, and Windows devices. Our product also has a wide range of capabilities for corporate-owned (COPE) and personal device (BYOD) enrollments.

+


Listed below are some instructions to guide you.

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+

How to Access Our Portals

+
+ + + + + + +
+
+

Please use the following log-in credentials to access any of our portals.

+


Username: $portal-username
Password: Password provided at registration

+
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + +
+
+

Endpoint Management Portal

+
+
+ + + + + + +
+
+

Send operations and apply policies to devices and overall management of the server.

+
+
+ + + + + + +
+ + +
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+
+

Application Store Portal

+
+
+ + + + + + +
+
+

In-house corporate app store to host all your corporate applications. You can browse apps and install them on your devices if the apps are publicly visible to users. Administrators can install, uninstall, and update apps on devices or device groups.

+
+
+ + + + + + +
+ + +
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ + + + +
+ +
+
+ +
+ +
+
+ + +
+
+ +
+ + + + + + + +
+ + + + + + +
+ &#160; +
+
+ + + + + + +
+
+

Application Publishing Portal

+
+
+ + + + + + +
+
+

Publish new applications for internal use. This portal gives you a developer's view of the enterprise application store that comes with the product.

+
+
+ + + + + + +
+ + +
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+

How to Enroll a Device

+
+ + + + + + +
+
+

Here's the comprehensive guide to enrolling and onboarding devices.

+


View guide

+


For questions, contact us at evaluations@entgra.io from your Entgra registered email address.

+


We hope you found this guide helpful and look forward to learning more about your experiences with Entgra.

+

+


Best wishes,
Entgra team

+
+
+ + + + + + +
+ + + + + + +
+ &#160; +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+ + +
+
+ +
+ + + + + + + +
+ +
+ + + + + + +
+
+

Follow Entgra on social media

+
+
+ + + + + + +
+
+
+ + + + + + + + +
+ + Facebook + +
+ + + + + + + + +
+ + LinkedIn + +
+ + + + + + + + +
+ + X + +
+ + + + + + + + +
+ + YouTube + +
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ + + ]]> - + \ No newline at end of file From e8dd6942adf123bd42ab304628e40f96224e582c Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Sun, 29 Oct 2023 19:35:21 +0530 Subject: [PATCH 132/157] Add storeVisibilityEnabled flag to plugin device types --- .../common/spi/DeviceManagementService.java | 3 ++ .../type/mgt/DeviceTypeMetaDetails.java | 43 +++++++++++++++++++ .../DeviceManagementPluginRepository.java | 4 +- .../mgt/core/TestDeviceManagementService.java | 6 +++ .../template/DeviceTypeManagerService.java | 17 ++++++++ .../config/DeviceTypeConfiguration.java | 11 +++++ .../mock/TypeXDeviceManagementService.java | 6 +++ .../mock/TypeXDeviceManagementService.java | 6 +++ 8 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java index d847fd8f9b..b7cd91f34e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringManager; import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; /** @@ -65,4 +66,6 @@ public interface DeviceManagementService { DeviceEnrollmentInvitationDetails getDeviceEnrollmentInvitationDetails(); License getLicenseConfig(); + + DeviceTypeMetaDefinition getDeviceTypeMetaDefinition(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java new file mode 100644 index 0000000000..4084b93245 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.entgra.device.mgt.core.device.mgt.common.type.mgt; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DeviceTypeMetaDetails", propOrder = { + "storeVisibilityEnabled" +}) +public class DeviceTypeMetaDetails { + + @XmlElement(name = "storeVisibilityEnabled") + private boolean storeVisibilityEnabled; + + public boolean isStoreVisibilityEnabled() { + return storeVisibilityEnabled; + } + + public void setStoreVisibilityEnabled(boolean storeVisibilityEnabled) { + this.storeVisibilityEnabled = storeVisibilityEnabled; + } +} + + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java index c0c9dbddb1..6ad7b53c74 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java @@ -85,7 +85,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis if (isInitiated) { /* Initializing Device Management Service Provider */ provider.init(); - DeviceTypeMetaDefinition deviceTypeDefinition = null; + DeviceTypeMetaDefinition deviceTypeDefinition; if (provider instanceof DeviceTypeDefinitionProvider) { DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( provider.getType()); @@ -102,6 +102,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis if (existingProvider != null) { removeDeviceManagementProvider(provider); } + } else { + deviceTypeDefinition = provider.getDeviceTypeMetaDefinition(); } DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants, deviceTypeDefinition); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java index 516159d597..0df3bdad7e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -135,4 +136,9 @@ public class TestDeviceManagementService implements DeviceManagementService { } @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java index 049c5e6cdf..b357c94cca 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDetails; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; @@ -38,6 +39,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.ConfigProperties; import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.DeviceStatusTaskConfiguration; @@ -81,6 +83,7 @@ public class DeviceTypeManagerService implements DeviceManagementService { private DeviceTypePlatformDetails deviceTypePlatformDetails; private DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails; private GeneralConfig generalConfig; + private DeviceTypeMetaDefinition deviceTypeMetaDefinition; private boolean isRegistryBasedConfigs = false; private boolean isScheduled = false; private String notifierType; @@ -108,6 +111,8 @@ public class DeviceTypeManagerService implements DeviceManagementService { this.setDeviceEnrollmentInvitationDetails(deviceTypeConfiguration); this.licenseConfig = new License(); this.setLicenseConfig(deviceTypeConfiguration); + this.deviceTypeMetaDefinition = new DeviceTypeMetaDefinition(); + this.setDeviceTypeMetaDefinition(deviceTypeConfiguration); } @Override @@ -261,6 +266,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { return licenseConfig; } + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return deviceTypeMetaDefinition; + } + private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { if (deviceTypeConfiguration.getProvisioningConfig() != null) { boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); @@ -388,4 +398,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { licenseConfig.setText(license.getText()); } } + + public void setDeviceTypeMetaDefinition(DeviceTypeConfiguration deviceTypeConfiguration) { + DeviceTypeMetaDetails deviceTypeMetaDefinitions = deviceTypeConfiguration.getDeviceTypeMetaDetails(); + if (deviceTypeMetaDefinitions != null) { + deviceTypeMetaDefinition.setStoreVisibilityEnabled(deviceTypeMetaDefinitions.isStoreVisibilityEnabled()); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java index cf94ccc235..3d8d95b1bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitationDetails; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDetails; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import javax.xml.bind.annotation.XmlElement; @@ -93,6 +94,8 @@ public class DeviceTypeConfiguration { protected DeviceTypePlatformDetails deviceTypePlatformDetails; @XmlElement(name = "DeviceEnrollmentInvitationDetails", required = true) protected DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails; + @XmlElement(name = "DeviceTypeMetaDetails") + protected DeviceTypeMetaDetails deviceTypeMetaDetails; public DeviceTypePlatformDetails getDeviceTypePlatformDetails() { return deviceTypePlatformDetails; @@ -417,4 +420,12 @@ public class DeviceTypeConfiguration { DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails) { this.deviceEnrollmentInvitationDetails = deviceEnrollmentInvitationDetails; } + + public DeviceTypeMetaDetails getDeviceTypeMetaDetails() { + return deviceTypeMetaDetails; + } + + public void setDeviceTypeMetaDetails(DeviceTypeMetaDetails deviceTypeMetaDetails) { + this.deviceTypeMetaDetails = deviceTypeMetaDetails; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java index fd61ec4cdc..3591d9caa8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java @@ -33,6 +33,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -124,4 +125,9 @@ public class TypeXDeviceManagementService implements DeviceManagementService { @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java index 6fad650b84..db4f5d7037 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -118,4 +119,9 @@ public class TypeXDeviceManagementService implements DeviceManagementService { @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } } From fdd5a7cfcf4414be9e552835476d51ba0adc2d2e Mon Sep 17 00:00:00 2001 From: Viranga Gunarathna Date: Tue, 31 Oct 2023 11:23:55 +0530 Subject: [PATCH 133/157] change permission string for update password --- .../device/mgt/api/jaxrs/service/api/UserManagementService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java index afa5fdfc08..2b7b81b72f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java @@ -145,7 +145,7 @@ import javax.ws.rs.core.Response; description = "Adding a User", key = "um:users:cred:change", roles = {"Internal/devicemgt-user"}, - permissions = {"/login/password/update"} + permissions = {"/device-mgt/users/password/update"} ), @Scope( name = "Sending Enrollment Invitations to Users", From 28775010bc22563a2c97479a86d7e21fd2e91826 Mon Sep 17 00:00:00 2001 From: nishan Date: Tue, 31 Oct 2023 14:39:04 +0530 Subject: [PATCH 134/157] set device identifire for certificate table --- .../mgt/core/dao/impl/AbstractCertificateDAOImpl.java | 5 +++-- .../core/certificate/mgt/core/impl/CertificateGenerator.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 78ea14c99f..888b3619ca 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -53,8 +53,8 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ try { conn = this.getConnection(); stmt = conn.prepareStatement( - "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID, USERNAME)" - + " VALUES (?,?,?,?)"); + "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID, USERNAME, DEVICE_IDENTIFIER)" + + " VALUES (?,?,?,?,?)"); PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. getThreadLocalCarbonContext(); String username = threadLocalCarbonContext.getUsername(); @@ -70,6 +70,7 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ stmt.setBytes(2, bytes); stmt.setInt(3, certificate.getTenantId()); stmt.setString(4, username); + stmt.setString(5, certificate.getDeviceIdentifier()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index a8fe131c41..a692a45ab2 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -871,6 +871,7 @@ public class CertificateGenerator { new io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate(); List certificates = new ArrayList<>(); certificate.setTenantId(tenantId); + certificate.setDeviceIdentifier(commonName); certificate.setCertificate(issuedCert); certificates.add(certificate); saveCertInKeyStore(certificates); From 2d6e512fdf3a2f5189dfd22fb09175de249a4d2e Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 2 Nov 2023 11:42:58 +0530 Subject: [PATCH 135/157] Add multiple device dis-enrollment support --- .../service/api/DeviceManagementService.java | 43 +++++++++++++++ .../impl/DeviceManagementServiceImpl.java | 53 ++++++++++++++++++- .../service/impl/util/DisenrollRequest.java | 40 ++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/DisenrollRequest.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index eeb7caeeb3..357609b122 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DisenrollRequest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -1279,6 +1280,48 @@ public interface DeviceManagementService { @Size(max = 45) String deviceId); + @PUT + @Produces(MediaType.APPLICATION_JSON) + @Path("/disenroll") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Remove Multiple Devices Specified by Device IDs and Device Type", + notes = "Deletes multiple devices of the specified device type specified by their device IDs and returns the status of the deletion operation.", + tags = "Device Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "dm:devices:delete") + }) + }, + nickname = "deleteMultipleDevicesByType" + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully deleted the devices.", + response = Device.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body") + }), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while deleting devices.", + response = ErrorResponse.class) + }) + Response disenrollMultipleDevices(@ApiParam( + name = "deviceTypeWithDeviceIds", + value = "The properties to advanced search devices.", + required = true) + DisenrollRequest deviceTypeWithDeviceIds); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/device-type/{type}/features") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 1960d0e41d..881a586f82 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionMa import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DisenrollRequest; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -101,8 +102,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Properties; -import java.util.concurrent.ExecutionException; +import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ExecutionException; @Path("/devices") public class DeviceManagementServiceImpl implements DeviceManagementService { @@ -474,6 +476,55 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } + @PUT + @Override + @Path("/disenroll") + public Response disenrollMultipleDevices(DisenrollRequest deviceTypeWithDeviceIds) { + + if (deviceTypeWithDeviceIds == null) { + String errorMsg = "Invalid request. The request body must not be null."; + return Response.status(Response.Status.BAD_REQUEST).entity(errorMsg).build(); + } + DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService(); + + List successfullyDisenrolledDevices = new ArrayList<>(); + List failedToDisenrollDevices = new ArrayList<>(); + + Map> list = deviceTypeWithDeviceIds.getDeviceTypeWithDeviceIds(); + + for (Map.Entry> entry : list.entrySet()) { + String deviceType = entry.getKey(); + List deviceIds = entry.getValue(); + + for (String deviceId : deviceIds) { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); + try { + Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true); + if (persistedDevice != null) { + boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); + if (response) { + successfullyDisenrolledDevices.add(deviceIdentifier); + } else { + failedToDisenrollDevices.add(deviceIdentifier); + } + } else { + failedToDisenrollDevices.add(deviceIdentifier); + } + } catch (DeviceManagementException e) { + String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId; + log.error(msg, e); + failedToDisenrollDevices.add(deviceIdentifier); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + } + + Map> responseMap = new HashMap<>(); + responseMap.put("successfullyDisenrollDevices", successfullyDisenrolledDevices); + responseMap.put("failedToDisenrollDevices", failedToDisenrollDevices); + + return Response.status(Response.Status.OK).entity(responseMap).build(); + } @POST @Override @Path("/type/{deviceType}/id/{deviceId}/rename") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/DisenrollRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/DisenrollRequest.java new file mode 100644 index 0000000000..026866b5e1 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/DisenrollRequest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Map; + +@ApiModel(value = "DisenrollRequest", description = "Contains the multiple devices specified by device IDs") +public class DisenrollRequest { + @ApiModelProperty(name = "deviceTypeWithDeviceIds", value = "Contains the multiple devices specified by device IDs with type", + required = true) + private Map> deviceTypeWithDeviceIds; + + public Map> getDeviceTypeWithDeviceIds() { + return deviceTypeWithDeviceIds; + } + + public void setDeviceTypeWithDeviceIds(Map> deviceTypeWithDeviceIds) { + this.deviceTypeWithDeviceIds = deviceTypeWithDeviceIds; + } +} From a4bd373c978689ad2aa2d02d7d70b796a66cb728 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 3 Nov 2023 00:01:02 +0530 Subject: [PATCH 136/157] Add tenant id when inserting operation --- .../operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java index 65415c752a..c09a2d5685 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ConfigOperati import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -52,7 +53,7 @@ public class ConfigOperationMSSQLDAOImpl extends GenericOperationDAOImpl { operation.setCreatedTimeStamp(new Timestamp(new Date().getTime()).toString()); Connection connection = OperationManagementDAOFactory.getConnection(); String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " + - "INITIATED_BY, OPERATION_DETAILS) VALUES (?, ?, ?, ?, ?, ?)"; + "INITIATED_BY, OPERATION_DETAILS, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)"; try (PreparedStatement stmt = connection.prepareStatement(sql, new String[]{"id"})) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); @@ -64,6 +65,7 @@ public class ConfigOperationMSSQLDAOImpl extends GenericOperationDAOImpl { stmt.setString(4, operation.getCode()); stmt.setString(5, operation.getInitiatedBy()); stmt.setBytes(6, operationBytes); + stmt.setInt(7, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); stmt.executeUpdate(); try (ResultSet rs = stmt.getGeneratedKeys()) { int id = -1; From fe9273ab45f0a64f03857728d9d693d93c075990 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 3 Nov 2023 00:38:22 +0530 Subject: [PATCH 137/157] Search roles with partial role names --- .../mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 19009bf436..c52b40c082 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -670,7 +670,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { if ((filter == null) || filter.isEmpty()) { filter = "*"; } else { - filter += "*"; + filter = "*" + filter + "*"; } if (log.isDebugEnabled()) { log.debug("Getting the list of user roles"); From ce626327021398b1a05da23c4fae56dd7dfa863e Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 3 Nov 2023 09:44:36 +0530 Subject: [PATCH 138/157] Fix geofence search by partial name --- .../device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java | 4 ++-- .../mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java index 393a11bf20..9c560a35cc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java @@ -153,7 +153,7 @@ public abstract class AbstractGeofenceDAOImpl implements GeofenceDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(index++, tenantId); if (isNameProvided) { - stmt.setString(index++, request.getProperty(DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); + stmt.setString(index++, "%" + request.getProperty(DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); } stmt.setInt(index++, request.getRowCount()); stmt.setInt(index, request.getStartIndex()); @@ -190,7 +190,7 @@ public abstract class AbstractGeofenceDAOImpl implements GeofenceDAO { "WHERE FENCE_NAME LIKE ?" + "AND TENANT_ID = ? "; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, fenceName + "%"); + stmt.setString(1, "%" + fenceName + "%"); stmt.setInt(2, tenantId); try (ResultSet rst = stmt.executeQuery()) { geofenceData = extractGeofenceData(rst); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java index cebd70012d..d49adaa9d4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java @@ -143,7 +143,7 @@ public class GenericGeofenceDAOImpl extends AbstractGeofenceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(index++, tenantId); if (isNameProvided) { - stmt.setString(index++, request.getProperty(DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); + stmt.setString(index++, request.getProperty("%" + DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); } stmt.setInt(index++, request.getRowCount()); stmt.setInt(index, request.getStartIndex()); @@ -180,7 +180,7 @@ public class GenericGeofenceDAOImpl extends AbstractGeofenceDAOImpl { "WHERE FENCE_NAME LIKE ?" + "AND TENANT_ID = ? "; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, fenceName + "%"); + stmt.setString(1,"%" + fenceName + "%"); stmt.setInt(2, tenantId); try (ResultSet rst = stmt.executeQuery()) { geofenceData = extractGeofenceData(rst); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java index fa04264286..1a40be25bd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java @@ -71,7 +71,7 @@ public class SQLServerGeofenceDAOImpl extends AbstractGeofenceDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(index++, tenantId); if (isNameProvided) { - stmt.setString(index++, request.getProperty(DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); + stmt.setString(index++, "%" + request.getProperty(DeviceManagementConstants.GeoServices.FENCE_NAME).toString() + "%"); } stmt.setInt(index++, request.getStartIndex()); stmt.setInt(index, request.getRowCount()); From 410e04c0159dc4fa60494475080a8d9323213fce Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 7 Nov 2023 18:38:15 +0530 Subject: [PATCH 139/157] Fix device permant delete with mssql --- .../impl/device/SQLServerDeviceDAOImpl.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 5628b77a2d..97fcfb6af1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -18,13 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; +import io.entgra.device.mgt.core.device.mgt.common.*; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.Count; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -1474,4 +1471,35 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { return geoClusters; } */ + + @Override + public void refactorDeviceStatus(Connection conn, List validDevices) throws DeviceManagementDAOException { + String updateQuery = "UPDATE DM_DEVICE_STATUS SET STATUS = ? WHERE ID = ?"; + String selectLastMatchingRecordQuery = "SELECT TOP 1 ID FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? AND DEVICE_ID = ? ORDER BY ID DESC"; + + try (PreparedStatement selectStatement = conn.prepareStatement(selectLastMatchingRecordQuery); + PreparedStatement updateStatement = conn.prepareStatement(updateQuery)) { + + for (Device device : validDevices) { + + selectStatement.setInt(1, device.getEnrolmentInfo().getId()); + selectStatement.setInt(2, device.getId()); + + ResultSet resultSet = selectStatement.executeQuery(); + int lastRecordId = 0; + if (resultSet.next()) { + lastRecordId = resultSet.getInt("ID"); + } + + updateStatement.setString(1, String.valueOf(EnrolmentInfo.Status.DELETED)); + updateStatement.setInt(2, lastRecordId); + updateStatement.execute(); + } + + } catch (SQLException e) { + String msg = "SQL error occurred while updating device status properties."; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } From 27d582456b17fc7fa44b7a03d4ba5036c8e616f9 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 7 Nov 2023 18:46:28 +0530 Subject: [PATCH 140/157] Add single class imports --- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 97fcfb6af1..a09185533c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -18,7 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.Count; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; From 8d1d418f6745b5516db87a63482f8292cf8d39b9 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 7 Nov 2023 21:05:34 +0530 Subject: [PATCH 141/157] Fix user search by partial filters --- .../api/jaxrs/service/impl/UserManagementServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index cdf3fb8342..6d34b2bc6d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -480,7 +480,7 @@ public class UserManagementServiceImpl implements UserManagementService { try { if (StringUtils.isNotEmpty(username)) { - commonUsers = getUserList(null, username); + commonUsers = getUserList(null, "*" + username + "*"); } if (commonUsers != null) { commonUsers.remove(Constants.APIM_RESERVED_USER); @@ -488,7 +488,7 @@ public class UserManagementServiceImpl implements UserManagementService { } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { - tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); + tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, "*" + firstName + "*"); if (commonUsers == null) { commonUsers = tempList; } else { @@ -497,7 +497,7 @@ public class UserManagementServiceImpl implements UserManagementService { } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(lastName)) { - tempList = getUserList(Constants.USER_CLAIM_LAST_NAME, lastName); + tempList = getUserList(Constants.USER_CLAIM_LAST_NAME, "*" + lastName + "*"); if (commonUsers == null || commonUsers.size() == 0) { commonUsers = tempList; } else { @@ -506,7 +506,7 @@ public class UserManagementServiceImpl implements UserManagementService { } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(emailAddress)) { - tempList = getUserList(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress); + tempList = getUserList(Constants.USER_CLAIM_EMAIL_ADDRESS, "*" + emailAddress + "*"); if (commonUsers == null || commonUsers.size() == 0) { commonUsers = tempList; } else { From b96074e56f7634060bb8a4e78b7ede8e1ff33c3b Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 7 Nov 2023 23:36:01 +0530 Subject: [PATCH 142/157] Fix geofence group device assignment in mssql --- .../geofence/SQLServerGeofenceDAOImpl.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java index 1a40be25bd..c1a719f446 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java @@ -166,4 +166,48 @@ public class SQLServerGeofenceDAOImpl extends AbstractGeofenceDAOImpl { throw new DeviceManagementDAOException(msg, e); } } + + @Override + public List getGeoFences(int groupId, int tenantId) throws DeviceManagementDAOException { + try { + Connection conn = this.getConnection(); + String sql = "SELECT " + + "G.ID AS FENCE_ID, " + + "FENCE_NAME, " + + "DESCRIPTION, " + + "LATITUDE, " + + "LONGITUDE, " + + "RADIUS, " + + "GEO_JSON, " + + "FENCE_SHAPE " + + "FROM DM_GEOFENCE G " + + "JOIN DM_GEOFENCE_GROUP_MAPPING M ON G.ID = M.FENCE_ID " + + "WHERE M.GROUP_ID = ? AND TENANT_ID = ?"; + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, groupId); + stmt.setInt(2, tenantId); + ResultSet rst = stmt.executeQuery(); + List geofenceDataList = new ArrayList<>(); + while (rst.next()) { + GeofenceData geofenceData = new GeofenceData(); + geofenceData.setId(rst.getInt("FENCE_ID")); + geofenceData.setFenceName(rst.getString("FENCE_NAME")); + geofenceData.setDescription(rst.getString("DESCRIPTION")); + geofenceData.setLatitude(rst.getDouble("LATITUDE")); + geofenceData.setLongitude(rst.getDouble("LONGITUDE")); + geofenceData.setRadius(rst.getFloat("RADIUS")); + geofenceData.setGeoJson(rst.getString("GEO_JSON")); + geofenceData.setFenceShape(rst.getString("FENCE_SHAPE")); + geofenceDataList.add(geofenceData); + } + return geofenceDataList; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving Geo fences of group " + groupId + + " and tenant " + tenantId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } From d297c55b73bba73fa891fbb40c416a8dff063892 Mon Sep 17 00:00:00 2001 From: Thameera Date: Wed, 8 Nov 2023 15:23:12 +0530 Subject: [PATCH 143/157] Update missiong scope --- .../mgt/api/jaxrs/service/api/ActivityInfoProviderService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java index 6bd31e76be..7cc2aaf0bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java @@ -396,7 +396,7 @@ public interface ActivityInfoProviderService { tags = "Device Activity Info Provider", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:get-activity") + @ExtensionProperty(name = Constants.SCOPE, value = "dm:activity:get") }) }, nickname = "getDeviceActivitiesWithFilters" From 8c6ac48c7b4828460f8358144c311213f8616e60 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 8 Nov 2023 16:05:31 +0530 Subject: [PATCH 144/157] [maven-release-plugin] prepare release v5.0.32 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 134 files changed, 136 insertions(+), 136 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index fd676b35a4..d0de565a1a 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 2899a5b950..fb816bfbd1 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0f9c44a295..c8cfeec295 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 57d2528979..88a861f5b4 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index b64fbba6c4..12f5d43eb9 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index 766c954dae..064d1ee54b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index ddc4161167..af98f5c1df 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 9d5818f314..e1798a4a01 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 858acad319..6f1accb91b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index e65b4e8636..703e235440 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 6a69e4d51f..8c258e5c90 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index c1c289a699..00756792f8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 07385d104f..87c8e5d8e7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2ff7fe6fea..baab911920 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index db830205d0..34b0b55357 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 83146e9da2..f721ff08b6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 690e7d0f5c..8c6062c99f 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index fa8d78029e..adeb647831 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index e902db93cd..ecc6b9690d 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 73450a139c..73efae1229 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 357ca9a65e..a7f130721c 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index b740a970e1..4e9881575f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 41dba7760d..2ba6b6d464 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index bc37947d52..f7454981d0 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 536fd8008b..24b3f139e4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index e232e0c35d..b719667f64 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index cff241f967..a06610026a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index b64598accd..691706db66 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index a93c5be96b..4d71b48523 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 8e0241d4a7..ec714f80be 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index d207e49a81..921768a267 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 0c0bbab66d..5ac93f49d4 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 1f59e29836..b03c615a69 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 19c8479b6d..ab48608e92 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 09928ad20a..a04162ac67 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index e05ba43b6c..c95838fcc1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 28fad52730..85a513c46e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 358f41cf05..2e2c960be6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7f5dce145e..b6aeea3477 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 0d7d7e9799..8c7327b90d 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index ef42f13e42..63d78cb364 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 179df09ea3..45d0a2ab44 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index c3f21bd9c7..fc62fd21b4 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index f7e3ba2ab5..b46a5316ba 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 35eca267eb..ee06d946ee 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.32-SNAPSHOT + 5.0.32 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 077e8ea5d1..bcde2886bd 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 45ed95f3c5..35ab855832 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 47fc30fbc7..2a437adfc0 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index f03f1f75f8..e3daf6c443 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index afdfa4c281..4bc8cc736d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index a3bcd42250..e6dd997039 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 28baf9639a..1ff27a7d10 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 3c53c5fb4e..d6ec593c48 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index eab3ba6c19..b128de1a56 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 90fe81295b..efd7ebb6dd 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 536ad2c6d6..05ee062945 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index a9601027df..c5ef7a698e 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 6bfb639310..37708bf618 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 6d37a0779e..216b2a8d7e 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 3163580710..7fcddc8e52 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 34a44fe13a..830a5181f9 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 337b71b193..24c167d9eb 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 57185312c7..bfbd44ea50 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 57959f08f0..0d03d8563f 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 702cdb44f7..00696b3258 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 604f05780f..adc3e898e5 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 5b2a0aad69..8f32f173a8 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 2e59d66fe1..2b03b6fc52 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 5edc3639b3..311a9be04e 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index bcaee05959..4ef54e10c9 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 505d5fc780..b818b0c40a 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 85d53a4015..d807f6ee60 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 44f5284c47..8797772796 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 4105b4a860..40a7bcb9c2 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index fc70dacffe..6c9647bf83 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 988a78862b..4817afa7f1 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index da76e639bb..f9b0074915 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 1c7202163a..f3ef8c1080 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 5357a9cb84..7ee159a1e5 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 91c4aa355d..4363fa754c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 47f34e3b85..a3a25e872a 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 47e95adaa3..67a10ebae3 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 064c378248..f82349a6f5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 11a6e19252..704df94fea 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 17053a76ba..2589cb6003 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index c1644c3752..c1bf2731ae 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 8d2091e4a5..e0b2b310a4 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 031d219c41..ab8adb13f7 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index c8806ac96c..c2cad984f3 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index c1aa0551c3..d57d3d1762 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 8515af2950..d85f349361 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index ee570e8f80..00f7979012 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index d5c0e68089..e1a0bf5a81 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index b30fa580b2..111e4b8451 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 3b9047b9b4..c9afa4f6a5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index c956b415ff..892e96b1d8 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 29c0e5855d..6331c042f0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 0156cfd604..a66ff082ed 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 38530519d1..3168eac901 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 6d11422d9e..5f9bcbbc33 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index c7ceead24f..a81c64db7a 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 40a2173ae4..c37b6411d8 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index f99531fee4..5e3860a2c1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 84f52b673d..1cb8d08761 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 7e42f904d1..11d7af5f67 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index b8d34017cf..ad5940d43c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 6f9b9f9b85..46282b3355 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index b92ad9882b..17caeee92a 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 4a87b249da..9974a7a3f2 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 2ab8490d40..9a49b6fdff 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 833a928979..a49723dc87 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 923eb42aa1..838cec9194 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index b711ecb589..af58dd1683 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index e03eedf1b9..13c5828d94 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 5f2b3aad0b..62d0d3b13a 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index fdbc51491d..0e0d8077eb 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 9dcd8d63ad..3c19717ebe 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 08e4626d41..0cfc19ef60 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index fa3f764580..b5d189be8b 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index d54478c608..22246fcc10 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index c914d3339b..c23dfa5bae 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 921a902e5d..b56c76d1fb 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 4522cca175..82c829b736 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 6764706510..04bd5ce204 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 5fdf88c14f..72b4cdb850 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index ab0d07e928..c3553ac743 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 3f86fa9f64..5812f5286a 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 4e94cf999b..dce03b865f 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 13762bd6b6..340337331d 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 93ad132316..304c19d0eb 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index f5f3004e70..5527ddcc8e 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 4181721142..d04d8f10b6 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.32-SNAPSHOT + 5.0.32 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 9cfcd17dc2..97b73d5ff6 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32-SNAPSHOT + 5.0.32 ../../pom.xml diff --git a/pom.xml b/pom.xml index 6401ed4885..3eaec044fa 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.32-SNAPSHOT + 5.0.32 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1884,7 +1884,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - HEAD + v5.0.32 @@ -2089,7 +2089,7 @@ 1.2.11.wso2v10 - 5.0.32-SNAPSHOT + 5.0.32 4.7.35 From d01e55ed08736aec18dab676d744fab4443a2d92 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 8 Nov 2023 16:05:38 +0530 Subject: [PATCH 145/157] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- components/webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 134 files changed, 136 insertions(+), 136 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index d0de565a1a..16415b7984 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index fb816bfbd1..8f1a489b56 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index c8cfeec295..9559065339 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 88a861f5b4..1e498a9cbd 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 12f5d43eb9..320c3bd644 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index 064d1ee54b..6c28e9f155 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index af98f5c1df..f6b00aa2d4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index e1798a4a01..35346e9d0e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 6f1accb91b..6177650fcf 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 703e235440..60f7054d04 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 8c258e5c90..f7ff2a65c4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 00756792f8..8c191867c1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 87c8e5d8e7..16d7e5c1c5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index baab911920..48bf5a2a29 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 34b0b55357..02174068bf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index f721ff08b6..25632c102b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 8c6062c99f..f6b7ea5667 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index adeb647831..02d7827669 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index ecc6b9690d..b11e8971a2 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 73efae1229..f409219db7 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index a7f130721c..0960af471c 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 4e9881575f..6934b4e268 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 2ba6b6d464..6c1c41693e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index f7454981d0..07196080c0 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 24b3f139e4..6e3696516d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index b719667f64..3b76d3c1a1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index a06610026a..a37bc33367 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 691706db66..ca31df153d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 4d71b48523..1f1e509020 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index ec714f80be..f34720cf4a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 921768a267..0e16c5ef26 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 5ac93f49d4..b74904f63e 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index b03c615a69..b2037f5e39 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index ab48608e92..ddb2188087 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index a04162ac67..4ed1497f87 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index c95838fcc1..6d298d39f7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 85a513c46e..bc4bc95dfa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 2e2c960be6..d839282d5a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index b6aeea3477..035bf42f50 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 8c7327b90d..3785b2e116 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 63d78cb364..3cd9312200 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 45d0a2ab44..e22a94f544 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index fc62fd21b4..af3c6adc94 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index b46a5316ba..3f5fed315e 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index ee06d946ee..663b4fe107 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.32 + 5.0.33-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index bcde2886bd..13a45f0c7b 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 35ab855832..a3218affb1 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 2a437adfc0..0a6afc87a5 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index e3daf6c443..e50c2d0c0c 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 4bc8cc736d..be00c1cef4 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index e6dd997039..72100f6b87 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 1ff27a7d10..0bc360906a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index d6ec593c48..435ce1e26c 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index b128de1a56..50cc781230 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index efd7ebb6dd..934ff1b4dd 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 05ee062945..4c97c8b86f 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index c5ef7a698e..79d1ca8a4c 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 37708bf618..e37951e0ae 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 216b2a8d7e..c6345fccac 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 7fcddc8e52..0fb8a51916 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 830a5181f9..c00b33fd70 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 24c167d9eb..0bcedc2765 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index bfbd44ea50..a9071eef5b 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 0d03d8563f..3913c59bbc 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 00696b3258..fdd0637b45 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index adc3e898e5..1db346e230 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 8f32f173a8..ef9b6e2f71 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 2b03b6fc52..c0f63858fa 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 311a9be04e..142e8f8646 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 4ef54e10c9..93013b3def 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index b818b0c40a..f106779a9b 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index d807f6ee60..67afa3f045 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 8797772796..7436102e2b 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 40a7bcb9c2..4dcc3fef09 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 6c9647bf83..ef7e8ee30f 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 4817afa7f1..b755950ebb 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index f9b0074915..41350e3293 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index f3ef8c1080..6bdd7d18d0 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 7ee159a1e5..6707746cca 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml index 4363fa754c..e8863a790c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index a3a25e872a..fb1f7e63e7 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 67a10ebae3..1bd33f2ec3 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index f82349a6f5..641b68798f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 704df94fea..17a1e3fa2c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 2589cb6003..c3d6ec599e 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index c1bf2731ae..9899d28784 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index e0b2b310a4..e4f033f192 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index ab8adb13f7..dbf2e1cbed 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index c2cad984f3..08332201ec 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index d57d3d1762..a1e1722dc9 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index d85f349361..c6b14d4335 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 00f7979012..63e95ead2d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index e1a0bf5a81..d0477b1f3a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 111e4b8451..686e829381 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index c9afa4f6a5..26b19346c4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 892e96b1d8..d1138ba644 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 6331c042f0..57fcf73f65 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index a66ff082ed..0764453563 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 3168eac901..2c24c75948 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 5f9bcbbc33..4d0b62fb18 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index a81c64db7a..b5da1f7ca5 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index c37b6411d8..20502239c4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 5e3860a2c1..9562d1f795 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 1cb8d08761..25c619e026 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 11d7af5f67..182e54288a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index ad5940d43c..3df5c60317 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 46282b3355..dcfa43362b 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 17caeee92a..e6e9661bf4 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 9974a7a3f2..46e9e1f913 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 9a49b6fdff..30206d2501 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index a49723dc87..7450359583 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 838cec9194..f10934363e 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index af58dd1683..f75cc1a71c 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 13c5828d94..eb7b8f0980 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 62d0d3b13a..f407363faa 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 0e0d8077eb..404f0e861c 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 3c19717ebe..59d88471f8 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 0cfc19ef60..390c8a3678 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index b5d189be8b..4779be9e5b 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 22246fcc10..8d9d2dae9b 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index c23dfa5bae..cab67f5419 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index b56c76d1fb..0a24b8166b 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 82c829b736..81fd1eca0b 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 04bd5ce204..02c4eaf151 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 72b4cdb850..ac0c5162c4 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index c3553ac743..42b1152bdf 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 5812f5286a..f9f5e75ce6 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index dce03b865f..ee8cdd8dfa 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 340337331d..3e0056956b 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 304c19d0eb..629d760ec1 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 5527ddcc8e..676aa56e23 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index d04d8f10b6..375d69a107 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.32 + 5.0.33-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 97b73d5ff6..7142ac99a2 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.32 + 5.0.33-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 3eaec044fa..4b4de33935 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.32 + 5.0.33-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1884,7 +1884,7 @@ https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git scm:git:https://repository.entgra.net/community/device-mgt-core.git - v5.0.32 + HEAD @@ -2089,7 +2089,7 @@ 1.2.11.wso2v10 - 5.0.32 + 5.0.33-SNAPSHOT 4.7.35 From 200e7e69c2481e49c8cce829c06087759def0a98 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 8 Nov 2023 17:05:25 +0530 Subject: [PATCH 146/157] Fix to ignore devicetype check for webclip --- .../core/impl/SubscriptionManagerImpl.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index fceb70e072..931c45ddcf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -177,23 +177,26 @@ public class SubscriptionManagerImpl implements SubscriptionManager { try { // Only for iOS devices int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO - .getDeviceTypeId()).getName())) { - // TODO: replace getAssetByAppId with the correct one in DAO - // Check if the app trying to subscribe is a VPP asset. - VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId); - if (storedAsset != null) { // This is a VPP asset - List users = new ArrayList<>(); - List devices = applicationSubscriptionInfo.getDevices();// get - // subscribed device list, so that we can extract the users of those devices. - for (Device device : devices) { - VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo() - .getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext() - .getTenantId(true)); - users.add(user); + // Ignore checking device type if app is a web clip + if(!applicationDTO.getType().equals("WEB_CLIP")){ + if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO + .getDeviceTypeId()).getName())) { + // TODO: replace getAssetByAppId with the correct one in DAO + // Check if the app trying to subscribe is a VPP asset. + VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId); + if (storedAsset != null) { // This is a VPP asset + List users = new ArrayList<>(); + List devices = applicationSubscriptionInfo.getDevices();// get + // subscribed device list, so that we can extract the users of those devices. + for (Device device : devices) { + VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo() + .getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getTenantId(true)); + users.add(user); + } + VPPApplicationManager vppManager = APIUtil.getVPPManager(); + vppManager.addAssociation(storedAsset, users); } - VPPApplicationManager vppManager = APIUtil.getVPPManager(); - vppManager.addAssociation(storedAsset, users); } } } catch (BadRequestException e) { From aa6c9f6734e1c98c7e5e00c3a0814d919bb136a4 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 10 Nov 2023 16:02:34 +0530 Subject: [PATCH 147/157] Fix certificate search by partial device identifiers --- .../mgt/core/dao/impl/GenericCertificateDAOImpl.java | 8 ++++---- .../mgt/core/dao/impl/OracleCertificateDAOImpl.java | 10 +++++----- .../core/dao/impl/PostgreSQLCertificateDAOImpl.java | 8 ++++---- .../mgt/core/dao/impl/SQLServerCertificateDAOImpl.java | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java index 3703101fd2..26cb256e29 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java @@ -67,7 +67,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - sql += " AND DEVICE_IDENTIFIER = ?"; + sql += " AND DEVICE_IDENTIFIER LIKE ?"; } if (StringUtils.isNotEmpty(username)) { @@ -83,7 +83,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (StringUtils.isNotEmpty(username)) { @@ -129,7 +129,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - query += "AND DEVICE_IDENTIFIER = ? "; + query += "AND DEVICE_IDENTIFIER LIKE ? "; isCertificateDeviceIdentifierProvided = true; } @@ -147,7 +147,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (isCertificateUsernameProvided) { stmt.setString(paramIdx++, "%" + username + "%"); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java index 31c4779dc5..e60ee4a6c0 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java @@ -68,7 +68,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - query += "AND DEVICE_IDENTIFIER = ? "; + query += "AND DEVICE_IDENTIFIER LIKE ? "; isCertificateDeviceIdentifierProvided = true; } @@ -83,10 +83,10 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { int paramIdx = 1; stmt.setInt(paramIdx++, tenantId); if (isCertificateSerialNumberProvided) { - stmt.setString(paramIdx++, "%" + serialNumber+ "%"); + stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (isCertificateUsernameProvided) { stmt.setString(paramIdx++, "%" + username + "%"); @@ -140,7 +140,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - sql += " AND DEVICE_IDENTIFIER = ?"; + sql += " AND DEVICE_IDENTIFIER LIKE ?"; } if (StringUtils.isNotEmpty(username)) { @@ -156,7 +156,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (StringUtils.isNotEmpty(username)) { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java index 55fd124a95..48effed43b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java @@ -68,7 +68,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - query += "AND DEVICE_IDENTIFIER = ? "; + query += "AND DEVICE_IDENTIFIER LIKE ? "; isCertificateDeviceIdentifierProvided = true; } @@ -86,7 +86,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (isCertificateUsernameProvided) { stmt.setString(paramIdx++, "%" + username + "%"); @@ -140,7 +140,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - sql += " AND DEVICE_IDENTIFIER = ?"; + sql += " AND DEVICE_IDENTIFIER LIKE ?"; } if (StringUtils.isNotEmpty(username)) { @@ -156,7 +156,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (StringUtils.isNotEmpty(username)) { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java index 6734fcd997..5cd02c63d0 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java @@ -68,7 +68,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - query += "AND DEVICE_IDENTIFIER = ? "; + query += "AND DEVICE_IDENTIFIER LIKE ? "; isCertificateDeviceIdentifierProvided = true; } @@ -86,7 +86,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { stmt.setString(paramIdx++, "%" + serialNumber + "%"); } if (isCertificateDeviceIdentifierProvided) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (isCertificateUsernameProvided) { stmt.setString(paramIdx++, "%" + username + "%"); @@ -140,7 +140,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - sql += " AND DEVICE_IDENTIFIER = ?"; + sql += " AND DEVICE_IDENTIFIER LIKE ?"; } if (StringUtils.isNotEmpty(username)) { @@ -156,7 +156,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { } if (StringUtils.isNotEmpty(deviceIdentifier)) { - stmt.setString(paramIdx++, deviceIdentifier); + stmt.setString(paramIdx++, "%" + deviceIdentifier + "%"); } if (StringUtils.isNotEmpty(username)) { From 46090437f013ab9f3f4c79353ac2ff9fd69918a0 Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Fri, 10 Nov 2023 18:06:58 +0530 Subject: [PATCH 148/157] Optimize multiple dis-enrollment --- .../service/api/DeviceManagementService.java | 5 +++-- .../impl/DeviceManagementServiceImpl.java | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index 357609b122..acb161d77e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -1287,7 +1287,8 @@ public interface DeviceManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", value = "Remove Multiple Devices Specified by Device IDs and Device Type", - notes = "Deletes multiple devices of the specified device type specified by their device IDs and returns the status of the deletion operation.", + notes = "Deletes multiple devices of the specified device type specified by their device IDs" + + " and returns the status of the dis-enrollment operation.", tags = "Device Management", extensions = { @Extension(properties = { @@ -1319,7 +1320,7 @@ public interface DeviceManagementService { }) Response disenrollMultipleDevices(@ApiParam( name = "deviceTypeWithDeviceIds", - value = "The properties to advanced search devices.", + value = "Device type and corresponding device IDs for disenrollment", required = true) DisenrollRequest deviceTypeWithDeviceIds); @GET diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 881a586f82..9e82728d3a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -491,17 +491,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { List failedToDisenrollDevices = new ArrayList<>(); Map> list = deviceTypeWithDeviceIds.getDeviceTypeWithDeviceIds(); + String deviceType; + List deviceIds; + DeviceIdentifier deviceIdentifier; + Device persistedDevice; + boolean response; for (Map.Entry> entry : list.entrySet()) { - String deviceType = entry.getKey(); - List deviceIds = entry.getValue(); + deviceType = entry.getKey(); + deviceIds = entry.getValue(); for (String deviceId : deviceIds) { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); + deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); try { - Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true); + persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier, true); if (persistedDevice != null) { - boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); + response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); if (response) { successfullyDisenrolledDevices.add(deviceIdentifier); } else { @@ -509,6 +514,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } else { failedToDisenrollDevices.add(deviceIdentifier); + if(log.isDebugEnabled()){ + String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId; + log.error(msg); + } } } catch (DeviceManagementException e) { String msg = "Error encountered while dis-enrolling device of type: " + deviceType + " with " + deviceId; From 52b2cccf9fab314c1871aa8527f8dfdd2dd1de91 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 14 Nov 2023 21:40:42 +0530 Subject: [PATCH 149/157] Upgrade apache http client version --- .../pom.xml | 4 ++-- .../pom.xml | 7 ++----- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 6 +++++- pom.xml | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index cb89652674..1b15c16e15 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -189,8 +189,8 @@ compile - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 io.entgra.device.mgt.core diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index b9fe8f9195..b4950a30c3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -151,13 +151,10 @@ commons-logging commons-logging - - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 - - org.apache.httpcomponents httpcore diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index cd2f1f8fe0..31c45579eb 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -34,6 +34,9 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.http.Consts; import org.apache.http.Header; import org.apache.http.HttpHeaders; @@ -44,6 +47,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; @@ -359,7 +363,7 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); + return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); } else { return HttpClients.createDefault(); } diff --git a/pom.xml b/pom.xml index 35f338c22e..4fb0968f72 100644 --- a/pom.xml +++ b/pom.xml @@ -1310,8 +1310,8 @@ ${github.openfeign.version} - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${apache.http.client.version} @@ -2043,7 +2043,7 @@ 11.0 1.1.1 1.2 - 4.5.6 + 5.2.1 4.4.13 4.5.10 From d4f9472e4883a4f401e361f462a19098bb982739 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 14 Nov 2023 23:06:12 +0530 Subject: [PATCH 150/157] Fix build failure --- .../pom.xml | 5 ++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 10 +++++++++- .../pom.xml | 18 ------------------ pom.xml | 1 - 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 9ebf07202e..21549bb117 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -173,10 +173,9 @@ - - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 org.apache.felix diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 02a7606b45..71dab6fb65 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -40,6 +40,7 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.TrustStrategy; import org.json.JSONArray; import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; @@ -120,6 +121,8 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -1385,7 +1388,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { private CloseableHttpClient getHttpClient() throws ApplicationManagementException { try { SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + builder.loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); return HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); } catch (NoSuchAlgorithmException e) { diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 0e16c5ef26..808841bd4b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -129,22 +129,10 @@ - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.carbon org.wso2.carbon.core - - org.wso2.carbon - org.wso2.carbon.logging - org.wso2.carbon org.wso2.carbon.utils @@ -193,7 +181,6 @@ org.wso2.carbon org.wso2.carbon.securevault - test @@ -216,11 +203,6 @@ org.wso2.carbon.queuing test - - javax.xml.bind - jaxb-api - test - io.entgra.device.mgt.core io.entgra.device.mgt.core.server.bootup.heartbeat.beacon diff --git a/pom.xml b/pom.xml index 9bd06cbf6d..3e3ed2bd3b 100644 --- a/pom.xml +++ b/pom.xml @@ -594,7 +594,6 @@ - org.testng testng From 2d9352a78817018ae7dedd1009fc89470d2586cb Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 21 Nov 2023 01:41:04 +0530 Subject: [PATCH 151/157] Upgrade with latest http client --- .../ui/request/interceptor/UserHandler.java | 91 +++++++--- .../interceptor/beans/ProxyResponse.java | 9 +- .../request/interceptor/util/HandlerUtil.java | 169 ++++++++++-------- 3 files changed, 166 insertions(+), 103 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index ac423d215c..52ba15712b 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -31,11 +35,11 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.core5.http.*; +import org.apache.hc.core5.http.io.entity.HttpEntities; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,7 +48,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.ArrayList; import java.util.Base64; +import java.util.List; +import java.util.Map; @MultipartConfig @WebServlet("/user") @@ -85,7 +92,22 @@ public class UserHandler extends HttpServlet { StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED); tokenEndpoint.setEntity(tokenEPPayload); - ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); + + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + + List nvps = new ArrayList<>(); + nvps.add(new BasicNameValuePair("token", accessToken)); +// nvps.add(new BasicNameValuePair("password", "secret")); + + ClassicHttpRequest httpPost = ClassicRequestBuilder.post(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nvps)) + .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())) + .build(); + + + ProxyResponse tokenStatus = HandlerUtil.execute(httpPost); if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { if (tokenStatus.getCode() == HttpStatus.SC_UNAUTHORIZED) { @@ -100,29 +122,52 @@ public class UserHandler extends HttpServlet { return; } } - String tokenData = tokenStatus.getData(); + JsonNode tokenData = tokenStatus.getData(); if (tokenData == null) { log.error("Invalid token data is received."); HandlerUtil.handleError(resp, tokenStatus); return; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenData); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { - HandlerUtil.sendUnAuthorizeResponse(resp); - return; - } - ProxyResponse proxyResponse = new ProxyResponse(); - proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setCode(HttpStatus.SC_OK); - proxyResponse.setData( - jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); - HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); - log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); + + if (!tokenData.get("active").asBoolean()) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; } + ProxyResponse proxyResponse = new ProxyResponse(); + proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); + proxyResponse.setCode(HttpStatus.SC_OK); +// proxyResponse.setData( +// tokenData.get("username").textValue().replaceAll("@carbon.super", "")); + + ObjectMapper mapper = new ObjectMapper(); + Map nodeMap = mapper.convertValue(tokenData, new TypeReference>(){}); + nodeMap.put("username", tokenData.get("username").textValue().replaceAll("@carbon.super", "")); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); +// tokenData = ; + + + + HandlerUtil.handleSuccess(resp, proxyResponse); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); + log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); + +// JsonParser jsonParser = new JsonParser(); +// JsonElement jTokenResult = jsonParser.parse(tokenData); +// if (jTokenResult.isJsonObject()) { +// JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); +// if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { +// HandlerUtil.sendUnAuthorizeResponse(resp); +// return; +// } +// ProxyResponse proxyResponse = new ProxyResponse(); +// proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); +// proxyResponse.setCode(HttpStatus.SC_OK); +// proxyResponse.setData( +// jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); +// HandlerUtil.handleSuccess(resp, proxyResponse); +// httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); +// log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); +// } } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java index 263a98bfeb..d259b33314 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java @@ -17,7 +17,8 @@ */ package io.entgra.device.mgt.core.ui.request.interceptor.beans; -import org.apache.http.Header; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.hc.core5.http.Header; public class ProxyResponse { @@ -27,7 +28,7 @@ public class ProxyResponse { } private int code; - private String data; + private JsonNode data; private String executorResponse; private int status; private Header[] headers; @@ -36,9 +37,9 @@ public class ProxyResponse { public void setCode(int code) { this.code = code; } - public String getData() { return data; } + public JsonNode getData() { return data; } - public void setData(String data) { this.data = data; } + public void setData(JsonNode data) { this.data = data; } public String getExecutorResponse() { return executorResponse; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 78ef321e5d..0161f74ec0 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -18,6 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -32,27 +35,25 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.entity.mime.InputStreamBody; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.apache.hc.client5.http.ssl.TrustAllStrategy; +import org.apache.hc.core5.http.*; +import org.apache.hc.core5.http.io.entity.BufferedHttpEntity; +import org.apache.hc.core5.http.io.entity.InputStreamEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.http.Consts; -import org.apache.http.Header; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; -import org.apache.http.entity.BufferedHttpEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.HttpMultipartMode; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.InputStreamBody; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.json.JSONArray; @@ -70,13 +71,11 @@ import javax.servlet.http.HttpSession; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.*; import java.math.BigInteger; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Enumeration; import java.util.List; @@ -96,71 +95,75 @@ public class HandlerUtil { * @return response as string * @throws IOException IO exception returns if error occurs when executing the httpMethod */ - public static ProxyResponse execute(HttpRequestBase httpRequest) throws IOException { + public static ProxyResponse execute(ClassicHttpRequest httpRequest) throws IOException { + try (CloseableHttpClient client = getHttpClient()) { - HttpResponse response = client.execute(httpRequest); - ProxyResponse proxyResponse = new ProxyResponse(); - - if (response == null) { - log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest - .getURI().toString()); - proxyResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey( - HandlerConstants.INTERNAL_ERROR_CODE)); - return proxyResponse; - } else { - int statusCode = response.getStatusLine().getStatusCode(); - String jsonString = getResponseString(response); - if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setExecutorResponse("SUCCESS"); - proxyResponse.setHeaders(response.getAllHeaders()); - return proxyResponse; - } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { - if (isTokenExpired(jsonString)) { - proxyResponse.setCode(statusCode); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); - } else { - log.error( - "Received " + statusCode + " response for http request : " + httpRequest.getMethod() - + " " + httpRequest.getURI().toString() + ". Error message: " + jsonString); - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse( - HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + + return client.execute(httpRequest, response -> { + final HttpEntity responseEntity = response.getEntity(); + ProxyResponse handlerResponse = new ProxyResponse(); + int statusCode = response.getCode(); + if (responseEntity == null) { + log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest.getRequestUri()); + handlerResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey( + HandlerConstants.INTERNAL_ERROR_CODE)); + return handlerResponse; + } + try (InputStream inputStream = responseEntity.getContent()) { + JsonNode responseData = objectMapper.readTree(inputStream); + if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); + handlerResponse.setExecutorResponse("SUCCESS"); + handlerResponse.setHeaders(response.getHeaders()); + return handlerResponse; + } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { + if (isTokenExpired(responseData)) { + handlerResponse.setCode(statusCode); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); + } else { + log.error( + "Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse( + HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + } + return handlerResponse; } - return proxyResponse; + log.error("Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse + .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + return handlerResponse; } - log.error("Received " + statusCode + - " response for http request : " + httpRequest.getMethod() + " " + httpRequest.getURI() - .toString() + ". Error message: " + jsonString); - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse - .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); - return proxyResponse; - } + }); } } - public static boolean isTokenExpired(String jsonBody) { - return jsonBody.contains("Access token expired") || jsonBody + public static boolean isTokenExpired(JsonNode jsonBody) { + return jsonBody.textValue().contains("Access token expired") || jsonBody.textValue() .contains("Invalid input. Access token validation failed"); } public static String getMemeType(HttpResponse response) { - String memeType = ""; Header contentType = response.getEntity().getContentType(); if (contentType != null) { - memeType = contentType.getValue().split(";")[0].trim(); + return contentType.getValue().split(";")[0].trim(); } - return memeType; + return ""; } /*** @@ -367,7 +370,21 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); + try { + return HttpClients.custom() + .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create() + .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create() + .setSslContext(SSLContextBuilder.create() + .loadTrustMaterial(TrustAllStrategy.INSTANCE) + .build()) + .setHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build()) + .build()) + .build(); + } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { + log.error("Error Occurred while creating the custom http client", e); + throw new RuntimeException(e); + } } else { return HttpClients.createDefault(); } From 717667126cfdc7ca502d4542825f6707b36dd229 Mon Sep 17 00:00:00 2001 From: Lasantha Dharmakeerthi Date: Mon, 20 Nov 2023 20:20:39 +0000 Subject: [PATCH 152/157] revert 52b2cccf9fab314c1871aa8527f8dfdd2dd1de91 revert Upgrade apache http client version --- .../pom.xml | 4 ++-- .../pom.xml | 7 +++++-- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 3 +-- pom.xml | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0c336eadda..0289d44e88 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -189,8 +189,8 @@ compile - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient io.entgra.device.mgt.core diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 747dd9b838..bf0036bdc7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -151,10 +151,13 @@ commons-logging commons-logging + - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient + + org.apache.httpcomponents httpcore diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 78ef321e5d..48285e5214 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -42,7 +42,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; @@ -367,7 +366,7 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); + return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); } else { return HttpClients.createDefault(); } diff --git a/pom.xml b/pom.xml index 3e3ed2bd3b..af0f8e6e45 100644 --- a/pom.xml +++ b/pom.xml @@ -1309,8 +1309,8 @@ ${github.openfeign.version} - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient ${apache.http.client.version} @@ -2054,7 +2054,7 @@ 11.0 1.1.1 1.2 - 5.2.1 + 4.5.6 4.4.13 4.5.10 From 66eac3c7441f19528fb710f8fe38da4465d5c77c Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Sat, 25 Nov 2023 01:18:15 +0530 Subject: [PATCH 153/157] Fix compilation issues in user handler --- .../DefaultOauth2TokenHandler.java | 83 ++++---- .../interceptor/DefaultTokenHandler.java | 26 ++- .../request/interceptor/HubspotHandler.java | 165 +++++++-------- .../ui/request/interceptor/LoginHandler.java | 6 +- .../interceptor/PermissionScopeHandler.java | 21 +- .../interceptor/SsoLoginCallbackHandler.java | 42 ++-- .../request/interceptor/SsoLoginHandler.java | 140 ++++--------- .../ui/request/interceptor/UserHandler.java | 73 ++----- .../request/interceptor/util/HandlerUtil.java | 192 ++++++------------ 9 files changed, 288 insertions(+), 460 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java index 343a9c620d..b0974a46a5 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java @@ -18,21 +18,20 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; @@ -42,11 +41,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/default-oauth2-credentials") public class DefaultOauth2TokenHandler extends HttpServlet { private static final Log log = LogFactory.getLog(DefaultTokenHandler.class); + private static final long serialVersionUID = 2254408216447549205L; @Override @@ -80,17 +81,16 @@ public class DefaultOauth2TokenHandler extends HttpServlet { } } - String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId - + "/" + clientSecret + "/default-token" + scopeString; - - HttpGet defaultTokenRequest = new HttpGet(tokenUrl); - defaultTokenRequest - .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); - defaultTokenRequest - .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); + ClassicHttpRequest defaultTokenRequest = + ClassicRequestBuilder.get(req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()) + + "/api/device-mgt/v1.0/devices/" + clientId + HandlerConstants.URI_SEPARATOR + + clientSecret + "/default-token" + scopeString) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()) + .build(); + ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { @@ -98,29 +98,24 @@ public class DefaultOauth2TokenHandler extends HttpServlet { HandlerUtil.handleError(resp, tokenResultResponse); return; } - String tokenResult = tokenResultResponse.getData(); + JsonNode tokenResult = tokenResultResponse.getData(); if (tokenResult == null) { log.error("Invalid default token response is received."); HandlerUtil.handleError(resp, tokenResultResponse); return; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - AuthData newDefaultAuthData = new AuthData(); - newDefaultAuthData.setClientId(clientId); - newDefaultAuthData.setClientSecret(clientSecret); - - String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); - newDefaultAuthData.setAccessToken(defaultToken); - newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); - newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); - httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); - - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); - } + AuthData newDefaultAuthData = new AuthData(); + newDefaultAuthData.setClientId(clientId); + newDefaultAuthData.setClientSecret(clientSecret); + + String defaultToken = tokenResult.get("accessToken").asText(); + newDefaultAuthData.setAccessToken(defaultToken); + newDefaultAuthData.setRefreshToken(tokenResult.get("refreshToken").asText()); + newDefaultAuthData.setScope(tokenResult.get("scopes").asText()); + httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); + + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); } else { HandlerUtil.sendUnAuthorizeResponse(resp); } @@ -152,19 +147,19 @@ public class DefaultOauth2TokenHandler extends HttpServlet { ub3.setHost(System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)); ub3.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_GATEWAY_WEBSOCKET_WS_PORT_ENV_VAR))); - JsonObject responseJsonObj = new JsonObject(); - responseJsonObj.addProperty("default-access-token", defaultAccessToken); - responseJsonObj.addProperty("remote-session-base-url", ub.toString()); - responseJsonObj.addProperty("secured-websocket-gateway-url", ub2.toString()); - responseJsonObj.addProperty("unsecured-websocket-gateway-url", ub3.toString()); - - Gson gson = new Gson(); - String payload = gson.toJson(responseJsonObj); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put("default-access-token", defaultAccessToken); + nodeMap.put("remote-session-base-url", ub.toString()); + nodeMap.put("secured-websocket-gateway-url", ub2.toString()); + nodeMap.put("unsecured-websocket-gateway-url", ub3.toString()); ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(payload); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); return proxyResponse; } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index e61cafd169..951b7b577a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -18,8 +18,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; @@ -43,11 +45,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/default-credentials") public class DefaultTokenHandler extends HttpServlet { private static final Log log = LogFactory.getLog(DefaultTokenHandler.class); + private static final long serialVersionUID = 6356346497117534430L; @Override @@ -110,19 +114,19 @@ public class DefaultTokenHandler extends HttpServlet { ub3.setHost(System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)); ub3.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_GATEWAY_WEBSOCKET_WS_PORT_ENV_VAR))); - JsonObject responseJsonObj = new JsonObject(); - responseJsonObj.addProperty("default-access-token", defaultAccessToken); - responseJsonObj.addProperty("remote-session-base-url", ub.toString()); - responseJsonObj.addProperty("secured-websocket-gateway-url", ub2.toString()); - responseJsonObj.addProperty("unsecured-websocket-gateway-url", ub3.toString()); - - Gson gson = new Gson(); - String payload = gson.toJson(responseJsonObj); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put("default-access-token", defaultAccessToken); + nodeMap.put("remote-session-base-url", ub.toString()); + nodeMap.put("secured-websocket-gateway-url", ub2.toString()); + nodeMap.put("unsecured-websocket-gateway-url", ub3.toString()); ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(payload); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); return proxyResponse; } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java index 2e2f5b73bf..f99531cc17 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java @@ -18,17 +18,15 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonObject; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import com.fasterxml.jackson.databind.JsonNode; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -48,89 +46,94 @@ import java.io.IOException; ) public class HubspotHandler extends HttpServlet { - private static final Log log = LogFactory.getLog(HubspotHandler.class); - private HttpSession httpSession; - private static String hubspotEndpoint; - private static String chatConfig; - private JsonObject uiConfigJsonObject; - private static String gatewayUrl; - private static String iotsCoreUrl; + private static final Log log = LogFactory.getLog(HubspotHandler.class); + private HttpSession httpSession; + private static String hubspotEndpoint; + private static String chatConfig; + private JsonNode uiConfigJsonObject; + private static String gatewayUrl; + private static String iotsCoreUrl; - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) { - try { - if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)); - HandlerUtil.generateChatRequestEntity(req, postRequest); - postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e) { - log.error("Error occurred when processing POST request.", e); - } + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig) + .build(); + HandlerUtil.generateChatRequestEntity(req, postRequest); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(postRequest)); + } + } catch (IOException e) { + log.error("Error occurred when processing POST request.", e); } + } - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) { - try { - if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint)); - getRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e) { - log.error("Error occurred when processing GET request.", e); - } + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest getRequest = + ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, + HandlerConstants.BEARER + chatConfig).build(); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(getRequest)); + } + } catch (IOException e) { + log.error("Error occurred when processing GET request.", e); } + } + + @Override + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest deleteRequest = + ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, + HandlerConstants.BEARER + chatConfig).build(); - @Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp){ - try{ - if(validateRequest(req, resp)){ - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint)); - deleteRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e){ - log.error("Error occurred when processing DELETE request.", e); + deleteRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(deleteRequest)); } + } catch (IOException e) { + log.error("Error occurred when processing DELETE request.", e); } + } - /*** - * Validates the hubspot's incoming request. - * - * @param req {@link HttpServletRequest} - * @param resp {@link HttpServletResponse} - * @return If request is a valid one, returns TRUE, otherwise return FALSE - * @throws IOException If and error occurs while witting error response to client side - */ - private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - httpSession = req.getSession(false); - if (httpSession == null) { - log.error("Unauthorized, You are not logged in. Please log in to the portal"); - HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED); - return false; - } - if (req.getMethod() == null) { - log.error("Bad Request, Request method is empty"); - HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST); - return false; - } - gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); - String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; - uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - chatConfig = uiConfigJsonObject.get("hubspotChat").getAsJsonObject().get("accessToken").getAsString(); - hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL; - return true; + /*** + * Validates the hubspot's incoming request. + * + * @param req {@link HttpServletRequest} + * @param resp {@link HttpServletResponse} + * @return If request is a valid one, returns TRUE, otherwise return FALSE + * @throws IOException If and error occurs while witting error response to client side + */ + private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) + throws IOException { + httpSession = req.getSession(false); + if (httpSession == null) { + log.error("Unauthorized, You are not logged in. Please log in to the portal"); + HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED); + return false; + } + if (req.getMethod() == null) { + log.error("Bad Request, Request method is empty"); + HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST); + return false; } + gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); + String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; + uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); + chatConfig = uiConfigJsonObject.get("hubspotChat").get("accessToken").textValue(); + hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL; + return true; + } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 9aa6eec0ad..2286d14c0a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.databind.JsonNode; import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; @@ -68,7 +69,8 @@ public class LoginHandler extends HttpServlet { } httpSession = req.getSession(true); - JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); + JsonNode uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, + resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); int sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); @@ -225,7 +227,7 @@ public class LoginHandler extends HttpServlet { * @return Invoke token endpoint and return the response as string. * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ - private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException { + private ProxyResponse getTokenResult(String encodedClientApp, JsonNode scopes) throws IOException { HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index 80b88885b7..623fd48b87 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -18,15 +18,17 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; -import org.json.JSONObject; -import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -34,12 +36,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/login-user/scopes") public class PermissionScopeHandler extends HttpServlet { + private static final long serialVersionUID = 976006906915355611L; + @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { HttpSession httpSession = req.getSession(false); if (httpSession == null) { HandlerUtil.sendUnAuthorizeResponse(resp); @@ -54,11 +59,15 @@ public class PermissionScopeHandler extends HttpServlet { if (!StringUtils.isEmpty(authData.getScope())) { ProxyResponse proxyResponse = new ProxyResponse(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(HandlerConstants.USER_SCOPES, authData.getScope()); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put(HandlerConstants.USER_SCOPES, authData.getScope()); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(jsonObject.toString()); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); HandlerUtil.handleSuccess(resp, proxyResponse); return; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java index 242ce38962..ee2b600eb4 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -18,20 +18,18 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.fasterxml.jackson.databind.JsonNode; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -75,33 +73,35 @@ public class SsoLoginCallbackHandler extends HttpServlet { } String scope = session.getAttribute("scope").toString(); - - HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - String loginCallbackUrl = iotsCoreUrl + req.getContextPath() + HandlerConstants.SSO_LOGIN_CALLBACK; StringEntity tokenEPPayload = new StringEntity( "grant_type=" + HandlerConstants.CODE_GRANT_TYPE + "&code=" + code + "&scope=" + scope + "&redirect_uri=" + loginCallbackUrl, ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); + + ClassicHttpRequest tokenEndpoint = ClassicRequestBuilder.post(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT) + .setEntity(tokenEPPayload) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")) + .build(); + ProxyResponse tokenResultResponse = HandlerUtil.execute(tokenEndpoint); + JsonNode jsonNode = tokenResultResponse.getData(); - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData()); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); + if (jsonNode != null) { AuthData authData = new AuthData(); authData.setClientId(session.getAttribute("clientId").toString()); authData.setClientSecret(session.getAttribute("clientSecret").toString()); authData.setEncodedClientApp(session.getAttribute("encodedClientApp").toString()); - authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + authData.setAccessToken(jsonNode.get("access_token").textValue()); + authData.setRefreshToken(jsonNode.get("refresh_token").textValue()); + authData.setScope(jsonNode.get("scope").textValue()); session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); resp.sendRedirect(session.getAttribute("redirectUrl").toString()); + } else { + log.error("Found empty response for token call."); + HandlerUtil.handleError(resp, HandlerConstants.INTERNAL_ERROR_CODE); } } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 8d3bc0d0c2..34584d03c3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -18,7 +18,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.*; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; @@ -26,21 +27,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.LoginException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.commons.lang.text.StrSubstitutor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HTTP; -import org.json.JSONArray; import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.servlet.annotation.MultipartConfig; @@ -54,30 +46,25 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.IOException; -import java.io.StringReader; +import java.util.ArrayList; import java.util.Base64; -import java.util.HashMap; -import java.util.Map; @MultipartConfig @WebServlet("/ssoLogin") public class SsoLoginHandler extends HttpServlet { private static final Log log = LogFactory.getLog(SsoLoginHandler.class); + private static final long serialVersionUID = 5594017767311123453L; private static String adminUsername; private static String adminPassword; private static String gatewayUrl; - private static String iotsCoreUrl; - private static String apiMgtUrl; - private static String keyManagerUrl; + private static String iotSCoreUrl; private static int sessionTimeOut; - private static String encodedAdminCredentials; private static String encodedClientApp; - private static String applicationId; private static String applicationName; private static String baseContextPath; - private JsonObject uiConfigJsonObject; + private JsonNode uiConfigJsonObject; private HttpSession httpSession; private LoginCache loginCache; private OAuthApp oAuthApp; @@ -101,15 +88,14 @@ public class SsoLoginHandler extends HttpServlet { gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + iotSCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); - apiMgtUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_APIM_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getAPIManagerPort(req.getScheme()); - keyManagerUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + String keyManagerUrl = + req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(req.getScheme()); // Fetch ui config and persists in session - String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; + String uiConfigUrl = iotSCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); // Retrieving login cache and do a DCR if the cache is not available. @@ -121,9 +107,10 @@ public class SsoLoginHandler extends HttpServlet { } String clientId = oAuthApp.getClientId(); - JsonArray scopesSsoJson = uiConfigJsonObject.get("scopes").getAsJsonArray(); - String scopesSsoString = HandlerUtil.getScopeString(scopesSsoJson); - String loginCallbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; + + JsonNode scopeJsonNode = uiConfigJsonObject.get("scopes"); + String scopesSsoString = HandlerUtil.getScopeString(scopeJsonNode); + String loginCallbackUrl = iotSCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; persistAuthSessionData(req, oAuthApp.getClientId(), oAuthApp.getClientSecret(), oAuthApp.getEncodedClientApp(), scopesSsoString, state); resp.sendRedirect(keyManagerUrl + HandlerConstants.AUTHORIZATION_ENDPOINT + @@ -134,8 +121,6 @@ public class SsoLoginHandler extends HttpServlet { "&redirect_uri=" + loginCallbackUrl); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); - } catch (JsonSyntaxException e) { - log.error("Error occurred while parsing the response. ", e); } catch (ParserConfigurationException e) { log.error("Error while creating the document builder."); } catch (SAXException e) { @@ -154,34 +139,32 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) throws LoginException { try { - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); - JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + ArrayNode tags = (ArrayNode) uiConfigJsonObject.get("appRegistration").get("tags"); + JsonNode scopes = uiConfigJsonObject.get("scopes"); sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); - JsonArray supportedGrantTypes = constructAppGrantTypeUpdateArray(); - String callbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; + String callbackUrl = iotSCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; - // Register the client application - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - encodedAdminCredentials = Base64.getEncoder() + String encodedAdminCredentials = Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes()); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, - callbackUrl, supportedGrantTypes)); + ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) + .setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, + callbackUrl, constructAppGrantTypeUpdateArray())) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + + encodedAdminCredentials) + .build(); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { - JsonParser jsonParser = new JsonParser(); - JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); String clientId = null; String clientSecret = null; + JsonNode jsonNode = clientAppResponse.getData(); - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + if (jsonNode != null) { + clientId = jsonNode.get("client_id").textValue(); + clientSecret = jsonNode.get("client_secret").textValue(); encodedClientApp = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes()); String scopesString = HandlerUtil.getScopeString(scopes); persistAuthSessionData(req, clientId, clientSecret, encodedClientApp, scopesString, state); @@ -206,8 +189,6 @@ public class SsoLoginHandler extends HttpServlet { } } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket.", e); - } catch (JsonSyntaxException e) { - throw new LoginException("Error occurred while parsing the response.", e); } } @@ -228,7 +209,6 @@ public class SsoLoginHandler extends HttpServlet { adminPassword = doc.getElementsByTagName("Password").item(0).getTextContent(); } - /** * Persist the Auth data inside the session * @@ -253,64 +233,14 @@ public class SsoLoginHandler extends HttpServlet { /*** * Generates payload for application grant_type update payload * - * @return {@link JsonArray} of the payload to update application grant type + * @return {@link ArrayList} of the payload to update application grant type */ - private JsonArray constructAppGrantTypeUpdateArray() { - JsonArray jsonArray = new JsonArray(); - + private ArrayList constructAppGrantTypeUpdateArray() { + ArrayList jsonArray = new ArrayList<>(); jsonArray.add(HandlerConstants.CODE_GRANT_TYPE); jsonArray.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); jsonArray.add(HandlerConstants.PASSWORD_GRANT_TYPE); jsonArray.add(HandlerConstants.JWT_BEARER_GRANT_TYPE); - return jsonArray; } - - /*** - * Generates tokens using password grant_type by invoking token endpoint - * - * @param encodedClientApp - Base64 encoded clientId:clientSecret. - * @return Invoke token endpoint and return the response as string. - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - */ - private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { - HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - - StringEntity tokenEPPayload = new StringEntity( - "grant_type=" + HandlerConstants.PASSWORD_GRANT_TYPE + "&username=" + adminUsername + "&password=" + adminPassword + - "&scope=apim:api_view apim:api_create apim:api_publish apim:subscribe", - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - return HandlerUtil.execute(tokenEndpoint); - } - - /*** - * Retrieves and returns access token - * - * @param resp - Http Servlet Response - * @param encodedClientApp - Base64 encoded clientId:clientSecret. - * @return Returns access token - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - */ - private String getAccessToken(HttpServletResponse resp, String encodedClientApp) throws IOException { - ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp); - - if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { - log.error("Error occurred while invoking the API to get token data."); - HandlerUtil.handleError(resp, tokenResultResponse); - } - String tokenResult = tokenResultResponse.getData(); - if (tokenResult == null) { - log.error("Invalid token response is received."); - HandlerUtil.handleError(resp, tokenResultResponse); - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - return jTokenResultAsJsonObject.get("access_token").getAsString(); - } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index 52ba15712b..dd06e5f08c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -18,13 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; @@ -36,8 +32,11 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; -import org.apache.hc.core5.http.*; -import org.apache.hc.core5.http.io.entity.HttpEntities; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.hc.core5.http.message.BasicNameValuePair; @@ -63,7 +62,7 @@ public class UserHandler extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { - String keymanagerUrl = + String keyManagerUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(req.getScheme()); @@ -80,39 +79,24 @@ public class UserHandler extends HttpServlet { } String accessToken = authData.getAccessToken(); -// String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); - - HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); DeviceManagementConfig dmc = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); String adminUsername = dmc.getKeyManagerConfigurations().getAdminUsername(); String adminPassword = dmc.getKeyManagerConfigurations().getAdminPassword(); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())); - StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - - JsonFactory jsonFactory = new JsonFactory(); - ObjectMapper objectMapper = new ObjectMapper(jsonFactory); - List nvps = new ArrayList<>(); - nvps.add(new BasicNameValuePair("token", accessToken)); -// nvps.add(new BasicNameValuePair("password", "secret")); + List nameValuePairs = new ArrayList<>(); + nameValuePairs.add(new BasicNameValuePair("token", accessToken)); - ClassicHttpRequest httpPost = ClassicRequestBuilder.post(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) - .setEntity(new UrlEncodedFormEntity(nvps)) + ClassicHttpRequest introspectCall = ClassicRequestBuilder.post(keyManagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nameValuePairs)) .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())) .build(); - - ProxyResponse tokenStatus = HandlerUtil.execute(httpPost); - + ProxyResponse tokenStatus = HandlerUtil.execute(introspectCall); if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { if (tokenStatus.getCode() == HttpStatus.SC_UNAUTHORIZED) { - tokenStatus = HandlerUtil.retryRequestWithRefreshedToken(req, tokenEndpoint, keymanagerUrl); - if(!HandlerUtil.isResponseSuccessful(tokenStatus)) { + tokenStatus = HandlerUtil.retryRequestWithRefreshedToken(req, introspectCall, keyManagerUrl); + if (!HandlerUtil.isResponseSuccessful(tokenStatus)) { HandlerUtil.handleError(resp, tokenStatus); return; } @@ -136,38 +120,17 @@ public class UserHandler extends HttpServlet { ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); proxyResponse.setCode(HttpStatus.SC_OK); -// proxyResponse.setData( -// tokenData.get("username").textValue().replaceAll("@carbon.super", "")); ObjectMapper mapper = new ObjectMapper(); - Map nodeMap = mapper.convertValue(tokenData, new TypeReference>(){}); + Map nodeMap = mapper.convertValue(tokenData, new TypeReference<>() { + }); nodeMap.put("username", tokenData.get("username").textValue().replaceAll("@carbon.super", "")); proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); -// tokenData = ; - - HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); - log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); - -// JsonParser jsonParser = new JsonParser(); -// JsonElement jTokenResult = jsonParser.parse(tokenData); -// if (jTokenResult.isJsonObject()) { -// JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); -// if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { -// HandlerUtil.sendUnAuthorizeResponse(resp); -// return; -// } -// ProxyResponse proxyResponse = new ProxyResponse(); -// proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); -// proxyResponse.setCode(HttpStatus.SC_OK); -// proxyResponse.setData( -// jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); -// HandlerUtil.handleSuccess(resp, proxyResponse); -// httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); -// log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); -// } + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, nodeMap.get("username").toString()); + log.info("Customer login", + userLogContextBuilder.setUserName(nodeMap.get("username").toString()).setUserRegistered(true).build()); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 0161f74ec0..b7a4b4e51c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -50,35 +51,25 @@ import org.apache.hc.core5.http.io.entity.BufferedHttpEntity; import org.apache.hc.core5.http.io.entity.InputStreamEntity; import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.ssl.SSLContextBuilder; +import org.apache.hc.client5.http.entity.mime.HttpMultipartMode; import org.apache.http.Consts; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.cookie.SM; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; import java.math.BigInteger; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.Enumeration; -import java.util.List; +import java.util.*; public class HandlerUtil { @@ -159,7 +150,7 @@ public class HandlerUtil { } public static String getMemeType(HttpResponse response) { - Header contentType = response.getEntity().getContentType(); + Header contentType = response.getFirstHeader("Content-Type"); if (contentType != null) { return contentType.getValue().split(";")[0].trim(); } @@ -273,29 +264,9 @@ public class HandlerUtil { resp.setStatus(proxyResponse.getCode()); resp.setContentType(ContentType.APPLICATION_JSON.getMimeType()); resp.setCharacterEncoding(Consts.UTF_8.name()); - JSONObject response = new JSONObject(); - String responseData = proxyResponse.getData(); - - if (!StringUtils.isEmpty(responseData)) { - try { - if (responseData.startsWith("{")) { - JSONObject responseDataJsonObj = new JSONObject(responseData); - response.put("data", responseDataJsonObj); - } else if (responseData.startsWith("[")) { - JSONArray responseDataJsonArr = new JSONArray(responseData); - response.put("data", responseDataJsonArr); - } else { - log.warn("Response data is not valid json string >> " + responseData); - response.put("data", responseData); - } - } catch (JSONException e) { - log.error("Response data is not passable"); - response.put("data", responseData); - } - } try (PrintWriter writer = resp.getWriter()) { - writer.write(response.toString()); + writer.write(proxyResponse.getData().toString()); } } @@ -435,13 +406,13 @@ public class HandlerUtil { * @throws FileUploadException If unable to parse the incoming request for multipart content extraction. * @throws IOException If error occurred while generating the request body. */ - public static void generateRequestEntity(HttpServletRequest req, HttpEntityEnclosingRequestBase proxyRequest) + public static void generateRequestEntity(HttpServletRequest req, ClassicHttpRequest proxyRequest) throws FileUploadException, IOException { if (ServletFileUpload.isMultipartContent(req)) { ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); List fileItemList = servletFileUpload.parseRequest(req); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); - entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + entityBuilder.setMode(HttpMultipartMode.LEGACY); for (FileItem item : fileItemList) { if (!item.isFormField()) { entityBuilder.addPart(item.getFieldName(), new InputStreamBody(item.getInputStream(), @@ -456,7 +427,7 @@ public class HandlerUtil { if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) || StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) { InputStreamEntity entity = new InputStreamEntity(req.getInputStream(), - Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH))); + Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH)), ContentType.parse(req.getContentType())); proxyRequest.setEntity(new BufferedHttpEntity(entity)); } HandlerUtil.copyRequestHeaders(req, proxyRequest, true); @@ -470,12 +441,12 @@ public class HandlerUtil { * @param proxyRequest proxy request instance. * @throws IOException If error occurred while generating the request body. */ - public static void generateChatRequestEntity(HttpServletRequest req, HttpEntityEnclosingRequestBase proxyRequest) + public static void generateChatRequestEntity(HttpServletRequest req, ClassicHttpRequest proxyRequest) throws IOException { if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) || StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) { InputStreamEntity entity = new InputStreamEntity(req.getInputStream(), - Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH))); + Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH)), ContentType.parse(req.getContentType())); proxyRequest.setEntity(new BufferedHttpEntity(entity)); } } @@ -490,23 +461,26 @@ public class HandlerUtil { * @param supportedGrantTypes - supported grant types * @return {@link StringEntity} of the payload to create the client application */ - public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password, - String callbackUrl, JsonArray supportedGrantTypes) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty(HandlerConstants.APP_NAME_KEY, appName); - jsonObject.addProperty(HandlerConstants.USERNAME, username); - jsonObject.addProperty(HandlerConstants.PASSWORD, password); - jsonObject.addProperty(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); - jsonObject.add(HandlerConstants.TAGS_KEY, tags); + public static StringEntity constructAppRegPayload(ArrayNode tags, String appName, String username, String password, + String callbackUrl, ArrayList supportedGrantTypes) { + + ObjectMapper objectMapper = new ObjectMapper(); + Map data = new HashMap<>(); + + data.put(HandlerConstants.APP_NAME_KEY, appName); + data.put(HandlerConstants.USERNAME, username); + data.put(HandlerConstants.PASSWORD, password); + data.put(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); + data.put(HandlerConstants.TAGS_KEY, tags); if (callbackUrl != null) { - jsonObject.addProperty(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); + data.put(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); } if (supportedGrantTypes != null) { - jsonObject.add(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); + data.put(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); } - String payload = jsonObject.toString(); - return new StringEntity(payload, ContentType.APPLICATION_JSON); + + return new StringEntity(objectMapper.valueToTree(data).toString(), ContentType.APPLICATION_JSON); } /*** @@ -516,9 +490,9 @@ public class HandlerUtil { * @param gatewayUrl - gateway endpoint URL * @param httpSession - current active HttpSession * @param resp - HttpServletResponse - * @return {@link JsonObject} of UI configurations + * @return {@link JsonNode} of UI configurations */ - public static JsonObject getUIConfigAndPersistInSession(String uiConfigUrl, String gatewayUrl, HttpSession httpSession, + public static JsonNode getUIConfigAndPersistInSession(String uiConfigUrl, String gatewayUrl, HttpSession httpSession, HttpServletResponse resp) throws IOException { HttpGet uiConfigEndpoint = new HttpGet(uiConfigUrl); ProxyResponse uiConfigResponse = HandlerUtil.execute(uiConfigEndpoint); @@ -529,39 +503,28 @@ public class HandlerUtil { HandlerUtil.handleError(resp, uiConfigResponse); } - if (uiConfigResponse.getData() == null) { + JsonNode responseData = uiConfigResponse.getData(); + if (responseData == null) { log.error("UI config retrieval is failed, and didn't find UI configuration for App manager."); HandlerUtil.handleError(resp, null); - } - JsonParser jsonParser = new JsonParser(); - - JsonElement uiConfigJsonElement = jsonParser.parse(uiConfigResponse.getData()); - JsonObject uiConfigJsonObject = null; - if (uiConfigJsonElement.isJsonObject()) { - uiConfigJsonObject = uiConfigJsonElement.getAsJsonObject(); - if (uiConfigJsonObject == null) { - log.error( - "Either UI config json element is not an json object or converting rom json element to json object is failed."); - HandlerUtil.handleError(resp, null); - } - httpSession.setAttribute(HandlerConstants.UI_CONFIG_KEY, uiConfigJsonObject); + } else { + httpSession.setAttribute(HandlerConstants.UI_CONFIG_KEY, responseData); httpSession.setAttribute(HandlerConstants.PLATFORM, gatewayUrl); } - return uiConfigJsonObject; + return responseData; } /*** * Converts scopes from JsonArray to string with space separated values. * - * @param scopes - scope Json Array and it is retrieved by reading UI config. + * @param scopes - scope Array and it is retrieved by reading UI config. * @return string value of the defined scopes */ - public static String getScopeString(JsonArray scopes) { - if (scopes != null && scopes.size() > 0) { + public static String getScopeString(JsonNode scopes) { + if (scopes != null && scopes.isArray() && !scopes.isEmpty()) { StringBuilder builder = new StringBuilder(); - for (JsonElement scope : scopes) { - String tmpScope = scope.getAsString() + " "; - builder.append(tmpScope); + for (JsonNode objNode : scopes) { + builder.append(objNode).append(" "); } return builder.toString(); } else { @@ -569,35 +532,6 @@ public class HandlerUtil { } } - /*** - * Converts xml file into string. - * - * @param xmlFile - xmlFile which needs to be converted into string. - * @return string value of the xml file. - */ - public static String xmlToString(File xmlFile) { - String stringOutput = null; - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(xmlFile); - OutputFormat format = new OutputFormat(doc); - StringWriter stringWriterOutput = new StringWriter(); - XMLSerializer serial = new XMLSerializer(stringWriterOutput, format); - serial.serialize(doc); - stringOutput = stringWriterOutput.toString(); - } catch (IOException e) { - log.error("Error occurred while sending the response into the socket. ", e); - } catch (ParserConfigurationException e) { - log.error("Error while creating the document builder."); - } catch (SAXException e) { - log.error("Error while parsing xml file.", e); - } - - return stringOutput; - } - /*** * Search a key from a given json string object. * @@ -640,11 +574,11 @@ public class HandlerUtil { * Retry request again after refreshing the access token * * @param req incoming {@link HttpServletRequest} - * @param httpRequest subclass of {@link HttpRequestBase} related to the current request. + * @param httpRequest {@link ClassicHttpRequest} related to the current request. * @return {@link ProxyResponse} if successful and null if failed. * @throws IOException If an error occurs when try to retry the request. */ - public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, HttpRequestBase httpRequest, + public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, ClassicHttpRequest httpRequest, String apiEndpoint) throws IOException { ProxyResponse retryResponse = refreshToken(req, apiEndpoint); if (isResponseSuccessful(retryResponse)) { @@ -660,7 +594,6 @@ public class HandlerUtil { return proxyResponse; } return proxyResponse; - } return retryResponse; } @@ -682,7 +615,6 @@ public class HandlerUtil { if (session == null) { log.error("Couldn't find a session, hence it is required to login and proceed."); tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_UNAUTHORIZED); -// handleError(resp, HttpStatus.SC_UNAUTHORIZED); return tokenResultResponse; } @@ -690,23 +622,20 @@ public class HandlerUtil { tokenResultResponse = getTokenResult(authData, keymanagerUrl); if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { log.error("Error occurred while refreshing access token."); -// HandlerUtil.handleError(resp, tokenResultResponse); return tokenResultResponse; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData()); - - if (jTokenResult.isJsonObject()) { - setNewAuthData(constructAuthDataFromTokenResult(jTokenResult, authData), session); + JsonNode tokenResponse = tokenResultResponse.getData(); + if (tokenResponse != null) { + setNewAuthData(constructAuthDataFromTokenResult(tokenResponse, authData), session); return tokenResultResponse; } log.error("Error Occurred in token renewal process."); tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); -// handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); return tokenResultResponse; } + public static ProxyResponse getTokenResult(AuthData authData, String keymanagerUrl) throws IOException { HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); StringEntity tokenEndpointPayload = new StringEntity( @@ -726,12 +655,17 @@ public class HandlerUtil { session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, newAuthData); } - public static AuthData constructAuthDataFromTokenResult(JsonElement tokenResult, AuthData authData) { - JsonObject jTokenResultAsJsonObject = tokenResult.getAsJsonObject(); + /** + * Construct {@link AuthData} from token response + * @param tokenResult {@link JsonNode} + * @param authData {@link AuthData} existing auth data values + * @return new {@link AuthData} object + */ + public static AuthData constructAuthDataFromTokenResult(JsonNode tokenResult, AuthData authData) { AuthData newAuthData = new AuthData(); - newAuthData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - newAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - newAuthData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + newAuthData.setAccessToken(tokenResult.get("access_token").textValue()); + newAuthData.setRefreshToken(tokenResult.get("refresh_token").textValue()); + newAuthData.setScope(tokenResult.get("scope").textValue()); newAuthData.setClientId(authData.getClientId()); newAuthData.setClientSecret(authData.getClientSecret()); newAuthData.setEncodedClientApp(authData.getEncodedClientApp()); @@ -748,7 +682,7 @@ public class HandlerUtil { * This should be set to false when handling multipart requests as Http * client will generate the Content-Type header automatically. */ - public static void copyRequestHeaders(HttpServletRequest req, HttpRequestBase httpRequest, boolean preserveContentType) { + public static void copyRequestHeaders(HttpServletRequest req, ClassicHttpRequest httpRequest, boolean preserveContentType) { Enumeration headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); @@ -774,18 +708,6 @@ public class HandlerUtil { return headerValue; } - public static String getResponseString(HttpResponse response) throws IOException { - try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { - StringBuilder responseBuilder = new StringBuilder(); - String line; - while ((line = rd.readLine()) != null) { - responseBuilder.append(line); - } - return responseBuilder.toString(); - } - } - - public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } From 8c841dfc2e19aee1d363642d122f12a2aa6b052e Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Mon, 1 Jan 2024 00:27:07 +0530 Subject: [PATCH 154/157] Fix login handler --- .../ui/request/interceptor/LoginHandler.java | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 2286d14c0a..6f38a18014 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; @@ -30,12 +31,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HTTP; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,7 +45,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; -import java.util.Base64; +import java.util.*; @MultipartConfig @WebServlet("/login") @@ -71,8 +72,8 @@ public class LoginHandler extends HttpServlet { JsonNode uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); - JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + ArrayNode tags = (ArrayNode) uiConfigJsonObject.get("appRegistration").get("tags"); + ArrayNode scopes = (ArrayNode) uiConfigJsonObject.get("scopes"); int sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); //setting session to expire in 1h @@ -84,12 +85,14 @@ public class LoginHandler extends HttpServlet { OAuthApp oAuthApp = loginCache.getOAuthAppCache(oAuthAppCacheKey); if (oAuthApp == null) { - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((username + HandlerConstants.COLON + password).getBytes())); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, - username, password, null, null)); + + ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) + .setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, + username, password, null, null)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((username + HandlerConstants.COLON + password).getBytes())) + .build(); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); @@ -99,15 +102,13 @@ public class LoginHandler extends HttpServlet { } if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { - JsonParser jsonParser = new JsonParser(); - JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); + JsonNode jsonNode = clientAppResponse.getData(); String clientId = null; String clientSecret = null; String encodedClientApp = null; - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + if (jsonNode != null) { + clientId = jsonNode.get("client_id").textValue(); + clientSecret = jsonNode.get("client_secret").textValue(); encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); oAuthApp = new OAuthApp( @@ -155,8 +156,7 @@ public class LoginHandler extends HttpServlet { */ private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, String clientId, String clientSecret, String encodedClientApp, - JsonArray scopes) throws LoginException { - JsonParser jsonParser = new JsonParser(); + ArrayNode scopes) throws LoginException { try { ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp, scopes); @@ -166,31 +166,26 @@ public class LoginHandler extends HttpServlet { HandlerUtil.handleError(resp, tokenResultResponse); return false; } - String tokenResult = tokenResultResponse.getData(); + JsonNode tokenResult = tokenResultResponse.getData(); if (tokenResult == null) { log.error("Invalid token response is received."); HandlerUtil.handleError(resp, tokenResultResponse); return false; } - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - HttpSession session = req.getSession(false); - if (session == null) { - return false; - } - AuthData authData = new AuthData(); - authData.setClientId(clientId); - authData.setClientSecret(clientSecret); - authData.setEncodedClientApp(encodedClientApp); - authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); - session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); - return true; + HttpSession session = req.getSession(false); + if (session == null) { + return false; } - return false; + AuthData authData = new AuthData(); + authData.setClientId(clientId); + authData.setClientSecret(clientSecret); + authData.setEncodedClientApp(encodedClientApp); + authData.setAccessToken(tokenResult.get("access_token").textValue()); + authData.setRefreshToken(tokenResult.get("refresh_token").textValue()); + authData.setScope(tokenResult.get("scope").textValue()); + session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); + return true; } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket", e); } @@ -228,22 +223,26 @@ public class LoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp, JsonNode scopes) throws IOException { - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); String scopeString = HandlerUtil.getScopeString(scopes); - if (scopeString != null) { scopeString = scopeString.trim(); } else { scopeString = "default"; } - StringEntity tokenEPPayload = new StringEntity( - "grant_type=" + HandlerConstants.PASSWORD_GRANT_TYPE + "&username=" + username + "&password=" + - password + "&scope=" + scopeString, - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); + List nameValuePairs = new ArrayList<>(); + nameValuePairs.add(new BasicNameValuePair("grant_type", HandlerConstants.PASSWORD_GRANT_TYPE)); + nameValuePairs.add(new BasicNameValuePair("username", username)); + nameValuePairs.add(new BasicNameValuePair("password", password)); + nameValuePairs.add(new BasicNameValuePair("scope", scopeString)); + + + ClassicHttpRequest tokenEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nameValuePairs)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp) + .build(); return HandlerUtil.execute(tokenEndpoint); } } From 7007558623260020fa4787346ea96e20c6d037d4 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 4 Jan 2024 01:31:38 +0530 Subject: [PATCH 155/157] Fix OTP request handler --- .../interceptor/OTPInvokerHandler.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java index 31d851ec03..bc52456be7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java @@ -25,8 +25,9 @@ import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.*; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -51,7 +52,9 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); +// HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); @@ -73,7 +76,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest getRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -93,7 +97,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpHead headRequest = new HttpHead(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest headRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -113,7 +118,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPut putRequest = new HttpPut(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest putRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -135,7 +141,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); From 8bf027f2b34aef3c84ea0c042c919b57d456470c Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 4 Jan 2024 02:13:47 +0530 Subject: [PATCH 156/157] Fix invoker handler --- .../request/interceptor/GrafanaHandler.java | 6 ++++-- .../request/interceptor/InvokerHandler.java | 21 ++++++++++++------- .../interceptor/OTPInvokerHandler.java | 9 ++++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java index 5fc86acde2..6f8dab9e68 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java @@ -30,6 +30,8 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -68,7 +70,7 @@ public class GrafanaHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet grafanaRequest = new HttpGet(); + ClassicHttpRequest grafanaRequest = ClassicRequestBuilder.get().build(); HandlerUtil.copyRequestHeaders(req, grafanaRequest, true); if (!GrafanaUtil.isGrafanaAPI(req.getRequestURI())) { proxyPassGrafanaRequest(grafanaRequest, resp, req); @@ -112,7 +114,7 @@ public class GrafanaHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost grafanaRequest = new HttpPost(); + ClassicHttpRequest grafanaRequest = ClassicRequestBuilder.post().build(); HandlerUtil.generateRequestEntity(req, grafanaRequest); HandlerUtil.copyRequestHeaders(req, grafanaRequest, true); if (!GrafanaUtil.isGrafanaAPI(req.getRequestURI())) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java index ed6d636afd..e8ffb2deef 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java @@ -26,9 +26,10 @@ import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.*; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -58,7 +59,7 @@ public class InvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); @@ -88,7 +89,8 @@ public class InvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest getRequest = ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -123,7 +125,8 @@ public class InvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpHead headRequest = new HttpHead(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest headRequest = ClassicRequestBuilder.head(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); headRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -150,7 +153,8 @@ public class InvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPut putRequest = new HttpPut(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest putRequest = ClassicRequestBuilder.put(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); putRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -180,7 +184,8 @@ public class InvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java index bc52456be7..9e6954fe47 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java @@ -52,7 +52,6 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { -// HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); @@ -76,7 +75,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest getRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest getRequest = ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -97,7 +96,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest headRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest headRequest = ClassicRequestBuilder.head(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -118,7 +117,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest putRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest putRequest = ClassicRequestBuilder.put(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -141,7 +140,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest deleteRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); From 56033e2e3ac57cf138fd80ec1349f3466b5dbad5 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Fri, 5 Jan 2024 07:22:52 +0530 Subject: [PATCH 157/157] Fix build failure --- .../request/interceptor/GrafanaHandler.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java index 6f8dab9e68..414067ff20 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java @@ -30,14 +30,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.*; -import org.apache.http.impl.client.CloseableHttpClient; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -208,10 +206,10 @@ public class GrafanaHandler extends HttpServlet { return true; } - private ProxyResponse executeGrafanaAPIRequest(HttpRequestBase requestBase, HttpServletRequest request) + private ProxyResponse executeGrafanaAPIRequest(ClassicHttpRequest requestBase, HttpServletRequest request) throws IOException { URI grafanaUri = HttpUtil.createURI(generateGrafanaAPIUrl(request)); - requestBase.setURI(grafanaUri); + requestBase.setUri(grafanaUri); return HandlerUtil.execute(requestBase); } @@ -232,14 +230,14 @@ public class GrafanaHandler extends HttpServlet { } return uri; } - private void proxyPassGrafanaRequest(HttpRequestBase requestBase, HttpServletResponse response, + private void proxyPassGrafanaRequest(ClassicHttpRequest requestBase, HttpServletResponse response, HttpServletRequest request) throws IOException { try (CloseableHttpClient client = HandlerUtil.getHttpClient()) { String grafanaUriStr = GrafanaHandlerUtil.generateGrafanaUrl(HttpUtil.createURI(getURIWithQuery(request)), GrafanaUtil.getGrafanaHTTPBase(request.getScheme())); URI grafanaURI = HttpUtil.createURI(grafanaUriStr); - requestBase.setURI(grafanaURI); - HttpResponse grafanaResponse = invokeGrafanaAPI(client, requestBase); + requestBase.setUri(grafanaURI); + CloseableHttpResponse grafanaResponse = invokeGrafanaAPI(client, requestBase); forwardGrafanaResponse(grafanaResponse, response); } catch (GrafanaEnvVariablesNotDefined e) { handleError(response, HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage()); @@ -250,17 +248,19 @@ public class GrafanaHandler extends HttpServlet { } } - private HttpResponse invokeGrafanaAPI(HttpClient client, HttpRequestBase request) throws IOException, GrafanaManagementException { + private CloseableHttpResponse invokeGrafanaAPI(CloseableHttpClient client, ClassicHttpRequest request) throws IOException, + GrafanaManagementException { setBasicAuthHeader(request); + //todo this is deprecated call return client.execute(request); } - private void setBasicAuthHeader(HttpRequestBase request) throws GrafanaManagementException { + private void setBasicAuthHeader(ClassicHttpRequest request) throws GrafanaManagementException { String basicAuth = GrafanaUtil.getBasicAuthBase64Header(); request.setHeader(HttpHeaders.AUTHORIZATION, basicAuth); } - private void forwardGrafanaResponse(HttpResponse grafanaResponse, HttpServletResponse response) throws IOException { + private void forwardGrafanaResponse(CloseableHttpResponse grafanaResponse, HttpServletResponse response) throws IOException { InputStream responseContent = grafanaResponse.getEntity().getContent(); String grafanaContentType = HandlerUtil.getMemeType(grafanaResponse); response.setHeader(HttpHeaders.CONTENT_TYPE, grafanaContentType);