Merge branch 'kernel-4.6.x' into 'master'

Merge kernel-4.6.x with master

See merge request entgra/carbon-device-mgt!808
release-temp
Inosh Perara 3 years ago
commit 5374963480

@ -22,13 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Annotations</name> <name>WSO2 Carbon - API Management Annotations</name>
<description>WSO2 Carbon - API Management Custom Annotation Module</description> <description>WSO2 Carbon - API Management Custom Annotation Module</description>
@ -73,8 +72,8 @@
org.wso2.carbon.apimgt.annotations.* org.wso2.carbon.apimgt.annotations.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.servlet, javax.servlet,
javax.xml.*, javax.xml.*,

@ -20,4 +20,6 @@ public @interface Scope {
String[] permissions(); String[] permissions();
String[] roles();
} }

@ -21,12 +21,11 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>4.1.16-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - API Application Management API</name> <name>WSO2 Carbon - API Application Management API</name>
@ -34,42 +33,24 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<dependencies> <dependencies>
<!--CXF -->
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>io.swagger</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>swagger-annotations</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.springframework</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>spring-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--JAX-RS -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId> <artifactId>jackson-jaxrs</artifactId>
</dependency> </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> <dependency>
<groupId>commons-httpclient.wso2</groupId> <groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>

@ -27,8 +27,6 @@ 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.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; 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.exception.APIManagerException;
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.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
@ -110,12 +108,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
if (username.equals(registrationProfile.getUsername())) { if (username.equals(registrationProfile.getUsername())) {
synchronized (ApiApplicationRegistrationServiceImpl.class) { synchronized (ApiApplicationRegistrationServiceImpl.class) {
StoreClient storeClient = new StoreClient(new OAuthRequestInterceptor(registrationProfile.getUsername(),
registrationProfile.getPassword()));
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
applicationName, registrationProfile.getTags(), applicationName, registrationProfile.getTags(),
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
registrationProfile.isAllowedToAllDomains(), validityPeriod, storeClient); registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
} }
} }
@ -126,7 +122,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
synchronized (ApiApplicationRegistrationServiceImpl.class) { synchronized (ApiApplicationRegistrationServiceImpl.class) {
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
applicationName, registrationProfile.getTags(), applicationName, registrationProfile.getTags(),
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(),
registrationProfile.isAllowedToAllDomains(), validityPeriod); registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); 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.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; 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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext; 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. 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. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

@ -54,6 +54,10 @@
<param-name>managed-api-owner</param-name> <param-name>managed-api-owner</param-name>
<param-value>admin</param-value> <param-value>admin</param-value>
</context-param> </context-param>
<context-param>
<param-name>resource-permission-validate</param-name>
<param-value>false</param-value>
</context-param>
<filter> <filter>
<filter-name>ApiPermissionFilter</filter-name> <filter-name>ApiPermissionFilter</filter-name>

@ -22,12 +22,11 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>4.1.16-SNAPSHOT</version>
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Application Management</name> <name>WSO2 Carbon - API Application Management</name>
@ -51,14 +50,15 @@
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <artifactId>org.wso2.carbon.apimgt.impl</artifactId>
</dependency> <scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.googlecode.json-simple.wso2</groupId> <groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId> <artifactId>json-simple</artifactId>
@ -100,24 +100,32 @@
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version> <Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>API Management Application Bundle</Bundle-Description> <Bundle-Description>API Management Application Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package> <Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
<Import-Package> <Import-Packages>
org.osgi.framework, org.apache.commons.lang;version="[2.6,3)",
org.osgi.service.component, org.apache.commons.logging;version="[1.2,2)",
org.apache.commons.logging.*,
org.wso2.carbon.user.core.*,
org.wso2.carbon.user.api,
org.wso2.carbon.utils.multitenancy,
org.json.simple, org.json.simple,
org.wso2.carbon.context, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.wso2.carbon.base, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.registry.core.*;resolution:=optional, org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}",
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}",
org.wso2.carbon.apimgt.integration.client.*, org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}",
org.wso2.carbon.apimgt.integration.generated.client.store.api, org.wso2.carbon.apimgt.application.extension.bean,
org.wso2.carbon.apimgt.integration.generated.client.store.model, org.wso2.carbon.apimgt.application.extension.dto,
org.wso2.carbon.identity.jwt.client.extension.*, org.wso2.carbon.apimgt.application.extension.exception,
feign org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}",
</Import-Package> org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}",
org.wso2.carbon.context;version="${carbon.kernel.version.range}",
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.extension.service,
org.wso2.carbon.registry.core.exceptions;version="[1.0,2)",
org.wso2.carbon.registry.core.service;version="[1.0,2)",
org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}",
org.wso2.carbon.user.api;version="[1.0,2)",
org.wso2.carbon.user.core.service;version="${carbon.kernel.version.range}",
org.wso2.carbon.user.core.tenant;version="${carbon.kernel.version.range}"
</Import-Packages>
<Export-Package> <Export-Package>
!org.wso2.carbon.apimgt.application.extension.internal, !org.wso2.carbon.apimgt.application.extension.internal,
org.wso2.carbon.apimgt.application.extension.* org.wso2.carbon.apimgt.application.extension.*

@ -20,7 +20,6 @@ package org.wso2.carbon.apimgt.application.extension;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; 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.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.identity.jwt.client.extension.dto.AccessTokenInfo;
/** /**
@ -51,28 +50,6 @@ public interface APIManagementProviderService {
String keyType, String username, boolean isAllowedAllDomains, String keyType, String username, boolean isAllowedAllDomains,
String validityTime) throws APIManagerException; String validityTime) throws APIManagerException;
/**
* Generate and retreive application keys. if the application does exist then
* create it and subscribe to apis that are grouped with the tags.
*
* @param apiApplicationName name of the application.
* @param tags tags of the apis that application needs to be subscribed.
* @param keyType of the application.
* @param username to whom the application is created
* @param isAllowedAllDomains application is allowed to all the tenants
* @param validityTime validity period of the application
* @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;
/** /**
* Remove APIM Application. * Remove APIM Application.
*/ */

