|
|
@@ -19,7 +19,6 @@ import org.springframework.security.access.intercept.InterceptorStatusToken;
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
-import org.springframework.security.core.AuthenticationException;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
@@ -32,6 +31,7 @@ import org.springframework.util.StringUtils;
|
|
|
import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.platform.b2b.service.UserService;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -137,20 +137,16 @@ public class SecurityInterceptor extends AbstractSecurityInterceptor implements
|
|
|
} else if (username.matches(UU_REGEXP)) {
|
|
|
user = userService.findUserByUserUU(Long.parseLong(username));
|
|
|
}
|
|
|
- if (user != null) {
|
|
|
+ if (user != null && user.getUserPwd().equals(Md5Utils.encode(password, user.getUserUU()))) {
|
|
|
ArrayList<GrantedAuthority> array = new ArrayList<GrantedAuthority>();
|
|
|
array.add(new SimpleGrantedAuthority(ROLE_USER));
|
|
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUserUU(), password, array);
|
|
|
- try {
|
|
|
- Authentication authenticatedUser = authenticationManager.authenticate(token);
|
|
|
- SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
|
|
|
- request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
|
|
- SecurityContextHolder.getContext());
|
|
|
- } catch (AuthenticationException e) {
|
|
|
- throw new UsernameNotFoundException("密码错误");
|
|
|
- }
|
|
|
+ Authentication authenticatedUser = authenticationManager.authenticate(token);
|
|
|
+ SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
|
|
|
+ request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
|
|
+ SecurityContextHolder.getContext());
|
|
|
} else
|
|
|
- throw new UsernameNotFoundException(username + "账号不存在");
|
|
|
+ throw new UsernameNotFoundException(username + " 账号或密码错误");
|
|
|
}
|
|
|
}
|
|
|
|