我已经使用spring security实现了更改密码功能,但((UserDetails)principal).getPassword())为登录用户返回null.
如果我没记错的话,过去常常在3.0中使用.这是在3.1中更改,以便无法检索登录用户的当前密码?
在下面的代码中,我正在检查从网页输入的用户密码中的当前密码.然后我检查登录用户的密码是否与输入的密码匹配.如果是,那么我想设置oldPasswordMatchNewPassword = true.
我该如何实现此功能?
@RequestMapping(value = "/account/changePassword.do", method = RequestMethod.POST)
public String submitChangePasswordPage(
@RequestParam("oldpassword") String oldPassword,
@RequestParam("password") String newPassword) {
Object principal = SecurityContextHolder.getContext()
.getAuthentication().getPrincipal();
String username = principal.toString();
if (principal instanceof UserDetails) {
username = ((UserDetails) principal).getUsername();
System.out.println("username: " + username);
System.out.println("password: "
+ ((UserDetails) principal).getPassword());
if (((UserDetails) principal).getPassword() != null) {
if (((UserDetails) principal).getPassword().equals(oldPassword)) {
oldPasswordMatchNewPassword = true;
}
}
}
if (oldPasswordMatchNewPassword == true) {
logger.info("Old password matches new password. Password will be updated."); …Run Code Online (Sandbox Code Playgroud) 我有基于Java的Spring MVC应用程序,它也使用Spring安全性.我正在使用hibernate作为此Web应用程序的ORM工具.
以下是我的要求 -
用户可以使用Web浏览器上传CSV文件.已知CSV文件的格式包含以下5个字段:
userId, location, itemId, quantity, tranDate 001, NY, 00A8D5, 2, 12/31/2012 002, MN, 00A7C1, 10, 12/22/2012 . .
像这样大约有100行.
我在项目中使用Super CSV:
private void readWithCsvBeanReader(String CSV_FILENAME) throws Exception {
String CSV_FILENAME = "\\\\Serv01\\Files\\QueryResult.csv";
//String CSV_FILENAME = "C:\\Files\\QueryResult.csv";
ICsvBeanReader beanReader = null;
try {
beanReader = new CsvBeanReader(new FileReader(CSV_FILENAME),
CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the values to the bean (names
// must match)
final String[] header = beanReader.getHeader(true);
// get Cell Processor
final CellProcessor[] …Run Code Online (Sandbox Code Playgroud)