updating to kernel 4.6.1

kernel-4.6.x
Amalka Subasinghe 4 years ago
parent 853ee700b8
commit c33e13b04c

@ -73,8 +73,8 @@
org.wso2.carbon.apimgt.annotations.*
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.servlet,
javax.xml.*,

@ -34,42 +34,56 @@
<url>http://wso2.org</url>
<dependencies>
<!--CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<scope>provided</scope>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!--CXF -->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--JAX-RS -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.codehaus.jackson</groupId>-->
<!--<artifactId>jackson-core-asl</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>javax</groupId>-->
<!--<artifactId>javaee-web-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>

@ -27,8 +27,8 @@ import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
//import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
@ -110,12 +110,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
if (username.equals(registrationProfile.getUsername())) {
synchronized (ApiApplicationRegistrationServiceImpl.class) {
StoreClient storeClient = new StoreClient(new OAuthRequestInterceptor(registrationProfile.getUsername(),
registrationProfile.getPassword()));
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
applicationName, registrationProfile.getTags(),
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
registrationProfile.isAllowedToAllDomains(), validityPeriod, storeClient);
registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
}
}

@ -25,7 +25,12 @@ import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.servlet.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -51,14 +51,25 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
<version>9.0.5</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<version>9.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId>
@ -72,6 +83,11 @@
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -100,24 +116,26 @@
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>API Management Application Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging.*,
org.wso2.carbon.user.core.*,
org.wso2.carbon.user.api,
org.wso2.carbon.utils.multitenancy,
org.json.simple,
org.wso2.carbon.context,
org.wso2.carbon.base,
org.wso2.carbon.registry.core.*;resolution:=optional,
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",
org.wso2.carbon.apimgt.integration.client.*,
org.wso2.carbon.apimgt.integration.generated.client.store.api,
org.wso2.carbon.apimgt.integration.generated.client.store.model,
org.wso2.carbon.identity.jwt.client.extension.*,
feign
</Import-Package>
<Import-Packages>
org.apache.commons.lang;version="[2.6,3)",org.apache.c
ommons.logging;version="[1.2,2)",org.json.simple,org.osgi.framework;v
ersion="${imp.package.version.osgi.framework}",org.osgi.service.component;version="${imp.package.version.osgi.service}",org.wso
2.carbon.apimgt.api;version="[9.0,10)",org.wso2.carbon.apimgt.api.dto
;version="[9.0,10)",org.wso2.carbon.apimgt.api.model;version="[9.0,10
)",org.wso2.carbon.apimgt.application.extension.bean,org.wso2.carbon.
apimgt.application.extension.dto,org.wso2.carbon.apimgt.application.e
xtension.exception,org.wso2.carbon.apimgt.impl;version="[9.0,10)",org
.wso2.carbon.apimgt.impl.utils;version="[9.0,10)",org.wso2.carbon.con
text;version="[4.6,5)",org.wso2.carbon.device.mgt.core.config.ui;vers
ion="[4.1,5)",org.wso2.carbon.identity.jwt.client.extension,org.wso2.
carbon.identity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt
.client.extension.exception,org.wso2.carbon.identity.jwt.client.exten
sion.service,org.wso2.carbon.registry.core.exceptions;version="[1.0,2
)",org.wso2.carbon.registry.core.service;version="[1.0,2)",org.wso2.c
arbon.registry.indexing.service;version="[4.7,5)",org.wso2.carbon.use
r.api;version="[1.0,2)",org.wso2.carbon.user.core.service;version="[4
.6,5)",org.wso2.carbon.user.core.tenant;version="[4.6,5)"
</Import-Packages>
<Export-Package>
!org.wso2.carbon.apimgt.application.extension.internal,
org.wso2.carbon.apimgt.application.extension.*

@ -20,8 +20,9 @@ package org.wso2.carbon.apimgt.application.extension;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
//import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
//import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
/**
* This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM.
@ -61,17 +62,17 @@ public interface APIManagementProviderService {
* @param username to whom the application is created
* @param isAllowedAllDomains application is allowed to all the tenants
* @param validityTime validity period of the application
* @param storeClient Specified store client
// * @param storeClient Specified store client
* @return consumerkey and secrete of the created application.
* @throws APIManagerException
*/
ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName,
String tags[],
String keyType,
String username,
boolean isAllowedAllDomains,
String validityTime,
StoreClient storeClient) throws APIManagerException;
String validityTime, String scopes) throws APIManagerException;
/**
* Remove APIM Application.

@ -18,19 +18,46 @@
package org.wso2.carbon.apimgt.application.extension;
import feign.FeignException;
//import feign.FeignException;
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.APIProvider;
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.KeyManagerConfiguration;
import org.wso2.carbon.apimgt.api.model.SubscribedAPI;
import org.wso2.carbon.apimgt.api.model.Subscriber;
import org.wso2.carbon.apimgt.application.extension.bean.APIRegistrationProfile;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder;
import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil;
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.apimgt.integration.generated.client.store.model.*;
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.integration.client.OAuthRequestInterceptor;
//import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIInfo;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIList;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Application;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationInfo;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKey;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKeyGenerateRequest;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationList;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Subscription;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.SubscriptionList;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration;
import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
@ -39,7 +66,11 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* This class represents an implementation of APIManagementProviderService.
@ -50,48 +81,66 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
private static final String CONTENT_TYPE = "application/json";
private static final int MAX_API_PER_TAG = 200;
private static final String APP_TIER_TYPE = "application";
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
@Override
public boolean isTierLoaded() {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient();
// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
// .getStoreClient();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain();
// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
// try {
try {
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
APP_TIER_TYPE,
tenantDomain, CONTENT_TYPE, null, null);
return true;
} catch (FeignException e) {
log.error("Feign Exception", e);
if (e.status() == 401) {
OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor();
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
oAuthRequestInterceptor.removeToken(username, tenantDomain);
try {
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null);
} catch (FeignException ex) {
log.error("Invalid Attempt : " + ex);
}
}
} catch (Exception e) {
APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain);
} catch (APIManagementException e) {
log.error("APIs not ready", e);
}
return false;
// storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
// APP_TIER_TYPE,
// tenantDomain, CONTENT_TYPE, null, null);
return true;
// } catch (FeignException e) {
// log.error("Feign Exception", e);
// if (e.status() == 401) {
// OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor();
// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
// oAuthRequestInterceptor.removeToken(username, tenantDomain);
// try {
// storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
// APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null);
// } catch (FeignException ex) {
// log.error("Invalid Attempt : " + ex);
// }
// }
// } catch (Exception e) {
// log.error("APIs not ready", e);
// }
// return false;
}
@Override
public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient();
ApplicationList applicationList = storeClient.getApplications()
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
if (applicationList.getList() != null && applicationList.getList().size() > 0) {
ApplicationInfo applicationInfo = applicationList.getList().get(0);
storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(),
null, null);
// StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
// .getStoreClient();
// ApplicationList applicationList = storeClient.getApplications()
// .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
try {
APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
if (application != null) {
// ApplicationInfo applicationInfo = applicationList.getList().get(0);
// storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(),
// null, null);
apiConsumer.removeApplication(application, username);
}
} catch (APIManagementException e) {
//todo:amalka
e.printStackTrace();
}
}
/**
@ -100,94 +149,80 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
@Override
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
String keyType, String username,
boolean isAllowedAllDomains, String validityTime,
StoreClient sClient) throws APIManagerException {
StoreClient storeClient;
boolean isAllowedAllDomains,
String validityTime, String scopes) throws APIManagerException {
if (sClient == null) {
storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient();
} else {
storeClient = sClient;
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
if (StringUtils.isEmpty(username)) {
username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
}
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain();
try {
ApplicationList applicationList = storeClient.getApplications()
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
Application application;
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) {
//create application;
application = new Application();
application.setName(applicationName);
application.setSubscriber(username);
application.setDescription("");
application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER);
APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
int applicationId = 0;
Subscriber subscriber = null;
if (application == null) {
subscriber = apiConsumer.getSubscriber(username);
if (subscriber == null) {
// create subscriber
apiConsumer.addSubscriber(username, "");
subscriber = apiConsumer.getSubscriber(username);
}
//create application
application = new Application(applicationName, subscriber);
application.setTier(ApiApplicationConstants.DEFAULT_TIER);
application.setGroupId("");
application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE);
applicationId = apiConsumer.addApplication(application, username);
} else {
ApplicationInfo applicationInfo = applicationList.getList().get(0);
application = storeClient.getIndividualApplication()
.applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null);
}
if (application == null) {
throw new APIManagerException(
"Api application creation failed for " + applicationName + " to the user " + username);
applicationId = application.getId();
subscriber = apiConsumer.getSubscriber(username);
}
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
List<Subscription> needToSubscribe = new ArrayList<>();
Set<SubscribedAPI> subscribedAPIs =
apiConsumer.getSubscribedAPIsByApplicationId(subscriber, applicationId, "");
log.info("Already subscribed API count: " + subscribedAPIs.size());
// subscribe to apis.
Set<String> tempApiIds = new HashSet<>();
if (tags != null && tags.length > 0) {
for (String tag : tags) {
APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag
, CONTENT_TYPE, null);
if (apiList.getList() == null || apiList.getList().size() == 0) {
apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
Set<API> apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain);
if (apisWithTag == null || apisWithTag.size() == 0) {
apisWithTag = apiConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
}
if (apiList.getList() != null && apiList.getList().size() > 0) {
for (APIInfo apiInfo : apiList.getList()) {
String id = apiInfo.getProvider().replace("@", "-AT-")
+ "-" + apiInfo.getName() + "-" + apiInfo.getVersion();
id = id.replace(" ", "+");
if (apisWithTag != null && apisWithTag.size() > 0) {
for (API apiInfo : apisWithTag) {
String id = apiInfo.getId().getProviderName().replace("@", "-AT-")
+ "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion();
// todo: amalka will this break old apis?
boolean subscriptionExist = false;
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) {
for (Subscription subs : subscriptionList.getList()) {
if (subs.getApiIdentifier().equals(id)) {
if (subscribedAPIs.size() > 0) {
for (SubscribedAPI subscribedAPI : subscribedAPIs) {
if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) {
subscriptionExist = true;
break;
}
}
}
if (!subscriptionExist) {
Subscription subscription = new Subscription();
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
subscription.setApiIdentifier(id);
subscription.setApplicationId(application.getApplicationId());
subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
if (!needToSubscribe.contains(subscription)) {
needToSubscribe.add(subscription);
}
if (!subscriptionExist && !tempApiIds.contains(id)) {
ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(apiInfo);
apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER);
apiConsumer.addSubscription(apiTypeWrapper, username, applicationId, "");
tempApiIds.add(id);
}
}
}
}
}
if (!needToSubscribe.isEmpty()) {
storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE);
}
//end of subscription
List<ApplicationKey> applicationKeys = application.getKeys();
List<APIKey> applicationKeys = application.getKeys();
if (applicationKeys != null) {
for (ApplicationKey applicationKey : applicationKeys) {
if (keyType.equals(applicationKey.getKeyType().toString())) {
for (APIKey applicationKey : applicationKeys) {
if (keyType.equals(applicationKey.getType())) {
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
@ -198,33 +233,74 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
}
}
ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest();
List<String> allowedDomains = new ArrayList<>();
if (isAllowedAllDomains) {
allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS);
} else {
allowedDomains.add(APIManagerUtil.getTenantDomain());
}
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
applicationKeyGenerateRequest.setCallbackUrl("");
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION);
applicationKeyGenerateRequest.setValidityTime(validityTime);
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost(
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null);
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
return apiApplicationKey;
APIAdmin apiAdmin = new APIAdminImpl();
String keyManagerId = null;
try {
List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiAdmin
.getKeyManagerConfigurationsByTenant(tenantDomain);
if (keyManagerConfigurations != null) {
for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) {
keyManagerId = keyManagerConfigurationDTO.getUuid();
}
}
String jsonString = "{\"grant_types\":\"refresh_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\\\":\\\"N\\/A\\\"," +
"\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," +
"\"username\":\"" + username + "\"}";
// if scopes not defined
if (StringUtils.isEmpty(scopes)) {
UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance();
UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig();
List<String> scopeList = uiConfiguration.getScopes();
if (scopeList != null && scopeList.size() > 0) {
StringBuilder builder = new StringBuilder();
for (String scope : scopeList) {
String tmpScope = scope + " ";
builder.append(tmpScope);
}
scopes = builder.toString();
}
if (StringUtils.isEmpty(scopes)) {
scopes = scopes.trim();
} else {
scopes = "default";
}
}
Map<String, Object> keyDetails = apiConsumer
.requestApprovalForApplicationRegistration(username, applicationName, keyType, "",
allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, scopes, "",
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);
} catch (APIManagementException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
}
throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain);
} catch (FeignException e) {
} catch (APIManagementException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
}
}
/**
/**
* {@inheritDoc}
*/
@Override
@ -311,7 +387,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) {
info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
registrationProfile.getTags(), tokenType, registrationProfile.getApplicationName(),
registrationProfile.getTags(), tokenType, null,
registrationProfile.isAllowedToAllDomains(), validityPeriod);
}
} finally {

@ -18,7 +18,7 @@
package org.wso2.carbon.apimgt.application.extension.internal;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
@ -35,7 +35,7 @@ public class APIApplicationManagerExtensionDataHolder {
private TenantManager tenantManager;
private TenantRegistryLoader tenantRegistryLoader;
private TenantIndexingLoader indexLoader;
private IntegrationClientService integrationClientService;
// private IntegrationClientService integrationClientService;
private JWTClientManagerService jwtClientManagerService;
private APIApplicationManagerExtensionDataHolder() {
@ -94,14 +94,14 @@ public class APIApplicationManagerExtensionDataHolder {
return indexLoader;
}
public IntegrationClientService getIntegrationClientService() {
return integrationClientService;
}
public void setIntegrationClientService(
IntegrationClientService integrationClientService) {
this.integrationClientService = integrationClientService;
}
// public IntegrationClientService getIntegrationClientService() {
// return integrationClientService;
// }
//
// public void setIntegrationClientService(
// IntegrationClientService integrationClientService) {
// this.integrationClientService = integrationClientService;
// }
public JWTClientManagerService getJwtClientManagerService() {
if (jwtClientManagerService == null) {

@ -23,7 +23,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader;
import org.wso2.carbon.user.core.service.RealmService;
@ -49,12 +49,6 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic"
* bind="setRealmService"
* unbind="unsetRealmService"
* @scr.reference name="integration.client.service"
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
* cardinality="1..1"
* policy="dynamic"
* bind="setIntegrationClientService"
* unbind="unsetIntegrationClientService"
*/
public class APIApplicationManagerExtensionServiceComponent {
@ -97,16 +91,16 @@ public class APIApplicationManagerExtensionServiceComponent {
APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null);
}
protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
if (integrationClientService != null && log.isDebugEnabled()) {
log.debug("integrationClientService initialized");
}
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService);
}
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null);
}
// protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
// if (integrationClientService != null && log.isDebugEnabled()) {
// log.debug("integrationClientService initialized");
// }
// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService);
// }
//
// protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
// APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null);
// }
/**
* Sets Realm Service.

@ -47,46 +47,39 @@
org.wso2.carbon.apimgt.integration.client.*,
!org.wso2.carbon.apimgt.integration.client.internal
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
feign,
feign.codec,
feign.auth,
feign.gson,
feign.slf4j,
org.wso2.carbon.apimgt.integration.generated.client.publisher.api,
org.wso2.carbon.apimgt.integration.generated.client.store.api,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers;resolution:=optional,
org.apache.commons.logging,
org.w3c.dom,
org.wso2.carbon.context,
org.wso2.carbon.identity.jwt.client.*,
org.wso2.carbon.user.api,
org.wso2.carbon.utils,
com.fasterxml.jackson.annotation,
io.swagger.annotations,
org.wso2.carbon.core.util,
javax.xml,
org.wso2.carbon.base,
javax.net.ssl,
org.apache.commons.lang,
android.util;resolution:=optional,
javax.annotation;resolution:=optional,
javax.net;resolution:=optional,
javax.security.auth.x500;resolution:=optional,
javax.crypto;resolution:=optional,
javax.crypto.spec;resolution:=optional
</Import-Package>
<Embed-Dependency>
jsr311-api,
feign-jaxrs,
feign-okhttp,
okhttp,
okio
</Embed-Dependency>
<!--<Import-Package>-->
<!--feign;version="9.3",feign.auth;version="9.3",feign.cod-->
<!--ec;version="9.3",feign.gson;version="9.3",feign.jaxrs;version="9.3",f-->
<!--eign.okhttp;version="9.3",feign.slf4j;version="10.7",javax.net.ssl,ja-->
<!--vax.ws.rs,javax.xml,javax.xml.bind;version="2.3",javax.xml.bind.annot-->
<!--ation;version="2.3",javax.xml.parsers,okhttp3,org.apache.commons.lang-->
<!--;version="2.4",org.apache.commons.logging;version="1.2",org.osgi.fram-->
<!--ework;version="1.7",org.osgi.service.component;version="1.2",org.w3c.-->
<!--dom,org.wso2.carbon.apimgt.integration.client,org.wso2.carbon.apimgt.-->
<!--integration.client.configs,org.wso2.carbon.apimgt.integration.client.-->
<!--exception,org.wso2.carbon.apimgt.integration.client.internal,org.wso2-->
<!--.carbon.apimgt.integration.client.model,org.wso2.carbon.apimgt.integr-->
<!--ation.client.publisher,org.wso2.carbon.apimgt.integration.client.serv-->
<!--ice,org.wso2.carbon.apimgt.integration.client.store,org.wso2.carbon.a-->
<!--pimgt.integration.client.util,org.wso2.carbon.base;version="1.0",org.-->
<!--wso2.carbon.context;version="4.6",org.wso2.carbon.core.util;version="-->
<!--4.6",org.wso2.carbon.identity.jwt.client.extension,org.wso2.carbon.id-->
<!--entity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt.client.e-->
<!--xtension.exception,org.wso2.carbon.identity.jwt.client.extension.serv-->
<!--ice,org.wso2.carbon.utils;version="4.6"-->
<!--org.osgi.framework.*;version="${imp.package.version.osgi.framework}",-->
<!--org.osgi.service.*;version="${imp.package.version.osgi.service}",-->
<!--</Import-Package>-->
<!--<Embed-Dependency>-->
<!--jsr311-api,-->
<!--feign-jaxrs,-->
<!--feign-okhttp,-->
<!--okhttp,-->
<!--okio-->
<!--</Embed-Dependency>-->
</instructions>
</configuration>
</plugin>
@ -120,55 +113,60 @@
</build>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.squareup.okhttp3</groupId>-->
<!--<artifactId>okhttp</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.squareup.okio</groupId>-->
<!--<artifactId>okio</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>10.7.2</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon</groupId>-->
<!--<artifactId>org.wso2.carbon.logging</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.osgi</groupId>-->
<!--<artifactId>org.eclipse.osgi</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.osgi</groupId>-->
<!--<artifactId>org.eclipse.osgi.services</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.google.code.gson</groupId>-->
<!--<artifactId>gson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>io.swagger</groupId>-->
<!--<artifactId>swagger-annotations</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>junit</groupId>-->
<!--<artifactId>junit</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-jackson</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jaxrs</artifactId>
@ -178,10 +176,10 @@
<artifactId>feign-gson</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.testng</groupId>-->
<!--<artifactId>testng</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>

@ -27,7 +27,8 @@ import feign.slf4j.Slf4jLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApIsApi;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApiLifecycleApi;
import org.wso2.carbon.core.util.Utils;
/**
@ -36,13 +37,15 @@ import org.wso2.carbon.core.util.Utils;
public class PublisherClient {
private static final Log log = LogFactory.getLog(PublisherClient.class);
private APIIndividualApi api = null;
private APICollectionApi apis = null;
private DocumentIndividualApi document = null;
private ApplicationIndividualApi application = null;
private EnvironmentCollectionApi environments = null;
private SubscriptionCollectionApi subscriptions = null;
private ThrottlingTierCollectionApi tiers = null;
private ApIsApi apIsApi = null;
private ApiLifecycleApi apiLifecycleApi = null;
// private APIIndividualApi api = null;
// private APICollectionApi apis = null;
// private DocumentIndividualApi document = null;
// private ApplicationIndividualApi application = null;
// private EnvironmentCollectionApi environments = null;
// private SubscriptionApi subscriptions = null;
// private ThrottlingTierCollectionApi tiers = null;
/**
@ -57,40 +60,50 @@ public class PublisherClient {
.requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint());
api = builder.target(APIIndividualApi.class, basePath);
apis = builder.target(APICollectionApi.class, basePath);
document = builder.target(DocumentIndividualApi.class, basePath);
application = builder.target(ApplicationIndividualApi.class, basePath);
environments = builder.target(EnvironmentCollectionApi.class, basePath);
subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
tiers = builder.target(ThrottlingTierCollectionApi.class, basePath);
apIsApi = builder.target(ApIsApi.class, basePath);
apiLifecycleApi = builder.target(ApiLifecycleApi.class, basePath);
// api = builder.target(APIIndividualApi.class, basePath);
// apis = builder.target(APICollectionApi.class, basePath);
// document = builder.target(DocumentIndividualApi.class, basePath);
// application = builder.target(ApplicationIndividualApi.class, basePath);
// environments = builder.target(EnvironmentCollectionApi.class, basePath);
// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
// tiers = builder.target(ThrottlingTierCollectionApi.class, basePath);
}
public APIIndividualApi getApi() {
return api;
public ApIsApi getApIsApi() {
return apIsApi;
}
public APICollectionApi getApis() {
return apis;
public ApiLifecycleApi getApiLifecycleApi() {
return apiLifecycleApi;
}
public DocumentIndividualApi getDocument() {
return document;
}
public ApplicationIndividualApi getApplication() {
return application;
}
public EnvironmentCollectionApi getEnvironments() {
return environments;
}
public SubscriptionCollectionApi getSubscriptions() {
return subscriptions;
}
public ThrottlingTierCollectionApi getTiers() {
return tiers;
}
// public APIIndividualApi getApi() {
// return api;
// }
//
// public APICollectionApi getApis() {
// return apis;
// }
//
// public DocumentIndividualApi getDocument() {
// return document;
// }
//
// public ApplicationIndividualApi getApplication() {
// return application;
// }
//
// public EnvironmentCollectionApi getEnvironments() {
// return environments;
// }
//
// public SubscriptionCollectionApi getSubscriptions() {
// return subscriptions;
// }
//
// public ThrottlingTierCollectionApi getTiers() {
// return tiers;
// }
}

@ -39,16 +39,17 @@ import java.util.concurrent.TimeUnit;
public class StoreClient {
private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class);
private APICollectionApi apis = null;
private APIIndividualApi individualApi = null;
private ApplicationCollectionApi applications = null;
private ApplicationIndividualApi individualApplication = null;
private SubscriptionCollectionApi subscriptions = null;
private SubscriptionIndividualApi individualSubscription = null;
private SubscriptionMultitpleApi subscriptionMultitpleApi = null;
private ThrottlingTierIndividualApi individualTier = null;
private TagCollectionApi tags = null;
private ThrottlingTierCollectionApi tiers = null;
private ApplicationsApi applicationsApi = null;
// private APICollectionApi apis = null;
// private ApIsApi individualApi = null;
// private ApplicationsApi applications = null;
// private ApplicationIndividualApi individualApplication = null;
// private SubscriptionCollectionApi subscriptions = null;
// private SubscriptionIndividualApi individualSubscription = null;
// private SubscriptionMultitpleApi subscriptionMultitpleApi = null;
// private ThrottlingTierIndividualApi individualTier = null;
// private TagsApi tags = null;
// private ThrottlingTierCollectionApi tiers = null;
public StoreClient(RequestInterceptor requestInterceptor) {
@ -60,58 +61,59 @@ public class StoreClient {
.requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint());
apis = builder.target(APICollectionApi.class, basePath);
individualApi = builder.target(APIIndividualApi.class, basePath);
applications = builder.target(ApplicationCollectionApi.class, basePath);
individualApplication = builder.target(ApplicationIndividualApi.class, basePath);
subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath);
subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath);
tags = builder.target(TagCollectionApi.class, basePath);
individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath);
tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1))
.options(new Request.Options(10000, 5000))
.target(ThrottlingTierCollectionApi.class, basePath);
applicationsApi = builder.target(ApplicationsApi.class, basePath);
// apis = builder.target(APICollectionApi.class, basePath);
// individualApi = builder.target(ApIsApi.class, basePath);
// applications = builder.target(ApplicationCollectionApi.class, basePath);
// individualApplication = builder.target(ApplicationIndividualApi.class, basePath);
// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
// individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath);
// subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath);
// tags = builder.target(TagCollectionApi.class, basePath);
// individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath);
// tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1))
// .options(new Request.Options(10000, 5000))
// .target(ThrottlingTierCollectionApi.class, basePath);
}
public APICollectionApi getApis() {
return apis;
}
public APIIndividualApi getIndividualApi() {
return individualApi;
}
public ApplicationCollectionApi getApplications() {
return applications;
}
public ApplicationIndividualApi getIndividualApplication() {
return individualApplication;
}
public SubscriptionCollectionApi getSubscriptions() {
return subscriptions;
}
public SubscriptionIndividualApi getIndividualSubscription() {
return individualSubscription;
}
public ThrottlingTierIndividualApi getIndividualTier() {
return individualTier;
}
public TagCollectionApi getTags() {
return tags;
}
public ThrottlingTierCollectionApi getTiers() {
return tiers;
}
public SubscriptionMultitpleApi getSubscriptionMultitpleApi() {
return subscriptionMultitpleApi;
}
// public APICollectionApi getApis() {
// return apis;
// }
//
// public APIIndividualApi getIndividualApi() {
// return individualApi;
// }
//
// public ApplicationCollectionApi getApplications() {
// return applications;
// }
//
// public ApplicationIndividualApi getIndividualApplication() {
// return individualApplication;
// }
//
// public SubscriptionCollectionApi getSubscriptions() {
// return subscriptions;
// }
//
// public SubscriptionIndividualApi getIndividualSubscription() {
// return individualSubscription;
// }
//
// public ThrottlingTierIndividualApi getIndividualTier() {
// return individualTier;
// }
//
// public TagCollectionApi getTags() {
// return tags;
// }
//
// public ThrottlingTierCollectionApi getTiers() {
// return tiers;
// }
//
// public SubscriptionMultitpleApi getSubscriptionMultitpleApi() {
// return subscriptionMultitpleApi;
// }
}

@ -26,61 +26,59 @@
<url>http://wso2.org</url>
<build>
<plugins>
<!--swagger yaml is used to generate code-->
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>process-resources</phase>
<id>publisher</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/publisher-api.yaml</inputSpec>
<language>java</language>
<configOptions>
<apiPackage>${project.artifactId}.publisher.api</apiPackage>
<modelPackage>${project.artifactId}.publisher.model</modelPackage>
</configOptions>
<library>feign</library>
</configuration>
</execution>
<execution>
<phase>process-resources</phase>
<id>store</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/store-api.yaml</inputSpec>
<language>java</language>
<configOptions>
<apiPackage>${project.artifactId}.store.api</apiPackage>
<modelPackage>${project.artifactId}.store.model</modelPackage>
</configOptions>
<library>feign</library>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<id>publisher</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/publisher-api.yaml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<apiPackage>${project.artifactId}.publisher.api</apiPackage>
<modelPackage>${project.artifactId}.publisher.model</modelPackage>
</configOptions>
</configuration>
</execution>
<execution>
<phase>process-resources</phase>
<id>store</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/devportal-api.yaml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<apiPackage>${project.artifactId}.store.api</apiPackage>
<modelPackage>${project.artifactId}.store.model</modelPackage>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<!-- Replace java code that is generated from swagger to fix swagger client generation issues. -->
<!--Replace java code that is generated from swagger to fix swagger client generation issues.-->
<execution>
<phase>process-resources</phase>
<id>replace-for-swagger-genenerated-code-publisher</id>
<id>replace-for-openapi-genenerated-code-publisher</id>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java</file>
<file>${project.basedir}/target/generated-sources/openapi/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java</file>
<replacements>
<replacement>
<token>CURRENT_TENANT</token>
@ -115,28 +113,33 @@
org.wso2.carbon.apimgt.integration.generated.client.store.api.*,
org.wso2.carbon.apimgt.integration.generated.client.store.model.*
</Export-Package>
<Import-Package>
feign;version="${io.github.openfeign.version.range}",
feign.jackson;version="${io.github.openfeign.version.range}",
feign.codec;version="${io.github.openfeign.version.range}",
feign.auth;version="${io.github.openfeign.version.range}",
feign.gson;version="${io.github.openfeign.version.range}",
feign.slf4j;version="${io.github.openfeign.version.range}",
com.google.gson,
com.fasterxml.jackson.core;resolution:=optional,
com.fasterxml.jackson.annotation,
com.fasterxml.jackson.databind;resolution:=optional,
io.swagger.annotations,
javax.net.ssl,
com.fasterxml.jackson.datatype.joda;resolution:=optional,
org.apache.oltu.oauth2.client.*;resolution:=optional,
org.apache.oltu.oauth2.common.*;resolution:=optional,
org.junit;resolution:=optional,
</Import-Package>
<Embed-Dependency>
jsr311-api,
feign-jaxrs
</Embed-Dependency>
<Import-Package>
com.google.gson;version="[2.8,3)",
com.google.gson.annotations;version="[2.8,3)",
com.google.gson.internal.bind.util,
com.google.gson.reflect;version="[2.8,3)",
com.google.gson.stream;version="[2.8,3)",
io.gsonfire;version="[1.8,2)",
io.swagger.annotations;version="[1.5,2)",
javax.annotation;version="[3.0,4)",
javax.net.ssl,
okhttp3,
okhttp3.internal.http,
okhttp3.internal.tls,
okhttp3.logging,
okio,
org.apache.oltu.oauth2.client;version="[1.0,2)",
org.apache.oltu.oauth2.client.request;version="[1.0,2)",
org.apache.oltu.oauth2.client.response;version="[1.0,2)",
org.apache.oltu.oauth2.common.exception;version="[1.0,2)",
org.apache.oltu.oauth2.common.message.types;version="[1.0,2)",
org.threeten.bp;version="[1.5,2)",
org.threeten.bp.format;version="[1.5,2)",
org.threeten.bp.temporal;version="[1.5,2)",
org.wso2.carbon.apimgt.integration.generated.client.publisher.model,
org.wso2.carbon.apimgt.integration.generated.client.store.model
</Import-Package>
</instructions>
</configuration>
</plugin>
@ -145,60 +148,105 @@
</build>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.1.7</version>
</dependency>
<!---->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-gson</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.9.1</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.0.25</version>
</dependency>
<!--<dependency>-->
<!--<groupId>junit</groupId>-->
<!--<artifactId>junit</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-core</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-jackson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-jaxrs</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-gson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.testng</groupId>-->
<!--<artifactId>testng</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.oltu.oauth2</groupId>-->
<!--<artifactId>org.apache.oltu.oauth2.client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-slf4j</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>-->
<!--<artifactId>jackson-databind</artifactId>-->
<!--<version>${jackson-databind.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.fasterxml.jackson.datatype</groupId>-->
<!--<artifactId>jackson-datatype-joda</artifactId>-->
<!--</dependency>-->
</dependencies>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>

@ -43,10 +43,22 @@
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testng</groupId>
@ -55,62 +67,166 @@
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.scannotation</groupId>
<artifactId>scannotation</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.lcm</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
<scope>provided</scope>
<version>9.0.5</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<version>9.0.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
@ -144,70 +260,62 @@
org.wso2.carbon.apimgt.webapp.publisher.*
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
javax.servlet,
javax.xml.*,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
com.google.gson.*,
org.apache.catalina,
org.apache.catalina.core,
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.wso2.carbon.core,
org.apache.commons.lang,
org.wso2.carbon.utils,
org.wso2.carbon.apimgt.annotations.*,
org.wso2.carbon.governance.lcm.util.*,
org.wso2.carbon.registry.core.*,
io.swagger.annotations,
javax.net.ssl,
org.scannotation,
org.scannotation.archiveiterator,
org.w3c.dom,
org.wso2.carbon.apimgt.integration.client.*,
org.wso2.carbon.context,
org.wso2.carbon.core.util,
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.*,
org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.apimgt.integration.generated.client.publisher.api,
org.wso2.carbon.apimgt.integration.generated.client.publisher.model
com.google.gson;version="2.3",com.google.gson.reflect;
version="2.3",io.swagger.annotations,javax.servlet;version="2.6",javax.xml,javax.xml.bind,javax.xml.bind.annotat
ion,javax.xml.parsers,org.apache.catalina;version="9.0",org.apache.ca
talina.core;version="9.0",org.apache.commons.logging;version="1.2",org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",org.scannotation;version="1.0",org.scannotation.archiveiterator;ve
rsion="1.0",org.w3c.dom,org.wso2.carbon.apimgt.annotations.api,org.ws
o2.carbon.apimgt.api,org.wso2.carbon.apimgt.api.model,org.wso2.carbon
.apimgt.impl,org.wso2.carbon.apimgt.webapp.publisher,org.wso2.carbon.
apimgt.webapp.publisher.config,org.wso2.carbon.apimgt.webapp.publishe
r.dto,org.wso2.carbon.apimgt.webapp.publisher.exception,org.wso2.carb
on.apimgt.webapp.publisher.lifecycle.listener,org.wso2.carbon.apimgt.
webapp.publisher.lifecycle.util,org.wso2.carbon.base;version="1.0",or
g.wso2.carbon.context;version="4.6",org.wso2.carbon.core;version="4.6
",org.wso2.carbon.core.util;version="4.6",org.wso2.carbon.registry.co
re.service;version="1.0",org.wso2.carbon.user.api;version="1.0",org.w
so2.carbon.user.core.service;version="4.6",org.wso2.carbon.user.core.
tenant;version="4.6",org.wso2.carbon.utils;version="4.6",org.wso2.car
bon.utils.multitenancy;version="4.6"
</Import-Package>
<Embed-Dependency>
javax.ws.rs-api,
scribe;scope=compile|runtime;inline=false;
<!--javax.ws.rs;scope=compile|runtime;inline=false-->
jsr311-api;scope=compile|runtime;inline=false
<!--scribe;scope=compile|runtime;inline=false;-->
</Embed-Dependency>
<DynamicImport-Package>*</DynamicImport-Package>
<!--<DynamicImport-Package>*</DynamicImport-Package>-->
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--<plugin>-->
<!--<groupId>org.jacoco</groupId>-->
<!--<artifactId>jacoco-maven-plugin</artifactId>-->
<!--<configuration>-->
<!--<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>-->
<!--</configuration>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>jacoco-initialize</id>-->
<!--<goals>-->
<!--<goal>prepare-agent</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--<execution>-->
<!--<id>jacoco-site</id>-->
<!--<phase>test</phase>-->
<!--<goals>-->
<!--<goal>report</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>-->
<!--<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins>
</build>
</project>

@ -18,15 +18,34 @@
*/
package org.wso2.carbon.apimgt.webapp.publisher;
import feign.FeignException;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*;
import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.FaultGatewaysException;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.apimgt.api.model.APIRevision;
import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment;
import org.wso2.carbon.apimgt.api.model.CORSConfiguration;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.apimgt.api.model.Tier;
import org.wso2.carbon.apimgt.api.model.URITemplate;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate;
import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
//import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*;
//import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
/**
* This class represents the concrete implementation of the APIPublisherService that corresponds to providing all
@ -39,6 +58,7 @@ public class APIPublisherServiceImpl implements APIPublisherService {
private static final String PUBLISHED_STATUS = "PUBLISHED";
private static final String CREATED_STATUS = "CREATED";
private static final String PUBLISH_ACTION = "Publish";
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
@Override
public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException {
@ -47,99 +67,127 @@ public class APIPublisherServiceImpl implements APIPublisherService {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner());
try {
PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService()
.getPublisherClient();
APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(apiConfig.getOwner());
API api = getAPI(apiConfig);
APIList apiList = publisherClient.getApis().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null);
if (!isExist(api, apiList)) {
api = publisherClient.getApi().apisPost(api, CONTENT_TYPE, null);
if (CREATED_STATUS.equals(api.getStatus())) {
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null);
if (!apiProvider.isAPIAvailable(api.getId())) {
API createdAPI = apiProvider.addAPI(api);
if (CREATED_STATUS.equals(createdAPI.getStatus())) {
apiProvider.changeLifeCycleStatus(tenantDomain, createdAPI.getUuid(), PUBLISH_ACTION, null);
APIRevision apiRevision = new APIRevision();
apiRevision.setApiUUID(createdAPI.getUuid());
apiRevision.setDescription("Initial Revision");
String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain);
APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment();
apiRevisionDeployment.setDeployment(API_PUBLISH_ENVIRONMENT);
apiRevisionDeployment.setVhost("localhost");
apiRevisionDeployment.setDisplayOnDevportal(true);
List<APIRevisionDeployment> apiRevisionDeploymentList = new ArrayList<>();
apiRevisionDeploymentList.add(apiRevisionDeployment);
apiProvider.deployAPIRevision(createdAPI.getUuid(), apiRevisionId, apiRevisionDeploymentList);
}
} else {
if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) {
for (APIInfo apiInfo : apiList.getList()) {
if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) {
api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null);
if (api != null && CREATED_STATUS.equals(api.getStatus())) {
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null,
null);
}
API existingAPI = apiProvider.getAPI(api.getId());
api.setStatus(existingAPI.getStatus());
apiProvider.updateAPI(api);
if (api.getId().getName().equals(existingAPI.getId().getName()) &&
api.getId().getVersion().equals(existingAPI.getId().getVersion())) {
if (CREATED_STATUS.equals(existingAPI.getStatus())) {
apiProvider.changeLifeCycleStatus(tenantDomain, existingAPI.getUuid(), PUBLISH_ACTION, null);
}
}
}
}
} catch (FeignException e) {
} catch (FaultGatewaysException | APIManagementException e) {
throw new APIManagerPublisherException(e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
private boolean isExist(API api, APIList apiList) {
if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) {
return false;
}
for (APIInfo existingApi : apiList.getList()) {
if (existingApi.getName() != null && existingApi.getName().equals(api.
getName()) && existingApi.getVersion() != null &&
existingApi.getVersion().equals(api.getVersion())) {
return true;
}
}
return false;
}
private API getAPI(APIConfig config) {
API api = new API();
api.setName(config.getName());
APIIdentifier apiIdentifier = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
API api = new API(apiIdentifier);
api.setDescription("");
String context = config.getContext();
context = context.startsWith("/") ? context : ("/" + context);
api.setContext(context);
api.setVersion(config.getVersion());
api.setProvider(config.getOwner());
api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config));
api.setWsdlUri(null);
api.setStatus(PUBLISHED_STATUS);
api.setResponseCaching("DISABLED");
api.setDestinationStatsEnabled("false");
api.isDefaultVersion(config.isDefault());
List<String> transport = new ArrayList<>();
transport.add("https");
transport.add("http");
api.transport(transport);
api.setTags(Arrays.asList(config.getTags()));
api.addTiersItem(UNLIMITED_TIER);
api.setGatewayEnvironments(API_PUBLISH_ENVIRONMENT);
api.setContext(context + "/" + config.getVersion());
// api.setContext(context);
api.setStatus(CREATED_STATUS);
api.setWsdlUrl(null);
api.setResponseCache("Disabled");
api.setContextTemplate(context + "/{version}" );
api.setSwaggerDefinition(APIPublisherUtil.getSwaggerDefinition(config));
api.setType("HTTP");
Set<URITemplate> uriTemplates = new HashSet<>();
Iterator<ApiUriTemplate> iterator;
for (iterator = config.getUriTemplates().iterator(); iterator.hasNext(); ) {
ApiUriTemplate apiUriTemplate = iterator.next();
URITemplate uriTemplate = new URITemplate();
uriTemplate.setAuthType(apiUriTemplate.getAuthType());
uriTemplate.setHTTPVerb(apiUriTemplate.getHttpVerb());
uriTemplate.setResourceURI(apiUriTemplate.getResourceURI());
uriTemplate.setUriTemplate(apiUriTemplate.getUriTemplate());
Scope scope = new Scope();
if (apiUriTemplate.getScope() != null) {
scope.setName(apiUriTemplate.getScope().getName());
scope.setDescription(apiUriTemplate.getScope().getDescription());
scope.setKey(apiUriTemplate.getScope().getKey());
scope.setRoles(apiUriTemplate.getScope().getRoles());
uriTemplate.setScope(scope);
}
uriTemplates.add(uriTemplate);
}
api.setUriTemplates(uriTemplates);
api.setApiOwner(config.getOwner());
api.setDefaultVersion(config.isDefault());
api.setTransports("https,http");
Set<String> tags = new HashSet<>();
tags.addAll(Arrays.asList(config.getTags()));
api.setTags(tags);
Set<Tier> availableTiers = new HashSet<>();
availableTiers.add(new Tier(UNLIMITED_TIER));
api.setAvailableTiers(availableTiers);
Set<String> environments = new HashSet<>();
environments.add(API_PUBLISH_ENVIRONMENT);
api.setEnvironments(environments);
if (config.isSharedWithAllTenants()) {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.all_tenants);
api.setVisibility(API.VisibilityEnum.PUBLIC);
api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_ALL_TENANTS);
api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
} else {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.current_tenant);
api.setVisibility(API.VisibilityEnum.PRIVATE);
api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT);
api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY);
}
String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() +
"\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}";
// String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() +
// "\",\"config\":null},\"endpoint_type\":\"http\"}";
String endpointConfig = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " +
config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }";
api.setEndpointConfig(endpointConfig);
APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration();
List<String> accessControlAllowOrigins = new ArrayList<>();
accessControlAllowOrigins.add("*");
apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins);
List<String> accessControlAllowHeaders = new ArrayList<>();
accessControlAllowHeaders.add("authorization");
accessControlAllowHeaders.add("Access-Control-Allow-Origin");
accessControlAllowHeaders.add("Content-Type");
accessControlAllowHeaders.add("SOAPAction");
apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders);
accessControlAllowHeaders.add("apikey");
accessControlAllowHeaders.add("testKey");
List<String> accessControlAllowMethods = new ArrayList<>();
accessControlAllowMethods.add("GET");
accessControlAllowMethods.add("PUT");
@ -147,10 +195,16 @@ public class APIPublisherServiceImpl implements APIPublisherService {
accessControlAllowMethods.add("POST");
accessControlAllowMethods.add("PATCH");
accessControlAllowMethods.add("OPTIONS");
apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods);
apiCorsConfiguration.setAccessControlAllowCredentials(false);
apiCorsConfiguration.corsConfigurationEnabled(false);
api.setCorsConfiguration(apiCorsConfiguration);
CORSConfiguration corsConfiguration = new CORSConfiguration(false, accessControlAllowOrigins, false,
accessControlAllowHeaders, accessControlAllowMethods);
api.setCorsConfiguration(corsConfiguration);
api.setAuthorizationHeader("Authorization");
List<String> keyManagers = new ArrayList<>();
keyManagers.add("all");
api.setKeyManagers(keyManagers);
api.setEnableStore(true);
return api;
}
}

@ -18,7 +18,7 @@
*/
package org.wso2.carbon.apimgt.webapp.publisher.internal;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.webapp.publisher.APIConfig;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.registry.core.service.RegistryService;
@ -37,7 +37,7 @@ public class APIPublisherDataHolder {
private RegistryService registryService;
private boolean isServerStarted;
private Stack<APIConfig> unpublishedApis = new Stack<>();
private IntegrationClientService integrationClientService;
// private IntegrationClientService integrationClientService;
private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder();
@ -117,12 +117,12 @@ public class APIPublisherDataHolder {
this.unpublishedApis = unpublishedApis;
}
public IntegrationClientService getIntegrationClientService() {
return integrationClientService;
}
// public IntegrationClientService getIntegrationClientService() {
// return integrationClientService;
// }
public void setIntegrationClientService(
IntegrationClientService integrationClientService) {
this.integrationClientService = integrationClientService;
}
// public void setIntegrationClientService(
// IntegrationClientService integrationClientService) {
// this.integrationClientService = integrationClientService;
// }
}

@ -22,7 +22,7 @@ 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.apimgt.integration.client.service.IntegrationClientService;
//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler;
@ -45,11 +45,7 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic"
* bind="setRegistryService"
* unbind="unsetRegistryService"
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
* cardinality="1..1"
* policy="dynamic"
* bind="setIntegrationClientService"
* unbind="unsetIntegrationClientService"
*/
public class APIPublisherServiceComponent {
@ -120,14 +116,14 @@ public class APIPublisherServiceComponent {
APIPublisherDataHolder.getInstance().setRegistryService(null);
}
protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
if (integrationClientService != null && log.isDebugEnabled()) {
log.debug("integrationClientService initialized");
}
APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService);
}
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
APIPublisherDataHolder.getInstance().setIntegrationClientService(null);
}
// protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
// if (integrationClientService != null && log.isDebugEnabled()) {
// log.debug("integrationClientService initialized");
// }
// APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService);
// }
//
// protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
// APIPublisherDataHolder.getInstance().setIntegrationClientService(null);
// }
}

