Search in sources :

Example 1 with PasswordChangeBean

use of org.apereo.cas.pm.PasswordChangeBean in project cas by apereo.

the class PasswordChangeAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    try {
        final UsernamePasswordCredential c = (UsernamePasswordCredential) WebUtils.getCredential(requestContext);
        final PasswordChangeBean bean = requestContext.getFlowScope().get(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
        if (passwordManagementService.change(c, bean)) {
            return new EventFactorySupport().event(this, PASSWORD_UPDATE_SUCCESS);
        }
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    requestContext.getMessageContext().addMessage(new MessageBuilder().error().code("pm.updateFailure").defaultText("Could not update the account password").build());
    return error();
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) PasswordChangeBean(org.apereo.cas.pm.PasswordChangeBean) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Aggregations

UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)1 PasswordChangeBean (org.apereo.cas.pm.PasswordChangeBean)1 MessageBuilder (org.springframework.binding.message.MessageBuilder)1 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)1