JAASLoginService loginService = new JAASLoginService("OpenGamma");
loginService.setLoginModuleName("og");
server.addBean(loginService);
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.addConstraintMapping(restrictedConstraintMapping);
securityHandler.addConstraintMapping(publicConstraintMapping);
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.setLoginService(loginService);
securityHandler.setIdentityService(new DefaultIdentityService());
securityHandler.setStrict(false);
securityHandler.setRealmName("OpenGamma");
server.addBean(securityHandler);
// Insert the security handler in the chain before the existing handler
securityHandler.setHandler(server.getHandler());
server.setHandler(securityHandler);
}