Ich habe diese Methode
Anscheinend kommt es bis zu der Zeile
Wegen der Zeile
passiert eine unhandled Exception.
Da steht:
Früher hat es funktioniert. Damals haben wir aber eine andere library verwendet. Die Interfaces Authentication und AuthenticationManager waren in spring-security-core:4.2.3:RELEASE. Jetzt verwenden wir spring-security-core:5.5.0.
Java:
private UserBean setUserData(final LoginResult login, UserBean userBean, HttpSession httpSession, HttpServletResponse response) {
httpSession.setAttribute("PHPSESSID", login.getSessionId());
Cookie phpCookie = new Cookie("PHPSESSID", login.getSessionId());
phpCookie.setPath("/");
response.addCookie(phpCookie);
try {
if (login.getLogin()) {
httpSession.setAttribute("ALARM-FROM", "0");
userBean.setPassword("not_set");
userBean.setLanguage("deu");
userBean.setAvailableLanguages(new ArrayList<>());
userBean.getAvailableLanguages().add(new LanguageBean("deu"));
userBean.setPhone("123456789");
httpSession.setAttribute("USER_BEAN", userBean);
UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(userBean.getNickname(), "");
Authentication auth = authenticationManager.authenticate(authReq);
SecurityContext sc = SecurityContextHolder.getContext();
sc.setAuthentication(auth);
httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, sc);
userBean.getRightControllerBean().addRight("x", "server", ConHelper.PROTOKOLL + ConHelper.IP);
return userBean;
} else {
logger.info("credentials not valid");
}
httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, null);
return null;
} catch (Exception e) {
logger.error("exception. " + e.getMessage() + " / " + e.getCause());
}
return null;
}
Java:
UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(userBean.getNickname(), credentials);
Code:
Authentication auth = authenticationManager.authenticate(authReq);
Da steht:
Code:
2023-11-15 11:51:44.351 [http-nio-8080-exec-9] ERROR c.a.v.b.c.GlobalExceptionHandler - Unhandled exception occurred
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.StackOverflowError
Früher hat es funktioniert. Damals haben wir aber eine andere library verwendet. Die Interfaces Authentication und AuthenticationManager waren in spring-security-core:4.2.3:RELEASE. Jetzt verwenden wir spring-security-core:5.5.0.
Zuletzt bearbeitet: