use of org.wso2.carbon.identity.mgt.config.EmailNotificationConfig in project carbon-identity-framework by wso2.
the class AccountCredentialMgtConfigService method saveEmailConfig.
/**
* This method is used to save the Email template configurations which is specific to tenant.
*
* @param emailTemplates - Email templates to be saved.
* @throws IdentityMgtServiceException
*/
public void saveEmailConfig(EmailTemplateDTO[] emailTemplates) throws IdentityMgtServiceException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
EmailNotificationConfig emailConfig = new EmailNotificationConfig();
ConfigBuilder configBuilder = ConfigBuilder.getInstance();
try {
Properties props = EmailConfigTransformer.transform(emailTemplates);
emailConfig.setProperties(props);
configBuilder.saveConfiguration(StorageType.REGISTRY, tenantId, emailConfig);
} catch (Exception e) {
log.error("Error occurred while saving email configuration", e);
throw new IdentityMgtServiceException("Error occurred while saving email configuration");
}
}
use of org.wso2.carbon.identity.mgt.config.EmailNotificationConfig in project carbon-identity-framework by wso2.
the class IdentityMgtServiceComponent method init.
private static void init() {
Registry registry;
IdentityMgtConfig.getInstance(realmService.getBootstrapRealmConfiguration());
recoveryProcessor = new RecoveryProcessor();
try {
registry = IdentityMgtServiceComponent.getRegistryService().getConfigSystemRegistry();
if (!registry.resourceExists(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH)) {
Collection questionCollection = registry.newCollection();
registry.put(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH, questionCollection);
UserIdentityManagementUtil.loadDefaultChallenges();
}
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(UserOperationEventListener.class.getName(), IdentityMgtEventListener.class.getName());
if (identityEventListenerConfig != null) {
if (Boolean.parseBoolean(identityEventListenerConfig.getEnable()) && !registry.resourceExists(IdentityMgtConstants.EMAIL_TEMPLATE_PATH)) {
Config emailConfigFile = ConfigBuilder.getInstance().loadEmailConfigFile();
EmailNotificationConfig emailNotificationConfig = new EmailNotificationConfig();
emailNotificationConfig.setProperties(emailConfigFile.getProperties());
ConfigBuilder.getInstance().saveConfiguration(StorageType.REGISTRY, MultitenantConstants.SUPER_TENANT_ID, emailNotificationConfig);
}
}
} catch (RegistryException e) {
log.error("Error while creating registry collection for org.wso2.carbon.identity.mgt component", e);
} catch (IdentityMgtConfigException e) {
log.error("Error occurred while saving default email templates in registry for super tenant");
}
}
use of org.wso2.carbon.identity.mgt.config.EmailNotificationConfig in project carbon-identity-framework by wso2.
the class TenantManagementListener method onTenantCreate.
/**
* Add the default challenge Question Set when a new tenant is registered.
*
* @param tenantInfo Information about the newly created tenant
*/
@Override
public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException {
try {
PrivilegedCarbonContext.getThreadLocalCarbonContext().startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantInfo.getTenantDomain());
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantInfo.getTenantId());
UserIdentityManagementUtil.loadDefaultChallenges();
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(UserOperationEventListener.class.getName(), IdentityMgtEventListener.class.getName());
if (identityEventListenerConfig != null) {
if (Boolean.parseBoolean(identityEventListenerConfig.getEnable())) {
Config emailConfigFile = ConfigBuilder.getInstance().loadEmailConfigFile();
EmailNotificationConfig emailNotificationConfig = new EmailNotificationConfig();
emailNotificationConfig.setProperties(emailConfigFile.getProperties());
ConfigBuilder.getInstance().saveConfiguration(StorageType.REGISTRY, tenantInfo.getTenantId(), emailNotificationConfig);
}
}
} catch (IdentityMgtConfigException e) {
log.error("Error occurred while saving default email templates in registry for tenant: " + tenantInfo.getTenantDomain());
} finally {
PrivilegedCarbonContext.getThreadLocalCarbonContext().endTenantFlow();
}
}
Aggregations