ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator();
authenticator.setAuthenticationListeners(toCollection(authenticationListeners));
authenticator.setRealms(Arrays.asList(realm));
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionListeners(toCollection(sessionListeners));
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(Arrays.asList(realm));
securityManager.setAuthenticator(authenticator);
securityManager.setSessionManager(sessionManager);