Skip to content

Commit

Permalink
fixing npe, improving erroir handling. added validator for emails..
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Nov 11, 2016
1 parent 58a172b commit 4d1758d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
Expand Up @@ -26,13 +26,15 @@
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.event.IEventSink;
import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.validation.validator.EmailAddressValidator;

import com.evolveum.midpoint.common.policy.ValuePolicyGenerator;
import com.evolveum.midpoint.gui.api.page.PageBase;
Expand Down Expand Up @@ -146,7 +148,7 @@ public boolean isVisible() {
emailContainer.setOutputMarkupId(true);
form.add(emailContainer);
RequiredTextField<String> email = new RequiredTextField<String>(ID_EMAIL, new Model<String>());

email.add(RfcCompliantEmailAddressValidator.getInstance());
email.setOutputMarkupId(true);
emailContainer.add(email);
emailContainer.add(new VisibleEnableBehaviour() {
Expand Down Expand Up @@ -214,7 +216,7 @@ public boolean isEnabled() {
}

private void processResetPassword(AjaxRequestTarget target, Form<?> form) {
try {

RequiredTextField<String> username = (RequiredTextField) form.get(createComponentPath(ID_USERNAME_CONTAINER, ID_USERNAME));
RequiredTextField<String> email = (RequiredTextField) form.get(createComponentPath(ID_EMAIL_CONTAINER, ID_EMAIL));
String usernameValue = username != null ? username.getModelObject() : null;
Expand All @@ -232,6 +234,13 @@ private void processResetPassword(AjaxRequestTarget target, Form<?> form) {
getSession().error(getString("pageForgetPassword.message.usernotfound"));
throw new RestartResponseException(PageForgotPassword.class);
}
// try {

if (getResetPasswordPolicy() == null) {
LOGGER.debug("No policies for reset password defined");
getSession().error(getString("pageForgetPassword.message.policy.not.found"));
throw new RestartResponseException(PageForgotPassword.class);
}

switch (getResetPasswordPolicy().getResetMethod()) {
case MAIL:
Expand Down Expand Up @@ -259,14 +268,14 @@ private void processResetPassword(AjaxRequestTarget target, Form<?> form) {



} catch (Throwable e) {
LOGGER.error("Error during processing of security questions: {}", e.getMessage(), e);
// Just log the error, but do not display it. We are still
// in unprivileged part of the web
// we do not want to provide any information to the
// attacker.
throw new RestartResponseException(PageError.class);
}
// } catch (Throwable e) {
// LOGGER.error("Error during processing of security questions: {}", e.getMessage(), e);
// // Just log the error, but do not display it. We are still
// // in unprivileged part of the web
// // we do not want to provide any information to the
// // attacker.
// throw new RestartResponseException(PageError.class);
// }

}

Expand Down
Expand Up @@ -362,17 +362,17 @@ protected void onSavePerformed(AjaxRequestTarget target) {
}
getModelService().executeChanges(deltas, null, createSimpleTask(OPERATION_SAVE_PASSWORD), result);

result.recordSuccess();
result.computeStatus();
} catch (Exception ex) {
MyPasswordsDto dto = model.getObject();
ProtectedStringType password = dto.getPassword();
if (password != null){
password.setEncryptedData(null);
}
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save password changes", ex);
result.recordFatalError("Couldn't save password changes.", ex);
result.recordFatalError(getString("PageAbstractSelfCredentials.save.password.failed", ex.getMessage()), ex);
} finally {
result.recomputeStatus();
result.computeStatusIfUnknown();;
}

finishChangePassword(result, target);
Expand Down
Expand Up @@ -1499,7 +1499,7 @@ pageForgetPassword.message.ContactAdminQuestionsNotSet=You have not set any secu
pageForgetPassword.message.usernotfound=User Not Found
PageForgetPassword.password=Password
PageForgetPassword.resetPassword=Reset Password
PageForgetPassword.title=Forgot Password
PageForgotPassword.title=Forgot Password
PageForgetPassword.username=Username
PageImportObject.button.import=Import object
PageImportObject.embeddedEditor=Embedded editor
Expand Down Expand Up @@ -3000,7 +3000,7 @@ operation.com.evolveum.midpoint.model.impl.lens.ChangeExecutor.execute.focus.Use
operation.com.evolveum.midpoint.model.impl.lens.ChangeExecutor.executeDelta=Execute delta (Model)
operation.com.evolveum.midpoint.task.api.Task.listSubtasksDeeply=List subtasks deeply (Task)
operation.com.evolveum.midpoint.task.api.Task.listSubtasksRaw=List subtasks raw (Task)
operation.com.evolveum.midpoint.web.page.self.PageSelfCredentials.savePassword=Password is successfully changed
operation.com.evolveum.midpoint.web.page.self.PageSelfCredentials.savePassword=Change password (GUI)
operation.com.evolveum.midpoint.web.page.self.PageRequestRole.save=Changes were successfully saved
operation.com.evolveum.midpoint.web.page.self.PageRequestRole.taskCreated=The process of assigning a role is waiting for the approval.
PageError.button.home=Home
Expand Down Expand Up @@ -3428,4 +3428,6 @@ PageSelfRegistration.welcome.message=Welcome to midPoint registration
PageSelfRegistration.additional.message=
PageSelfRegistration.password.policy=
PageResetPassword.reset.successful=New password was set successfully. Continue with login.
PageForgotPassword.form.submited.message=Confirmation link was sent to the email provided. To reset your password, click on the confirmation link and follow instructions.
PageForgotPassword.form.submited.message=Confirmation link was sent to the email provided. To reset your password, click on the confirmation link and follow instructions.
pageForgetPassword.message.policy.not.found=Reset password not allowed
PageAbstractSelfCredentials.save.password.failed=Failed to change password: {0}

0 comments on commit 4d1758d

Please sign in to comment.