@ -34,13 +34,13 @@
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.apimgt.integration.generated.client</module>
<module>org.wso2.carbon.apimgt.integration.client</module>
<!--<module>org.wso2.carbon.apimgt.integration.generated.client</module>-->
<!--<module>org.wso2.carbon.apimgt.integration.client</module>-->
<module>org.wso2.carbon.apimgt.webapp.publisher</module>
<module>org.wso2.carbon.apimgt.application.extension</module>
<module>org.wso2.carbon.apimgt.application.extension.api</module>
<module>org.wso2.carbon.apimgt.annotations</module>
<module>org.wso2.carbon.apimgt.handlers</module>
<!--<module>org.wso2.carbon.apimgt.handlers</module>-->
</modules>
<build>

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -56,7 +56,7 @@
io.swagger.annotations.*;resolution:=optional,
com.fasterxml.jackson.annotation,
javax.validation.constraints,
javax.xml.bind.annotation.*,
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
</Import-Package>
<Export-Package>
org.wso2.carbon.device.application.mgt.common.*

@ -51,8 +51,66 @@
<Bundle-Description>Application Management Core Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.application.mgt.core.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
<!--com.dd.plist;version="[1.21,2)",com.google.gson;versio-->
<!--n="[2.3,3)",com.google.gson.reflect;version="[2.3,3)",javax.annotatio-->
<!--n;version="[1.3,2)",javax.naming,javax.sql,javax.ws.rs.core;version="-->
<!--[2.0,3)",javax.xml.bind;version="[2.3,3)",javax.xml.bind.annotation;v-->
<!--ersion="[2.3,3)",javax.xml.parsers,org.apache.commons.codec.binary;ve-->
<!--rsion="[1.4,2)",org.apache.commons.codec.digest;version="[1.4,2)",org-->
<!--.apache.commons.httpclient;version="[3.1,4)",org.apache.commons.httpc-->
<!--lient.methods;version="[3.1,4)",org.apache.commons.io;version="[2.4,3-->
<!--)",org.apache.commons.lang;version="[2.6,3)",org.apache.commons.loggi-->
<!--ng;version="[1.2,2)",org.apache.commons.validator.routines;version="[-->
<!--1.6,2)",org.apache.cxf.jaxrs.ext.multipart;version="[3.3,4)",org.boun-->
<!--cycastle.cert,org.bouncycastle.cert.jcajce,org.bouncycastle.cms,org.b-->
<!--ouncycastle.jce.provider;version="[1.60,2)",org.bouncycastle.util;ver-->
<!--sion="[1.60,2)",org.json;version="[3.0,4)",org.osgi.framework;version-->
<!--="[1.7,2)",org.osgi.service.component;version="[1.2,2)",org.quartz;ve-->
<!--rsion="[2.1,3)",org.wso2.carbon.apimgt.application.extension;version=-->
<!--"[4.1,5)",org.wso2.carbon.apimgt.application.extension.dto;version="[-->
<!--4.1,5)",org.wso2.carbon.apimgt.application.extension.exception;versio-->
<!--n="[4.1,5)",org.wso2.carbon.context;version="[4.6,5)",org.wso2.carbon-->
<!--.device.application.mgt.common;version="[4.1,5)",org.wso2.carbon.devi-->
<!--ce.application.mgt.common.config;version="[4.1,5)",org.wso2.carbon.de-->
<!--vice.application.mgt.common.dto;version="[4.1,5)",org.wso2.carbon.dev-->
<!--ice.application.mgt.common.exception;version="[4.1,5)",org.wso2.carbo-->
<!--n.device.application.mgt.common.response;version="[4.1,5)",org.wso2.c-->
<!--arbon.device.application.mgt.common.services;version="[4.1,5)",org.ws-->
<!--o2.carbon.device.application.mgt.common.wrapper;version="[4.1,5)",org-->
<!--.wso2.carbon.device.application.mgt.core.config,org.wso2.carbon.devic-->
<!--e.application.mgt.core.dao,org.wso2.carbon.device.application.mgt.cor-->
<!--e.dao.common,org.wso2.carbon.device.application.mgt.core.dao.impl,org-->
<!--.wso2.carbon.device.application.mgt.core.dao.impl.application,org.wso-->
<!--2.carbon.device.application.mgt.core.dao.impl.application.release,org-->
<!--.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate,org.-->
<!--wso2.carbon.device.application.mgt.core.dao.impl.review,org.wso2.carb-->
<!--on.device.application.mgt.core.dao.impl.subscription,org.wso2.carbon.-->
<!--device.application.mgt.core.dao.impl.visibility,org.wso2.carbon.devic-->
<!--e.application.mgt.core.exception,org.wso2.carbon.device.mgt.common;ve-->
<!--rsion="[4.1,5)",org.wso2.carbon.device.mgt.common.app.mgt;version="[4-->
<!--.1,5)",org.wso2.carbon.device.mgt.common.app.mgt.android;version="[4.-->
<!--1,5)",org.wso2.carbon.device.mgt.common.exceptions;version="[4.1,5)",-->
<!--org.wso2.carbon.device.mgt.common.group.mgt;version="[4.1,5)",org.wso-->
<!--2.carbon.device.mgt.common.operation.mgt;version="[4.1,5)",org.wso2.c-->
<!--arbon.device.mgt.common.permission.mgt;version="[4.1,5)",org.wso2.car-->
<!--bon.device.mgt.core.dto;version="[4.1,5)",org.wso2.carbon.device.mgt.-->
<!--core.operation.mgt;version="[4.1,5)",org.wso2.carbon.device.mgt.core.-->
<!--permission.mgt;version="[4.1,5)",org.wso2.carbon.device.mgt.core.serv-->
<!--ice;version="[4.1,5)",org.wso2.carbon.device.mgt.core.task.impl;versi-->
<!--on="[4.1,5)",org.wso2.carbon.device.mgt.core.util;version="[4.1,5)",o-->
<!--rg.wso2.carbon.identity.jwt.client.extension,org.wso2.carbon.identity-->
<!--.jwt.client.extension.dto,org.wso2.carbon.identity.jwt.client.extensi-->
<!--on.exception,org.wso2.carbon.identity.jwt.client.extension.service,or-->
<!--g.wso2.carbon.ndatasource.core;version="[4.6,5)",org.wso2.carbon.ntas-->
<!--k.common;version="[4.6,5)",org.wso2.carbon.ntask.core;version="[4.6,5-->
<!--)",org.wso2.carbon.ntask.core.service;version="[4.6,5)",org.wso2.carb-->
<!--on.user.api;version="[1.0,2)",org.wso2.carbon.user.core.service;versi-->
<!--on="[4.6,5)",org.wso2.carbon.utils;version="[4.6,5)",org.wso2.carbon.-->
<!--utils.dbcreator;version="[4.6,5)",org.xml.sax,org.xml.sax.helpers-->
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context.*,
@ -62,8 +120,8 @@
javax.sql,
com.google.gson.*,
javax.naming,
javax.xml.bind.annotation,
javax.xml.bind,
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
javax.xml.bind; version="${javax.xml.bind.imp.pkg.version}",
org.wso2.carbon.device.application.mgt.common.*,
org.wso2.carbon.device.mgt.core.*,
org.wso2.carbon.device.mgt.common.*,
@ -348,6 +406,14 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId></groupId>-->
<!--<artifactId></artifactId>-->
<!--</dependency>-->
</dependencies>
</project>

