Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit fbba8200 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Fix failed bamboo plans

parent 6516723e
Branches apiTestsUpdate26082024N
No related tags found
No related merge requests found
......@@ -45,10 +45,23 @@ public class SMPAuthenticationEventListener implements ApplicationListener<Authe
public void onApplicationEvent (AuthenticationSuccessEvent event) {
Collection<? extends GrantedAuthority> authorities = event.getAuthentication().getAuthorities();
boolean hasAdminRole = authorities.stream().anyMatch(grantedAuthority -> StringUtils.equalsIgnoreCase(grantedAuthority.getAuthority(), SMPAuthority.S_AUTHORITY_SYSTEM_ADMIN.getAuthority()));
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpSession session = attr.getRequest().getSession();
int idleTimeout =(hasAdminRole ? configurationService.getSessionIdleTimeoutForAdmin():configurationService.getSessionIdleTimeoutForUser());
LOG.debug("Set session idle timeout [{}] for user [{}]", idleTimeout,event.getAuthentication().getName());
session.setMaxInactiveInterval(idleTimeout);
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attr!= null) {
HttpSession session = attr.getRequest().getSession();
int idleTimeout = (hasAdminRole ? configurationService.getSessionIdleTimeoutForAdmin() : configurationService.getSessionIdleTimeoutForUser());
LOG.debug("Set session idle timeout [{}] for user [{}]", idleTimeout, event.getAuthentication().getName());
session.setMaxInactiveInterval(idleTimeout);
} else {
LOG.warn("Could not get ServletRequestAttributes attributes for authentication [{}]", event.getAuthentication() );
}
/*try {
HttpSession session = attr.getRequest().getSession();
int idleTimeout = (hasAdminRole ? configurationService.getSessionIdleTimeoutForAdmin() : configurationService.getSessionIdleTimeoutForUser());
LOG.debug("Set session idle timeout [{}] for user [{}]", idleTimeout, event.getAuthentication().getName());
session.setMaxInactiveInterval(idleTimeout);
} catch (RuntimeException ex) {
LOG.error("Session error: " , ex);
}*/
}
}
\ No newline at end of file
......@@ -102,6 +102,10 @@
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
</web-app>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment