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");
}
}
}
}
}
}
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");
}
}
}
}
}
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());
}
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;
}
Aggregations