@ -63,7 +63,7 @@ public class OAuthUtils {
apiApplicationKeyInfo = apiManagementProviderService.
generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE,
registrationProfile.getApplicationName(), registrationProfile.isAllowedToAllDomains(),
null, registrationProfile.isAllowedToAllDomains(),
Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD);
} finally {
PrivilegedCarbonContext.endTenantFlow();

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -133,10 +133,22 @@
</profiles>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
@ -147,24 +159,26 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
@ -207,11 +221,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>javax.servlet-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -133,10 +133,26 @@
</profiles>
<dependencies>
<!--<dependency>-->
<!--<groupId>io.swagger</groupId>-->
<!--<artifactId>swagger-jaxrs</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
@ -147,14 +163,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -204,11 +216,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>javax.servlet-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -72,8 +72,8 @@
org.wso2.carbon.certificate.mgt.core.util
</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
org.apache.commons.collections.map,
javax.security.auth.x500,

@ -140,8 +140,8 @@
org.apache.axis2.deployment.*,
org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}",
org.apache.commons.logging,
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom,
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.*,

@ -82,8 +82,8 @@
org.wso2.carbon.device.mgt.extensions.pull.notification.*
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.core.service

@ -135,7 +135,8 @@
</Export-Package>
<Import-Package>
com.google.gson,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
org.apache.commons.logging,

@ -126,13 +126,13 @@
</Export-Package>
<Import-Package>
org.apache.commons.logging,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.core.service,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core,
com.google.gson,

@ -148,7 +148,8 @@
</Export-Package>
<Import-Package>
org.apache.commons.logging,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
@ -157,7 +158,6 @@
org.wso2.carbon.device.mgt.core.service,
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core,
org.wso2.carbon.device.application.mgt.common.*,

@ -135,14 +135,14 @@
</Export-Package>
<Import-Package>
org.apache.commons.logging,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.core.service,
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.core,
org.wso2.carbon.device.mgt.common.*
</Import-Package>

@ -146,15 +146,26 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!---->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>

@ -200,8 +200,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
KeyManagerConfigurations kmConfig = deviceManagementConfig.getKeyManagerConfigurations();
AppRegistrationCredentials credentials = DeviceManagerUtil.getApplicationRegistrationCredentials(
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HOST),
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HTTPS_PORT),
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HOST),
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HTTPS_PORT),
kmConfig.getAdminUsername(),
kmConfig.getAdminPassword());
AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner(

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -107,8 +107,8 @@
org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${carbon.device.mgt.version}"
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging.*,
org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.context;version="${carbon.kernel.version.range}",

@ -146,30 +146,41 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!---->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
@ -200,11 +211,11 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
@ -351,11 +362,11 @@
<artifactId>org.wso2.carbon.analytics.api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics</groupId>
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics</groupId>-->
<!--<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
@ -402,11 +413,11 @@
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>

@ -67,64 +67,64 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON)
public interface DeviceEventManagementService {
@POST
@Path("/{type}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Adding the Event Type Definition",
notes = "Add the event definition for a device.",
tags = "Device Event Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully added the event defintion.",
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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@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 fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response deployDeviceTypeEventDefinition(
@ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
@PathParam("type")String deviceType,
@ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
@QueryParam("skipPersist") boolean skipPersist,
@ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
@ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
required = true)
@Valid DeviceTypeEvent deviceTypeEvent);
// @POST
// @Path("/{type}")
// @ApiOperation(
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "POST",
// value = "Adding the Event Type Definition",
// notes = "Add the event definition for a device.",
// tags = "Device Event Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully added the event defintion.",
// 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 was last modified.\n" +
// "Used by caches, or in conditional requests."),
// }
// ),
// @ApiResponse(
// code = 400,
// message =
// "Bad Request. \n"),
// @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 fetching the " +
// "list of supported device types.",
// response = ErrorResponse.class)
// }
// )
// Response deployDeviceTypeEventDefinition(
// @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
// @PathParam("type")String deviceType,
// @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
// @QueryParam("skipPersist") boolean skipPersist,
// @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
// @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
// required = true)
// @Valid DeviceTypeEvent deviceTypeEvent);
@DELETE
@Path("/{type}")
@ -178,183 +178,183 @@ public interface DeviceEventManagementService {
"ios, and windows.", required = false)
@PathParam("type")String deviceType);
@GET
@Path("/{type}/{deviceId}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Device Events",
notes = "Get the events for the device.",
tags = "Device Event Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the event definition.",
response = EventRecords.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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@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 fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
@PathParam("deviceId") String deviceId,
@ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
@QueryParam("from") long from,
@ApiParam(name = "to", value = "unix time to retrieve", required = false)
@QueryParam("to") long to,
@ApiParam(name = "type", value = "name of the device type", required = false)
@PathParam("type") String deviceType,
@ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
@QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
@QueryParam("limit") int limit);
// @GET
// @Path("/{type}/{deviceId}")
// @ApiOperation(
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "GET",
// value = "Getting Device Events",
// notes = "Get the events for the device.",
// tags = "Device Event Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully fetched the event definition.",
// response = EventRecords.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 was last modified.\n" +
// "Used by caches, or in conditional requests."),
// }
// ),
// @ApiResponse(
// code = 400,
// message =
// "Bad Request. \n"),
// @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 fetching the " +
// "list of supported device types.",
// response = ErrorResponse.class)
// }
// )
// Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
// @PathParam("deviceId") String deviceId,
// @ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
// @QueryParam("from") long from,
// @ApiParam(name = "to", value = "unix time to retrieve", required = false)
// @QueryParam("to") long to,
// @ApiParam(name = "type", value = "name of the device type", required = false)
// @PathParam("type") String deviceType,
// @ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
// @QueryParam("offset") int offset,
// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
// @QueryParam("limit") int limit);
@GET
@Path("last-known/{type}/{deviceId}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Last Known Device Events",
notes = "Get the last known events for the device.",
tags = "Device Event Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the event.",
response = EventRecords.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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@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 fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true)
@PathParam("deviceId") String deviceId,
@ApiParam(name = "type", value = "name of the device type", required = true)
@PathParam("type") String deviceType,
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
@QueryParam("limit") int limit);
// @GET
// @Path("last-known/{type}/{deviceId}")
// @ApiOperation(
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "GET",
// value = "Getting Last Known Device Events",
// notes = "Get the last known events for the device.",
// tags = "Device Event Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully fetched the event.",
// response = EventRecords.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 was last modified.\n" +
// "Used by caches, or in conditional requests."),
// }
// ),
// @ApiResponse(
// code = 400,
// message =
// "Bad Request. \n"),
// @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 fetching the " +
// "list of supported device types.",
// response = ErrorResponse.class)
// }
// )
// Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true)
// @PathParam("deviceId") String deviceId,
// @ApiParam(name = "type", value = "name of the device type", required = true)
// @PathParam("type") String deviceType,
// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
// @QueryParam("limit") int limit);
@GET
@Path("filter/{type}/{parameter}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting the filtered devices",
notes = "Get the list of devices based on the filter parameter",
tags = "Device Event Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the event.",
response = EventRecords.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 was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message =
"Bad Request. \n"),
@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 fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response getFilteredDevices(
@ApiParam(name = "type", value = "name of the device type", required = true)
@PathParam("type") String deviceType,
@ApiParam(name = "type", value = "name of the parameter", required = true)
@PathParam("type") String parameter,
@ApiParam(name = "limit", value = "minimum value the parameter can have", required = false)
@QueryParam("min") double min,
@ApiParam(name = "max", value = "max value the parameter can have", required = false)
@QueryParam("max") double max
);
// @GET
// @Path("filter/{type}/{parameter}")
// @ApiOperation(
// produces = MediaType.APPLICATION_JSON,
// httpMethod = "GET",
// value = "Getting the filtered devices",
// notes = "Get the list of devices based on the filter parameter",
// tags = "Device Event Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
// })
// }
// )
// @ApiResponses(
// value = {
// @ApiResponse(
// code = 200,
// message = "OK. \n Successfully fetched the event.",
// response = EventRecords.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 was last modified.\n" +
// "Used by caches, or in conditional requests."),
// }
// ),
// @ApiResponse(
// code = 400,
// message =
// "Bad Request. \n"),
// @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 fetching the " +
// "list of supported device types.",
// response = ErrorResponse.class)
// }
// )
// Response getFilteredDevices(
// @ApiParam(name = "type", value = "name of the device type", required = true)
// @PathParam("type") String deviceType,
// @ApiParam(name = "type", value = "name of the parameter", required = true)
// @PathParam("type") String parameter,
// @ApiParam(name = "limit", value = "minimum value the parameter can have", required = false)
// @QueryParam("min") double min,
// @ApiParam(name = "max", value = "max value the parameter can have", required = false)
// @QueryParam("max") double max
// );
@GET
@Path("/{type}")

