|
|
@ -28,9 +28,6 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceNotFoundException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceNotFoundException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
|
|
|
|
import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
|
|
|
@ -41,6 +38,7 @@ import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|
|
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
|
|
|
|
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.common.configuration.mgt.PlatformConfiguration;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
|
@ -55,6 +53,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationSubscriber;
|
|
|
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
|
|
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
|
|
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
@ -69,6 +69,7 @@ import org.wso2.carbon.device.mgt.core.dao.EnrollmentDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
|
|
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.DeviceManagementServiceComponent;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
|
|
@ -77,7 +78,9 @@ import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
|
|
|
import org.wso2.carbon.email.sender.core.ContentProviderInfo;
|
|
|
|
import org.wso2.carbon.email.sender.core.ContentProviderInfo;
|
|
|
|
import org.wso2.carbon.email.sender.core.EmailContext;
|
|
|
|
import org.wso2.carbon.email.sender.core.EmailContext;
|
|
|
|
import org.wso2.carbon.email.sender.core.EmailSendingFailedException;
|
|
|
|
import org.wso2.carbon.email.sender.core.EmailSendingFailedException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.email.sender.core.EmailTransportNotConfiguredException;
|
|
|
|
import org.wso2.carbon.email.sender.core.TypedValue;
|
|
|
|
import org.wso2.carbon.email.sender.core.TypedValue;
|
|
|
|
|
|
|
|
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
@ -769,7 +772,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException {
|
|
|
|
public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException,
|
|
|
|
|
|
|
|
ConfigurationManagementException {
|
|
|
|
if (metaInfo == null) {
|
|
|
|
if (metaInfo == null) {
|
|
|
|
String msg = "Received incomplete data to method sendEnrolmentInvitation";
|
|
|
|
String msg = "Received incomplete data to method sendEnrolmentInvitation";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
@ -798,6 +802,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
String msg = "Error occurred while sending enrollment invitation";
|
|
|
|
String msg = "Error occurred while sending enrollment invitation";
|
|
|
|
log.error(msg, ex);
|
|
|
|
log.error(msg, ex);
|
|
|
|
throw new DeviceManagementException(msg, ex);
|
|
|
|
throw new DeviceManagementException(msg, ex);
|
|
|
|
|
|
|
|
} catch (EmailTransportNotConfiguredException ex) {
|
|
|
|
|
|
|
|
String msg = "Mail Server is not configured.";
|
|
|
|
|
|
|
|
throw new ConfigurationManagementException(msg, ex);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
String msg = "Error occurred in setEnrollmentInvitation";
|
|
|
|
String msg = "Error occurred in setEnrollmentInvitation";
|
|
|
|
log.error(msg, ex);
|
|
|
|
log.error(msg, ex);
|
|
|
@ -806,7 +813,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException {
|
|
|
|
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException,
|
|
|
|
|
|
|
|
ConfigurationManagementException {
|
|
|
|
if (metaInfo == null) {
|
|
|
|
if (metaInfo == null) {
|
|
|
|
String msg = "Received incomplete request for sendRegistrationEmail";
|
|
|
|
String msg = "Received incomplete request for sendRegistrationEmail";
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
@ -815,35 +823,41 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Send registration email");
|
|
|
|
log.debug("Send registration email");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
|
|
|
EmailSenderService emailSenderService = DeviceManagementDataHolder.getInstance().getEmailSenderService();
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME,
|
|
|
|
if (emailSenderService != null) {
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("first-name")));
|
|
|
|
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.USERNAME,
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME,
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("username")));
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("first-name")));
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.PASSWORD,
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.USERNAME,
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("password")));
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("username")));
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.DOMAIN,
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.PASSWORD,
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("domain")));
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("password")));
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTPS,
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.DOMAIN,
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl()));
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("domain")));
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP,
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTPS,
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl()));
|
|
|
|
try {
|
|
|
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP,
|
|
|
|
EmailContext ctx =
|
|
|
|
new TypedValue<Class<?>, Object>(String.class, DeviceManagerUtil.getServerBaseHttpUrl()));
|
|
|
|
new EmailContext.EmailContextBuilder(
|
|
|
|
try {
|
|
|
|
new ContentProviderInfo(
|
|
|
|
EmailContext ctx =
|
|
|
|
DeviceManagementConstants.EmailAttributes.USER_REGISTRATION_TEMPLATE,
|
|
|
|
new EmailContext.EmailContextBuilder(
|
|
|
|
params),
|
|
|
|
new ContentProviderInfo(
|
|
|
|
metaInfo.getRecipients()).build();
|
|
|
|
DeviceManagementConstants.EmailAttributes.USER_REGISTRATION_TEMPLATE,
|
|
|
|
DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx);
|
|
|
|
params),
|
|
|
|
} catch (EmailSendingFailedException e) {
|
|
|
|
metaInfo.getRecipients()).build();
|
|
|
|
String msg = "Error occurred while sending user registration notification." + e.getMessage();
|
|
|
|
emailSenderService.sendEmail(ctx);
|
|
|
|
log.error(msg, e);
|
|
|
|
} catch (EmailSendingFailedException e) {
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
String msg = "Error occurred while sending user registration notification." + e.getMessage();
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error(msg, e);
|
|
|
|
String msg = "Error occurred in sendRegistrationEmail";
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
} catch (EmailTransportNotConfiguredException e) {
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
String msg = "Error occurred while sending user registration email." + e.getMessage();
|
|
|
|
|
|
|
|
throw new ConfigurationManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while sending Registration Email.";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new DeviceManagementException(msg, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|