LoginConfigType[] loginConfigArray = webApp.getLoginConfigArray();
if (loginConfigArray.length > 1) {
throw new DeploymentException("Web app " + module.getName() + " cannot have more than one login-config element. Currently has " + loginConfigArray.length + " login-config elements.");
}
if (loginConfigArray.length == 1) {
LoginConfigType loginConfig = loginConfigArray[0];
if (loginConfig.isSetAuthMethod()) {
String authMethod = loginConfig.getAuthMethod().getStringValue();
if ("BASIC".equals(authMethod)) {
webModuleData.setAttribute("authenticator", new BasicAuthenticator());
} else if ("DIGEST".equals(authMethod)) {
webModuleData.setAttribute("authenticator", new DigestAuthenticator());
} else if ("FORM".equals(authMethod)) {
FormAuthenticator formAuthenticator = new FormAuthenticator();
webModuleData.setAttribute("authenticator", formAuthenticator);
if (loginConfig.isSetFormLoginConfig()) {
FormLoginConfigType formLoginConfig = loginConfig.getFormLoginConfig();
formAuthenticator.setLoginPage(formLoginConfig.getFormLoginPage().getStringValue());
formAuthenticator.setErrorPage(formLoginConfig.getFormErrorPage().getStringValue());
}
} else if ("CLIENT-CERT".equals(authMethod)) {
webModuleData.setAttribute("authenticator", new ClientCertAuthenticator());
}
}
if (loginConfig.isSetRealmName()) {
webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
}
} else if (jettyWebApp.isSetSecurityRealmName()) {
webModuleData.setAttribute("authenticator", new NonAuthenticator());
}