@ -97,71 +97,71 @@ public interface GeoLocationBasedService {
/**
* Retrieve Analytics for the device type
*/
@GET
@Path("stats/{deviceType}/{deviceId}")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "GET",
value = "Getting the Location Details of a Device",
notes = "Get the location details of a device during a define time period.",
response = Response.class,
tags = "Geo Service Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = Response.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class)
})
Response getGeoDeviceStats(
@ApiParam(
name = "deviceId",
value = "The device ID.",
required = true)
@PathParam("deviceId") String deviceId,
@ApiParam(
name = "device-type",
value = "The device type, such as ios, android, or windows.",
required = true)
@PathParam("deviceType")
@Size(max = 45)
String deviceType,
@ApiParam(
name = "from",
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
required = true)
@QueryParam("from") long from,
@ApiParam(
name = "to",
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
required = true)
@QueryParam("to") long to);
// @GET
// @Path("stats/{deviceType}/{deviceId}")
// @ApiOperation(
// consumes = "application/json",
// produces = "application/json",
// httpMethod = "GET",
// value = "Getting the Location Details of a Device",
// notes = "Get the location details of a device during a define time period.",
// response = Response.class,
// tags = "Geo Service Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
// })
// }
// )
// @ApiResponses(value = {
// @ApiResponse(
// code = 200,
// message = "OK.",
// response = Response.class,
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Type",
// description = "The content type of the body"),
// @ResponseHeader(
// name = "Last-Modified",
// description = "Date and time the resource was last modified.\n" +
// "Used by caches, or in conditional requests."),
// }),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid Device Identifiers found.",
// response = Response.class),
// @ApiResponse(
// code = 401,
// message = "Unauthorized. \n Unauthorized request."),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error on retrieving stats",
// response = Response.class)
// })
// Response getGeoDeviceStats(
// @ApiParam(
// name = "deviceId",
// value = "The device ID.",
// required = true)
// @PathParam("deviceId") String deviceId,
// @ApiParam(
// name = "device-type",
// value = "The device type, such as ios, android, or windows.",
// required = true)
// @PathParam("deviceType")
// @Size(max = 45)
// String deviceType,
// @ApiParam(
// name = "from",
// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
// required = true)
// @QueryParam("from") long from,
// @ApiParam(
// name = "to",
// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
// required = true)
// @QueryParam("to") long to);
/**
* Get data to show device locations in a map
@ -602,128 +602,128 @@ public interface GeoLocationBasedService {
/**
* Retrieve Geo alerts history
*/
@GET
@Path("alerts/history/{deviceType}/{deviceId}")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "GET",
value = "Getting the Geo Service Alert History of a Device",
notes = "Get the geo alert history of a device during the defined time period.",
response = Response.class,
tags = "Geo Service Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = Response.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")
}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class)
})
Response getGeoAlertsHistory(
@ApiParam(
name = "deviceId",
value = "The device ID.",
required = true)
@PathParam("deviceId") String deviceId,
@ApiParam(
name = "device-type",
value = "The device type, such as ios, android, or windows.",
required = true)
@PathParam("deviceType")
@Size(max = 45)
String deviceType,
@ApiParam(
name = "from",
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
required = true)
@QueryParam("from") long from,
@ApiParam(
name = "to",
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
required = true)
@QueryParam("to") long to);
// @GET
// @Path("alerts/history/{deviceType}/{deviceId}")
// @ApiOperation(
// consumes = "application/json",
// produces = "application/json",
// httpMethod = "GET",
// value = "Getting the Geo Service Alert History of a Device",
// notes = "Get the geo alert history of a device during the defined time period.",
// response = Response.class,
// tags = "Geo Service Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
// })
// }
// )
// @ApiResponses(value = {
// @ApiResponse(
// code = 200,
// message = "OK.",
// response = Response.class,
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Type",
// description = "The content type of the body"),
// @ResponseHeader(
// name = "Last-Modified",
// description = "Date and time the resource was last modified.\n" +
// "Used by caches, or in conditional requests.")
// }),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid Device Identifiers found.",
// response = Response.class),
// @ApiResponse(
// code = 401,
// message = "Unauthorized. \n Unauthorized request."),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error on retrieving stats",
// response = Response.class)
// })
// Response getGeoAlertsHistory(
// @ApiParam(
// name = "deviceId",
// value = "The device ID.",
// required = true)
// @PathParam("deviceId") String deviceId,
// @ApiParam(
// name = "device-type",
// value = "The device type, such as ios, android, or windows.",
// required = true)
// @PathParam("deviceType")
// @Size(max = 45)
// String deviceType,
// @ApiParam(
// name = "from",
// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
// required = true)
// @QueryParam("from") long from,
// @ApiParam(
// name = "to",
// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
// required = true)
// @QueryParam("to") long to);
/**
* Retrieve Geo alerts history for geo clusters
*/
@GET
@Path("alerts/history")
@ApiOperation(
consumes = "application/json",
produces = "application/json",
httpMethod = "GET",
value = "Retrieve Geo alerts history for geo clusters",
notes = "Retrieving geo alert history of all defined alerts for geo clusters",
response = Response.class,
tags = "Geo Service Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
})
}
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK.",
response = Response.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.")
}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class),
@ApiResponse(
code = 401,
message = "Unauthorized. \n Unauthorized request."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class)
})
Response getGeoAlertsHistoryForGeoClusters(
@ApiParam(
name = "from",
value = "Get stats from what time",
required = true)
@QueryParam("from") long from,
@ApiParam(
name = "to",
value = "Get stats up to what time",
required = true)
@QueryParam("to") long to);
// @GET
// @Path("alerts/history")
// @ApiOperation(
// consumes = "application/json",
// produces = "application/json",
// httpMethod = "GET",
// value = "Retrieve Geo alerts history for geo clusters",
// notes = "Retrieving geo alert history of all defined alerts for geo clusters",
// response = Response.class,
// tags = "Geo Service Management",
// extensions = {
// @Extension(properties = {
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
// })
// }
// )
// @ApiResponses(value = {
// @ApiResponse(
// code = 200,
// message = "OK.",
// response = Response.class,
// responseHeaders = {
// @ResponseHeader(
// name = "Content-Type",
// description = "The content type of the body"),
// @ResponseHeader(
// name = "Last-Modified",
// description = "Date and time the resource was last modified.\n" +
// "Used by caches, or in conditional requests.")
// }),
// @ApiResponse(
// code = 400,
// message = "Bad Request. \n Invalid Device Identifiers found.",
// response = Response.class),
// @ApiResponse(
// code = 401,
// message = "Unauthorized. \n Unauthorized request."),
// @ApiResponse(
// code = 500,
// message = "Internal Server Error. \n Error on retrieving stats",
// response = Response.class)
// })
// Response getGeoAlertsHistoryForGeoClusters(
// @ApiParam(
// name = "from",
// value = "Get stats from what time",
// required = true)
// @QueryParam("from") long from,
// @ApiParam(
// name = "to",
// value = "Get stats up to what time",
// required = true)
// @QueryParam("to") long to);
/**

@ -26,7 +26,7 @@ import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
@ -280,19 +280,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
i++;
}
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
, Constants.DEFAULT_STREAM_VERSION, metaData
, null, payloadData)) {
// todo: amalka: commented data publishing
// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
// , Constants.DEFAULT_STREAM_VERSION, metaData
// , null, payloadData)) {
return Response.status(Response.Status.OK).build();
} else {
String msg = "Error occurred while publishing the event.";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
} catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing the event.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
// } else {
// String msg = "Error occurred while publishing the event.";
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
// }
// } catch (DataPublisherConfigurationException e) {
// String msg = "Error occurred while publishing the event.";
// log.error(msg, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred when checking for authorization";
log.error(msg, e);
@ -380,19 +381,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
i++;
}
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
, Constants.DEFAULT_STREAM_VERSION, metaData
, null, payloadData)) {
// todo: amalka: commented data publishing
// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
// , Constants.DEFAULT_STREAM_VERSION, metaData
// , null, payloadData)) {
return Response.status(Response.Status.OK).build();
} else {
String msg = "Error occurred while publishing the event.";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
} catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing the event.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
// } else {
// String msg = "Error occurred while publishing the event.";
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
// }
// } catch (DataPublisherConfigurationException e) {
// String msg = "Error occurred while publishing the event.";
// log.error(msg, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred when checking for authorization";
log.error(msg, e);

@ -4,18 +4,18 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Stub;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
//import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
//import org.wso2.carbon.analytics.dataservice.commons.SortByField;
//import org.wso2.carbon.analytics.dataservice.commons.SortType;
//import org.wso2.carbon.analytics.datasource.commons.Record;
//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException;
//import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
//import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@ -81,49 +81,49 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
private static final String MQTT_CONTENT_VALIDATOR = "default";
private static final String TIMESTAMP_FIELD_NAME = "_timestamp";
private static AnalyticsDataAPI getAnalyticsDataAPI() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
AnalyticsDataAPI analyticsDataAPI =
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
if (analyticsDataAPI == null) {
String msg = "Analytics api service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return analyticsDataAPI;
}
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
, int offset, int limit) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
EventRecords eventRecords = new EventRecords();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
if (eventCount == 0) {
eventRecords.setCount(0);
}
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
sortByFields);
List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
eventRecords.setCount(eventCount);
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
records.sort(new Comparator<Record>() {
@Override public int compare(Record r1, Record r2) {
return Long.compare(r2.getTimestamp(), r1.getTimestamp());
}
});
eventRecords.setList(records);
return eventRecords;
}
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
List<String> ids = new ArrayList<>();
for (SearchResultEntry searchResult : searchResults) {
ids.add(searchResult.getId());
}
return ids;
}
// private static AnalyticsDataAPI getAnalyticsDataAPI() {
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
// AnalyticsDataAPI analyticsDataAPI =
// (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
// if (analyticsDataAPI == null) {
// String msg = "Analytics api service has not initialized.";
// log.error(msg);
// throw new IllegalStateException(msg);
// }
// return analyticsDataAPI;
// }
// private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
// , int offset, int limit) throws AnalyticsException {
// int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
// AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
// EventRecords eventRecords = new EventRecords();
// int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
// if (eventCount == 0) {
// eventRecords.setCount(0);
// }
// List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
// sortByFields);
// List<String> recordIds = getRecordIds(resultEntries);
// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
// eventRecords.setCount(eventCount);
// List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
// records.sort(new Comparator<Record>() {
// @Override public int compare(Record r1, Record r2) {
// return Long.compare(r2.getTimestamp(), r1.getTimestamp());
// }
// });
// eventRecords.setList(records);
// return eventRecords;
// }
// private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
// List<String> ids = new ArrayList<>();
// for (SearchResultEntry searchResult : searchResults) {
// ids.add(searchResult.getId());
// }
// return ids;
// }
/**
* Retrieves the stream definition from das for the given device type.
@ -195,65 +195,65 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
/**
* Deploy Event Stream, Receiver, Publisher and Store Configuration.
*/
@POST
@Path("/{type}")
@Override
public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
@QueryParam("skipPersist") boolean skipPersist,
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
@Valid DeviceTypeEvent deviceTypeEvent) {
TransportType transportType = deviceTypeEvent.getTransportType();
EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
try {
if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
deviceType == null || transportType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid Payload";
log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build();
}
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
if (!skipPersist) {
publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
}
publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
try {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
}
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return Response.ok().build();
} catch (AxisFault e) {
log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (RemoteException e) {
log.error("Failed to connect with the remote services:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (JWTClientException e) {
log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (UserStoreException e) {
log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) {
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
// @POST
// @Path("/{type}")
// @Override
// public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
// @QueryParam("skipPersist") boolean skipPersist,
// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
// @Valid DeviceTypeEvent deviceTypeEvent) {
// TransportType transportType = deviceTypeEvent.getTransportType();
// EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// try {
// if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
// deviceType == null || transportType == null ||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
// String errorMessage = "Invalid Payload";
// log.error(errorMessage);
// return Response.status(Response.Status.BAD_REQUEST).build();
// }
// String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
// String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
// if (!skipPersist) {
// publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
// }
// publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
// try {
// PrivilegedCarbonContext.startTenantFlow();
// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
// MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
// if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
// }
// } finally {
// PrivilegedCarbonContext.endTenantFlow();
// }
// return Response.ok().build();
// } catch (AxisFault e) {
// log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (RemoteException e) {
// log.error("Failed to connect with the remote services:" + tenantDomain, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (JWTClientException e) {
// log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (UserStoreException e) {
// log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (DeviceManagementException e) {
// log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
// log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
// e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// }
// }
/**
* Delete device type specific artifacts from DAS.
@ -349,175 +349,175 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
/**
* Returns device specific data for the give period of time.
*/
@GET
@Path("/{type}/{deviceId}")
@Override
public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
@QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
int offset, @QueryParam("limit") int limit) {
if (from == 0 || to == 0) {
String errorMessage = "Invalid values for from/to";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
}
if (limit == 0) {
String errorMessage = "Invalid values for offset/limit";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
}
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
+ " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try {
if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type";
log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build();
}
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType))) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField);
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
}
}
// @GET
// @Path("/{type}/{deviceId}")
// @Override
// public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
// @QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
// int offset, @QueryParam("limit") int limit) {
// if (from == 0 || to == 0) {
// String errorMessage = "Invalid values for from/to";
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
// }
// if (limit == 0) {
// String errorMessage = "Invalid values for offset/limit";
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
// }
// String fromDate = String.valueOf(from);
// String toDate = String.valueOf(to);
// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
// + " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
// try {
// if (deviceType == null ||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
// String errorMessage = "Invalid device type";
// log.error(errorMessage);
// return Response.status(Response.Status.BAD_REQUEST).build();
// }
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
// new DeviceIdentifier(deviceId, deviceType))) {
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
// sortByFields.add(sortByField);
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
// } catch (AnalyticsException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// } catch (DeviceAccessAuthorizationException e) {
// log.error(e.getErrorMessage(), e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (DeviceManagementException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// }
// }
/**
* Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point.
* Limit parameter needs to be zero or positive.
*/
@GET
@Path("/last-known/{type}/{deviceId}")
@Override
public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) {
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try {
if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type";
log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build();
}
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType))) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField);
if (limit == 0) {
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} else if (limit > 0) {
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} else {
String errorMessage = "Invalid limit value";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
}
} catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
}
}
// @GET
// @Path("/last-known/{type}/{deviceId}")
// @Override
// public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) {
// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
// try {
// if (deviceType == null ||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
// String errorMessage = "Invalid device type";
// log.error(errorMessage);
// return Response.status(Response.Status.BAD_REQUEST).build();
// }
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
// new DeviceIdentifier(deviceId, deviceType))) {
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
// sortByFields.add(sortByField);
// if (limit == 0) {
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
// } else if (limit > 0) {
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
// } else {
// String errorMessage = "Invalid limit value";
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
// }
// } catch (AnalyticsException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// } catch (DeviceAccessAuthorizationException e) {
// log.error(e.getErrorMessage(), e);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
// } catch (DeviceManagementException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// }
// }
/**
* Returns the filterd device list. Devices are filterd using the paramter given and the timestamp of the record.
* parameter should given as a range.
*/
@GET
@Path("filter/{type}/{parameter}")
@Override
public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter,
@QueryParam("min") double min, @QueryParam("max") double max) {
String query;
Calendar c = java.util.Calendar.getInstance();
long currentTimestamp = c.getTimeInMillis();
long previousTimestamp = currentTimestamp - 300 * 1000;
String fromDate = String.valueOf(previousTimestamp);
String toDate = String.valueOf(currentTimestamp);
if (min != 0 & max != 0) {
query = parameter + " : [" + min + " TO " + max + "]" +
" AND _timestamp : [" + fromDate + " TO " + toDate + "]";
} else {
String errorMessage = "The of range values need to be given";
log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build();
}
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try {
if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type";
log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField);
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100);
List<Record> filterdEvents = eventRecords.getRecord();
List<Record> uniqueFilterdEvents = new ArrayList<Record>();
Set<String> devices = new HashSet<>();
for (int i = 0; i < filterdEvents.size(); i++) {
String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId");
if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceid, deviceType))) {
devices.add(deviceid);
uniqueFilterdEvents.add(filterdEvents.get(i));
}
}
EventRecords filterdRecords = new EventRecords();
filterdRecords.setList(uniqueFilterdEvents);
return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build();
} catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg);
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
}
// @GET
// @Path("filter/{type}/{parameter}")
// @Override
// public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter,
// @QueryParam("min") double min, @QueryParam("max") double max) {
// String query;
// Calendar c = java.util.Calendar.getInstance();
// long currentTimestamp = c.getTimeInMillis();
// long previousTimestamp = currentTimestamp - 300 * 1000;
// String fromDate = String.valueOf(previousTimestamp);
// String toDate = String.valueOf(currentTimestamp);
// if (min != 0 & max != 0) {
// query = parameter + " : [" + min + " TO " + max + "]" +
// " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
// } else {
// String errorMessage = "The of range values need to be given";
// log.error(errorMessage);
// return Response.status(Response.Status.BAD_REQUEST).build();
// }
//
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
// try {
// if (deviceType == null ||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
// String errorMessage = "Invalid device type";
// log.error(errorMessage);
// return Response.status(Response.Status.BAD_REQUEST).build();
// }
//
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
// sortByFields.add(sortByField);
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100);
// List<Record> filterdEvents = eventRecords.getRecord();
// List<Record> uniqueFilterdEvents = new ArrayList<Record>();
// Set<String> devices = new HashSet<>();
//
// for (int i = 0; i < filterdEvents.size(); i++) {
// String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId");
// if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
// new DeviceIdentifier(deviceid, deviceType))) {
// devices.add(deviceid);
// uniqueFilterdEvents.add(filterdEvents.get(i));
// }
// }
//
// EventRecords filterdRecords = new EventRecords();
// filterdRecords.setList(uniqueFilterdEvents);
// return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build();
//
// } catch (AnalyticsException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// } catch (DeviceManagementException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
// } catch (DeviceAccessAuthorizationException e) {
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
// log.error(errorMsg);
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// }
private void publishEventReceivers(String streamNameWithVersion, TransportType transportType
@ -613,47 +613,47 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
}
}
private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
throws RemoteException, UserStoreException, JWTClientException,
EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
try {
AnalyticsTable analyticsTable = new AnalyticsTable();
analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
analyticsTable.setStreamVersion(version);
analyticsTable.setTableName(streamName);
analyticsTable.setMergeSchema(false);
analyticsTable.setPersist(true);
AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
int i = 0;
for (Attribute attribute : eventAttributes.getList()) {
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
analyticsTableRecord.setColumnName(attribute.getName());
analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
analyticsTableRecord.setFacet(false);
analyticsTableRecord.setIndexed(false);
analyticsTableRecord.setPersist(true);
analyticsTableRecord.setPrimaryKey(false);
analyticsTableRecord.setScoreParam(false);
analyticsTableRecords[i] = analyticsTableRecord;
i++;
}
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
analyticsTableRecord.setFacet(false);
analyticsTableRecord.setIndexed(true);
analyticsTableRecord.setPersist(true);
analyticsTableRecord.setPrimaryKey(false);
analyticsTableRecord.setScoreParam(false);
analyticsTableRecords[i] = analyticsTableRecord;
analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
} finally {
cleanup(eventStreamPersistenceAdminServiceStub);
}
}
// private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
// throws RemoteException, UserStoreException, JWTClientException,
// EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
// EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
// DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
// try {
// AnalyticsTable analyticsTable = new AnalyticsTable();
// analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
// analyticsTable.setStreamVersion(version);
// analyticsTable.setTableName(streamName);
// analyticsTable.setMergeSchema(false);
// analyticsTable.setPersist(true);
// AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
// int i = 0;
// for (Attribute attribute : eventAttributes.getList()) {
// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
// analyticsTableRecord.setColumnName(attribute.getName());
// analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
// analyticsTableRecord.setFacet(false);
// analyticsTableRecord.setIndexed(false);
// analyticsTableRecord.setPersist(true);
// analyticsTableRecord.setPrimaryKey(false);
// analyticsTableRecord.setScoreParam(false);
// analyticsTableRecords[i] = analyticsTableRecord;
// i++;
// }
// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
// analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
// analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
// analyticsTableRecord.setFacet(false);
// analyticsTableRecord.setIndexed(true);
// analyticsTableRecord.setPersist(true);
// analyticsTableRecord.setPrimaryKey(false);
// analyticsTableRecord.setScoreParam(false);
// analyticsTableRecords[i] = analyticsTableRecord;
// analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
// eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
// } finally {
// cleanup(eventStreamPersistenceAdminServiceStub);
// }
// }
private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType)
throws RemoteException, UserStoreException, JWTClientException {

@ -25,14 +25,14 @@ import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpStatus;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
//import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
//import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
//import org.wso2.carbon.analytics.dataservice.commons.SortByField;
//import org.wso2.carbon.analytics.dataservice.commons.SortType;
//import org.wso2.carbon.analytics.datasource.commons.Record;
//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@ -93,63 +93,63 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class);
@Path("stats/{deviceType}/{deviceId}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId,
@PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) {
try {
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build();
}
} catch (DeviceManagementException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build();
}
String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT";
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
String query = "id:" + deviceId + " AND type:" + deviceType;
if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
}
try {
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType),
DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField);
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername());
try {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
0,
100,
sortByFields);
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
searchResults);
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
}
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
}
}
// @Path("stats/{deviceType}/{deviceId}")
// @GET
// @Consumes("application/json")
// @Produces("application/json")
// public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId,
// @PathParam("deviceType") String deviceType,
// @QueryParam("from") long from, @QueryParam("to") long to) {
// try {
// if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
// return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
// .entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build();
// }
// } catch (DeviceManagementException e) {
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build();
// }
// String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT";
// String fromDate = String.valueOf(from);
// String toDate = String.valueOf(to);
// String query = "id:" + deviceId + " AND type:" + deviceType;
// if (from != 0 || to != 0) {
// query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
// }
// try {
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
// new DeviceIdentifier(deviceId, deviceType),
// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
// sortByFields.add(sortByField);
//
// // this is the user who initiates the request
// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
// CarbonContext.getThreadLocalCarbonContext().getUsername());
//
// try {
// String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
// List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
// 0,
// 100,
// sortByFields);
// List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
// searchResults);
// return Response.ok().entity(null).build();
// } catch (AnalyticsException| UserStoreException e) {
// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
// throw DeviceMgtUtil.buildBadRequestException(
// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
// }
// } catch (DeviceAccessAuthorizationException e) {
// log.error(e.getErrorMessage());
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
// }
// }
@Path("stats/device-locations")
@GET
@ -471,142 +471,142 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
}
}
@Path("alerts/history/{deviceType}/{deviceId}")
@GET
@Consumes("application/json")
@Produces("application/json")
public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId,
@PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) {
String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
String query = "id:" + deviceId + " AND type:" + deviceType;
if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
}
try {
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType),
DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField);
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername());
try {
String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
0,
100,
sortByFields);
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
searchResults);
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
}
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
}
}
@Path("alerts/history")
@GET
@Consumes("application/json")
@Produces("application/json")
public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) {
String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
String query = "";
if (from != 0 || to != 0) {
query = "timeStamp : [" + fromDate + " TO " + toDate + "]";
}
try {
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField);
// this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername());
String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
0,
100,
sortByFields);
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
searchResults);
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
}
}
private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
List<String> columns,
List<SearchResultEntry> searchResults) throws AnalyticsException {
List<String> ids = getIds(searchResults);
List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
return getSortedEventBeans(eventBeanMap, searchResults);
}
private List<Event> getSortedEventBeans(Map<String, Event> eventBeanMap,
List<SearchResultEntry> searchResults) {
List<Event> sortedRecords = new ArrayList<>();
for (SearchResultEntry entry : searchResults) {
sortedRecords.add(eventBeanMap.get(entry.getId()));
}
return sortedRecords;
}
private Map<String, Event> getEventBeanKeyedWithIds(List<Record> records) {
Map<String, Event> eventBeanMap = new HashMap<>();
for (Record record : records) {
Event event = getEventBean(record);
eventBeanMap.put(event.getId(), event);
}
return eventBeanMap;
}
private List<String> getIds(List<SearchResultEntry> searchResults) {
List<String> ids = new ArrayList<>();
if (searchResults != null) {
for (SearchResultEntry resultEntry : searchResults) {
ids.add(resultEntry.getId());
}
}
return ids;
}
private static Event getEventBean(Record record) {
Event eventBean = new Event();
eventBean.setId(record.getId());
eventBean.setTableName(record.getTableName());
eventBean.setTimestamp(record.getTimestamp());
eventBean.setValues(record.getValues());
return eventBean;
}
// @Path("alerts/history/{deviceType}/{deviceId}")
// @GET
// @Consumes("application/json")
// @Produces("application/json")
// public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId,
// @PathParam("deviceType") String deviceType,
// @QueryParam("from") long from, @QueryParam("to") long to) {
// String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
// String fromDate = String.valueOf(from);
// String toDate = String.valueOf(to);
// String query = "id:" + deviceId + " AND type:" + deviceType;
// if (from != 0 || to != 0) {
// query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
// }
// try {
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
// new DeviceIdentifier(deviceId, deviceType),
// DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
// sortByFields.add(sortByField);
//
// // this is the user who initiates the request
// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
// CarbonContext.getThreadLocalCarbonContext().getUsername());
//
// try {
// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
// List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
// 0,
// 100,
// sortByFields);
// List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
// searchResults);
// return Response.ok().entity(events).build();
// } catch (AnalyticsException | UserStoreException e) {
// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
// throw DeviceMgtUtil.buildBadRequestException(
// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
// }
// } catch (DeviceAccessAuthorizationException e) {
// log.error(e.getErrorMessage());
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
// }
// }
// @Path("alerts/history")
// @GET
// @Consumes("application/json")
// @Produces("application/json")
// public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) {
// String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
// String fromDate = String.valueOf(from);
// String toDate = String.valueOf(to);
// String query = "";
// if (from != 0 || to != 0) {
// query = "timeStamp : [" + fromDate + " TO " + toDate + "]";
// }
// try {
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
// sortByFields.add(sortByField);
//
// // this is the user who initiates the request
// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
// CarbonContext.getThreadLocalCarbonContext().getUsername());
//
// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
// List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
// 0,
// 100,
// sortByFields);
// List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
// searchResults);
// return Response.ok().entity(events).build();
//
// } catch (AnalyticsException | UserStoreException e) {
// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
// throw DeviceMgtUtil.buildBadRequestException(
// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
// }
// }
// private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
// List<String> columns,
// List<SearchResultEntry> searchResults) throws AnalyticsException {
// List<String> ids = getIds(searchResults);
// List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
// List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
// Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
// return getSortedEventBeans(eventBeanMap, searchResults);
// }
// private List<Event> getSortedEventBeans(Map<String, Event> eventBeanMap,
// List<SearchResultEntry> searchResults) {
// List<Event> sortedRecords = new ArrayList<>();
// for (SearchResultEntry entry : searchResults) {
// sortedRecords.add(eventBeanMap.get(entry.getId()));
// }
// return sortedRecords;
// }
// private Map<String, Event> getEventBeanKeyedWithIds(List<Record> records) {
// Map<String, Event> eventBeanMap = new HashMap<>();
// for (Record record : records) {
// Event event = getEventBean(record);
// eventBeanMap.put(event.getId(), event);
// }
// return eventBeanMap;
// }
// private List<String> getIds(List<SearchResultEntry> searchResults) {
// List<String> ids = new ArrayList<>();
// if (searchResults != null) {
// for (SearchResultEntry resultEntry : searchResults) {
// ids.add(resultEntry.getId());
// }
// }
// return ids;
// }
// private static Event getEventBean(Record record) {
// Event eventBean = new Event();
// eventBean.setId(record.getId());
// eventBean.setTableName(record.getTableName());
// eventBean.setTimestamp(record.getTimestamp());
// eventBean.setValues(record.getValues());
// return eventBean;
// }
@Path("/geo-fence")
@POST

