mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #257 from charithag/master
Fix for https://wso2.org/jira/browse/IOTS-110
This commit is contained in:
commit
4266532638
@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
||||
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
|
||||
import org.wso2.carbon.ntask.core.service.TaskService;
|
||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
@ -36,6 +37,7 @@ import java.util.HashMap;
|
||||
|
||||
public class DeviceManagementDataHolder {
|
||||
|
||||
private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder();
|
||||
private RealmService realmService;
|
||||
private TenantManager tenantManager;
|
||||
private DeviceManagementProviderService deviceManagerProvider;
|
||||
@ -49,12 +51,8 @@ public class DeviceManagementDataHolder {
|
||||
private HashMap<String,Boolean> requireDeviceAuthorization = new HashMap<>();
|
||||
private DeviceAccessAuthorizationService deviceAccessAuthorizationService;
|
||||
private GroupManagementProviderService groupManagementProviderService;
|
||||
|
||||
private TaskService taskService;
|
||||
//private EmailSenderService emailSenderService;
|
||||
|
||||
|
||||
private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder();
|
||||
private EmailSenderService emailSenderService;
|
||||
|
||||
private DeviceManagementDataHolder() {}
|
||||
|
||||
@ -74,6 +72,10 @@ public class DeviceManagementDataHolder {
|
||||
this.setTenantManager(realmService);
|
||||
}
|
||||
|
||||
public TenantManager getTenantManager() {
|
||||
return tenantManager;
|
||||
}
|
||||
|
||||
private void setTenantManager(RealmService realmService) {
|
||||
if (realmService == null) {
|
||||
throw new IllegalStateException("Realm service is not initialized properly");
|
||||
@ -81,10 +83,6 @@ public class DeviceManagementDataHolder {
|
||||
this.tenantManager = realmService.getTenantManager();
|
||||
}
|
||||
|
||||
public TenantManager getTenantManager() {
|
||||
return tenantManager;
|
||||
}
|
||||
|
||||
public DeviceManagementProviderService getDeviceManagementProvider() {
|
||||
return deviceManagerProvider;
|
||||
}
|
||||
@ -189,13 +187,13 @@ public class DeviceManagementDataHolder {
|
||||
public void setTaskService(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
//
|
||||
// public EmailSenderService getEmailSenderService() {
|
||||
// return emailSenderService;
|
||||
// }
|
||||
//
|
||||
// public void setEmailSenderService(EmailSenderService emailSenderService) {
|
||||
// this.emailSenderService = emailSenderService;
|
||||
// }
|
||||
|
||||
public EmailSenderService getEmailSenderService() {
|
||||
return emailSenderService;
|
||||
}
|
||||
|
||||
public void setEmailSenderService(EmailSenderService emailSenderService) {
|
||||
this.emailSenderService = emailSenderService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -54,6 +54,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.util.DeviceManagementSchemaInitializer;
|
||||
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
|
||||
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
@ -100,6 +101,12 @@ import java.util.List;
|
||||
* policy="dynamic"
|
||||
* bind="setConfigurationContextService"
|
||||
* unbind="unsetConfigurationContextService"
|
||||
* @scr.reference name="email.sender.service"
|
||||
* interface="org.wso2.carbon.email.sender.core.service.EmailSenderService"
|
||||
* cardinality="0..1"
|
||||
* policy="dynamic"
|
||||
* bind="setEmailSenderService"
|
||||
* unbind="unsetEmailSenderService"
|
||||
*/
|
||||
public class DeviceManagementServiceComponent {
|
||||
|
||||
@ -360,4 +367,18 @@ public class DeviceManagementServiceComponent {
|
||||
DeviceManagementDataHolder.getInstance().setConfigurationContextService(null);
|
||||
}
|
||||
|
||||
protected void setEmailSenderService(EmailSenderService emailSenderService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Setting Email Sender Service");
|
||||
}
|
||||
DeviceManagementDataHolder.getInstance().setEmailSenderService(emailSenderService);
|
||||
}
|
||||
|
||||
protected void unsetEmailSenderService(EmailSenderService emailSenderService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Un-setting Email Sender Service");
|
||||
}
|
||||
DeviceManagementDataHolder.getInstance().setEmailSenderService(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -47,6 +47,9 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
||||
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||
import org.wso2.carbon.email.sender.core.ContentProviderInfo;
|
||||
import org.wso2.carbon.email.sender.core.EmailContext;
|
||||
import org.wso2.carbon.email.sender.core.EmailSendingFailedException;
|
||||
import org.wso2.carbon.email.sender.core.TypedValue;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
|
||||
@ -540,14 +543,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl()));
|
||||
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP,
|
||||
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
|
||||
// try {
|
||||
// EmailContext ctx =
|
||||
// new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-enrollment", params),
|
||||
// metaInfo.getRecipients()).build();
|
||||
//// DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
|
||||
// } catch (EmailSendingFailedException e) {
|
||||
// throw new DeviceManagementException("Error occurred while sending enrollment invitation", e);
|
||||
// }
|
||||
try {
|
||||
EmailContext ctx =
|
||||
new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-enrollment", params),
|
||||
metaInfo.getRecipients()).build();
|
||||
DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
|
||||
} catch (EmailSendingFailedException e) {
|
||||
throw new DeviceManagementException("Error occurred while sending enrollment invitation", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -565,14 +568,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl()));
|
||||
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP,
|
||||
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
|
||||
// try {
|
||||
// EmailContext ctx =
|
||||
// new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-registration", params),
|
||||
// metaInfo.getRecipients()).build();
|
||||
// DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
|
||||
// } catch (EmailSendingFailedException e) {
|
||||
// throw new DeviceManagementException("Error occurred while sending user registration notification", e);
|
||||
// }
|
||||
try {
|
||||
EmailContext ctx =
|
||||
new EmailContext.EmailContextBuilder(new ContentProviderInfo("user-registration", params),
|
||||
metaInfo.getRecipients()).build();
|
||||
DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
|
||||
} catch (EmailSendingFailedException e) {
|
||||
throw new DeviceManagementException("Error occurred while sending user registration notification", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
#*
|
||||
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.
|
||||
*#
|
||||
<EmailConfig>
|
||||
<Subject>You have been invited to enroll your device in WSO2 EMM</Subject>
|
||||
<Body>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>WSO2 Enterprise Mobility Manager</title>
|
||||
</head>
|
||||
<body style="color: #666666; background-color:#cdcdcd; padding: 0px; margin: 0px;">
|
||||
<div style="background-color:#cdcdcd; font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; padding: 20px 0px; margin: 0px;">
|
||||
<div style="width: 86%; max-width: 650px; padding: 2%; background-color: #ffffff; margin: auto; border-radius: 14px;">
|
||||
<div style="background-color: #49c8f5; line-height: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px; padding: 0px 10px 0px 0px;">
|
||||
<div style="display: inline-block; line-height: 0px;">
|
||||
<img src="http://b.content.wso2.com/sites/all/2015-june-theme/navigation/wso2-nav-logo.png"
|
||||
alt="WSO2" style="margin: 0px 20px 0px 25px; width: 100%; max-width: 251px;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #ffffff; line-height: 170%; color: #666666; padding: 20px 25px;">
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px 20px;">
|
||||
Hi $first-name,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
You have been invited to enrol your device in WSO2 Enterprise Mobility Manager.
|
||||
Click <a href="$base-url-https/emm-web-agent/enrollment">here</a> to download the WSO2 EMM client application to begin device
|
||||
enrolment.</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Should you need assistance, please contact your administrator.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 20px 0px 5px;">
|
||||
Regards,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
WSO2 EMM Administrator
|
||||
</p>
|
||||
</div>
|
||||
<div style="background-color: #333333; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding: 0px 20px 0px 0px;"><img
|
||||
src="http://b.content.wso2.com/newsletter/images/wso2-logo-cloud-footer.png" alt="WSO2"
|
||||
style="margin: 15px 0px 15px 25px; width: 100%; max-width: 258px;"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</Body>
|
||||
</EmailConfig>
|
||||
@ -1,82 +0,0 @@
|
||||
#*
|
||||
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.
|
||||
*#
|
||||
<EmailConfig>
|
||||
<Subject>You have successfully been registered in WSO2 EMM</Subject>
|
||||
<Body>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>WSO2 Enterprise Mobility Manager</title>
|
||||
</head>
|
||||
<body style="color: #666666; background-color:#cdcdcd; padding: 0px; margin: 0px;">
|
||||
<div style="background-color:#cdcdcd; font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; padding: 20px 0px; margin: 0px;">
|
||||
<div style="width: 86%; max-width: 650px; padding: 2%; background-color: #ffffff; margin: auto; border-radius: 14px;">
|
||||
<div style="background-color: #49c8f5; line-height: 0px; border-top-left-radius: 10px; border-top-right-radius: 10px; padding: 0px 10px 0px 0px;">
|
||||
<div style="display: inline-block; line-height: 0px;">
|
||||
<img src="http://b.content.wso2.com/sites/all/2015-june-theme/navigation/wso2-nav-logo.png"
|
||||
alt="WSO2" style="margin: 0px 20px 0px 25px; width: 100%; max-width: 251px;"/>
|
||||
</div>
|
||||
</div>
|
||||
<div style="background-color: #ffffff; line-height: 170%; color: #666666; padding: 20px 25px;">
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px 20px;">
|
||||
Hi $first-name,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
You have been registered in WSO2 Enterprise Mobility Manager and invited to enrol your device.
|
||||
Click <a href="$base-url-https/emm-web-agent/enrollment">here</a> to download the WSO2 EMM client application to begin device
|
||||
enrolment.</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Use following credentials to log in to WSO2 EMM client application.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
<b>Username:</b> $username
|
||||
<br/>
|
||||
<b>Password:</b> $password
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
Should you need assistance, please contact your administrator.
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 20px 0px 5px;">
|
||||
Regards,
|
||||
</p>
|
||||
|
||||
<p style="font-size: 1em; font-family: Arial, Helvetica; line-height: 170%; color: #666666; margin: 5px 0px;">
|
||||
WSO2 EMM Administrator
|
||||
</p>
|
||||
</div>
|
||||
<div style="background-color: #333333; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;">
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="padding: 0px 20px 0px 0px;"><img
|
||||
src="http://b.content.wso2.com/newsletter/images/wso2-logo-cloud-footer.png" alt="WSO2"
|
||||
style="margin: 15px 0px 15px 25px; width: 100%; max-width: 258px;"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</Body>
|
||||
</EmailConfig>
|
||||
@ -3,5 +3,4 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${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.server_${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.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\
|
||||
Loading…
Reference in New Issue
Block a user