/**
* Construct new security handler for basic authentication.
*/
public SecurityHandler getObject() throws Exception {
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator(authenticator);
securityHandler.setRealmName(realm);
for (Entry<String, Constraint> constraint : constraints.entrySet()) {
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint.getValue());
constraintMapping.setPathSpec(constraint.getKey());
securityHandler.addConstraintMapping(constraintMapping);
}
for (User user : users) {
loginService.putUser(user.getName(), Credential.getCredential(user.getPassword()), user.getRoles());
}
securityHandler.setLoginService(loginService);
return securityHandler;
}