StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
pentahoSession.setAuthenticated( repositoryAdminUsername );
final GrantedAuthority[] repositoryAdminAuthorities = new GrantedAuthority[] {};
final String password = "ignored";
UserDetails repositoryAdminUserDetails =
new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
Authentication repositoryAdminAuthentication =
new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
PentahoSessionHolder.setSession( pentahoSession );
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );