Skip to content

Commit

Permalink
MID-1999 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Suta committed Jul 18, 2014
1 parent f909b07 commit 4e871a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
Expand Up @@ -112,7 +112,7 @@ private SystemConfigurationDto loadSystemConfiguration() {
PrismObject<SystemConfigurationType> systemConfig = getModelService().getObject(SystemConfigurationType.class,
SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, task, result);

dto = new SystemConfigurationDto(systemConfig);
dto = new SystemConfigurationDto(systemConfig, getMidpointApplication().getProtector());
result.recordSuccess();
} catch(Exception ex){
LoggingUtils.logException(LOGGER, "Couldn't load system configuration", ex);
Expand All @@ -132,7 +132,7 @@ private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);

List<ITab> tabs = new ArrayList<ITab>();
List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(createStringResource("pageSystemConfiguration.system.title")) {

@Override
Expand Down
Expand Up @@ -76,7 +76,7 @@ protected void initLayout(){
add(passPolicyChoosePanel);
add(userTemplateChoosePanel);

DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<AEPlevel>(ID_GLOBAL_AEP,
DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<>(ID_GLOBAL_AEP,
new PropertyModel<AEPlevel>(getModel(), "aepLevel"),
WebMiscUtil.createReadonlyModelFromEnum(AEPlevel.class),
new EnumChoiceRenderer<AEPlevel>(SystemConfigPanel.this));
Expand All @@ -86,22 +86,23 @@ protected void initLayout(){
}
add(aepLevel);

TextField<String> auditRecordsField = new TextField<String>(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), "auditCleanupValue"));
TextField<String> closedTasksField = new TextField<String>(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), "taskCleanupValue"));
TextField<String> auditRecordsField = new TextField<>(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), "auditCleanupValue"));
TextField<String> closedTasksField = new TextField<>(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), "taskCleanupValue"));
add(auditRecordsField);
add(closedTasksField);

createTooltip(ID_CLEANUP_AUDIT_RECORDS_TOOLTIP, this);
createTooltip(ID_CLEANUP_CLOSED_TASKS_TOOLTIP, this);

TextField<String> defaultFromField = new TextField<String>(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "notificationConfig.defaultFrom"));
TextField<String> defaultFromField = new TextField<>(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "notificationConfig.defaultFrom"));
CheckBox debugCheck = new CheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "notificationConfig.debug"));
TextField<String> hostField = new TextField<String>(ID_HOST, new PropertyModel<String>(getModel(), "notificationConfig.host"));
TextField<Integer> portField = new TextField<Integer>(ID_PORT, new PropertyModel<Integer>(getModel(), "notificationConfig.port"));
TextField<String> userNameField = new TextField<String>(ID_USERNAME, new PropertyModel<String>(getModel(), "notificationConfig.username"));
TextField<String> hostField = new TextField<>(ID_HOST, new PropertyModel<String>(getModel(), "notificationConfig.host"));
TextField<Integer> portField = new TextField<>(ID_PORT, new PropertyModel<Integer>(getModel(), "notificationConfig.port"));
TextField<String> userNameField = new TextField<>(ID_USERNAME, new PropertyModel<String>(getModel(), "notificationConfig.username"));
PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "notificationConfig.password"));
passwordField.setRequired(false);
TextField<String> redirectToFileField = new TextField<String>(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "notificationConfig.redirectToFile"));
passwordField.setResetPassword(false);
TextField<String> redirectToFileField = new TextField<>(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "notificationConfig.redirectToFile"));

IModel choices = WebMiscUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class);
IChoiceRenderer renderer = new EnumChoiceRenderer();
Expand Down
Expand Up @@ -15,6 +15,10 @@
*/
package com.evolveum.midpoint.web.page.admin.configuration.dto;

import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MailConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType;
Expand All @@ -31,6 +35,8 @@
* */
public class NotificationConfigurationDto implements Serializable{

private static final Trace LOGGER = TraceManager.getTrace(NotificationConfigurationDto.class);

private String defaultFrom;
private boolean debug;
private String redirectToFile;
Expand All @@ -42,7 +48,7 @@ public class NotificationConfigurationDto implements Serializable{

public NotificationConfigurationDto(){}

public NotificationConfigurationDto(NotificationConfigurationType config){
public NotificationConfigurationDto(NotificationConfigurationType config, Protector protector){

if(config.getMail() != null){
MailConfigurationType mailConfig = config.getMail();
Expand All @@ -65,7 +71,11 @@ public NotificationConfigurationDto(NotificationConfigurationType config){
username = serverConfig.getUsername();

if(serverConfig.getPassword() != null){
password = serverConfig.getPassword().getClearValue();
try {
password = protector.decryptString(serverConfig.getPassword());
} catch (Exception e){
LoggingUtils.logException(LOGGER, "Unable to decrypt password in mail configuration.", e);
}
} else {
password = null;
}
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.web.page.admin.configuration.dto;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

Expand All @@ -38,14 +39,14 @@ public class SystemConfigurationDto implements Serializable {
private NotificationConfigurationDto notificationConfig;

public SystemConfigurationDto(){
this(null);
this(null, null);
}

public SystemConfigurationDto(PrismObject<SystemConfigurationType> config) {
init(config.asObjectable());
public SystemConfigurationDto(PrismObject<SystemConfigurationType> config, Protector protector) {
init(config.asObjectable(), protector);
}

private void init(SystemConfigurationType config){
private void init(SystemConfigurationType config, Protector protector){
if(config == null){
return;
}
Expand All @@ -65,7 +66,7 @@ private void init(SystemConfigurationType config){
objectTemplateDto = loadObjectTemplate(config);

if(config.getNotificationConfiguration() != null){
notificationConfig = new NotificationConfigurationDto(config.getNotificationConfiguration());
notificationConfig = new NotificationConfigurationDto(config.getNotificationConfiguration(), protector);
} else {
notificationConfig = new NotificationConfigurationDto();
}
Expand Down

0 comments on commit 4e871a2

Please sign in to comment.