if (context instanceof Authenticator)
return;
if (context instanceof ContainerBase) {
Pipeline pipeline = ((ContainerBase) context).getPipeline();
if (pipeline != null) {
Valve basic = pipeline.getBasic();
if ((basic != null) && (basic instanceof Authenticator))
return;
Valve valves[] = pipeline.getValves();
for (int i = 0; i < valves.length; i++) {
if (valves[i] instanceof Authenticator)
return;
}
}
} else {
return; // Cannot install a Valve even if it would be needed
}
// Has a Realm been configured for us to authenticate against?
if (context.getRealm() == null) {
log(sm.getString("contextConfig.missingRealm"));
ok = false;
return;
}
// Load our mapping properties if necessary
if (authenticators == null) {
try {
authenticators = ResourceBundle.getBundle
("org.apache.catalina.startup.Authenticators");
} catch (MissingResourceException e) {
log(sm.getString("contextConfig.authenticatorResources"), e);
ok = false;
return;
}
}
// Identify the class name of the Valve we should configure
String authenticatorName = null;
try {
authenticatorName =
authenticators.getString(loginConfig.getAuthMethod());
} catch (MissingResourceException e) {
authenticatorName = null;
}
if (authenticatorName == null) {
log(sm.getString("contextConfig.authenticatorMissing",
loginConfig.getAuthMethod()));
ok = false;
return;
}
// Instantiate and install an Authenticator of the requested class
Valve authenticator = null;
try {
Class authenticatorClass = Class.forName(authenticatorName);
authenticator = (Valve) authenticatorClass.newInstance();
if (context instanceof ContainerBase) {
Pipeline pipeline = ((ContainerBase) context).getPipeline();