/* ------------------------------------------------------------ */
protected void initLoginConfig(XmlParser.Node node)
{
XmlParser.Node method=node.get("auth-method");
FormAuthenticator _formAuthenticator=null;
if(method!=null)
{
Authenticator authenticator=null;
String m=method.toString(false,true);
if(Constraint.__FORM_AUTH.equals(m))
authenticator=_formAuthenticator=new FormAuthenticator();
else if(Constraint.__BASIC_AUTH.equals(m))
authenticator=new BasicAuthenticator();
else if(Constraint.__DIGEST_AUTH.equals(m))
authenticator=new DigestAuthenticator();
else if(Constraint.__CERT_AUTH.equals(m))
authenticator=new ClientCertAuthenticator();
else if(Constraint.__CERT_AUTH2.equals(m))
authenticator=new ClientCertAuthenticator();
else
Log.warn("UNKNOWN AUTH METHOD: "+m);
getWebAppContext().getSecurityHandler().setAuthenticator(authenticator);
}
XmlParser.Node name=node.get("realm-name");
UserRealm[] realms=ContextHandler.getCurrentContext().getContextHandler().getServer().getUserRealms();
String realm_name=name==null?"default":name.toString(false,true);
UserRealm realm=getWebAppContext().getSecurityHandler().getUserRealm();
for (int i=0;realm==null && realms!=null && i<realms.length; i++)
{
if (realms[i]!=null && realm_name.equals(realms[i].getName()))
realm=realms[i];
}
if (realm==null)
{
String msg = "Unknown realm: "+realm_name;
Log.warn(msg);
}
else
getWebAppContext().getSecurityHandler().setUserRealm(realm);
XmlParser.Node formConfig=node.get("form-login-config");
if(formConfig!=null)
{
if(_formAuthenticator==null)
Log.warn("FORM Authentication miss-configured");
else
{
XmlParser.Node loginPage=formConfig.get("form-login-page");
if(loginPage!=null)
_formAuthenticator.setLoginPage(loginPage.toString(false,true));
XmlParser.Node errorPage=formConfig.get("form-error-page");
if(errorPage!=null)
{
String ep=errorPage.toString(false,true);
_formAuthenticator.setErrorPage(ep);
}
}
}
}