@@ -0,0 +1,1578 @@
+package eu.dariah.de.colreg.security;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport javax.servlet.http.HttpSession;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Value;%0Aimport org.springframework.security.core.Authentication;%0Aimport org.springframework.security.core.context.SecurityContextHolder;%0Aimport org.springframework.web.servlet.handler.HandlerInterceptorAdapter;%0A%0Aimport eu.dariah.de.colreg.model.PersistedUserDetails;%0Aimport eu.dariah.de.colreg.service.CollectionService;%0A%0Apublic class UserContextInterceptor extends HandlerInterceptorAdapter %7B%0A%09@Autowired private CollectionService collectionService;%0A%09%0A%09@Value(value=%22$%7Burl.login:null%7D%22)%0A%09private String loginUrl;%0A%09%0A%09@Value(value=%22$%7Burl.logout:null%7D%22)%0A%09private String logoutUrl;%0A%09%0A%09@Override%0A%09public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception %7B%0A%09%09Authentication auth = SecurityContextHolder.getContext().getAuthentication();%0A%09%09PersistedUserDetails user = null;%0A%09%09HttpSession session = request.getSession();%0A%09%09%0A%09%09if (auth != null && auth.getDetails() instanceof PersistedUserDetails) %7B%0A%09%09%09user = (PersistedUserDetails) auth.getDetails();%0A%09%09%09%0A%09%09%09int draftCount = collectionService.findAllDrafts(user.getId()).size();%0A%09%09%09session.setAttribute(%22_draftCount%22, draftCount);%0A%09%09%7D%0A%09%09session.setAttribute(%22_loginUrl%22, loginUrl);%0A%09%09session.setAttribute(%22_logoutUrl%22, logoutUrl);%0A%09%09return super.preHandle(request, response, handler);%0A%09%7D%0A%7D%0A

Implement simple security with local logins