@ -64,8 +64,9 @@ public class CredentialManagementResponseBuilder {
username = CarbonContext.getThreadLocalCarbonContext().getUsername();
userStoreManager.updateCredential(username, credentials.getNewPassword(),
credentials.getOldPassword());
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
//todo:amalka
// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
username + " was successfully changed.").build();
} catch (UserStoreException e) {
@ -108,8 +109,9 @@ public class CredentialManagementResponseBuilder {
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build();
}
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
//todo:amalka
// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
username + " was successfully changed.").build();
} catch (UserStoreException e) {

@ -46,14 +46,14 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
//import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.util.Utils;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
@ -171,7 +171,7 @@ public class DeviceMgtAPIUtils {
private static KeyStore trustStore;
private static char[] keyStorePassword;
private static IntegrationClientService integrationClientService;
// private static IntegrationClientService integrationClientService;
private static MetadataManagementService metadataManagementService;
private static OTPManagementService otpManagementService;
@ -374,22 +374,22 @@ public class DeviceMgtAPIUtils {
}
public static IntegrationClientService getIntegrationClientService() {
if (integrationClientService == null) {
synchronized (DeviceMgtAPIUtils.class) {
if (integrationClientService == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null);
if (integrationClientService == null) {
String msg = "IntegrationClientService is not initialized";
log.error(msg);
throw new IllegalStateException(msg);
}
}
}
}
return integrationClientService;
}
// public static IntegrationClientService getIntegrationClientService() {
// if (integrationClientService == null) {
// synchronized (DeviceMgtAPIUtils.class) {
// if (integrationClientService == null) {
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
// integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null);
// if (integrationClientService == null) {
// String msg = "IntegrationClientService is not initialized";
// log.error(msg);
// throw new IllegalStateException(msg);
// }
// }
// }
// }
// return integrationClientService;
// }
/**
* Initializing and accessing method for OTPManagementService.
@ -626,17 +626,18 @@ public class DeviceMgtAPIUtils {
return username;
}
public static EventsPublisherService getEventPublisherService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
EventsPublisherService eventsPublisherService =
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
if (eventsPublisherService == null) {
String msg = "Event Publisher service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return eventsPublisherService;
}
// todo: amalka: commented
// public static EventsPublisherService getEventPublisherService() {
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
// EventsPublisherService eventsPublisherService =
// (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
// if (eventsPublisherService == null) {
// String msg = "Event Publisher service has not initialized.";
// log.error(msg);
// throw new IllegalStateException(msg);
// }
// return eventsPublisherService;
// }
public static String getStreamDefinition(String deviceType, String tenantDomain) {
return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", ".");

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -50,7 +50,7 @@
<Import-Package>
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
com.fasterxml.jackson.annotation;version="${jackson-annotations.version}",
org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}",
<!--org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}",-->
io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional,
com.google.gson
</Import-Package>
@ -96,14 +96,14 @@
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics</groupId>
<artifactId>org.wso2.carbon.analytics.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics</groupId>
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics</groupId>-->
<!--<artifactId>org.wso2.carbon.analytics.api</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics</groupId>-->
<!--<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>

@ -78,8 +78,8 @@
<Private-Package>org.wso2.carbon.device.mgt.core.internal</Private-Package>
<Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.naming,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
@ -90,7 +90,7 @@
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.analytics.data.publisher.service,
<!--org.wso2.carbon.device.mgt.analytics.data.publisher.service,-->
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.*,
org.wso2.carbon.registry.core.service,
@ -104,8 +104,8 @@
org.wso2.carbon.ndatasource.core,
org.wso2.carbon.ntask.core.*,
org.wso2.carbon.ntask.common,
org.apache.catalina,
org.apache.catalina.core,
<!--org.apache.catalina,-->
<!--org.apache.catalina.core,-->
org.apache.commons.collections;version="${commons-collections.version.range}",
org.wso2.carbon.email.sender.*,
io.swagger.annotations.*;resolution:=optional,
@ -166,32 +166,32 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.user.mgt</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.slf4j</groupId>-->
<!--<artifactId>slf4j-api</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>javax.servlet</groupId>-->
<!--<artifactId>javax.servlet-api</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>org.wso2.carbon.registry</groupId>-->
<!--<artifactId>org.wso2.carbon.registry.indexing</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>org.wso2.carbon.identity.framework</groupId>-->
<!--<artifactId>org.wso2.carbon.user.mgt</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>commons-lang</groupId>-->
<!--<artifactId>commons-lang</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>

@ -53,6 +53,8 @@ public final class DeviceManagementConstants {
public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event perm:windows:enroll";
public static final String IOT_GATEWAY_HOST = "iot.gateway.host";
public static final String IOT_GATEWAY_HTTPS_PORT = "iot.gateway.https.port";
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 APPLICATION_REGISTRATION_API_ENDPOINT =
"/api-application-registration/register";
public static final String AUTHORIZATION_HEADER = "authorization";

@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
@ -178,9 +178,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceInfo.getAvailableRAMMemory(),
deviceInfo.isPluggedIn()
};
DeviceManagerUtil.getEventPublisherService().publishEvent(
DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
);
// DeviceManagerUtil.getEventPublisherService().publishEvent(
// DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
// );
}
} catch (TransactionManagementException e) {
throw new DeviceDetailsMgtException("Transactional error occurred while adding the device information.", e);
@ -193,8 +193,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " +
"device", e);
} catch (DataPublisherConfigurationException e) {
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
// } catch (DataPublisherConfigurationException e) {
// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
@ -389,9 +389,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceLocation.getBearing(),
deviceLocation.getDistance()
};
DeviceManagerUtil.getEventPublisherService().publishEvent(
LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
);
// DeviceManagerUtil.getEventPublisherService().publishEvent(
// LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
// );
}
DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) {
@ -403,9 +403,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} catch (DeviceManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e);
} catch (DataPublisherConfigurationException e) {
DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
// } catch (DataPublisherConfigurationException e) {
// DeviceManagementDAOFactory.rollbackTransaction();
// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}

@ -49,7 +49,7 @@ import org.apache.http.protocol.HTTP;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
//import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.ActivityPaginationRequest;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceEnrollmentInfoNotification;
@ -1964,20 +1964,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
operation.getStatus() != null ? operation.getStatus().toString() : null,
operation.getOperationResponse()
};
DeviceManagerUtil.getEventPublisherService().publishEvent(
OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
);
// DeviceManagerUtil.getEventPublisherService().publishEvent(
// OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
// );
}
}
} catch (DeviceManagementException e) {
String msg = "Error occurred while reading configs.";
log.error(msg, e);
throw new OperationManagementException(msg, e);
} catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing event.";
log.error(msg, e);
throw new OperationManagementException(msg, e);
}
} //catch (DataPublisherConfigurationException e) {
// String msg = "Error occurred while publishing event.";
// log.error(msg, e);
// throw new OperationManagementException(msg, e);
// }
}
@Override
@ -2006,20 +2006,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
operation.getStatus() != null ? operation.getStatus().toString() : null,
operation.getOperationResponse()
};
DeviceManagerUtil.getEventPublisherService().publishEvent(
OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
);
// DeviceManagerUtil.getEventPublisherService().publishEvent(
// OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
// );
}
}
} catch (DeviceManagementException e) {
String msg = "Error occurred while reading configs.";
log.error(msg, e);
throw new OperationManagementException(msg, e);
} catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing event.";
log.error(msg, e);
throw new OperationManagementException(msg, e);
}
} //catch (DataPublisherConfigurationException e) {
// String msg = "Error occurred while publishing event.";
// log.error(msg, e);
// throw new OperationManagementException(msg, e);
// }
}
@Override

@ -50,7 +50,7 @@ import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.caching.impl.CacheImpl;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
//import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials;
import org.wso2.carbon.device.mgt.common.ApplicationRegistration;
import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException;
@ -595,17 +595,17 @@ public final class DeviceManagerUtil {
return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER);
}
public static EventsPublisherService getEventPublisherService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
EventsPublisherService eventsPublisherService =
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
if (eventsPublisherService == null) {
String msg = "Event Publisher service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return eventsPublisherService;
}
// public static EventsPublisherService getEventPublisherService() {
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
// EventsPublisherService eventsPublisherService =
// (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
// if (eventsPublisherService == null) {
// String msg = "Event Publisher service has not initialized.";
// log.error(msg);
// throw new IllegalStateException(msg);
// }
// return eventsPublisherService;
// }
/**
* Retrieve EventConfigurationProviderService osgi service component

@ -178,15 +178,15 @@
javax.xml.stream,
javax.xml.parsers;resolution:=optional,
org.apache.commons.lang,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom,
org.wso2.carbon.ndatasource.core,
org.wso2.carbon.registry.core.service,
org.wso2.carbon.utils.dbcreator,
org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.device.mgt.core.service,
com.google.gson,
org.osgi.framework
com.google.gson
</Import-Package>
<DynamicImport-Package>org.wso2.carbon.device.mgt.extensions.pull.notification,
org.wso2.carbon.device.mgt.extensions.pull.notification.*</DynamicImport-Package>

@ -61,8 +61,8 @@
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.url.printer.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
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,

@ -38,9 +38,9 @@
<module>org.wso2.carbon.device.mgt.extensions</module>
<module>org.wso2.carbon.device.mgt.ui</module>
<module>org.wso2.carbon.device.mgt.api</module>
<module>org.wso2.carbon.device.mgt.analytics.data.publisher</module>
<!--<module>org.wso2.carbon.device.mgt.analytics.data.publisher</module>-->
<module>org.wso2.carbon.device.mgt.url.printer</module>
<module>org.wso2.carbon.device.mgt.analytics.wsproxy</module>
<!--<module>org.wso2.carbon.device.mgt.analytics.wsproxy</module>-->
<module>io.entgra.carbon.device.mgt.config.api</module>
</modules>

@ -53,20 +53,20 @@
<Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context,
org.wso2.carbon.utils.*,
org.wso2.carbon.ndatasource.core,
org.w3c.dom,
org.apache.velocity;version="${velocity.version}",
org.apache.velocity.app;version="${velocity.version}",
org.apache.velocity.context;version="${velocity.version}",
org.apache.velocity.exception;version="${velocity.version}",
org.apache.velocity.runtime.resource;version="${velocity.version}",
org.apache.velocity.runtime.resource.loader;version="${velocity.version}",
<!--org.apache.velocity;version="${velocity.version}",-->
<!--org.apache.velocity.app;version="${velocity.version}",-->
<!--org.apache.velocity.context;version="${velocity.version}",-->
<!--org.apache.velocity.exception;version="${velocity.version}",-->
<!--org.apache.velocity.runtime.resource;version="${velocity.version}",-->
<!--org.apache.velocity.runtime.resource.loader;version="${velocity.version}",-->
org.apache.commons.io,
org.apache.axis2.transport.mail,
org.apache.commons.collections,
@ -149,10 +149,14 @@
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.orbit.org.apache.velocity</groupId>-->
<!--<artifactId>velocity</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.velocity</groupId>-->
<!--<artifactId>velocity</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>commons-io.wso2</groupId>
<artifactId>commons-io</artifactId>

@ -87,10 +87,11 @@
org.wso2.carbon.device.mgt.oauth.extensions.*
</Export-Package>
<Import-Package>
org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}",
<!--org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}",-->
org.apache.commons.lang,
org.apache.commons.logging,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}",
@ -113,6 +114,10 @@
org.apache.oltu.oauth2.common.validators,
org.apache.commons.lang3.tuple,
</Import-Package>
<!--<Embed-Dependency>-->
<!--</Embed-Dependency>-->
</instructions>
</configuration>
</plugin>

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
@ -58,8 +57,8 @@ public class AccessTokenGrantHandler extends AbstractAuthorizationGrantHandler {
}
@Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx);
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return super.validateScope(tokReqMsgCtx);
}
@Override

@ -20,14 +20,10 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler;
import org.wso2.carbon.identity.oauth2.model.RequestParameter;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
/**
* This sets up user with tenant aware username.
@ -38,8 +34,8 @@ public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler {
private static final String TENANT_DOMAIN_KEY = "tenantDomain";
@Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx);
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return super.validateScope(tokReqMsgCtx);
}
@Override

@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
@ -35,8 +34,8 @@ public class ExtendedSAML2BearerGrantHandler extends SAML2BearerGrantHandler {
private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class);
@Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx);
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return super.validateScope(tokReqMsgCtx);
}
@Override

@ -109,8 +109,8 @@
org.apache.commons.httpclient,
org.apache.commons.logging,
org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}",
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.core.security,
org.wso2.carbon.core.services.authentication,
org.wso2.carbon.utils.multitenancy,

@ -185,8 +185,8 @@
org.wso2.carbon.identity.jwt.client.extension.*
</Export-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context,
org.wso2.carbon.registry.core,
org.wso2.carbon.registry.core.exceptions,

@ -33,8 +33,8 @@
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.identity.authenticator.backend.oauth</module>
<module>org.wso2.carbon.device.mgt.oauth.extensions</module>
<!--<module>org.wso2.carbon.identity.authenticator.backend.oauth</module>-->
<!--<module>org.wso2.carbon.device.mgt.oauth.extensions</module>-->
<module>org.wso2.carbon.identity.jwt.client.extension</module>
</modules>

@ -35,9 +35,9 @@
<Bundle-Description>Policy Decision Point Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.decision.point.internal</Private-Package>
<Import-Package>
org.wso2.carbon.context.*;
org.osgi.framework,
org.osgi.service.component,
org.wso2.carbon.context;version="${carbon.kernel.version.range}",
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
org.wso2.carbon.policy.mgt.common.*,
org.wso2.carbon.policy.mgt.core.*,

@ -53,8 +53,8 @@
<Bundle-Description>Policy Management Core Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.mgt.core.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.sql,
javax.cache,

@ -39,7 +39,7 @@
<module>org.wso2.carbon.policy.mgt.core</module>
<module>org.wso2.carbon.policy.information.point</module>
<module>org.wso2.carbon.policy.decision.point</module>
<module>org.wso2.carbon.complex.policy.decision.point</module>
<!--<module>org.wso2.carbon.complex.policy.decision.point</module>-->
</modules>
<build>

@ -53,8 +53,8 @@
<Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.osgi.framework,
org.osgi.service.component,
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context,

@ -87,20 +87,30 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>CXF,Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -99,20 +99,35 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

@ -73,6 +73,7 @@ public class InvokerHandler extends HttpServlet {
private static final long serialVersionUID = -6508020875358160165L;
private static AuthData authData;
private static String apiEndpoint;
private static String iotsCoreUrl;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -368,8 +369,14 @@ public class InvokerHandler extends HttpServlet {
if (log.isDebugEnabled()) {
log.debug("refreshing the token");
}
String iotsCorePort = System.getProperty("iot.core.https.port");
if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
iotsCorePort = System.getProperty("iot.core.http.port");
}
iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort;
HttpPost tokenEndpoint = new HttpPost(
apiEndpoint + HandlerConstants.API_COMMON_CONTEXT + HandlerConstants.TOKEN_ENDPOINT);
iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
HttpSession session = req.getSession(false);
if (session == null) {
log.error("Couldn't find a session, hence it is required to login and proceed.");

@ -35,7 +35,16 @@ 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.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.authenticator.stub.AuthenticationAdmin;
import org.wso2.carbon.authenticator.stub.Login;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import io.entgra.ui.request.interceptor.beans.ProxyResponse;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
@ -44,7 +53,9 @@ 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;
@MultipartConfig
@WebServlet("/login")
@ -56,6 +67,7 @@ public class LoginHandler extends HttpServlet {
private static String password;
private static String gatewayUrl;
private static String uiConfigUrl;
private static String keyManagerUrl;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -68,26 +80,37 @@ public class LoginHandler extends HttpServlet {
httpSession = req.getSession(true);
//setting session to expiry in 5 minutes
httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT));
//todo: amalka do we need this remote call?
JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp);
JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray();
JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray();
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));
List<String> list = new ArrayList<String>();
for(int i=0; i < tags.size(); i++) {
list.add(tags.get(i).getAsString());
}
ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint);
String[] tagsAsStringArray = list.toArray(new String[list.size()]);
if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) {
HandlerUtil.handleError(resp, clientAppResponse);
return;
String scopeString = HandlerUtil.getScopeString(scopes);
if (scopeString != null) {
scopeString = scopeString.trim();
} else {
scopeString = "default";
}
if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp,
clientAppResponse.getData(), scopes)) {
APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl();
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
HandlerConstants.PUBLISHER_APPLICATION_NAME,
tagsAsStringArray, HandlerConstants.PRODUCTION_KEY, username, false,
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, scopeString);
if (apiApplicationKey != null && getTokenAndPersistInSession(apiApplicationKey.getConsumerKey(),
apiApplicationKey.getConsumerSecret(), req, resp, scopes)) {
log.info("tenantDomain : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
log.info("username : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername());
ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setCode(HttpStatus.SC_OK);
HandlerUtil.handleSuccess(resp, proxyResponse);
@ -100,6 +123,8 @@ public class LoginHandler extends HttpServlet {
log.error("Error occurred while parsing the response. ", e);
} catch (LoginException e) {
log.error("Error occurred while getting token data. ", e);
} catch (APIManagerException e) {
log.error("Error occurred while creating application. ", e);
}
}
@ -107,19 +132,19 @@ public class LoginHandler extends HttpServlet {
* Generates token from token endpoint and persists them inside the session
*
* @param req - {@link HttpServletRequest}
* @param clientAppResult - clientAppResult
// * @param clientAppResult - clientAppResult
* @param scopes - scopes defied in the application-mgt.xml
* @throws LoginException - login exception throws when getting token result
*/
private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp,
String clientAppResult, JsonArray scopes) throws LoginException {
private boolean getTokenAndPersistInSession(String clientId, String clientSecret, HttpServletRequest req,
HttpServletResponse resp, JsonArray scopes) throws LoginException {
JsonParser jsonParser = new JsonParser();
try {
JsonElement jClientAppResult = jsonParser.parse(clientAppResult);
if (jClientAppResult.isJsonObject()) {
JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject();
String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString();
String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString();
// JsonElement jClientAppResult = jsonParser.parse(clientAppResult);
if (clientId != null && clientSecret != null) {
// JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject();
// String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString();
// String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString();
String encodedClientApp = Base64.getEncoder()
.encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes());
@ -171,12 +196,18 @@ public class LoginHandler extends HttpServlet {
if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
iotsCorePort = System.getProperty("iot.core.http.port");
}
String keyManagerPort = System.getProperty("iot.keymanager.https.port");
username = req.getParameter("username");
password = req.getParameter("password");
gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host")
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT;
keyManagerUrl = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR +
System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + keyManagerPort;
if (username == null || password == null) {
String msg = "Invalid login request. Username or Password is not received for login request.";
log.error(msg);
@ -193,7 +224,7 @@ public class LoginHandler extends HttpServlet {
* @throws IOException IO exception throws if an error occurred when invoking token endpoint
*/
private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException {
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT);
HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());
String scopeString = HandlerUtil.getScopeString(scopes);

@ -61,7 +61,7 @@ public class SsoLoginCallbackHandler extends HttpServlet {
String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort;
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT);
HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp"));
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());

@ -101,7 +101,7 @@ public class SsoLoginHandler extends HttpServlet {
*/
private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) {
try {
File userMgtConf = new File("conf/user-mgt.xml");
File userMgtConf = new File("repository/conf/user-mgt.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(userMgtConf);
@ -136,7 +136,7 @@ public class SsoLoginHandler extends HttpServlet {
JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray();
// Register the client application
HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT);
HttpPost apiRegEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.APP_REG_ENDPOINT);
encodedAdminCredentials = Base64.getEncoder()
.encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes());
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC +
@ -262,7 +262,7 @@ public class SsoLoginHandler extends HttpServlet {
* @throws IOException IO exception throws if an error occurred when invoking token endpoint
*/
private ProxyResponse getTokenResult(String encodedClientApp) throws IOException {
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT);
HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());

@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Base64;
@MultipartConfig
@WebServlet("/user")
@ -52,8 +53,8 @@ public class UserHandler extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
try {
String serverUrl =
req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host")
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme());
HttpSession httpSession = req.getSession(false);
if (httpSession == null) {
HandlerUtil.sendUnAuthorizeResponse(resp);
@ -68,26 +69,32 @@ public class UserHandler extends HttpServlet {
String accessToken = authData.getAccessToken();
HttpPost tokenEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());
StringEntity tokenEPPayload = new StringEntity("token=" + accessToken,
HttpPost introspectionEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT);
introspectionEndpoint.setHeader(HttpHeaders.CONTENT_TYPE,
ContentType.APPLICATION_FORM_URLENCODED.toString());
//todo:amalka
String username = "admin";
String password = "admin";
introspectionEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
.encodeToString((username + HandlerConstants.COLON + password).getBytes()));
StringEntity introspectionPayload = new StringEntity("token=" + accessToken,
ContentType.APPLICATION_FORM_URLENCODED);
tokenEndpoint.setEntity(tokenEPPayload);
ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint);
introspectionEndpoint.setEntity(introspectionPayload);
ProxyResponse introspectionStatus = HandlerUtil.execute(introspectionEndpoint);
if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) {
if (introspectionStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) {
log.error("Error occurred while invoking the API to get token status.");
HandlerUtil.handleError(resp, tokenStatus);
HandlerUtil.handleError(resp, introspectionStatus);
return;
}
String tokenData = tokenStatus.getData();
if (tokenData == null) {
String introspectionData = introspectionStatus.getData();
if (introspectionData == null) {
log.error("Invalid token data is received.");
HandlerUtil.handleError(resp, tokenStatus);
HandlerUtil.handleError(resp, introspectionStatus);
return;
}
JsonParser jsonParser = new JsonParser();
JsonElement jTokenResult = jsonParser.parse(tokenData);
JsonElement jTokenResult = jsonParser.parse(introspectionData);
if (jTokenResult.isJsonObject()) {
JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject();
if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) {

@ -22,7 +22,7 @@ public class HandlerConstants {
public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher";
public static final String APP_REG_ENDPOINT = "/api-application-registration/register";
public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt-config/v1.0/configurations/ui-config";
public static final String TOKEN_ENDPOINT = "/token";
public static final String TOKEN_ENDPOINT = "/oauth2/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/store/v0.12/applications/";
@ -59,6 +59,7 @@ public class HandlerConstants {
public static final String SCHEME_SEPARATOR = "://";
public static final String COLON = ":";
public static final String HTTP_PROTOCOL = "http";
public static final String HTTPS_PROTOCOL = "https";
public static final String UNDERSCORE = "_";
public static final int INTERNAL_ERROR_CODE = 500;

@ -23,6 +23,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -36,12 +38,12 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
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.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Document;
import io.entgra.ui.request.interceptor.beans.ProxyResponse;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.xml.sax.SAXException;
import javax.servlet.http.HttpServletRequest;
@ -80,6 +82,7 @@ public class HandlerUtil {
HandlerConstants.INTERNAL_ERROR_CODE));
return proxyResponse;
} else {
int statusCode = response.getStatusLine().getStatusCode();
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
StringBuilder result = new StringBuilder();
@ -400,4 +403,16 @@ public class HandlerUtil {
return stringOutput;
}
public static APIManagementProviderService getAPIManagementProviderService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
APIManagementProviderService 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;
}
}

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
-->
<Environments>Carbon</Environments>
<Environments>CXF3,Carbon</Environments>
</Classloading>

@ -63,15 +63,15 @@
javax.xml.bind.annotation,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
javax.xml.validation,
org.apache.catalina,
org.apache.catalina.connector,
org.apache.catalina.util,
<!--org.apache.catalina,-->
<!--org.apache.catalina.connector,-->
<!--org.apache.catalina.util,-->
org.apache.commons.logging,
org.apache.coyote,
org.apache.tomcat.util.buf,
org.apache.tomcat.util.http,
org.osgi.service.component,
org.osgi.framework,
<!--org.apache.coyote,-->
<!--org.apache.tomcat.util.buf,-->
<!--org.apache.tomcat.util.http,-->
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom,
org.wso2.carbon.context,
org.wso2.carbon.core.util,
@ -79,7 +79,7 @@
org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.oauth2.*;
version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
org.wso2.carbon.tomcat.ext.valves,
<!--org.wso2.carbon.tomcat.ext.valves,-->
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.service,
org.wso2.carbon.user.core.tenant,
@ -106,8 +106,8 @@
org.apache.commons.pool.impl,
org.apache.http.conn,
org.apache.http.impl.conn,
javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}",
javax.xml.stream,
<!--javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}",-->
<!--javax.xml.stream,-->
org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.wso2.carbon.registry.core.*,
org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}",

@ -107,9 +107,9 @@
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version}
</bundleDef>
<!--<bundleDef>-->
<!--org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version}-->
<!--</bundleDef>-->
</bundles>
</configuration>
</execution>

@ -24,7 +24,7 @@
<WebappPublisherConfigs>
<!-- This host is used to define the host address which is used to publish APIs -->
<Host>https://${iot.core.host}:${iot.core.https.port}</Host>
<Host>https://localhost:9443</Host>
<!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI>

@ -35,10 +35,10 @@
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.apimgt.integration.client.feature</module>
<!--<module>org.wso2.carbon.apimgt.integration.client.feature</module>-->
<module>org.wso2.carbon.apimgt.webapp.publisher.feature</module>
<module>org.wso2.carbon.apimgt.application.extension.feature</module>
<module>org.wso2.carbon.apimgt.handler.server.feature</module>
<!--<module>org.wso2.carbon.apimgt.handler.server.feature</module>-->
</modules>
</project>

@ -30,7 +30,7 @@
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<url>jdbc:h2:./repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>

@ -27,7 +27,6 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>pom</packaging>

@ -43,34 +43,34 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.registry</groupId>
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.receiver.stub</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.stream.stub</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.publisher.stub</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.orbit.org.scannotation</groupId>
<artifactId>scannotation</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.registry</groupId>-->
<!--<artifactId>org.wso2.carbon.registry.indexing</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<!--<artifactId>org.wso2.carbon.event.receiver.stub</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<!--<artifactId>org.wso2.carbon.event.stream.stub</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<!--<artifactId>org.wso2.carbon.event.publisher.stub</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<!--<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.orbit.org.scannotation</groupId>-->
<!--<artifactId>scannotation</artifactId>-->
<!--</dependency>-->
</dependencies>
<build>
@ -127,27 +127,27 @@
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.analytics.data.publisher:${carbon.device.mgt.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.analytics-common:org.wso2.carbon.event.receiver.stub:${carbon.analytics.common.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.stub:${carbon.analytics.common.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.analytics-common:org.wso2.carbon.event.publisher.stub:${carbon.analytics.common.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.persistence.stub:${carbon.analytics.common.version}
</bundleDef>
<bundleDef>
org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version}
</bundleDef>
<bundleDef>
org.wso2.orbit.org.scannotation:scannotation:${scannotation.version}
</bundleDef>
<!--<bundleDef>-->
<!--org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.analytics.data.publisher:${carbon.device.mgt.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.receiver.stub:${carbon.analytics.common.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.stub:${carbon.analytics.common.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.publisher.stub:${carbon.analytics.common.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.persistence.stub:${carbon.analytics.common.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version}-->
<!--</bundleDef>-->
<!--<bundleDef>-->
<!--org.wso2.orbit.org.scannotation:scannotation:${scannotation.version}-->
<!--</bundleDef>-->
</bundles>
<importBundles>
<importBundleDef>

@ -20,7 +20,7 @@
</filter>
</inSequence>
<outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>
<!--<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>-->
<send/>
</outSequence>
</resource>

@ -20,7 +20,7 @@
</filter>
</inSequence>
<outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>
<!--<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>-->
<send/>
</outSequence>
</resource>

@ -19,7 +19,7 @@
<UIConfiguration>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>true</EnableSSO>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>

@ -87,8 +87,8 @@
<importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
</importFeatureDef>
<importFeatureDef>org.wso2.carbon.governance.metadata.server:${carbon.governance.version}
</importFeatureDef>
<!--<importFeatureDef>org.wso2.carbon.governance.metadata.server:${carbon.governance.version}-->
<!--</importFeatureDef>-->
</importFeatures>
</configuration>
</execution>

@ -39,7 +39,7 @@
<module>org.wso2.carbon.device.mgt.api.feature</module>
<module>org.wso2.carbon.device.mgt.feature</module>
<module>org.wso2.carbon.device.mgt.extensions.feature</module>
<module>org.wso2.carbon.device.mgt.analytics.feature</module>
<!--<module>org.wso2.carbon.device.mgt.analytics.feature</module>-->
</modules>
</project>

@ -73,14 +73,14 @@
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.analytics</groupId>
<artifactId>org.wso2.carbon.analytics.api</artifactId>
</exclusion>
<!--<exclusion>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>org.wso2.carbon.analytics</groupId>-->
<!--<artifactId>org.wso2.carbon.analytics.api</artifactId>-->
<!--</exclusion>-->
</exclusions>
</dependency>
</dependencies>

@ -27,7 +27,6 @@
<name>WSO2 Carbon - Device Management - Parent</name>
<url>http://wso2.org</url>
<description>WSO2 Connected Device Manager Components</description>
<parent>
<groupId>org.wso2</groupId>
<artifactId>wso2</artifactId>
@ -43,21 +42,23 @@
<module>components/application-mgt</module>
<module>components/policy-mgt</module>
<module>components/certificate-mgt</module>
<module>components/webapp-authenticator-framework</module>
<module>components/ui-request-interceptor</module>
<module>components/transport-mgt</module>
<module>features/device-mgt</module>
<module>features/apimgt-extensions</module>
<module>features/application-mgt</module>
<module>features/policy-mgt</module>
<module>features/webapp-authenticator-framework</module>
<module>features/certificate-mgt</module>
<module>features/oauth-extensions</module>
<module>features/heartbeat-management</module>
<module>features/ui-request-interceptor</module>
<module>features/jwt-client</module>
<module>features/device-mgt-extensions</module>
<module>features/transport-mgt</module>
<!--<module>components/webapp-authenticator-framework</module>-->
<!--<module>features/webapp-authenticator-framework</module>-->
<!--<module>features/oauth-extensions</module>-->
</modules>
<dependencyManagement>
@ -245,16 +246,16 @@
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
<!--<version>${carbon.device.mgt.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>-->
<!--<version>${carbon.device.mgt.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
@ -286,11 +287,11 @@
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.wsproxy</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.device.mgt.analytics.wsproxy</artifactId>-->
<!--<version>${carbon.device.mgt.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId>
@ -331,11 +332,11 @@
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<!--<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>-->
<!--<version>${carbon.device.mgt.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.server.feature</artifactId>
@ -832,7 +833,7 @@
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<version>${carbon.kernel.version}</version>
<version>4.4.9</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
@ -1153,17 +1154,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-http</artifactId>
<version>${cxf.bindings.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.jra</groupId>
<artifactId>jra</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-bindings-http</artifactId>-->
<!--<version>${cxf.bindings.version}</version>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>org.codehaus.jra</groupId>-->
<!--<artifactId>jra</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
@ -1347,11 +1348,21 @@
<artifactId>gson</artifactId>
<version>${google.gson.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.orbit.com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.wso2.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${squareup.okhttp3.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.orbit.com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>${okio.wso2.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
@ -1794,6 +1805,16 @@
<artifactId>commons-validator</artifactId>
<version>${apache.validator.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-web.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>${cxf-bundle-package.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -2054,9 +2075,9 @@
<properties>
<servelet.jsp.version>2.2.1</servelet.jsp.version>
<testng.version>6.1.1</testng.version>
<carbon.kernel.version>4.4.26</carbon.kernel.version>
<carbon.kernel.version.range>[4.4.0, 5.0.0)</carbon.kernel.version.range>
<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version>
<carbon.kernel.version>4.6.1</carbon.kernel.version>
<carbon.kernel.version.range>[4.6.0, 5.0.0)</carbon.kernel.version.range>
<carbon.p2.plugin.version>5.1.2</carbon.p2.plugin.version>
<maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version>
<carbon.feature.plugin.version>3.1.3</carbon.feature.plugin.version>
@ -2097,16 +2118,16 @@
<carbon.deployment.version>4.7.15</carbon.deployment.version>
<!-- Carbon Identity -->
<carbon.identity.framework.version>5.11.148</carbon.identity.framework.version>
<carbon.identity.framework.version.range>[5.2.0, 6.0.0)</carbon.identity.framework.version.range>
<identity.inbound.auth.oauth.version>5.6.63</identity.inbound.auth.oauth.version>
<carbon.identity.framework.version>5.18.187</carbon.identity.framework.version>
<carbon.identity.framework.version.range>[5.2.0, 7.0.0)</carbon.identity.framework.version.range>
<identity.inbound.auth.oauth.version>6.4.111</identity.inbound.auth.oauth.version>
<identity.inbound.auth.saml.version>5.4.6</identity.inbound.auth.saml.version>
<carbon.identity.jwt.grant.version>1.0.10</carbon.identity.jwt.grant.version>
<carbon.identity.jwt.grant.version.range>[1.0.10, 2.0.0)</carbon.identity.jwt.grant.version.range>
<carbon.identity.jwt.grant.version>1.0.31</carbon.identity.jwt.grant.version>
<carbon.identity.jwt.grant.version.range>[1.0.31, 2.0.0)</carbon.identity.jwt.grant.version.range>
<!-- Carbon Identity import version ranges -->
<carbon.identity.imp.pkg.version>[5.7.0, 6.0.0)</carbon.identity.imp.pkg.version>
<carbon.identity-inbound-auth-oauth.imp.pkg.version>[5.2.0, 6.0.0)</carbon.identity-inbound-auth-oauth.imp.pkg.version>
<carbon.identity-user-ws.imp.pkg.version>[5.1.0, 6.0.0)</carbon.identity-user-ws.imp.pkg.version>
<carbon.identity-inbound-auth-oauth.imp.pkg.version>[5.2.0, 7.0.0)</carbon.identity-inbound-auth-oauth.imp.pkg.version>
<carbon.identity-user-ws.imp.pkg.version>[5.1.0, 7.0.0)</carbon.identity-user-ws.imp.pkg.version>
<!-- Carbon Multi-tenancy -->
<carbon.multitenancy.version>4.6.11</carbon.multitenancy.version>
@ -2131,8 +2152,8 @@
<commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range>
<!-- Carbon API Management -->
<carbon.api.mgt.version>6.2.201</carbon.api.mgt.version>
<carbon.api.mgt.version.range>(6.0.0,7.0.0]</carbon.api.mgt.version.range>
<carbon.api.mgt.version>9.0.5</carbon.api.mgt.version>
<carbon.api.mgt.version.range>(6.0.0,10.0.0]</carbon.api.mgt.version.range>
<!-- Carbon Analytics -->
<carbon.analytics.common.version>5.1.37</carbon.analytics.common.version>
@ -2142,20 +2163,20 @@
<carbon.event-processing.version>2.1.23</carbon.event-processing.version>
<!-- Carbon Registry -->
<carbon.registry.version>4.6.28</carbon.registry.version>
<carbon.registry.resource.version>4.6.8</carbon.registry.resource.version>
<carbon.registry.imp.pkg.version.range>[4.4.8, 5.0.0)</carbon.registry.imp.pkg.version.range>
<carbon.registry.version>4.7.38</carbon.registry.version>
<carbon.registry.resource.version>${carbon.registry.version}</carbon.registry.resource.version>
<carbon.registry.imp.pkg.version.range>[4.7.0, 5.0.0)</carbon.registry.imp.pkg.version.range>
<!--CXF properties-->
<cxf.version>3.2.0</cxf.version>
<cxf.bindings.version>2.5.11</cxf.bindings.version>
<cxf.version>3.3.6</cxf.version>
<!--<cxf.bindings.version>2.5.11</cxf.bindings.version>-->
<json-simple.version>1.1.wso2v1</json-simple.version>
<jackson.version>1.9.0</jackson.version>
<!-- BouncyCastle -->
<bcprov.wso2.version>1.52.0.wso2v1</bcprov.wso2.version>
<bcpkix.wso2.version>1.52.0.wso2v2</bcpkix.wso2.version>
<bcprov.wso2.version.range>[1.52.0,1.60.0)</bcprov.wso2.version.range>
<bcprov.wso2.version>1.60.0.wso2v1</bcprov.wso2.version>
<bcpkix.wso2.version>1.60.0.wso2v1</bcpkix.wso2.version>
<bcprov.wso2.version.range>[1.52.0,1.70.0)</bcprov.wso2.version.range>
<!-- JSCEP -->
<jscep.version>2.3.0.wso2v2</jscep.version>
@ -2166,7 +2187,9 @@
<commons-json.version>3.0.0.wso2v1</commons-json.version>
<json.smart.version>1.3</json.smart.version>
<google.gson.version>2.3.1</google.gson.version>
<squareup.okhttp3.version>3.8.1</squareup.okhttp3.version>
<squareup.okhttp3.version>4.6.0</squareup.okhttp3.version>
<okhttp.wso2.version>4.2.0.wso2v1</okhttp.wso2.version>
<okio.wso2.version>2.4.0.wso2v1</okio.wso2.version>
<okio.version>1.13.0</okio.version>
<github.openfeign.version>9.3.1</github.openfeign.version>
<jsr311.version>1.1.1</jsr311.version>
@ -2282,6 +2305,12 @@
<tomcat.websocket.version>7.0.85</tomcat.websocket.version>
<javax.websocket.version>1.0</javax.websocket.version>
<glassfish.tyrus.version>1.13.1</glassfish.tyrus.version>
<spring-web.version>5.1.2.RELEASE</spring-web.version>
<cxf-bundle-package.version>2.7.18</cxf-bundle-package.version>
<imp.package.version.osgi.framework>[1.6.0, 2.0.0)</imp.package.version.osgi.framework>
<imp.package.version.osgi.service>[1.2.0,1.3.0)</imp.package.version.osgi.service>
</properties>
<distributionManagement>

Loading…
Cancel
Save