services = new HashMap<String,AuthService>();
autoServices = new HashMap<String,AuthService>();
for (ServerConfiguration.Auth auth : serverConf.getAuthServices().values()) {
try {
AuthService service = auth.newInstance();
services.put(auth.getName(),service);
} catch (AuthException ex) {
getLogger().log(Level.SEVERE,"Cannot instantiate auth service "+auth.getName(),ex);
}
}
ServerAdminApplication admin = new ServerAdminApplication(childContext,dbConfList,autodbList,storageFactory);
for (ServerConfiguration.AdminHost adminHost : serverConf.getAdminHosts().values()) {
VirtualHost vhost = createVirtualHost(adminHost);
getHosts().add(vhost);
adminRouters.add(vhost);
String authName = adminHost.getAuthName();
if (authName==null) {
getLogger().severe("The admin interface is missing a named auth service.");
continue;
}
AuthService service = services.get(authName);
if (service==null) {
getLogger().severe("Cannot find auth service "+authName+" for admin interface.");
continue;
}
UserGuard adminGuard = new UserGuard(childContext,ChallengeScheme.HTTP_BASIC,"Atom Administrator",service);
adminGuard.getRequiredGroups().add(AuthService.ADMIN_GROUP);
adminGuard.setNext(admin);
vhost.attach("/admin",adminGuard);
}
admins = new HashMap<String,Restlet>();
Restlet lastAdmin = null;
for (final DB adminDB : dbList.values()) {
getLogger().info("Configuring database "+adminDB.getName()+" for administration");
ServerConfiguration.Database databaseConf = serverConf.getDatabases().get(adminDB.getName());
AuthService service = null;
if (databaseConf==null || databaseConf.getAuthName()==null) {
service = new DBAuthService();
Properties props = new Properties();
props.setProperty("database",adminDB.getName());
props.setProperty("dir", adminDB.getDatabaseDir().getAbsolutePath());
try {
service.init(props);
} catch (AuthException ex) {
getLogger().log(Level.SEVERE,"Cannot instantiate auth service for database "+adminDB.getName(),ex);
continue;
}
} else {