Add an open endpoint to get UI config

This API endpoint will be used to get app tags, scopes etc. These data will be used in proxy level when it creates access token.
feature/appm-store/pbac
tcdlpds@gmail.com 5 years ago
parent 6a2a2faffd
commit 3d0bbf0b1c

@ -1,83 +0,0 @@
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.application.mgt.api.services;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition;
import org.wso2.carbon.device.application.mgt.common.*;
import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* APIs to handle application management related tasks.
*/
@SwaggerDefinition(
info = @Info(
version = "1.0.0",
title = "Application Management Config Retrieve Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = "name", value = "ApplicationManagementConfigRetrieveService"),
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/config"),
})
}
)
)
@Path("/config")
@Api(value = "ApplicationDTO Management Common Service")
@Produces(MediaType.APPLICATION_JSON)
public interface ConfigRetrieveAPI {
@GET
@Path("/ui-config")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "get application management UI configuration",
notes = "This will get all UI configuration of application management"
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully got UI config.",
response = ApplicationList.class),
@ApiResponse(
code = 404,
message = "Not Found. There doesn't have an defined UI config." +
"query."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while getting the UI config.",
response = ErrorResponse.class)
})
Response getUiConfig();
}

@ -1,56 +0,0 @@
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.application.mgt.api.services.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.api.services.ConfigRetrieveAPI;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler;
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
/**
* Implementation of ApplicationDTO Management related APIs.
*/
@Produces({"application/json"})
@Path("/config")
public class ConfigRetrieveAPIImpl implements ConfigRetrieveAPI {
private static Log log = LogFactory.getLog(ConfigRetrieveAPIImpl.class);
@GET
@Override
@Consumes("application/json")
@Path("/ui-config")
public Response getUiConfig() {
AppmDataHandler dataHandler = APIUtil.getDataHandler();
UIConfiguration uiConfiguration = dataHandler.getUIConfiguration();
if (uiConfiguration == null){
String msg = "UI configuration is not initiated.";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
return Response.status(Response.Status.OK).entity(uiConfiguration).build();
}
}

@ -25,7 +25,6 @@
<jaxrs:server id="applicationMgtCommonService" address="/">
<jaxrs:serviceBeans>
<ref bean="applicationMgtConfigService"/>
<ref bean="applicationMgtArtifactService"/>
<ref bean="swaggerResource"/>
</jaxrs:serviceBeans>
@ -53,7 +52,6 @@
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
<bean id="applicationMgtConfigService" class="org.wso2.carbon.device.application.mgt.api.services.impl.ConfigRetrieveAPIImpl"/>
<bean id="applicationMgtArtifactService" class="org.wso2.carbon.device.application.mgt.api.services.impl.ArtifactDownloadAPIImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.addons.JSONMessageHandler"/>
<bean id="multipartProvider" class="org.wso2.carbon.device.application.mgt.addons.MultipartCustomProvider"/>

@ -18,7 +18,6 @@
package org.wso2.carbon.device.application.mgt.common.services;
import org.wso2.carbon.device.application.mgt.common.config.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
@ -26,12 +25,6 @@ import java.io.InputStream;
import java.util.Map;
public interface AppmDataHandler {
/**
* Get UI configuration which is defined in the app-manager.xml
*
* @return {@link UIConfiguration} UI configuration
*/
UIConfiguration getUIConfiguration();
Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException;

@ -19,7 +19,6 @@ package org.wso2.carbon.device.application.mgt.core.config;
import org.wso2.carbon.device.application.mgt.common.config.MDMConfig;
import org.wso2.carbon.device.application.mgt.common.config.RatingConfiguration;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.common.config.LifecycleState;
import java.util.List;
@ -39,8 +38,6 @@ public class Configuration {
private List<LifecycleState> lifecycleStates;
private UIConfiguration uiConfiguration;
private List<String> appCategories;
private RatingConfiguration ratingConfiguration;
@ -76,15 +73,6 @@ public class Configuration {
this.lifecycleStates = lifecycleStates;
}
@XmlElement(name = "UIConfigs")
public UIConfiguration getUiConfiguration() {
return uiConfiguration;
}
public void setUiConfiguration(UIConfiguration uiConfiguration) {
this.uiConfiguration = uiConfiguration;
}
@XmlElement(name = "RatingConfig")
public RatingConfiguration getRatingConfiguration() { return ratingConfiguration; }

@ -19,7 +19,6 @@ package org.wso2.carbon.device.application.mgt.core.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.config.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException;
@ -27,7 +26,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManageme
import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
@ -44,19 +42,12 @@ import java.util.Map;
public class AppmDataHandlerImpl implements AppmDataHandler {
private static final Log log = LogFactory.getLog(AppmDataHandlerImpl.class);
private UIConfiguration uiConfiguration;
private LifecycleStateManager lifecycleStateManager;
public AppmDataHandlerImpl(UIConfiguration config) {
this.uiConfiguration = config;
public AppmDataHandlerImpl() {
lifecycleStateManager = DataHolder.getInstance().getLifecycleStateManager();
}
@Override
public UIConfiguration getUIConfiguration() {
return this.uiConfiguration;
}
@Override
public Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException {
return lifecycleStateManager.getLifecycleConfig();

@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.application.mgt.common.config.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler;
@ -108,9 +107,7 @@ public class ApplicationManagementServiceComponent {
DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager);
bundleContext.registerService(ApplicationStorageManager.class.getName(), applicationStorageManager, null);
UIConfiguration uiConfiguration = ConfigurationManager.getInstance().
getConfiguration().getUiConfiguration();
AppmDataHandler configManager = new AppmDataHandlerImpl(uiConfiguration);
AppmDataHandler configManager = new AppmDataHandlerImpl();
DataHolder.getInstance().setConfigManager(configManager);
bundleContext.registerService(AppmDataHandler.class.getName(), configManager, null);

@ -132,47 +132,6 @@
</LifecycleState>
</LifecycleStates>
<UIConfigs>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>
<Tag>device_management</Tag>
<Tag>subscription_management</Tag>
<Tag>review_management</Tag>
</Tags>
<AllowToAllDomains>true</AllowToAllDomains>
</AppRegistration>
<Scopes>
<Scope>perm:app:review:view</Scope>
<Scope>perm:app:review:update</Scope>
<Scope>perm:app:publisher:view</Scope>
<Scope>perm:app:publisher:update</Scope>
<Scope>perm:app:store:view</Scope>
<Scope>perm:app:subscription:install</Scope>
<Scope>perm:app:subscription:uninstall</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:review:view</Scope>
<Scope>perm:admin:app:publisher:update</Scope>
<Scope>perm:admin:app:review:update</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>app-mgt</Issuer>
</SSOConfiguration>
<ErrorCallback>
<BadRequest>/pages/error/client-errors/400</BadRequest>
<Unauthorized>/pages/error/client-errors/401</Unauthorized>
<Forbidden>/pages/error/client-errors/403</Forbidden>
<NotFound>/pages/error/client-errors/404</NotFound>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<InternalServerError>/pages/error/server-errors/500</InternalServerError>
<DefaultPage>/pages/error/default</DefaultPage>
</ErrorCallback>
</UIConfigs>
<AppCategories>
<Category>EMM</Category>
<Category>IoT</Category>

@ -132,47 +132,6 @@
</LifecycleState>
</LifecycleStates>
<UIConfigs>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>
<Tag>device_management</Tag>
<Tag>subscription_management</Tag>
<Tag>review_management</Tag>
</Tags>
<AllowToAllDomains>true</AllowToAllDomains>
</AppRegistration>
<Scopes>
<Scope>perm:app:review:view</Scope>
<Scope>perm:app:review:update</Scope>
<Scope>perm:app:publisher:view</Scope>
<Scope>perm:app:publisher:update</Scope>
<Scope>perm:app:store:view</Scope>
<Scope>perm:app:subscription:install</Scope>
<Scope>perm:app:subscription:uninstall</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:review:view</Scope>
<Scope>perm:admin:app:publisher:update</Scope>
<Scope>perm:admin:app:review:update</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>app-mgt</Issuer>
</SSOConfiguration>
<ErrorCallback>
<BadRequest>/pages/error/client-errors/400</BadRequest>
<Unauthorized>/pages/error/client-errors/401</Unauthorized>
<Forbidden>/pages/error/client-errors/403</Forbidden>
<NotFound>/pages/error/client-errors/404</NotFound>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<InternalServerError>/pages/error/server-errors/500</InternalServerError>
<DefaultPage>/pages/error/default</DefaultPage>
</ErrorCallback>
</UIConfigs>
<AppCategories>
<Category>EMM</Category>
<Category>IoT</Category>

@ -192,4 +192,30 @@ public interface ConfigurationManagementService {
required = true)
PlatformConfiguration configuration);
@GET
@Path("/ui-config")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "get application management UI configuration",
notes = "This will get all UI configuration of application management"
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully got UI config."),
@ApiResponse(
code = 404,
message = "Not Found. There doesn't have an defined UI config." +
"query."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while getting the UI config.",
response = ErrorResponse.class)
})
Response getUiConfig();
}

@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.core.ui.config.UIConfiguration;
import org.wso2.carbon.device.mgt.core.ui.config.UIConfigurationManager;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.api.ConfigurationManagementService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
@ -31,6 +33,7 @@ import org.wso2.carbon.device.mgt.common.MDMAppConstants;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PUT;
@ -91,4 +94,23 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
}
}
@GET
@Override
@Consumes("application/json")
@Path("/ui-config")
public Response getUiConfig() {
UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance();
if (uiConfigurationManager == null) {
String msg = "IoTS UI configuration manager is not initialized.";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig();
if (uiConfiguration == null) {
String msg = "IoTS UI configuration is not defined.";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
return Response.status(Response.Status.OK).entity(uiConfiguration).build();
}
}

@ -48,7 +48,8 @@
<context-param>
<param-name>nonSecuredEndPoints</param-name>
<param-value>
/api/device-mgt/v1.0/users/validate
/api/device-mgt/v1.0/users/validate,
/api/device-mgt/v1.0/configuration/ui-config
</param-value>
</context-param>

@ -27,6 +27,7 @@ public final class DeviceManagementConstants {
public static final String DB_CHECK_QUERY = "SELECT * FROM DM_DEVICE";
public static final String SECURE_VAULT_NS = "http://org.wso2.securevault/configuration";
public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml";
public static final String UI_CONFIG_XML_NAME = "mdm-ui-config.xml";
}
public static final class SecureValueProperties {

@ -18,9 +18,6 @@
package org.wso2.carbon.device.mgt.core.config;
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
import org.wso2.carbon.device.mgt.core.config.task.TaskConfiguration;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@ -66,6 +66,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceIm
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.ui.config.UIConfigurationManager;
import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
@ -161,6 +162,7 @@ public class DeviceManagementServiceComponent {
}
/* Initializing Device Management Configuration */
DeviceConfigurationManager.getInstance().initConfig();
UIConfigurationManager.getInstance().initConfig();
DeviceManagementConfig config =
DeviceConfigurationManager.getInstance().getDeviceManagementConfig();

@ -23,8 +23,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Count;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.PaginationRequest;

@ -0,0 +1,47 @@
/* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.ui.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.List;
public class AppRegistration {
private List<String> tags;
private boolean isAllowToAllDomains;
@XmlElementWrapper(name = "Tags")
@XmlElement(name = "Tag")
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
@XmlElement(name = "AllowToAllDomains")
public boolean isAllowToAllDomains() {
return isAllowToAllDomains;
}
public void setAllowToAllDomains(boolean allowToAllDomains) {
isAllowToAllDomains = allowToAllDomains;
}
}

@ -1,6 +1,7 @@
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* 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
@ -14,18 +15,22 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.application.mgt.common.config;
package org.wso2.carbon.device.mgt.core.ui.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* Represents the Application Management Configuration.
*/
@XmlRootElement(name = "UIConfiguration")
public class UIConfiguration {
private AppRegistration appRegistration;
private List<String> scopes;
private boolean isSsoEnable;
private ErrorCallback errorCallback;
@XmlElement(name = "AppRegistration", required=true)
public AppRegistration getAppRegistration() {
@ -54,9 +59,4 @@ public class UIConfiguration {
public void setSsoEnable(boolean ssoEnable) {
isSsoEnable = ssoEnable;
}
@XmlElement(name = "ErrorCallback", required=true)
public ErrorCallback getErrorCallback() { return errorCallback; }
public void setErrorCallback(ErrorCallback errorCallback) { this.errorCallback = errorCallback; }
}

@ -0,0 +1,79 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.ui.config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
/**
* Class responsible for the UI configuration initialization.
*/
public class UIConfigurationManager {
private static final Log log = LogFactory.getLog(UIConfigurationManager.class);
private UIConfiguration currentUIConfiguration;
private static UIConfigurationManager uiConfigurationManager;
private static final String UI_CONFIG_PATH = CarbonUtils.getCarbonConfigDirPath() + File.separator
+ DeviceManagementConstants.DataSourceProperties.UI_CONFIG_XML_NAME;
public static UIConfigurationManager getInstance() {
if (uiConfigurationManager == null) {
synchronized (UIConfigurationManager.class) {
if (uiConfigurationManager == null) {
uiConfigurationManager = new UIConfigurationManager();
}
}
}
return uiConfigurationManager;
}
public synchronized void initConfig(String configLocation) throws DeviceManagementException {
try {
File uiConfig = new File(configLocation);
Document doc = DeviceManagerUtil.convertToDocument(uiConfig);
/* Un-marshaling UI configuration */
JAXBContext cdmContext = JAXBContext.newInstance(UIConfiguration.class);
Unmarshaller unmarshaller = cdmContext.createUnmarshaller();
this.currentUIConfiguration = (UIConfiguration) unmarshaller.unmarshal(doc);
} catch (JAXBException e) {
String msg = "Error occurred while initializing UI config";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
}
public void initConfig() throws DeviceManagementException {
this.initConfig(UI_CONFIG_PATH);
}
public UIConfiguration getUIConfig() {
return currentUIConfiguration;
}
}

@ -57,7 +57,6 @@ import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
import org.wso2.carbon.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;

@ -221,16 +221,16 @@ public class LoginHandler extends HttpServlet {
* Define username and password static parameters.
*/
private static void validateLoginRequest(HttpServletRequest req) throws LoginException {
String gatewayCarbonPort = System.getProperty("iot.gateway.carbon.https.port");
String gatewayCarbonPort = System.getProperty("iot.core.https.port");
if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
gatewayCarbonPort = System.getProperty("iot.gateway.carbon.http.port");
gatewayCarbonPort = System.getProperty("iot.core.http.port");
}
username = req.getParameter("username");
password = req.getParameter("password");
gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host")
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + req.getServerName() + HandlerConstants.COLON
+ gatewayCarbonPort + HandlerConstants.UI_CONFIG_ENDPOINT;
uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + gatewayCarbonPort + HandlerConstants.UI_CONFIG_ENDPOINT;
if (username == null || password == null) {
String msg = "Invalid login request. Username or Password is not received for login request.";
log.error(msg);

@ -21,7 +21,7 @@ package io.entgra.ui.request.interceptor.util;
public class HandlerConstants {
public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher";
public static final String APP_REG_ENDPOINT = "/api-application-registration/register";
public static final String UI_CONFIG_ENDPOINT = "/api/application-mgt/v1.0/config/ui-config";
public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt/v1.0/configuration/ui-config";
public static final String TOKEN_ENDPOINT = "/token";
public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect";
public static final String LOGIN_PAGE = "/login";

@ -132,151 +132,6 @@
</LifecycleState>
</LifecycleStates>
<UIConfigs>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>
<Tag>device_management</Tag>
<Tag>subscription_management</Tag>
<Tag>review_management</Tag>
</Tags>
<AllowToAllDomains>true</AllowToAllDomains>
</AppRegistration>
<Scopes>
<Scope>perm:app:review:view</Scope>
<Scope>perm:app:review:update</Scope>
<Scope>perm:app:publisher:view</Scope>
<Scope>perm:app:publisher:update</Scope>
<Scope>perm:app:store:view</Scope>
<Scope>perm:app:subscription:install</Scope>
<Scope>perm:app:subscription:uninstall</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:review:view</Scope>
<Scope>perm:admin:app:publisher:update</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:subscription:view</Scope>
<Scope>perm:device-types:types</Scope>
<Scope>perm:enterprise:modify</Scope>
<Scope>perm:enterprise:view</Scope>
<Scope>perm:android-work:customer</Scope>
<Scope>perm:android-work:admin</Scope>
<Scope>perm:application-command:modify</Scope>
<Scope>perm:sign-csr</Scope>
<Scope>perm:admin:devices:view</Scope>
<Scope>perm:admin:topics:view</Scope>
<Scope>perm:roles:add</Scope>
<Scope>perm:roles:add-users</Scope>
<Scope>perm:roles:update</Scope>
<Scope>perm:roles:permissions</Scope>
<Scope>perm:roles:details</Scope>
<Scope>perm:roles:view</Scope>
<Scope>perm:roles:create-combined-role</Scope>
<Scope>perm:roles:delete</Scope>
<Scope>perm:dashboard:vulnerabilities</Scope>
<Scope>perm:dashboard:non-compliant-count</Scope>
<Scope>perm:dashboard:non-compliant</Scope>
<Scope>perm:dashboard:by-groups</Scope>
<Scope>perm:dashboard:device-counts</Scope>
<Scope>perm:dashboard:feature-non-compliant</Scope>
<Scope>perm:dashboard:count-overview</Scope>
<Scope>perm:dashboard:filtered-count</Scope>
<Scope>perm:dashboard:details</Scope>
<Scope>perm:get-activity</Scope>
<Scope>perm:devices:delete</Scope>
<Scope>perm:devices:applications</Scope>
<Scope>perm:devices:effective-policy</Scope>
<Scope>perm:devices:compliance-data</Scope>
<Scope>perm:devices:features</Scope>
<Scope>perm:devices:operations</Scope>
<Scope>perm:devices:search</Scope>
<Scope>perm:devices:details</Scope>
<Scope>perm:devices:update</Scope>
<Scope>perm:devices:view</Scope>
<Scope>perm:view-configuration</Scope>
<Scope>perm:manage-configuration</Scope>
<Scope>perm:policies:remove</Scope>
<Scope>perm:policies:priorities</Scope>
<Scope>perm:policies:deactivate</Scope>
<Scope>perm:policies:get-policy-details</Scope>
<Scope>perm:policies:manage</Scope>
<Scope>perm:policies:activate</Scope>
<Scope>perm:policies:update</Scope>
<Scope>perm:policies:changes</Scope>
<Scope>perm:policies:get-details</Scope>
<Scope>perm:users:add</Scope>
<Scope>perm:users:details</Scope>
<Scope>perm:users:count</Scope>
<Scope>perm:users:delete</Scope>
<Scope>perm:users:roles</Scope>
<Scope>perm:users:user-details</Scope>
<Scope>perm:users:credentials</Scope>
<Scope>perm:users:search</Scope>
<Scope>perm:users:is-exist</Scope>
<Scope>perm:users:update</Scope>
<Scope>perm:users:send-invitation</Scope>
<Scope>perm:admin-users:view</Scope>
<Scope>perm:admin:devices:update-enrollment</Scope>
<Scope>perm:groups:devices</Scope>
<Scope>perm:groups:update</Scope>
<Scope>perm:groups:add</Scope>
<Scope>perm:groups:device</Scope>
<Scope>perm:groups:devices-count</Scope>
<Scope>perm:groups:remove</Scope>
<Scope>perm:groups:groups</Scope>
<Scope>perm:groups:groups-view</Scope>
<Scope>perm:groups:share</Scope>
<Scope>perm:groups:count</Scope>
<Scope>perm:groups:roles</Scope>
<Scope>perm:groups:devices-remove</Scope>
<Scope>perm:groups:devices-add</Scope>
<Scope>perm:groups:assign</Scope>
<Scope>perm:device-types:configs</Scope>
<Scope>perm:device-types:features</Scope>
<Scope>perm:device-types:types</Scope>
<Scope>perm:applications:install</Scope>
<Scope>perm:applications:uninstall</Scope>
<Scope>perm:admin-groups:count</Scope>
<Scope>perm:admin-groups:view</Scope>
<Scope>perm:notifications:mark-checked</Scope>
<Scope>perm:notifications:view</Scope>
<Scope>perm:admin:certificates:delete</Scope>
<Scope>perm:admin:certificates:details</Scope>
<Scope>perm:admin:certificates:view</Scope>
<Scope>perm:admin:certificates:add</Scope>
<Scope>perm:admin:certificates:verify</Scope>
<Scope>perm:admin</Scope>
<Scope>perm:devicetype:deployment</Scope>
<Scope>perm:device-types:events</Scope>
<Scope>perm:device-types:events:view</Scope>
<Scope>perm:admin:device-type</Scope>
<Scope>perm:admin:device-type:view</Scope>
<Scope>perm:admin:device-type:configs</Scope>
<Scope>perm:device:enroll</Scope>
<Scope>perm:geo-service:analytics-view</Scope>
<Scope>perm:geo-service:alerts-manage</Scope>
<Scope>appm:read</Scope>
<Scope>perm:devices:permanent-delete</Scope>
<Scope>perm:android:manage-configuration</Scope>
<Scope>perm:android:view-configuration</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>app-mgt</Issuer>
</SSOConfiguration>
<ErrorCallback>
<BadRequest>/pages/error/client-errors/400</BadRequest>
<Unauthorized>/pages/error/client-errors/401</Unauthorized>
<Forbidden>/pages/error/client-errors/403</Forbidden>
<NotFound>/pages/error/client-errors/404</NotFound>
<MethodNotAllowed>/pages/error/client-errors/405</MethodNotAllowed>
<NotAcceptable>/pages/error/client-errors/406</NotAcceptable>
<UnsupportedMediaType>/pages/error/client-errors/415</UnsupportedMediaType>
<InternalServerError>/pages/error/server-errors/500</InternalServerError>
<DefaultPage>/pages/error/default</DefaultPage>
</ErrorCallback>
</UIConfigs>
<AppCategories>
<Category>EMM</Category>
<Category>IoT</Category>

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright (c) 2020, 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.
-->
<UIConfiguration>
<EnableOAuth>true</EnableOAuth>
<EnableSSO>false</EnableSSO>
<AppRegistration>
<Tags>
<Tag>application_management</Tag>
<Tag>device_management</Tag>
<Tag>subscription_management</Tag>
<Tag>review_management</Tag>
</Tags>
<AllowToAllDomains>true</AllowToAllDomains>
</AppRegistration>
<Scopes>
<Scope>perm:app:review:view</Scope>
<Scope>perm:app:review:update</Scope>
<Scope>perm:app:publisher:view</Scope>
<Scope>perm:app:publisher:update</Scope>
<Scope>perm:app:store:view</Scope>
<Scope>perm:app:subscription:install</Scope>
<Scope>perm:app:subscription:uninstall</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:review:view</Scope>
<Scope>perm:admin:app:publisher:update</Scope>
<Scope>perm:admin:app:review:update</Scope>
<Scope>perm:admin:app:subscription:view</Scope>
<Scope>perm:device-types:types</Scope>
<Scope>perm:enterprise:modify</Scope>
<Scope>perm:enterprise:view</Scope>
<Scope>perm:android-work:customer</Scope>
<Scope>perm:android-work:admin</Scope>
<Scope>perm:application-command:modify</Scope>
<Scope>perm:sign-csr</Scope>
<Scope>perm:admin:devices:view</Scope>
<Scope>perm:admin:topics:view</Scope>
<Scope>perm:roles:add</Scope>
<Scope>perm:roles:add-users</Scope>
<Scope>perm:roles:update</Scope>
<Scope>perm:roles:permissions</Scope>
<Scope>perm:roles:details</Scope>
<Scope>perm:roles:view</Scope>
<Scope>perm:roles:create-combined-role</Scope>
<Scope>perm:roles:delete</Scope>
<Scope>perm:dashboard:vulnerabilities</Scope>
<Scope>perm:dashboard:non-compliant-count</Scope>
<Scope>perm:dashboard:non-compliant</Scope>
<Scope>perm:dashboard:by-groups</Scope>
<Scope>perm:dashboard:device-counts</Scope>
<Scope>perm:dashboard:feature-non-compliant</Scope>
<Scope>perm:dashboard:count-overview</Scope>
<Scope>perm:dashboard:filtered-count</Scope>
<Scope>perm:dashboard:details</Scope>
<Scope>perm:get-activity</Scope>
<Scope>perm:devices:delete</Scope>
<Scope>perm:devices:applications</Scope>
<Scope>perm:devices:effective-policy</Scope>
<Scope>perm:devices:compliance-data</Scope>
<Scope>perm:devices:features</Scope>
<Scope>perm:devices:operations</Scope>
<Scope>perm:devices:search</Scope>
<Scope>perm:devices:details</Scope>
<Scope>perm:devices:update</Scope>
<Scope>perm:devices:view</Scope>
<Scope>perm:view-configuration</Scope>
<Scope>perm:manage-configuration</Scope>
<Scope>perm:policies:remove</Scope>
<Scope>perm:policies:priorities</Scope>
<Scope>perm:policies:deactivate</Scope>
<Scope>perm:policies:get-policy-details</Scope>
<Scope>perm:policies:manage</Scope>
<Scope>perm:policies:activate</Scope>
<Scope>perm:policies:update</Scope>
<Scope>perm:policies:changes</Scope>
<Scope>perm:policies:get-details</Scope>
<Scope>perm:users:add</Scope>
<Scope>perm:users:details</Scope>
<Scope>perm:users:count</Scope>
<Scope>perm:users:delete</Scope>
<Scope>perm:users:roles</Scope>
<Scope>perm:users:user-details</Scope>
<Scope>perm:users:credentials</Scope>
<Scope>perm:users:search</Scope>
<Scope>perm:users:is-exist</Scope>
<Scope>perm:users:update</Scope>
<Scope>perm:users:send-invitation</Scope>
<Scope>perm:admin-users:view</Scope>
<Scope>perm:admin:devices:update-enrollment</Scope>
<Scope>perm:groups:devices</Scope>
<Scope>perm:groups:update</Scope>
<Scope>perm:groups:add</Scope>
<Scope>perm:groups:device</Scope>
<Scope>perm:groups:devices-count</Scope>
<Scope>perm:groups:remove</Scope>
<Scope>perm:groups:groups</Scope>
<Scope>perm:groups:groups-view</Scope>
<Scope>perm:groups:share</Scope>
<Scope>perm:groups:count</Scope>
<Scope>perm:groups:roles</Scope>
<Scope>perm:groups:devices-remove</Scope>
<Scope>perm:groups:devices-add</Scope>
<Scope>perm:groups:assign</Scope>
<Scope>perm:device-types:configs</Scope>
<Scope>perm:device-types:features</Scope>
<Scope>perm:device-types:types</Scope>
<Scope>perm:applications:install</Scope>
<Scope>perm:applications:uninstall</Scope>
<Scope>perm:admin-groups:count</Scope>
<Scope>perm:admin-groups:view</Scope>
<Scope>perm:notifications:mark-checked</Scope>
<Scope>perm:notifications:view</Scope>
<Scope>perm:admin:certificates:delete</Scope>
<Scope>perm:admin:certificates:details</Scope>
<Scope>perm:admin:certificates:view</Scope>
<Scope>perm:admin:certificates:add</Scope>
<Scope>perm:admin:certificates:verify</Scope>
<Scope>perm:admin</Scope>
<Scope>perm:devicetype:deployment</Scope>
<Scope>perm:device-types:events</Scope>
<Scope>perm:device-types:events:view</Scope>
<Scope>perm:admin:device-type</Scope>
<Scope>perm:admin:device-type:view</Scope>
<Scope>perm:admin:device-type:configs</Scope>
<Scope>perm:device:enroll</Scope>
<Scope>perm:geo-service:analytics-view</Scope>
<Scope>perm:geo-service:alerts-manage</Scope>
<Scope>appm:read</Scope>
<Scope>perm:devices:permanent-delete</Scope>
<Scope>perm:android:manage-configuration</Scope>
<Scope>perm:android:view-configuration</Scope>
</Scopes>
<SSOConfiguration>
<Issuer>device-mgt</Issuer>
</SSOConfiguration>
</UIConfiguration>

@ -1,5 +1,6 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/mdm-ui-config.xml,target:${installFolder}/../../conf/mdm-ui-config.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/conf/remote-appmanager-config.xml,target:${installFolder}/../../conf/etc/remote-appmanager-config.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.basics_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\

Loading…
Cancel
Save