diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java index 8a5c395699c..1b541d1c90d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java @@ -19,11 +19,14 @@ package org.wso2.carbon.device.mgt.core.email; public final class EmailConstants { - public static final String DOMAIN = "domain-name"; - public static final String USERNAME = "user-name"; - public static final String DOWNLOAD_URL = "download-url"; public static final String ENCODED_SCHEME = "UTF-8"; - public static final String PASSWORD = "password"; public static final String FIRST_NAME = "first-name"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String DOMAIN = "domain-name"; + + public static final String SERVER_BASE_URL_HTTPS = "base-url-https"; + public static final String SERVER_BASE_URL_HTTP = "base-url-http"; + public static final String DOWNLOAD_URL = "download-url"; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailUtil.java new file mode 100644 index 00000000000..f7d8bfb3e6f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailUtil.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, 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.email; + +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; +import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.utils.ConfigurationContextService; +import org.wso2.carbon.utils.NetworkUtils; + +public class EmailUtil { + + public static String getServerBaseHttpsUrl() { + String hostName = "localhost"; + try { + hostName = NetworkUtils.getMgtHostName(); + } catch (Exception ignored) { + } + String mgtConsoleTransport = CarbonUtils.getManagementTransport(); + ConfigurationContextService configContextService = + DeviceManagementDataHolder.getInstance().getConfigurationContextService(); + int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); + int httpsProxyPort = + CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), + mgtConsoleTransport); + if (httpsProxyPort > 0) { + port = httpsProxyPort; + } + return "https://" + hostName + ":" + port; + } + + public static String getServerBaseHttpUrl() { + String hostName = "localhost"; + try { + hostName = NetworkUtils.getMgtHostName(); + } catch (Exception ignored) { + } + ConfigurationContextService configContextService = + DeviceManagementDataHolder.getInstance().getConfigurationContextService(); + int port = CarbonUtils.getTransportPort(configContextService, "http"); + int httpProxyPort = + CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), + "http"); + if (httpProxyPort > 0) { + port = httpProxyPort; + } + return "http://" + hostName + ":" + port; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java index 9df73dc8daf..cad75c266c4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.core.email.sender; -import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.impl.llom.util.AXIOMUtil; import org.apache.axis2.AxisFault; @@ -28,7 +27,6 @@ import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; -import org.apache.axis2.transport.base.BaseConstants; import org.apache.axis2.transport.mail.MailConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; 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 f9ba0b10985..e7c972bb8c9 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 @@ -522,6 +522,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv params.put(EmailConstants.DOWNLOAD_URL, new TypedValue, Object>(String.class, emailConfig.getlBHostPortPrefix() + emailConfig.getEnrollmentContextPath())); + params.put(EmailConstants.SERVER_BASE_URL_HTTPS, + new TypedValue, Object>(String.class, EmailUtil.getServerBaseHttpsUrl())); + params.put(EmailConstants.SERVER_BASE_URL_HTTP, + new TypedValue, Object>(String.class, EmailUtil.getServerBaseHttpUrl())); try { EmailData data = contentProvider.getContent("user-enrollment", params); EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailCtx.getRecipients(), data); @@ -550,6 +554,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv new TypedValue, Object>(String.class, emailCtx.getProperty("password"))); params.put(EmailConstants.DOMAIN, new TypedValue, Object>(String.class, emailCtx.getProperty("domain"))); + params.put(EmailConstants.SERVER_BASE_URL_HTTPS, + new TypedValue, Object>(String.class, EmailUtil.getServerBaseHttpsUrl())); + params.put(EmailConstants.SERVER_BASE_URL_HTTP, + new TypedValue, Object>(String.class, EmailUtil.getServerBaseHttpUrl())); try { EmailData data = contentProvider.getContent("user-registration", params); EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailCtx.getRecipients(), data); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java index fb777f61767..0c5b6707ac6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/license/mgt/registry/RegistryBasedLicenseManager.java @@ -44,7 +44,6 @@ import java.util.Locale; @SuppressWarnings("unused") public class RegistryBasedLicenseManager implements LicenseManager { - private Registry registry; private GenericArtifactManager artifactManager; private static final Log log = LogFactory.getLog(RegistryBasedLicenseManager.class); @@ -54,7 +53,6 @@ public class RegistryBasedLicenseManager implements LicenseManager { throw new IllegalArgumentException("Registry instance retrieved is null. Hence, " + "'Registry based license manager cannot be initialized'"); } - this.registry = registry; try { this.artifactManager = GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager(registry); } catch (LicenseManagementException e) { diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm new file mode 100644 index 00000000000..a02931564e8 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-enrollment.vm @@ -0,0 +1,55 @@ + + You have been invited to enroll your device in WSO2 EMM + + + + WSO2 Enterprise Mobility Manager + + +
+
+
+
+ WSO2 +
+
+
+

+ Hi $first-name, +

+ +

+ You have been invited to enrol your device in WSO2 Enterprise Mobility Manager. + Click here to download the WSO2 EMM client application to begin device + enrolment.

+ +

+ Should you need assistance, please contact your administrator. +

+ +

+ Regards, +

+ +

+ WSO2 EMM Administrator +

+
+
+ + + + +
WSO2
+
+
+
+ + + ]]> + +
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm new file mode 100644 index 00000000000..1147bf12140 --- /dev/null +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/email/templates/user-registration.vm @@ -0,0 +1,65 @@ + + You have successfully been registered in WSO2 EMM + + + + WSO2 Enterprise Mobility Manager + + +
+
+
+
+ WSO2 +
+
+
+

+ Hi $first-name, +

+ +

+ You have been registered in WSO2 Enterprise Mobility Manager and invited to enrol your device. + Click here to download the WSO2 EMM client application to begin device + enrolment.

+ +

+ Use following credentials to log in to WSO2 EMM client application. +

+ +

+ Username: $username +
+ Password: $password +

+ +

+ Should you need assistance, please contact your administrator. +

+ +

+ Regards, +

+ +

+ WSO2 EMM Administrator +

+
+
+ + + + +
WSO2
+
+
+
+ + + ]]> + +
diff --git a/pom.xml b/pom.xml index 0c4b67a5890..45ff421ffd3 100644 --- a/pom.xml +++ b/pom.xml @@ -1225,12 +1225,6 @@ ${version.commons.codec} - - commons-io.wso2 - commons-io - ${version.commons.io} - - commons-lang.wso2 commons-lang