use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageRegistrationBase method initResetCredentialsConfiguration.
private void initResetCredentialsConfiguration() {
SecurityPolicyType securityPolicy = resolveSecurityPolicy();
this.resetPasswordPolicy = new ResetPolicyDto();
try {
this.resetPasswordPolicy.initResetPolicyDto(securityPolicy);
} catch (SchemaException e) {
LOGGER.error("Failed to initialize self registration configuration.", e);
getSession().error(createStringResource("PageSelfRegistration.selfRegistration.configuration.init.failed").getString());
throw new RestartResponseException(PageLogin.class);
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageSecurityQuestions method createUsersSecurityQuestionsList.
private List<SecurityQuestionDto> createUsersSecurityQuestionsList(PrismObject<UserType> user) {
SecurityQuestionsCredentialsType credentialsPolicyType = user.asObjectable().getCredentials().getSecurityQuestions();
if (credentialsPolicyType == null || credentialsPolicyType.getQuestionAnswer() == null || credentialsPolicyType.getQuestionAnswer().isEmpty()) {
String key = "web.security.flexAuth.any.security.questions";
error(getString(key));
LOGGER.error(key);
throw new RestartResponseException(PageSecurityQuestions.class);
}
List<SecurityQuestionAnswerType> secQuestAnsList = credentialsPolicyType.getQuestionAnswer();
SecurityPolicyType securityPolicy = resolveSecurityPolicy(user);
LOGGER.trace("Found security policy: {}", securityPolicy);
if (securityPolicy == null) {
LOGGER.error("No security policy, cannot process security questions");
// we do not want to provide any information to the attacker.
throw new RestartResponseException(PageError.class);
}
if (securityPolicy.getCredentials() == null) {
LOGGER.error("No credential for security policy, cannot process security questions");
// we do not want to provide any information to the attacker.
throw new RestartResponseException(PageError.class);
}
SecurityQuestionsCredentialsPolicyType secQuestionsPolicy = securityPolicy.getCredentials().getSecurityQuestions();
List<SecurityQuestionDefinitionType> questionList = secQuestionsPolicy != null ? secQuestionsPolicy.getQuestion() : new ArrayList<SecurityQuestionDefinitionType>();
List<SecurityQuestionDto> questionsDto = new ArrayList<SecurityQuestionDto>();
int questionNumber = secQuestionsPolicy != null ? secQuestionsPolicy.getQuestionNumber() : 1;
for (SecurityQuestionDefinitionType question : questionList) {
if (Boolean.TRUE.equals(question.isEnabled())) {
for (SecurityQuestionAnswerType userAnswer : secQuestAnsList) {
if (question.getIdentifier().equals(userAnswer.getQuestionIdentifier())) {
SecurityQuestionDto questionDto = new SecurityQuestionDto(question.getIdentifier());
questionDto.setQuestionText(question.getQuestionText());
questionsDto.add(questionDto);
break;
}
}
}
if (questionNumber == questionsDto.size()) {
break;
}
}
if (questionsDto.size() < questionNumber) {
String key = "pageForgetPassword.message.ContactAdminQuestionsNotSetEnough";
error(getString(key));
LOGGER.error(key);
throw new RestartResponseException(PageSecurityQuestions.class);
}
return questionsDto;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccountActivation method propagatePassword.
private void propagatePassword(AjaxRequestTarget target, Form<?> form) {
List<ShadowType> shadowsToActivate = getShadowsToActivate();
PasswordTextField passwordPanel = (PasswordTextField) form.get(createComponentPath(ID_PASSWORD));
String value = passwordPanel.getModelObject();
ConnectionEnvironment connEnv = ConnectionEnvironment.create(SchemaConstants.CHANNEL_USER_URI);
UsernamePasswordAuthenticationToken token;
try {
token = authenticationEvaluator.authenticate(connEnv, new PasswordAuthenticationContext(userModel.getObject().getName().getOrig(), value, userModel.getObject().getClass()));
} catch (Exception ex) {
LOGGER.error("Failed to authenticate user, reason {}", ex.getMessage());
getSession().error(getString("PageAccountActivation.authentication.failed"));
throw new RestartResponseException(PageAccountActivation.class, getPageParameters());
}
if (token == null) {
LOGGER.error("Failed to authenticate user");
getSession().error(getString("PageAccountActivation.authentication.failed"));
throw new RestartResponseException(PageAccountActivation.class, getPageParameters());
}
ProtectedStringType passwordValue = new ProtectedStringType();
passwordValue.setClearValue(value);
Collection<ObjectDelta<ShadowType>> passwordDeltas = new ArrayList<>(shadowsToActivate.size());
for (ShadowType shadow : shadowsToActivate) {
ObjectDelta<ShadowType> shadowDelta = getPrismContext().deltaFactory().object().createModificationReplaceProperty(ShadowType.class, shadow.getOid(), SchemaConstants.PATH_PASSWORD_VALUE, passwordValue);
shadowDelta.addModificationReplaceProperty(ShadowType.F_LIFECYCLE_STATE, SchemaConstants.LIFECYCLE_ACTIVE);
passwordDeltas.add(shadowDelta);
}
OperationResult result = runPrivileged(new Producer<OperationResult>() {
private static final long serialVersionUID = 1L;
@Override
public OperationResult run() {
OperationResult result = new OperationResult(OPERATION_ACTIVATE_SHADOWS);
Task task = createAnonymousTask(OPERATION_ACTIVATE_SHADOWS);
WebModelServiceUtils.save((Collection) passwordDeltas, null, result, task, PageAccountActivation.this);
return result;
}
});
result.recomputeStatus();
if (!result.isSuccess()) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
LOGGER.error("Failed to acitvate accounts, reason: {} ", result.getMessage());
target.add(getFeedbackPanel());
} else {
getSession().success(getString("PageAccountActivation.account.activation.successful"));
target.add(getFeedbackPanel());
activated = true;
}
target.add(PageAccountActivation.this);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PagePostAuthentication method initStaticLayout.
@Override
protected WebMarkupContainer initStaticLayout() {
Task task = createSimpleTask(OPERATION_LOAD_WRAPPER);
OperationResult result = new OperationResult(OPERATION_LOAD_WRAPPER);
PrismObjectWrapperFactory<UserType> factory = findObjectWrapperFactory(userModel.getObject().asPrismObject().getDefinition());
WrapperContext context = new WrapperContext(task, result);
try {
objectWrapper = factory.createObjectWrapper(userModel.getObject().asPrismObject(), ItemStatus.NOT_CHANGED, context);
} catch (SchemaException e) {
result.recordFatalError(getString("PagePostAuthentication.message.couldntPerformPostAuth.fatalError"));
showResult(result);
throw new RestartResponseException(PageLogin.class);
}
WebMarkupContainer wrappers = new WebMarkupContainer(ID_WRAPPER_CONTENT);
try {
Panel main = initItemPanel(ID_MAIN_PANEL, UserType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(Model.of(objectWrapper), ItemPath.EMPTY_PATH), null);
wrappers.add(main);
Panel password = initItemPanel(ID_PASSWORD_PANEL, PasswordType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(Model.of(objectWrapper), ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD)), null);
wrappers.add(password);
} catch (SchemaException e) {
LOGGER.error("Cannot create panel, {}", e.getMessage(), e);
getSession().error("Unexpected error occurred. Please contact system administrator.");
throw new RestartResponseException(PageLogin.class);
}
return wrappers;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageEmailNonse method processResetPassword.
private void processResetPassword(AjaxRequestTarget target) {
UserType user = searchUser();
if (user == null) {
getSession().error(getString("pageForgetPassword.message.user.not.found"));
throw new RestartResponseException(PageEmailNonse.class);
}
LOGGER.trace("Reset Password user: {}", user);
if (getResetPasswordPolicy() == null) {
LOGGER.debug("No policies for reset password defined");
getSession().error(getString("pageForgetPassword.message.policy.not.found"));
throw new RestartResponseException(PageEmailNonse.class);
}
OperationResult result = saveUserNonce(user, getMailNoncePolicy(user.asPrismObject()));
if (result.getStatus() == OperationResultStatus.SUCCESS) {
submited = true;
target.add(PageEmailNonse.this);
} else {
getSession().error(getString("PageForgotPassword.send.nonce.failed"));
LOGGER.error("Failed to send nonce to user: {} ", result.getMessage());
throw new RestartResponseException(PageEmailNonse.this);
}
}
Aggregations