Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mycompany.CRMFly.Security; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import org.springframework.context.annotation.Scope; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.transaction.annotation.Transactional; /** * * @author ?? */ @Named @Scope("request") public class AccountController { @Inject private IChangePassword changePasswordDao; private String newPassword; public String submitChangePasswordPage() { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); String username = principal.toString(); if (principal instanceof UserDetails) { username = ((UserDetails) principal).getUsername(); } changePasswordDao.changePassword(username, newPassword); SecurityContextHolder.clearContext(); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, " ? .", null)); return null; } public String getNewPassword() { return newPassword; } public void setNewPassword(String newPassword) { this.newPassword = newPassword; } /** * @return the authority */ /** * @return the userRole */ }