@ -18,18 +18,29 @@
package org.wso2.carbon.apimgt.application.extension; package org.wso2.carbon.apimgt.application.extension;
import feign.FeignException; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIAdmin;
import org.wso2.carbon.apimgt.api.APIConsumer;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIKey;
import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper;
import org.wso2.carbon.apimgt.api.model.Application;
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.bean.APIRegistrationProfile;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; 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.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; 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.internal.APIApplicationManagerExtensionDataHolder;
import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil;
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; import org.wso2.carbon.apimgt.impl.APIAdminImpl;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.integration.generated.client.store.model.*; import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient; 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.dto.AccessTokenInfo;
@ -39,7 +50,10 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* This class represents an implementation of APIManagementProviderService. * This class represents an implementation of APIManagementProviderService.
@ -47,51 +61,37 @@ import java.util.List;
public class APIManagementProviderServiceImpl implements APIManagementProviderService { public class APIManagementProviderServiceImpl implements APIManagementProviderService {
private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class);
private static final String CONTENT_TYPE = "application/json"; public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
private static final int MAX_API_PER_TAG = 200;
private static final String APP_TIER_TYPE = "application";
@Override
public boolean isTierLoaded() { public boolean isTierLoaded() {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain();
try { try {
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain);
APP_TIER_TYPE,
tenantDomain, CONTENT_TYPE, null, null);
return true; return true;
} catch (FeignException e) { } catch (APIManagementException 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); log.error("APIs not ready", e);
} }
return false; return false;
} }
@Override @Override
public void removeAPIApplication(String applicationName, String username) throws APIManagerException { public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() try {
.getStoreClient(); APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
ApplicationList applicationList = storeClient.getApplications() Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); if (application != null) {
if (applicationList.getList() != null && applicationList.getList().size() > 0) { apiConsumer.removeApplication(application, username);
ApplicationInfo applicationInfo = applicationList.getList().get(0); }
storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), } catch (APIManagementException e) {
null, null); throw new APIManagerException("Failed to remove api application : " + applicationName, e);
} }
} }
/** /**
@ -99,95 +99,83 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
*/ */
@Override @Override
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
String keyType, String username, String keyType, String username, boolean isAllowedAllDomains, String validityTime)
boolean isAllowedAllDomains, String validityTime, throws APIManagerException {
StoreClient sClient) throws APIManagerException {
StoreClient storeClient;
if (sClient == null) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() if (StringUtils.isEmpty(username)) {
.getStoreClient(); username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
} else {
storeClient = sClient;
} }
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain();
try { try {
ApplicationList applicationList = storeClient.getApplications() APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
Application application;
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { int applicationId = 0;
//create application; Subscriber subscriber = null;
application = new Application(); if (application == null) {
application.setName(applicationName); subscriber = apiConsumer.getSubscriber(username);
application.setSubscriber(username); if (subscriber == null) {
application.setDescription(""); // create subscriber
application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER); apiConsumer.addSubscriber(username, "");
subscriber = apiConsumer.getSubscriber(username);
}
//create application
application = new Application(applicationName, subscriber);
application.setTier(ApiApplicationConstants.DEFAULT_TIER);
application.setGroupId(""); application.setGroupId("");
application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE); application.setTokenType("OAUTH");
apiConsumer.addApplication(application, username);
application = apiConsumer.getApplicationsByName(username, applicationName, "");
} else { } else {
ApplicationInfo applicationInfo = applicationList.getList().get(0); subscriber = apiConsumer.getSubscriber(username);
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);
} }
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet Set<SubscribedAPI> subscribedAPIs =
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); apiConsumer.getSubscribedAPIs(subscriber, applicationName, "");
List<Subscription> needToSubscribe = new ArrayList<>();
log.info("Already subscribed API count: " + subscribedAPIs.size());
// subscribe to apis. // subscribe to apis.
Set<String> tempApiIds = new HashSet<>();
if (tags != null && tags.length > 0) { if (tags != null && tags.length > 0) {
for (String tag : tags) { for (String tag : tags) {
APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag Set<API> apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain);
, CONTENT_TYPE, null); if (apisWithTag == null || apisWithTag.size() == 0) {
if (apiList.getList() == null || apiList.getList().size() == 0) { apisWithTag = apiConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
} }
if (apiList.getList() != null && apiList.getList().size() > 0) { if (apisWithTag != null && apisWithTag.size() > 0) {
for (APIInfo apiInfo : apiList.getList()) { for (API apiInfo : apisWithTag) {
String id = apiInfo.getProvider().replace("@", "-AT-") String id = apiInfo.getId().getProviderName().replace("@", "-AT-")
+ "-" + apiInfo.getName() + "-" + apiInfo.getVersion(); + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion();
id = id.replace(" ", "+"); // todo: amalka will this break old apis?
boolean subscriptionExist = false; boolean subscriptionExist = false;
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { if (subscribedAPIs.size() > 0) {
for (Subscription subs : subscriptionList.getList()) { for (SubscribedAPI subscribedAPI : subscribedAPIs) {
if (subs.getApiIdentifier().equals(id)) { if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) {
subscriptionExist = true; subscriptionExist = true;
break; break;
} }
} }
} }
if (!subscriptionExist) { if (!subscriptionExist && !tempApiIds.contains(id)) {
Subscription subscription = new Subscription(); ApiTypeWrapper apiTypeWrapper = apiConsumer.getAPIorAPIProductByUUID(
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0 apiInfo.getUuid(), tenantDomain);
apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER);
subscription.setApiIdentifier(id);
subscription.setApplicationId(application.getApplicationId()); apiConsumer.addSubscription(apiTypeWrapper, username, application);
subscription.tier(ApiApplicationConstants.DEFAULT_TIER); tempApiIds.add(id);
if (!needToSubscribe.contains(subscription)) {
needToSubscribe.add(subscription);
}
} }
} }
} }
} }
} }
if (!needToSubscribe.isEmpty()) {
storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE);
}
//end of subscription //end of subscription
List<ApplicationKey> applicationKeys = application.getKeys(); List<APIKey> applicationKeys = application.getKeys();
if (applicationKeys != null) { if (applicationKeys != null) {
for (ApplicationKey applicationKey : applicationKeys) { for (APIKey applicationKey : applicationKeys) {
if (keyType.equals(applicationKey.getKeyType().toString())) { if (keyType.equals(applicationKey.getType())) {
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
@ -198,45 +186,51 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
} }
} }
ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest();
List<String> allowedDomains = new ArrayList<>(); List<String> allowedDomains = new ArrayList<>();
if (isAllowedAllDomains) { if (isAllowedAllDomains) {
allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS);
} else { } else {
allowedDomains.add(APIManagerUtil.getTenantDomain()); allowedDomains.add(APIManagerUtil.getTenantDomain());
} }
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
applicationKeyGenerateRequest.setCallbackUrl(""); APIAdmin apiAdmin = new APIAdminImpl();
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION); String keyManagerId = null;
applicationKeyGenerateRequest.setValidityTime(validityTime); try {
List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiAdmin
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( .getKeyManagerConfigurationsByTenant(tenantDomain);
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); if (keyManagerConfigurations != null) {
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); keyManagerId = keyManagerConfigurationDTO.getUuid();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); }
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); }
return apiApplicationKey; 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 + "\"}";
Map<String, Object> keyDetails = apiConsumer
.requestApprovalForApplicationRegistration(username, applicationName, keyType, "",
allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "",
jsonString, keyManagerId, tenantDomain);
if (keyDetails != null) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey"));
apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret"));
return apiApplicationKey;
}
throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain);
} 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 (APIManagementException e) {
} catch (FeignException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
} }
} }
/**
* {@inheritDoc}
*/
@Override
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
String keyType, String username,
boolean isAllowedAllDomains,
String validityTime)
throws APIManagerException {
return this.generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,
isAllowedAllDomains, validityTime, null);
}
@Override @Override
public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType,
String validityPeriod) throws APIManagerException { String validityPeriod) throws APIManagerException {
@ -311,7 +305,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) { if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) {
info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
registrationProfile.getTags(), tokenType, registrationProfile.getApplicationName(), registrationProfile.getTags(), tokenType, null,
registrationProfile.isAllowedToAllDomains(), validityPeriod); registrationProfile.isAllowedToAllDomains(), validityPeriod);
} }
} finally { } finally {

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

@ -23,7 +23,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;; import org.osgi.service.component.ComponentContext;;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
@ -49,12 +48,6 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic" * policy="dynamic"
* bind="setRealmService" * bind="setRealmService"
* unbind="unsetRealmService" * 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 { public class APIApplicationManagerExtensionServiceComponent {
@ -97,17 +90,6 @@ public class APIApplicationManagerExtensionServiceComponent {
APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null); 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);
}
/** /**
* Sets Realm Service. * Sets Realm Service.
* *

@ -21,13 +21,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId> <artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Security Handler Component</name> <name>WSO2 Carbon - API Security Handler Component</name>
<description>WSO2 Carbon - API Management Security Handler Module</description> <description>WSO2 Carbon - API Management Security Handler Module</description>

@ -13,13 +13,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Client</name> <name>WSO2 Carbon - API Management Integration Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -13,13 +13,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Integration Generated Client</name> <name>WSO2 Carbon - API Management Integration Generated Client</name>
<description>WSO2 Carbon - API Management Integration Client</description> <description>WSO2 Carbon - API Management Integration Client</description>

@ -22,13 +22,12 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - API Management Webapp Publisher</name> <name>WSO2 Carbon - API Management Webapp Publisher</name>
<description>WSO2 Carbon - API Management Webapp Publisher</description> <description>WSO2 Carbon - API Management Webapp Publisher</description>
@ -109,8 +108,14 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database.wso2</groupId> <groupId>com.h2database.wso2</groupId>
@ -144,41 +149,46 @@
org.wso2.carbon.apimgt.webapp.publisher.* org.wso2.carbon.apimgt.webapp.publisher.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, com.google.gson;version="2.3",
org.osgi.service.component, com.google.gson.reflect;version="2.3",
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, io.swagger.annotations,
javax.net.ssl, javax.servlet;version="2.6",
org.scannotation, javax.xml,
org.scannotation.archiveiterator, javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.parsers,
org.apache.catalina;version="9.0",
org.apache.catalina.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;version="1.0",
org.w3c.dom, org.w3c.dom,
org.wso2.carbon.apimgt.integration.client.*, org.wso2.carbon.apimgt.annotations.api,
org.wso2.carbon.context, org.wso2.carbon.apimgt.api,
org.wso2.carbon.core.util, org.wso2.carbon.apimgt.api.model,
org.wso2.carbon.user.api, org.wso2.carbon.apimgt.impl,
org.wso2.carbon.user.core.*, org.wso2.carbon.apimgt.webapp.publisher,
org.wso2.carbon.utils.multitenancy, org.wso2.carbon.apimgt.webapp.publisher.config,
org.wso2.carbon.apimgt.integration.generated.client.publisher.api, org.wso2.carbon.apimgt.webapp.publisher.dto,
org.wso2.carbon.apimgt.integration.generated.client.publisher.model org.wso2.carbon.apimgt.webapp.publisher.exception,
org.wso2.carbon.apimgt.webapp.publisher.lifecycle.listener,
org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util,
org.wso2.carbon.base;version="1.0",
org.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.core.service;version="1.0",
org.wso2.carbon.user.api;version="1.0",
org.wso2.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.carbon.utils.multitenancy;version="4.6"
</Import-Package> </Import-Package>
<Embed-Dependency> <Embed-Dependency>
javax.ws.rs-api, jsr311-api;scope=compile|runtime;inline=false
scribe;scope=compile|runtime;inline=false;
</Embed-Dependency> </Embed-Dependency>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
@ -210,4 +220,9 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<!-- TODO -->
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</project> </project>

@ -18,15 +18,32 @@
*/ */
package org.wso2.carbon.apimgt.webapp.publisher; package org.wso2.carbon.apimgt.webapp.publisher;
import feign.FeignException; import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiScope;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*; import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate;
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.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; 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.context.PrivilegedCarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; 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;
/** /**
* This class represents the concrete implementation of the APIPublisherService that corresponds to providing all * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all
@ -34,11 +51,10 @@ import java.util.*;
*/ */
public class APIPublisherServiceImpl implements APIPublisherService { public class APIPublisherServiceImpl implements APIPublisherService {
private static final String UNLIMITED_TIER = "Unlimited"; private static final String UNLIMITED_TIER = "Unlimited";
private static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; private static final String API_PUBLISH_ENVIRONMENT = "Default";
private static final String CONTENT_TYPE = "application/json";
private static final String PUBLISHED_STATUS = "PUBLISHED";
private static final String CREATED_STATUS = "CREATED"; private static final String CREATED_STATUS = "CREATED";
private static final String PUBLISH_ACTION = "Publish"; private static final String PUBLISH_ACTION = "Publish";
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
@Override @Override
public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException { public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException {
@ -46,100 +62,219 @@ public class APIPublisherServiceImpl implements APIPublisherService {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner()); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService() APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(apiConfig.getOwner());
.getPublisherClient(); APIIdentifier apiIdentifier = new APIIdentifier(apiConfig.getOwner(), apiConfig.getName(), apiConfig.getVersion());
API api = getAPI(apiConfig);
APIList apiList = publisherClient.getApis().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null); if (!apiProvider.isAPIAvailable(apiIdentifier)) {
if (!isExist(api, apiList)) { // add new scopes as shared scopes
api = publisherClient.getApi().apisPost(api, CONTENT_TYPE, null); Set<String> allSharedScopeKeys = apiProvider.getAllSharedScopeKeys(tenantDomain);
if (CREATED_STATUS.equals(api.getStatus())) { for (ApiScope apiScope : apiConfig.getScopes()) {
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); if (!allSharedScopeKeys.contains(apiScope.getKey())) {
Scope scope = new Scope();
scope.setName(apiScope.getName());
scope.setDescription(apiScope.getDescription());
scope.setKey(apiScope.getKey());
scope.setRoles(apiScope.getRoles());
apiProvider.addSharedScope(scope, tenantDomain);
}
}
API api = getAPI(apiConfig, true);
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(System.getProperty("iot.gateway.host"));
apiRevisionDeployment.setDisplayOnDevportal(true);
List<APIRevisionDeployment> apiRevisionDeploymentList = new ArrayList<>();
apiRevisionDeploymentList.add(apiRevisionDeployment);
apiProvider.deployAPIRevision(createdAPI.getUuid(), apiRevisionId, apiRevisionDeploymentList);
} }
} else { } else {
if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) {
for (APIInfo apiInfo : apiList.getList()) {
if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) { // With 4.x to 5.x upgrade
api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null); // - there cannot be same local scope assigned in 2 different APIs
if (api != null && CREATED_STATUS.equals(api.getStatus())) { // - local scopes will be deprecated in the future, so need to move all scopes as shared scopes
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null,
null); // if an api scope is not available as shared scope, but already assigned as local scope -> that means, the scopes available for this API has not moved as shared scopes
// in order to do that :
// 1. update the same API removing scopes from URI templates
// 2. add scopes as shared scopes
// 3. update the API again adding scopes for the URI Templates
// if an api scope is not available as shared scope, and not assigned as local scope -> that means, there are new scopes
// 1. add new scopes as shared scopes
// 2. update the API adding scopes for the URI Templates
Set<String> allSharedScopeKeys = apiProvider.getAllSharedScopeKeys(tenantDomain);
Set<ApiScope> scopesToMoveAsSharedScopes = new HashSet<>();
for (ApiScope apiScope : apiConfig.getScopes()) {
// if the scope is not available as shared scope and it is assigned to an API as a local scope
// need remove the local scope and add as a shared scope
if (!allSharedScopeKeys.contains(apiScope.getKey())) {
if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) {
// collect scope to move as shared scopes
scopesToMoveAsSharedScopes.add(apiScope);
} else {
// if new scope add as shared scope
Scope scope = new Scope();
scope.setName(apiScope.getName());
scope.setDescription(apiScope.getDescription());
scope.setKey(apiScope.getKey());
scope.setRoles(apiScope.getRoles());
apiProvider.addSharedScope(scope, tenantDomain);
} }
} }
}
// Get existing API
API existingAPI = apiProvider.getAPI(apiIdentifier);
if (scopesToMoveAsSharedScopes.size() > 0) {
// update API to remove local scopes
API api = getAPI(apiConfig, false);
api.setStatus(existingAPI.getStatus());
apiProvider.updateAPI(api);
for (ApiScope apiScope : scopesToMoveAsSharedScopes) {
Scope scope = new Scope();
scope.setName(apiScope.getName());
scope.setDescription(apiScope.getDescription());
scope.setKey(apiScope.getKey());
scope.setRoles(apiScope.getRoles());
apiProvider.addSharedScope(scope, tenantDomain);
}
}
existingAPI = apiProvider.getAPI(apiIdentifier);
API api = getAPI(apiConfig, true);
api.setStatus(existingAPI.getStatus());
apiProvider.updateAPI(api);
// Assumption: Assume the latest revision is the published one
String latestRevisionUUID = apiProvider.getLatestRevisionUUID(existingAPI.getUuid());
List<APIRevisionDeployment> latestRevisionDeploymentList =
apiProvider.getAPIRevisionDeploymentList(latestRevisionUUID);
List<APIRevision> apiRevisionList = apiProvider.getAPIRevisions(existingAPI.getUuid());
if (apiRevisionList.size() >= 5) {
String earliestRevisionUUID = apiProvider.getEarliestRevisionUUID(existingAPI.getUuid());
List<APIRevisionDeployment> earliestRevisionDeploymentList =
apiProvider.getAPIRevisionDeploymentList(earliestRevisionUUID);
apiProvider.undeployAPIRevisionDeployment(existingAPI.getUuid(), earliestRevisionUUID, earliestRevisionDeploymentList);
apiProvider.deleteAPIRevision(existingAPI.getUuid(), earliestRevisionUUID, tenantDomain);
}
// create new revision
APIRevision apiRevision = new APIRevision();
apiRevision.setApiUUID(existingAPI.getUuid());
apiRevision.setDescription("Updated Revision");
String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain);
apiProvider.deployAPIRevision(existingAPI.getUuid(), apiRevisionId, latestRevisionDeploymentList);
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); throw new APIManagerPublisherException(e);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
} }
private boolean isExist(API api, APIList apiList) { private API getAPI(APIConfig config, boolean includeScopes) {
if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) {
return false; APIIdentifier apiIdentifier = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
} API api = new API(apiIdentifier);
for (APIInfo existingApi : apiList.getList()) { api.setDescription("");
if (existingApi.getName() != null && existingApi.getName().equals(api. String context = config.getContext();
getName()) && existingApi.getVersion() != null && context = context.startsWith("/") ? context : ("/" + context);
existingApi.getVersion().equals(api.getVersion())) { api.setContext(context + "/" + config.getVersion());
return true; 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());
if (includeScopes) {
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.setScopes(scope);
}
} }
uriTemplates.add(uriTemplate);
} }
return false; api.setUriTemplates(uriTemplates);
}
private API getAPI(APIConfig config) { api.setApiOwner(config.getOwner());
API api = new API();
api.setName(config.getName());
api.setDescription("");
String context = config.getContext(); api.setDefaultVersion(config.isDefault());
context = context.startsWith("/") ? context : ("/" + context); api.setTransports("https,http");
api.setContext(context);
api.setVersion(config.getVersion()); Set<String> tags = new HashSet<>();
api.setProvider(config.getOwner()); tags.addAll(Arrays.asList(config.getTags()));
api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config)); api.setTags(tags);
api.setWsdlUri(null);
api.setStatus(PUBLISHED_STATUS); Set<Tier> availableTiers = new HashSet<>();
api.setResponseCaching("DISABLED"); availableTiers.add(new Tier(UNLIMITED_TIER));
api.setDestinationStatsEnabled("false"); api.setAvailableTiers(availableTiers);
api.isDefaultVersion(config.isDefault());
List<String> transport = new ArrayList<>(); Set<String> environments = new HashSet<>();
transport.add("https"); environments.add(API_PUBLISH_ENVIRONMENT);
transport.add("http"); api.setEnvironments(environments);
api.transport(transport);
api.setTags(Arrays.asList(config.getTags()));
api.addTiersItem(UNLIMITED_TIER);
api.setGatewayEnvironments(API_PUBLISH_ENVIRONMENT);
if (config.isSharedWithAllTenants()) { if (config.isSharedWithAllTenants()) {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.all_tenants); api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_ALL_TENANTS);
api.setVisibility(API.VisibilityEnum.PUBLIC); api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
} else { } else {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.current_tenant); api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT);
api.setVisibility(API.VisibilityEnum.PRIVATE); api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY);
} }
String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() + String endpointConfig = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " +
"\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}"; config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }";
api.setEndpointConfig(endpointConfig); api.setEndpointConfig(endpointConfig);
APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration();
List<String> accessControlAllowOrigins = new ArrayList<>(); List<String> accessControlAllowOrigins = new ArrayList<>();
accessControlAllowOrigins.add("*"); accessControlAllowOrigins.add("*");
apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins);
List<String> accessControlAllowHeaders = new ArrayList<>(); List<String> accessControlAllowHeaders = new ArrayList<>();
accessControlAllowHeaders.add("authorization"); accessControlAllowHeaders.add("authorization");
accessControlAllowHeaders.add("Access-Control-Allow-Origin"); accessControlAllowHeaders.add("Access-Control-Allow-Origin");
accessControlAllowHeaders.add("Content-Type"); accessControlAllowHeaders.add("Content-Type");
accessControlAllowHeaders.add("SOAPAction"); accessControlAllowHeaders.add("SOAPAction");
apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders); accessControlAllowHeaders.add("apikey");
accessControlAllowHeaders.add("Internal-Key");
List<String> accessControlAllowMethods = new ArrayList<>(); List<String> accessControlAllowMethods = new ArrayList<>();
accessControlAllowMethods.add("GET"); accessControlAllowMethods.add("GET");
accessControlAllowMethods.add("PUT"); accessControlAllowMethods.add("PUT");
@ -147,10 +282,16 @@ public class APIPublisherServiceImpl implements APIPublisherService {
accessControlAllowMethods.add("POST"); accessControlAllowMethods.add("POST");
accessControlAllowMethods.add("PATCH"); accessControlAllowMethods.add("PATCH");
accessControlAllowMethods.add("OPTIONS"); accessControlAllowMethods.add("OPTIONS");
apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods); CORSConfiguration corsConfiguration = new CORSConfiguration(false, accessControlAllowOrigins, false,
apiCorsConfiguration.setAccessControlAllowCredentials(false); accessControlAllowHeaders, accessControlAllowMethods);
apiCorsConfiguration.corsConfigurationEnabled(false); api.setCorsConfiguration(corsConfiguration);
api.setCorsConfiguration(apiCorsConfiguration);
api.setAuthorizationHeader("Authorization");
List<String> keyManagers = new ArrayList<>();
keyManagers.add("all");
api.setKeyManagers(keyManagers);
api.setEnableStore(true);
return api; return api;
} }
} }

