diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 6b593e85c6..f3d878393f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo.Status; import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.util.HashMap; import java.util.List; @@ -163,6 +164,14 @@ public interface DeviceDAO { */ int getDeviceCount(int tenantId) throws DeviceManagementDAOException; + /** + * This method is used to retrieve the available device types of a given tenant. + * + * @return returns list of device types. + * @throws DeviceManagementDAOException + */ + List getDeviceTypes() throws DeviceManagementDAOException; + /** * This method is used to retrieve devices of a given device name. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GenericDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GenericDeviceDAOImpl.java index f24b3c761e..4df319c577 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GenericDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/GenericDeviceDAOImpl.java @@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.sql.Connection; import java.sql.PreparedStatement; @@ -120,7 +121,33 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { return result; } - private Connection getConnection() throws SQLException { + @Override + public List getDeviceTypes() + throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List deviceTypes; + try { + conn = this.getConnection(); + String sql = "SELECT t.ID, t.NAME " + + "FROM DM_DEVICE_TYPE t"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + deviceTypes = new ArrayList<>(); + while (rs.next()) { + DeviceType deviceType = DeviceManagementDAOUtil.loadDeviceType(rs); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while listing device types.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return deviceTypes; + } + + private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/OracleDeviceDAOImpl.java index 2524945f59..92d790fe60 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/OracleDeviceDAOImpl.java @@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.sql.Connection; import java.sql.PreparedStatement; @@ -116,7 +117,31 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { return result; } - private Connection getConnection() throws SQLException { + @Override public List getDeviceTypes() throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List deviceTypes; + try { + conn = this.getConnection(); + String sql = "SELECT t.ID, t.NAME " + + "FROM DM_DEVICE_TYPE t"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + deviceTypes = new ArrayList<>(); + while (rs.next()) { + DeviceType deviceType = DeviceManagementDAOUtil.loadDeviceType(rs); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while listing device types.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return deviceTypes; + } + + private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/PostgreSQLDeviceDAOImpl.java index 5a65c807c2..26b0d34d9d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/PostgreSQLDeviceDAOImpl.java @@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.sql.Connection; import java.sql.PreparedStatement; @@ -116,7 +117,31 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { return result; } - private Connection getConnection() throws SQLException { + @Override public List getDeviceTypes() throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List deviceTypes; + try { + conn = this.getConnection(); + String sql = "SELECT t.ID, t.NAME " + + "FROM DM_DEVICE_TYPE t"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + deviceTypes = new ArrayList<>(); + while (rs.next()) { + DeviceType deviceType = DeviceManagementDAOUtil.loadDeviceType(rs); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while listing device types.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return deviceTypes; + } + + private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/SQLServerDeviceDAOImpl.java index 224c7ee280..21c3ef8848 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/SQLServerDeviceDAOImpl.java @@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.sql.Connection; import java.sql.PreparedStatement; @@ -116,7 +117,32 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { return result; } - private Connection getConnection() throws SQLException { + @Override + public List getDeviceTypes() throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List deviceTypes; + try { + conn = this.getConnection(); + String sql = "SELECT t.ID, t.NAME " + + "FROM DM_DEVICE_TYPE t"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + deviceTypes = new ArrayList<>(); + while (rs.next()) { + DeviceType deviceType = DeviceManagementDAOUtil.loadDeviceType(rs); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while listing device types.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return deviceTypes; + } + + private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 201265f4d5..c7bc50eb2b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -23,6 +23,7 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -153,4 +154,11 @@ public final class DeviceManagementDAOUtil { device.setEnrolmentInfo(loadEnrolment(rs)); return device; } + + public static DeviceType loadDeviceType(ResultSet rs) throws SQLException { + DeviceType deviceType = new DeviceType(); + deviceType.setId(rs.getInt("ID")); + deviceType.setName(rs.getString("NAME")); + return deviceType; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index aead0bda52..5f0677756a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -24,6 +24,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; + import java.util.List; /** @@ -127,6 +129,8 @@ public interface DeviceManagementProviderService extends OperationManager { Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException; + List getAvailableDeviceTypes() throws DeviceManagementException; + boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException; boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index f28c7f8bcf..054e4c5e3b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -617,7 +617,23 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return device; } - @Override + @Override + public List getAvailableDeviceTypes() throws DeviceManagementException { + List deviceTypes; + try { + DeviceManagementDAOFactory.openConnection(); + deviceTypes = deviceDAO.getDeviceTypes(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while obtaining the device types.", e); + } catch (SQLException e) { + throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + return deviceTypes; + } + + @Override public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { DeviceManager deviceManager = this.getDeviceManager(deviceId.getType()); if (deviceManager == null) { diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java index 0679b5f1e2..859a0d8c55 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.registration/src/main/java/org/wso2/carbon/dynamic/client/registration/impl/DynamicClientRegistrationServiceImpl.java @@ -123,7 +123,7 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist boolean isSaaSApp = profile.isSaasApp(); String audience = profile.getAudience(); String assertionConsumerURL = profile.getAssertionConsumerURL(); - String recepientValidationURL = profile.getRecepientValidationURL(); + String recipientValidationURL = profile.getRecepientValidationURL(); if (userId == null || userId.isEmpty()) { return null; @@ -223,7 +223,7 @@ public class DynamicClientRegistrationServiceImpl implements DynamicClientRegist samlssoServiceProviderDTO.setDoSignResponse(true); samlssoServiceProviderDTO.setRequestedAudiences(new String[] { audience }); samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl(assertionConsumerURL); - samlssoServiceProviderDTO.setRequestedRecipients(new String[] {recepientValidationURL}); + samlssoServiceProviderDTO.setRequestedRecipients(new String[] {recipientValidationURL}); samlssoServiceProviderDTO.setDoSignAssertions(true); diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java index fbb6023251..14e2ca00b6 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/DynamicClientWebAppRegistrationManager.java @@ -117,7 +117,7 @@ public class DynamicClientWebAppRegistrationManager { } public void initiateDynamicClientRegistration() { - String requiredDynamicClientRegistration, webAppName; + String requiredDynamicClientRegistration, webAppName, serviceProviderName; ServletContext servletContext; RegistrationProfile registrationProfile; OAuthAppDetails oAuthAppDetails; @@ -131,15 +131,15 @@ public class DynamicClientWebAppRegistrationManager { while (enumeration.hasMoreElements()) { oAuthAppDetails = new OAuthAppDetails(); webAppName = (String) enumeration.nextElement(); + serviceProviderName = DynamicClientWebAppRegistrationUtil.getUserName() + "_" + webAppName; servletContext = DynamicClientWebAppRegistrationManager.webAppContexts.get(webAppName); requiredDynamicClientRegistration = servletContext.getInitParameter( DynamicClientWebAppRegistrationConstants.DYNAMIC_CLIENT_REQUIRED_FLAG); //Java web-app section - if ((requiredDynamicClientRegistration != null) && (Boolean. - parseBoolean( - requiredDynamicClientRegistration))) { + if ((requiredDynamicClientRegistration != null) && (Boolean.parseBoolean( + requiredDynamicClientRegistration))) { //Check whether this is an already registered application - if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(webAppName)) { + if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) { //Construct the RegistrationProfile registrationProfile = DynamicClientWebAppRegistrationUtil. constructRegistrationProfile(servletContext, webAppName); @@ -155,7 +155,7 @@ public class DynamicClientWebAppRegistrationManager { JaggeryOAuthConfigurationSettings jaggeryOAuthConfigurationSettings = DynamicClientWebAppRegistrationUtil.getJaggeryAppOAuthSettings(servletContext); if (jaggeryOAuthConfigurationSettings.isRequireDynamicClientRegistration()) { - if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(webAppName)) { + if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) { registrationProfile = DynamicClientWebAppRegistrationUtil. constructRegistrationProfile(jaggeryOAuthConfigurationSettings, webAppName); diff --git a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java index 9540d0e9e8..034e1e3f8c 100644 --- a/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java +++ b/components/identity-extensions/dynamic-client-registration/org.wso2.carbon.dynamic.client.web.app.registration/src/main/java/org/wso2/carbon/dynamic/client/web/app/registration/util/DynamicClientWebAppRegistrationUtil.java @@ -116,7 +116,7 @@ public class DynamicClientWebAppRegistrationUtil { resource.setContent(writer.toString()); resource.setMediaType(DynamicClientWebAppRegistrationConstants.ContentTypes.MEDIA_TYPE_XML); String resourcePath = DynamicClientWebAppRegistrationConstants.OAUTH_APP_DATA_REGISTRY_PATH + "/" + - oAuthAppDetails.getWebAppName(); + oAuthAppDetails.getClientName(); status = DynamicClientWebAppRegistrationUtil.putRegistryResource(resourcePath, resource); } catch (RegistryException e) { throw new DynamicClientRegistrationException( diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index 75350b3fdc..f6d14166a4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -62,6 +62,8 @@ public class MonitoringManagerImpl implements MonitoringManager { private static final Log log = LogFactory.getLog(MonitoringManagerImpl.class); private static final String OPERATION_MONITOR = "MONITOR"; + private static final String OPERATION_INFO = "DEVICE_INFO"; + private static final String OPERATION_APP_LIST = "APPLICATION_LIST"; public MonitoringManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -378,9 +380,19 @@ public class MonitoringManagerImpl implements MonitoringManager { monitoringOperation.setEnabled(true); monitoringOperation.setType(Operation.Type.COMMAND); monitoringOperation.setCode(OPERATION_MONITOR); + CommandOperation infoOperation = new CommandOperation(); + infoOperation.setEnabled(true); + infoOperation.setType(Operation.Type.COMMAND); + infoOperation.setCode(OPERATION_INFO); + CommandOperation appListOperation = new CommandOperation(); + appListOperation.setEnabled(true); + appListOperation.setType(Operation.Type.COMMAND); + appListOperation.setCode(OPERATION_APP_LIST); DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl(); service.addOperation(monitoringOperation, deviceIdentifiers); + service.addOperation(infoOperation, deviceIdentifiers); + service.addOperation(appListOperation, deviceIdentifiers); } private List getDeviceIdentifiersFromDevices(List devices) { diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java index da7734a046..abe4eac0c4 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java @@ -102,7 +102,8 @@ public class OAuthAuthenticator implements WebappAuthenticator { resourceContextParam.setValue(requestUri + ":" + requestMethod); OAuth2TokenValidationRequestDTO.TokenValidationContextParam[] - tokenValidationContextParams = new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1]; + tokenValidationContextParams = + new OAuth2TokenValidationRequestDTO.TokenValidationContextParam[1]; tokenValidationContextParams[0] = resourceContextParam; dto.setContext(tokenValidationContextParams); @@ -110,14 +111,9 @@ public class OAuthAuthenticator implements WebappAuthenticator { AuthenticatorFrameworkDataHolder.getInstance().getoAuth2TokenValidationService().validate(dto); if (oAuth2TokenValidationResponseDTO.isValid()) { String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser(); - // try { - authenticationInfo.setUsername(username); - authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username)); - authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username)); -// } catch (AuthenticationException e) { -// throw new AuthenticationException( -// "Error occurred while retrieving the tenant ID of user '" + username + "'", e); -// } + authenticationInfo.setUsername(username); + authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username)); + authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username)); if (oAuth2TokenValidationResponseDTO.isValid()) { authenticationInfo.setStatus(Status.CONTINUE); } @@ -148,7 +144,7 @@ public class OAuthAuthenticator implements WebappAuthenticator { tokenValue = tokenValue.substring(matcher.end()); } } - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Oauth Token : " + tokenValue); } return tokenValue; diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index 1959c2f241..10e15533ed 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -355,8 +355,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CREATE TABLE IF NOT EXISTS DM_APPLICATION ( ID INTEGER AUTO_INCREMENT NOT NULL, - NAME VARCHAR(50) NOT NULL, - APP_IDENTIFIER VARCHAR(50) NOT NULL, + NAME VARCHAR(150) NOT NULL, + APP_IDENTIFIER VARCHAR(150) NOT NULL, PLATFORM VARCHAR(50) DEFAULT NULL, CATEGORY VARCHAR(50) NULL, VERSION VARCHAR(50) NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index 118895e81c..c61879a5e3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -358,7 +358,7 @@ CREATE TABLE DM_ENROLMENT ( CREATE TABLE DM_APPLICATION ( ID INTEGER IDENTITY NOT NULL, - NAME VARCHAR(50) NOT NULL, + NAME VARCHAR(150) NOT NULL, APP_IDENTIFIER VARCHAR(150) NOT NULL, PLATFORM VARCHAR(50) DEFAULT NULL, CATEGORY VARCHAR(50) NULL, @@ -400,5 +400,3 @@ CREATE TABLE DM_NOTIFICATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql index a2b00a1744..3145b029db 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -352,7 +352,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CREATE TABLE IF NOT EXISTS DM_APPLICATION ( ID INTEGER AUTO_INCREMENT NOT NULL, - NAME VARCHAR(50) NOT NULL, + NAME VARCHAR(150) NOT NULL, APP_IDENTIFIER VARCHAR(150) NOT NULL, PLATFORM VARCHAR(50) DEFAULT NULL, CATEGORY VARCHAR(50) NULL, @@ -398,4 +398,3 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( -- END NOTIFICATION TABLES -- - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index fa522c3dc7..51c6900506 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -551,7 +551,7 @@ END; CREATE TABLE DM_APPLICATION ( ID NUMBER(10) NOT NULL, - NAME VARCHAR2(50) NOT NULL, + NAME VARCHAR2(150) NOT NULL, APP_IDENTIFIER VARCHAR2(150) NOT NULL, PLATFORM VARCHAR2(50) DEFAULT NULL, CATEGORY VARCHAR2(50) NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index d9af353100..b4d2de68bf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -309,7 +309,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CREATE TABLE IF NOT EXISTS DM_APPLICATION ( ID BIGSERIAL NOT NULL PRIMARY KEY, - NAME VARCHAR(50) NOT NULL, + NAME VARCHAR(150) NOT NULL, APP_IDENTIFIER VARCHAR(150) NOT NULL, PLATFORM VARCHAR(50) DEFAULT NULL, CATEGORY VARCHAR(50) NULL,