+ // Security
+ static void anonymousLogin(AuthenticationManager authenticationManager) {
+ try {
+ List<SimpleGrantedAuthority> anonAuthorities = Collections
+ .singletonList(new SimpleGrantedAuthority(ROLE_ANONYMOUS));
+ UserDetails anonUser = new User(ANONYMOUS_USER, "", true, true,
+ true, true, anonAuthorities);
+ AnonymousAuthenticationToken anonToken = new AnonymousAuthenticationToken(
+ DEFAULT_SECURITY_KEY, anonUser, anonAuthorities);
+ Authentication authentication = authenticationManager
+ .authenticate(anonToken);
+ SecurityContextHolder.getContext()
+ .setAuthentication(authentication);
+ } catch (Exception e) {
+ throw new CmsException("Cannot authenticate", e);
+ }
+ }
+
+ // HTTP
+ static void logRequestHeaders(Log log, HttpServletRequest request) {
+ if (!log.isDebugEnabled())
+ return;
+ for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames
+ .hasMoreElements();) {
+ String headerName = headerNames.nextElement();
+ Object headerValue = request.getHeader(headerName);
+ log.debug(headerName + ": " + headerValue);
+ }
+ }
+