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 {
service = services.get(databaseConf.getAuthName());
if (service==null) {
getLogger().severe("Cannot find auth service "+databaseConf.getAuthName()+" for database "+adminDB.getName());
continue;
}
}
DBInfo dbinfo = new DBInfo(adminDB.getName(),adminDB,service,databaseConf==null ? null : databaseConf.getGroup(),databaseConf==null ? null : databaseConf.getGroupAlias());
dbConfList.put(dbinfo.getName(),dbinfo);
UserGuard adminGuard = new UserGuard(childContext,ChallengeScheme.HTTP_BASIC,"Atom Administrator",service);
adminGuard.getRequiredGroups().add(AuthService.ADMIN_GROUP);
try {
adminGuard.setNext(new AdminApplication(childContext,adminDB,storageFactory.getStorage(adminDB),AtomApplication.RESOURCE_BASE));
admins.put(adminDB.getName(),adminGuard);
for (Router router : adminRouters) {
router.attach("/admin/database/"+adminDB.getName(),adminGuard).getTemplate().setMatchingMode(Template.MODE_STARTS_WITH);
}
lastAdmin = adminGuard;