use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class PageSelfRegistration method createPasswordPanel.
private void createPasswordPanel(WebMarkupContainer staticRegistrationForm) {
// ProtectedStringType initialPassword = null;
PasswordPanel password = new PasswordPanel(ID_PASSWORD, new PropertyModel<ProtectedStringType>(userModel, "credentials.password.value"), false, true);
password.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
password.getBaseFormComponent().setRequired(true);
staticRegistrationForm.add(password);
Label help = new Label(ID_TOOLTIP);
final StringResourceModel tooltipText = createStringResource("PageSelfRegistration.password.policy");
help.add(AttributeModifier.replace("title", tooltipText));
help.add(new InfoTooltipBehavior());
help.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return StringUtils.isNotEmpty(tooltipText.getObject());
}
});
staticRegistrationForm.add(help);
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class PageSelfRegistration method createNonce.
private NonceType createNonce(NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
ProtectedStringType nonceCredentials = new ProtectedStringType();
nonceCredentials.setClearValue(generateNonce(noncePolicy, null, task, result));
NonceType nonceType = new NonceType();
nonceType.setValue(nonceCredentials);
return nonceType;
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class PageAbstractSelfCredentials method onSavePerformed.
protected void onSavePerformed(AjaxRequestTarget target) {
List<PasswordAccountDto> selectedAccounts = getSelectedAccountsList();
if (isCheckOldPassword()) {
LOGGER.debug("Check old password");
if (model.getObject().getOldPassword() == null || model.getObject().getOldPassword().trim().equals("")) {
warn(getString("PageSelfCredentials.specifyOldPasswordMessage"));
target.add(getFeedbackPanel());
return;
} else {
OperationResult checkPasswordResult = new OperationResult(OPERATION_CHECK_PASSWORD);
Task checkPasswordTask = createSimpleTask(OPERATION_CHECK_PASSWORD);
try {
ProtectedStringType oldPassword = new ProtectedStringType();
oldPassword.setClearValue(model.getObject().getOldPassword());
boolean isCorrectPassword = getModelInteractionService().checkPassword(user.getOid(), oldPassword, checkPasswordTask, checkPasswordResult);
if (!isCorrectPassword) {
warn(getString("PageSelfCredentials.incorrectOldPassword"));
target.add(getFeedbackPanel());
return;
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check password", ex);
checkPasswordResult.recordFatalError("Couldn't check password." + ex.getMessage(), ex);
target.add(getFeedbackPanel());
return;
} finally {
checkPasswordResult.computeStatus();
}
}
}
if (selectedAccounts.isEmpty()) {
warn(getString("PageSelfCredentials.noAccountSelected"));
target.add(getFeedbackPanel());
return;
}
if (getModelObject().getPassword() == null) {
warn(getString("PageSelfCredentials.emptyPasswordFiled"));
target.add(getFeedbackPanel());
return;
}
OperationResult result = new OperationResult(OPERATION_SAVE_PASSWORD);
try {
MyPasswordsDto dto = model.getObject();
ProtectedStringType password = dto.getPassword();
if (!password.isEncrypted()) {
WebComponentUtil.encryptProtectedString(password, true, getMidpointApplication());
}
final ItemPath valuePath = new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
for (PasswordAccountDto accDto : selectedAccounts) {
PrismObjectDefinition objDef = accDto.isMidpoint() ? registry.findObjectDefinitionByCompileTimeClass(UserType.class) : registry.findObjectDefinitionByCompileTimeClass(ShadowType.class);
PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(valuePath, objDef, password);
Class<? extends ObjectType> type = accDto.isMidpoint() ? UserType.class : ShadowType.class;
deltas.add(ObjectDelta.createModifyDelta(accDto.getOid(), delta, type, getPrismContext()));
}
getModelService().executeChanges(deltas, null, createSimpleTask(OPERATION_SAVE_PASSWORD), result);
result.computeStatus();
} catch (Exception ex) {
setEncryptedPasswordData(null);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save password changes", ex);
result.recordFatalError(getString("PageAbstractSelfCredentials.save.password.failed", ex.getMessage()), ex);
} finally {
result.computeStatusIfUnknown();
;
}
finishChangePassword(result, target);
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class WebComponentUtil method encryptCredentials.
public static void encryptCredentials(ObjectDelta delta, boolean encrypt, MidPointApplication app) {
if (delta == null || delta.isEmpty()) {
return;
}
PropertyDelta propertyDelta = delta.findPropertyDelta(new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE));
if (propertyDelta == null) {
return;
}
Collection<PrismPropertyValue<ProtectedStringType>> values = propertyDelta.getValues(ProtectedStringType.class);
for (PrismPropertyValue<ProtectedStringType> value : values) {
ProtectedStringType string = value.getValue();
encryptProtectedString(string, encrypt, app);
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType 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