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