@ -23,6 +23,7 @@ public class ApiScope {
String key; String key;
String name; String name;
String roles; String roles;
String permissions;
String description; String description;
int id; int id;
@ -61,4 +62,11 @@ public class ApiScope {
this.description = description; this.description = description;
} }
public String getPermissions() {
return permissions;
}
public void setPermissions(String permissions) {
this.permissions = permissions;
}
} }

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

@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler;
@ -45,11 +44,6 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic" * policy="dynamic"
* bind="setRegistryService" * bind="setRegistryService"
* unbind="unsetRegistryService" * unbind="unsetRegistryService"
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
* cardinality="1..1"
* policy="dynamic"
* bind="setIntegrationClientService"
* unbind="unsetIntegrationClientService"
*/ */
public class APIPublisherServiceComponent { public class APIPublisherServiceComponent {
@ -120,14 +114,4 @@ public class APIPublisherServiceComponent {
APIPublisherDataHolder.getInstance().setRegistryService(null); 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);
}
} }

@ -70,6 +70,7 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION = "description"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_DESCRIPTION = "description";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_KEY = "key"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_KEY = "key";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_ROLES = "roles";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VERSION = "version";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_CONTEXT = "context";
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value";
@ -78,6 +79,7 @@ public class AnnotationProcessor {
private static final String DEFAULT_SCOPE_NAME = "default admin scope"; private static final String DEFAULT_SCOPE_NAME = "default admin scope";
private static final String DEFAULT_SCOPE_KEY = "perm:admin"; private static final String DEFAULT_SCOPE_KEY = "perm:admin";
private static final String DEFAULT_SCOPE_PERMISSION = "/permision/device-mgt"; private static final String DEFAULT_SCOPE_PERMISSION = "/permision/device-mgt";
private static final String DEFAULT_SCOPE_ROLE = "admin";
private static final String PERMISSION_PREFIX = "/permission/admin"; private static final String PERMISSION_PREFIX = "/permission/admin";
@ -217,8 +219,11 @@ public class AnnotationProcessor {
ApiScope scope; ApiScope scope;
String permissions[]; String permissions[];
StringBuilder aggregatedPermissions; StringBuilder aggregatedPermissions;
String roles[];
StringBuilder aggregatedRoles;
for(int i=0; i<annotatedScopes.length; i++){ for(int i=0; i<annotatedScopes.length; i++){
aggregatedPermissions = new StringBuilder(); aggregatedPermissions = new StringBuilder();
aggregatedRoles = new StringBuilder();
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]); methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
scope = new ApiScope(); scope = new ApiScope();
scope.setName(invokeMethod(scopeClass scope.setName(invokeMethod(scopeClass
@ -234,7 +239,14 @@ public class AnnotationProcessor {
aggregatedPermissions.append(permission); aggregatedPermissions.append(permission);
aggregatedPermissions.append(" "); aggregatedPermissions.append(" ");
} }
scope.setRoles(aggregatedPermissions.toString().trim()); scope.setPermissions(aggregatedPermissions.toString().trim());
roles = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_ROLES, null),null);
for (String role : roles) {
aggregatedRoles.append(role);
aggregatedRoles.append(",");
}
scope.setRoles(aggregatedRoles.substring(0, aggregatedRoles.lastIndexOf(",")));
scopes.put(scope.getKey(), scope); scopes.put(scope.getKey(), scope);
} }
return scopes; return scopes;
@ -288,7 +300,8 @@ public class AnnotationProcessor {
scope.setName(DEFAULT_SCOPE_NAME); scope.setName(DEFAULT_SCOPE_NAME);
scope.setDescription(DEFAULT_SCOPE_NAME); scope.setDescription(DEFAULT_SCOPE_NAME);
scope.setKey(DEFAULT_SCOPE_KEY); scope.setKey(DEFAULT_SCOPE_KEY);
scope.setRoles(DEFAULT_SCOPE_PERMISSION); scope.setRoles(DEFAULT_SCOPE_ROLE);
scope.setPermissions(DEFAULT_SCOPE_PERMISSION);
resource.setScope(scope); resource.setScope(scope);
} }
} }

@ -22,22 +22,11 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.testng.annotations.BeforeSuite; import org.testng.annotations.BeforeSuite;
import org.wso2.carbon.apimgt.integration.client.IntegrationClientServiceImpl;
import org.wso2.carbon.apimgt.integration.client.internal.APIIntegrationClientDataHolder;
import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.APIIndividualApi;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.apimgt.webapp.publisher.utils.MockAPIIndividualApi; import org.wso2.carbon.apimgt.webapp.publisher.utils.MockAPIIndividualApi;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.internal.OSGiDataHolder; import org.wso2.carbon.context.internal.OSGiDataHolder;
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;
import org.wso2.carbon.identity.jwt.client.extension.internal.JWTClientExtensionDataHolder;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerServiceImpl;
import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.config.RegistryContext;
import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.internal.RegistryDataHolder; import org.wso2.carbon.registry.core.internal.RegistryDataHolder;
@ -45,6 +34,7 @@ import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;

@ -22,25 +22,21 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - API Management Extensions Component</name> <name>WSO2 Carbon - API Management Extensions Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<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.webapp.publisher</module>
<module>org.wso2.carbon.apimgt.application.extension</module> <module>org.wso2.carbon.apimgt.application.extension</module>
<module>org.wso2.carbon.apimgt.application.extension.api</module> <module>org.wso2.carbon.apimgt.application.extension.api</module>
<module>org.wso2.carbon.apimgt.annotations</module> <module>org.wso2.carbon.apimgt.annotations</module>
<module>org.wso2.carbon.apimgt.handlers</module>
</modules> </modules>
<build> <build>

@ -1,17 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <!--
~ Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
~
~ Entgra (pvt) Ltd. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.application.mgt.addons</artifactId> <artifactId>io.entgra.application.mgt.addons</artifactId>
<version>4.1.16-SNAPSHOT</version> <name>Entgra - Application Management Add-Ons</name>
<name>WSO2 Carbon - Application Management Add-Ons</name> <description>Entgra - Application Management Add-Ons</description>
<description>WSO2 Carbon - Application Management Add-Ons</description>
<url>https://entgra.io</url> <url>https://entgra.io</url>
<build> <build>
@ -36,7 +53,7 @@
io.swagger.annotations.*;resolution:=optional io.swagger.annotations.*;resolution:=optional
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
org.wso2.carbon.device.application.mgt.addons.* io.entgra.application.mgt.addons.*
</Export-Package> </Export-Package>
</instructions> </instructions>
</configuration> </configuration>
@ -95,7 +112,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId> <artifactId>io.entgra.application.mgt.common</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons; package io.entgra.application.mgt.addons;
import javax.servlet.Filter; import javax.servlet.Filter;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons; package io.entgra.application.mgt.addons;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
@ -24,7 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
/** /**
* org.wso2.carbon.device.application.mgt.addons.FileStreamingOutput to allow the user to send the files as Stream. * io.entgra.application.mgt.addons.FileStreamingOutput to allow the user to send the files as Stream.
*/ */
public class FileStreamingOutput implements StreamingOutput { public class FileStreamingOutput implements StreamingOutput {
private InputStream inputStream; private InputStream inputStream;

@ -14,11 +14,11 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons; package io.entgra.application.mgt.addons;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import org.wso2.carbon.device.application.mgt.addons.jaxrs.AnnotationExclusionStrategy; import io.entgra.application.mgt.addons.jaxrs.AnnotationExclusionStrategy;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;

@ -14,14 +14,14 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons; package io.entgra.application.mgt.addons;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.wso2.carbon.device.application.mgt.addons.jaxrs.AnnotationExclusionStrategy; import io.entgra.application.mgt.addons.jaxrs.AnnotationExclusionStrategy;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons; package io.entgra.application.mgt.addons;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons.jaxrs; package io.entgra.application.mgt.addons.jaxrs;
import com.google.gson.ExclusionStrategy; import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes; import com.google.gson.FieldAttributes;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.addons.jaxrs; package io.entgra.application.mgt.addons.jaxrs;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

@ -22,16 +22,15 @@
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.application.mgt.api</artifactId> <artifactId>io.entgra.application.mgt.api</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>WSO2 Carbon - Application Management API</name> <name>Entgra - Application Management API</name>
<description>WSO2 Carbon - Application Management API</description> <description>Entgra - Application Management API</description>
<url>https://entgra.io</url> <url>https://entgra.io</url>
<build> <build>
@ -155,12 +154,12 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.core</artifactId> <artifactId>io.entgra.application.mgt.core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId> <artifactId>io.entgra.application.mgt.common</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -219,7 +218,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.addons</artifactId> <artifactId>io.entgra.application.mgt.addons</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.api.services; package io.entgra.application.mgt.api.services;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -26,8 +26,8 @@ import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info; import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;
import org.wso2.carbon.device.application.mgt.common.ApplicationList; import io.entgra.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.ErrorResponse; import io.entgra.application.mgt.common.ErrorResponse;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;

@ -15,19 +15,19 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.api.services.impl; package io.entgra.application.mgt.api.services.impl;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.api.services.ArtifactDownloadAPI; import io.entgra.application.mgt.api.services.ArtifactDownloadAPI;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import io.entgra.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import io.entgra.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler; import io.entgra.application.mgt.common.services.AppmDataHandler;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; import io.entgra.application.mgt.core.exception.BadRequestException;
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import io.entgra.application.mgt.core.exception.NotFoundException;
import org.wso2.carbon.device.application.mgt.core.util.APIUtil; import io.entgra.application.mgt.core.util.APIUtil;
import org.wso2.carbon.device.application.mgt.core.util.Constants; import io.entgra.application.mgt.core.util.Constants;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;

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

@ -36,7 +36,7 @@
</jaxrs:server> </jaxrs:server>
<bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig"> <bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
<property name="resourcePackage" value="org.wso2.carbon.device.application.mgt.publisher.api"/> <property name="resourcePackage" value="io.entgra.application.mgt.api"/>
<property name="version" value="1.0"/> <property name="version" value="1.0"/>
<property name="host" value="localhost:9443"/> <property name="host" value="localhost:9443"/>
<property name="schemes" value="https" /> <property name="schemes" value="https" />
@ -48,17 +48,17 @@
<property name="scan" value="true"/> <property name="scan" value="true"/>
</bean> </bean>
<bean id="org.wso2.carbon.device.application.mgt.addons.ValidationInterceptor" class="org.wso2.carbon.device.application.mgt.addons.ValidationInterceptor"/> <bean id="io.entgra.application.mgt.addons.ValidationInterceptor" class="io.entgra.application.mgt.addons.ValidationInterceptor"/>
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" /> <bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" /> <bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
<bean id="applicationMgtArtifactService" class="org.wso2.carbon.device.application.mgt.api.services.impl.ArtifactDownloadAPIImpl"/> <bean id="applicationMgtArtifactService" class="io.entgra.application.mgt.api.services.impl.ArtifactDownloadAPIImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.addons.JSONMessageHandler"/> <bean id="jsonProvider" class="io.entgra.application.mgt.addons.JSONMessageHandler"/>
<bean id="multipartProvider" class="org.wso2.carbon.device.application.mgt.addons.MultipartCustomProvider"/> <bean id="multipartProvider" class="io.entgra.application.mgt.addons.MultipartCustomProvider"/>
<cxf:bus> <cxf:bus>
<cxf:inInterceptors> <cxf:inInterceptors>
<ref bean="org.wso2.carbon.device.application.mgt.addons.ValidationInterceptor"/> <ref bean="io.entgra.application.mgt.addons.ValidationInterceptor"/>
</cxf:inInterceptors> </cxf:inInterceptors>
</cxf:bus> </cxf:bus>

@ -74,7 +74,7 @@
<filter> <filter>
<filter-name>ApiOriginFilter</filter-name> <filter-name>ApiOriginFilter</filter-name>
<filter-class>org.wso2.carbon.device.application.mgt.addons.ApiOriginFilter</filter-class> <filter-class>io.entgra.application.mgt.addons.ApiOriginFilter</filter-class>
</filter> </filter>
<filter> <filter>

@ -21,16 +21,15 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<version>4.1.16-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId> <artifactId>io.entgra.application.mgt.common</artifactId>
<version>4.1.16-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Application Management Common</name> <name>Entgra - Application Management Common</name>
<description>WSO2 Carbon - Application Management Common</description> <description>Entgra - Application Management Common</description>
<url>https://entgra.io</url> <url>https://entgra.io</url>
<build> <build>
@ -56,10 +55,10 @@
io.swagger.annotations.*;resolution:=optional, io.swagger.annotations.*;resolution:=optional,
com.fasterxml.jackson.annotation, com.fasterxml.jackson.annotation,
javax.validation.constraints, javax.validation.constraints,
javax.xml.bind.annotation.*, javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
org.wso2.carbon.device.application.mgt.common.* io.entgra.application.mgt.common.*
</Export-Package> </Export-Package>
</instructions> </instructions>
</configuration> </configuration>

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**

@ -14,9 +14,9 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import io.entgra.application.mgt.common.dto.ApplicationDTO;
public class AppOperation { public class AppOperation {

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public class ApplicationInstaller { public class ApplicationInstaller {

@ -14,10 +14,10 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import io.entgra.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.response.Application; import io.entgra.application.mgt.common.response.Application;
import java.util.List; import java.util.List;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**
* Possible Subscription Type of the application. * Possible Subscription Type of the application.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public enum DeviceTypes { public enum DeviceTypes {
ANDROID, IOS, WINDOWS ANDROID, IOS, WINDOWS

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public enum ExecutionStatus { public enum ExecutionStatus {
PENDING, EXECUTED, FAILED PENDING, EXECUTED, FAILED

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import java.util.List; import java.util.List;

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**
* This represents a image artifact of a application. Icon, Screen-shot or Banner. * This represents a image artifact of a application. Icon, Screen-shot or Banner.

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public class LifecycleChanger { public class LifecycleChanger {

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import java.sql.Timestamp; import java.sql.Timestamp;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**
* This class represents the pagination details that will be used when fetching application details from database. * This class represents the pagination details that will be used when fetching application details from database.

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**
* This class holds required parameters for a querying a paginated device response. * This class holds required parameters for a querying a paginated device response.

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import java.util.TreeMap; import java.util.TreeMap;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public enum SubAction { public enum SubAction {
INSTALL, UNINSTALL INSTALL, UNINSTALL

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
public enum SubscriptionType { public enum SubscriptionType {
USER, ROLE, GROUP, DEVICE USER, ROLE, GROUP, DEVICE

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common; package io.entgra.application.mgt.common;
/** /**
* Represents an user. * Represents an user.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.config; package io.entgra.application.mgt.common.config;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.config; package io.entgra.application.mgt.common.config;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.config; package io.entgra.application.mgt.common.config;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.config; package io.entgra.application.mgt.common.config;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
public class ApiRegistrationProfile { public class ApiRegistrationProfile {

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
public class CategoryDTO { public class CategoryDTO {
int id; int id;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import java.sql.Timestamp; import java.sql.Timestamp;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import java.sql.Timestamp; import java.sql.Timestamp;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import java.sql.Timestamp; import java.sql.Timestamp;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import java.sql.Timestamp; import java.sql.Timestamp;

@ -16,13 +16,12 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.wso2.carbon.device.application.mgt.common.ExecutionStatus; import io.entgra.application.mgt.common.ExecutionStatus;
import org.wso2.carbon.device.application.mgt.common.SubscriptionType; import io.entgra.application.mgt.common.SubscriptionType;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -41,7 +40,7 @@ public class ScheduledSubscriptionDTO {
* Task name is a generated field and in the following pattern: * Task name is a generated field and in the following pattern:
* {@code <SUBSCRIPTION-TYPE>_<ACTION>_<HASH-VALUE>} * {@code <SUBSCRIPTION-TYPE>_<ACTION>_<HASH-VALUE>}
* {@code SUBSCRIPTION-TYPE} - {@see {@linkplain SubscriptionType}} * {@code SUBSCRIPTION-TYPE} - {@see {@linkplain SubscriptionType}}
* {@code ACTION} - {@see {@linkplain org.wso2.carbon.device.application.mgt.common.SubAction} * {@code ACTION} - {@see {@linkplain io.entgra.application.mgt.common.SubAction}
* {@code HASH-VALUE} - this is a hash value of the combination of application uuid and the subscriber list. * {@code HASH-VALUE} - this is a hash value of the combination of application uuid and the subscriber list.
* *
* Example: {@code DEVICE_INSTALL_e593e00e8ef55efc764295b6aa9ad56b} * Example: {@code DEVICE_INSTALL_e593e00e8ef55efc764295b6aa9ad56b}
@ -50,7 +49,7 @@ public class ScheduledSubscriptionDTO {
/** /**
* UUID of the application release which is subscribed to. * UUID of the application release which is subscribed to.
* {@see {@link org.wso2.carbon.device.application.mgt.common.response.ApplicationRelease}} * {@see {@link io.entgra.application.mgt.common.response.ApplicationRelease}}
*/ */
private String applicationUUID; private String applicationUUID;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
public class TagDTO { public class TagDTO {

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.dto; package io.entgra.application.mgt.common.dto;
import java.sql.Timestamp; import java.sql.Timestamp;

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Exception that will be thrown during Application Category Management. * Exception that will be thrown during Application Category Management.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Represents the exception thrown during application management. * Represents the exception thrown during application management.

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Represents the exception thrown during storing and retrieving the artifacts. * Represents the exception thrown during storing and retrieving the artifacts.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Exception thrown due to Database Connection issues. * Exception thrown due to Database Connection issues.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Represents the exception thrown during device connections. * Represents the exception thrown during device connections.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Exception thrown due to an issue in database transactions. * Exception thrown due to an issue in database transactions.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Exception thrown due to invalid configurations provided for Application Management. * Exception thrown due to invalid configurations provided for Application Management.

@ -14,7 +14,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Exception caused during the lifecycle management. * Exception caused during the lifecycle management.

@ -15,7 +15,7 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.device.application.mgt.common.exception; package io.entgra.application.mgt.common.exception;
/** /**
* Represents the exception thrown during validating the request. * Represents the exception thrown during validating the request.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save