Search in sources :

Example 1 with EmailNotificationConfig

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");
    }
}
Also used : EmailNotificationConfig(org.wso2.carbon.identity.mgt.config.EmailNotificationConfig) IdentityMgtServiceException(org.wso2.carbon.identity.mgt.IdentityMgtServiceException) ConfigBuilder(org.wso2.carbon.identity.mgt.config.ConfigBuilder) Properties(java.util.Properties) IdentityMgtServiceException(org.wso2.carbon.identity.mgt.IdentityMgtServiceException)

Example 2 with EmailNotificationConfig

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");
    }
}
Also used : IdentityMgtConfigException(org.wso2.carbon.identity.mgt.IdentityMgtConfigException) UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) EmailNotificationConfig(org.wso2.carbon.identity.mgt.config.EmailNotificationConfig) IdentityMgtConfig(org.wso2.carbon.identity.mgt.IdentityMgtConfig) EmailNotificationConfig(org.wso2.carbon.identity.mgt.config.EmailNotificationConfig) Config(org.wso2.carbon.identity.mgt.config.Config) IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) IdentityMgtEventListener(org.wso2.carbon.identity.mgt.IdentityMgtEventListener) RecoveryProcessor(org.wso2.carbon.identity.mgt.RecoveryProcessor) Collection(org.wso2.carbon.registry.core.Collection) IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) Registry(org.wso2.carbon.registry.core.Registry) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Example 3 with EmailNotificationConfig

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();
    }
}
Also used : IdentityMgtConfigException(org.wso2.carbon.identity.mgt.IdentityMgtConfigException) UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) EmailNotificationConfig(org.wso2.carbon.identity.mgt.config.EmailNotificationConfig) EmailNotificationConfig(org.wso2.carbon.identity.mgt.config.EmailNotificationConfig) Config(org.wso2.carbon.identity.mgt.config.Config) IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig) IdentityMgtEventListener(org.wso2.carbon.identity.mgt.IdentityMgtEventListener) IdentityEventListenerConfig(org.wso2.carbon.identity.core.model.IdentityEventListenerConfig)

Aggregations

EmailNotificationConfig (org.wso2.carbon.identity.mgt.config.EmailNotificationConfig)3 IdentityEventListenerConfig (org.wso2.carbon.identity.core.model.IdentityEventListenerConfig)2 IdentityMgtConfigException (org.wso2.carbon.identity.mgt.IdentityMgtConfigException)2 IdentityMgtEventListener (org.wso2.carbon.identity.mgt.IdentityMgtEventListener)2 Config (org.wso2.carbon.identity.mgt.config.Config)2 UserOperationEventListener (org.wso2.carbon.user.core.listener.UserOperationEventListener)2 Properties (java.util.Properties)1 IdentityMgtConfig (org.wso2.carbon.identity.mgt.IdentityMgtConfig)1 IdentityMgtServiceException (org.wso2.carbon.identity.mgt.IdentityMgtServiceException)1 RecoveryProcessor (org.wso2.carbon.identity.mgt.RecoveryProcessor)1 ConfigBuilder (org.wso2.carbon.identity.mgt.config.ConfigBuilder)1 Collection (org.wso2.carbon.registry.core.Collection)1 Registry (org.wso2.carbon.registry.core.Registry)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1