Search in sources :

Example 1 with NotificationConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType in project midpoint by Evolveum.

the class CryptoUtil method checkEncrypted.

private static <T extends ObjectType> void checkEncrypted(PrismPropertyValue<?> pval) {
    Itemable item = pval.getParent();
    if (item == null) {
        return;
    }
    ItemDefinition itemDef = item.getDefinition();
    if (itemDef == null || itemDef.getTypeName() == null) {
        return;
    }
    if (itemDef.getTypeName().equals(ProtectedStringType.COMPLEX_TYPE)) {
        QName propName = item.getElementName();
        PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>) pval;
        ProtectedStringType ps = psPval.getValue();
        if (ps.getClearValue() != null) {
            throw new IllegalStateException("Unencrypted value in field " + propName);
        }
    } else if (itemDef.getTypeName().equals(NotificationConfigurationType.COMPLEX_TYPE)) {
        // this is really ugly hack needed because currently it is not possible to break NotificationConfigurationType into prism item [pm]
        NotificationConfigurationType ncfg = ((PrismPropertyValue<NotificationConfigurationType>) pval).getValue();
        if (ncfg.getMail() != null) {
            for (MailServerConfigurationType mscfg : ncfg.getMail().getServer()) {
                if (mscfg.getPassword() != null && mscfg.getPassword().getClearValue() != null) {
                    throw new IllegalStateException("Unencrypted value in mail server config password entry");
                }
            }
        }
        if (ncfg.getSms() != null) {
            for (SmsConfigurationType smscfg : ncfg.getSms()) {
                for (SmsGatewayConfigurationType gwcfg : smscfg.getGateway()) {
                    if (gwcfg.getPassword() != null && gwcfg.getPassword().getClearValue() != null) {
                        throw new IllegalStateException("Unencrypted value in SMS gateway config password entry");
                    }
                }
            }
        }
    }
}
Also used : NotificationConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType) Itemable(com.evolveum.midpoint.prism.Itemable) QName(javax.xml.namespace.QName) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) MailServerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType) SmsGatewayConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsGatewayConfigurationType) SmsConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsConfigurationType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 2 with NotificationConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType in project midpoint by Evolveum.

the class CryptoUtil method encryptValue.

private static <T extends ObjectType> void encryptValue(Protector protector, PrismPropertyValue<?> pval) throws EncryptionException {
    Itemable item = pval.getParent();
    if (item == null) {
        return;
    }
    ItemDefinition itemDef = item.getDefinition();
    if (itemDef == null || itemDef.getTypeName() == null) {
        return;
    }
    if (itemDef.getTypeName().equals(ProtectedStringType.COMPLEX_TYPE)) {
        QName propName = item.getElementName();
        PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>) pval;
        ProtectedStringType ps = psPval.getValue();
        encryptProtectedStringType(protector, ps, propName.getLocalPart());
        if (pval.getParent() == null) {
            pval.setParent(item);
        }
    } else if (itemDef.getTypeName().equals(NotificationConfigurationType.COMPLEX_TYPE)) {
        // this is really ugly hack needed because currently it is not possible to break NotificationConfigurationType into prism item [pm]
        NotificationConfigurationType ncfg = ((PrismPropertyValue<NotificationConfigurationType>) pval).getValue();
        if (ncfg.getMail() != null) {
            for (MailServerConfigurationType mscfg : ncfg.getMail().getServer()) {
                encryptProtectedStringType(protector, mscfg.getPassword(), "mail server password");
            }
        }
        if (ncfg.getSms() != null) {
            for (SmsConfigurationType smscfg : ncfg.getSms()) {
                for (SmsGatewayConfigurationType gwcfg : smscfg.getGateway()) {
                    encryptProtectedStringType(protector, gwcfg.getPassword(), "sms gateway password");
                }
            }
        }
    }
}
Also used : NotificationConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType) Itemable(com.evolveum.midpoint.prism.Itemable) QName(javax.xml.namespace.QName) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) MailServerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType) SmsGatewayConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsGatewayConfigurationType) SmsConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SmsConfigurationType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 3 with NotificationConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType in project midpoint by Evolveum.

the class NotificationManagerImpl method processEvent.

public void processEvent(@Nullable Event event, Task task, OperationResult result) {
    if (event == null) {
        return;
    }
    if (event instanceof BaseEvent) {
        ((BaseEvent) event).setNotificationFunctions(notificationFunctions);
    }
    LOGGER.trace("NotificationManager processing event {}", event);
    if (event.getAdHocHandler() != null) {
        processEvent(event, event.getAdHocHandler(), task, result);
    }
    SystemConfigurationType systemConfigurationType = NotificationFunctionsImpl.getSystemConfiguration(cacheRepositoryService, result);
    if (systemConfigurationType == null) {
        // something really wrong happened (or we are doing initial import of objects)
        return;
    }
    if (systemConfigurationType.getNotificationConfiguration() == null) {
        LOGGER.trace("No notification configuration in repository, finished event processing.");
        return;
    }
    NotificationConfigurationType notificationConfigurationType = systemConfigurationType.getNotificationConfiguration();
    processNotifications(notificationConfigurationType, event, task, result);
    LOGGER.trace("NotificationManager successfully processed event {} ({} top level handler(s))", event, notificationConfigurationType.getHandler().size());
}
Also used : NotificationConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType) BaseEvent(com.evolveum.midpoint.notifications.api.events.BaseEvent) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Example 4 with NotificationConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType in project midpoint by Evolveum.

the class NotificationConfigurationDto method getNewObject.

public NotificationConfigurationType getNewObject(SystemConfigurationType systemConfig) {
    NotificationConfigurationType notificationConfig = (systemConfig.getNotificationConfiguration() != null) ? systemConfig.getNotificationConfiguration() : new NotificationConfigurationType();
    MailConfigurationType mailConfig = (notificationConfig.getMail() != null) ? notificationConfig.getMail() : new MailConfigurationType();
    mailConfig.setDebug(isDebug());
    mailConfig.setDefaultFrom(getDefaultFrom());
    mailConfig.setRedirectToFile(getRedirectToFile());
    mailConfig.getServer().clear();
    for (MailServerConfigurationTypeDto serverDto : getServers()) {
        MailServerConfigurationType newConfig = new MailServerConfigurationType();
        newConfig.setHost(serverDto.getHost());
        newConfig.setPort(serverDto.getPort());
        newConfig.setUsername(serverDto.getUsername());
        newConfig.setTransportSecurity(serverDto.getMailTransportSecurityType());
        if (serverDto.getPassword() != null && StringUtils.isNotEmpty(serverDto.getPassword())) {
            ProtectedStringType pass = new ProtectedStringType();
            pass.setClearValue(serverDto.getPassword());
            newConfig.setPassword(pass);
        } else {
            newConfig.setPassword(serverDto.getOldConfig().getPassword());
        }
        mailConfig.getServer().add(newConfig);
    }
    notificationConfig.setMail(mailConfig);
    return notificationConfig;
}
Also used : NotificationConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType) MailConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailConfigurationType) MailServerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Aggregations

NotificationConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType)4 MailServerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType)3 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)3 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)2 Itemable (com.evolveum.midpoint.prism.Itemable)2 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)2 SmsConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SmsConfigurationType)2 SmsGatewayConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SmsGatewayConfigurationType)2 QName (javax.xml.namespace.QName)2 BaseEvent (com.evolveum.midpoint.notifications.api.events.BaseEvent)1 MailConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.MailConfigurationType)1 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)1