- List<SimpleGrantedAuthority> anonAuthorities = Collections
- .singletonList(new SimpleGrantedAuthority(
- KernelHeader.USERNAME_ANONYMOUS));
- UserDetails anonUser = new User("anonymous", "", true, true, true,
- true, anonAuthorities);
- AnonymousAuthenticationToken anonToken = new AnonymousAuthenticationToken(
- systemKey, anonUser, anonAuthorities);
- Authentication authentication = authenticationManager
- .authenticate(anonToken);
- SecurityContextHolder.getContext()
- .setAuthentication(authentication);
- } catch (Exception e) {
- throw new CmsException("Cannot authenticate", e);
+ loginContext = new ArgeoLoginContext(
+ KernelHeader.LOGIN_CONTEXT_ANONYMOUS, subject);
+ loginContext.login();
+ } catch (LoginException e1) {
+ throw new ArgeoException("Cannot authenticate anonymous", e1);