switch(settings.getInt("/user/authentication/type")) {
case Userbase.SQL:
case Userbase.RMI:
System.out.println("Initializing REMOTE userbase");
if (settings.get("/user/authentication/remote/host") == null || settings.get("/user/authentication/remote/port") == null || settings.get("/user/authentication/remote/retry_interval") == null) {
throw new ConfigurationException("must specify {host, port, retry_interval} when using remote statistics");
}
userbase = new RmiRemoteUserbase(settings.get("/user/authentication/remote/host"), settings.getInt("/user/authentication/remote/port"), settings.getInt("/user/authentication/remote/retry_interval"));
initializeCuftpdUserbaseActions();
break;
case Userbase.ANONYMOUS:
System.out.println("Initializing ANONYMOUS userbase");
userbase = new AnonymousUserbase();
break;
case Userbase.ASYNCHRONOUS:
System.out.println("Initializing ASYNCHRONOUS userbase");
try {
String name = settings.get("/user/authentication/asynchronous/name");
String uri = settings.get("/user/authentication/asynchronous/uri");
AsynchronousMessageQueueChangeTracker changeTracker = new AsynchronousMessageQueueChangeTracker(URI.create(uri), name);
this.changeTracker = changeTracker;
userbase = new LocalUserbase(settings.getDataDirectory(), true, changeTracker);
ChangeApplicator changeApplicator = new ChangeApplicator((LocalUserbase)userbase);
int i = 1;
String peerName;
String peerUri;
while(true) {
// loop over the sections in the file
peerName = settings.get("/user/authentication/asynchronous/peers/peer[" + i + "]/name");
if (peerName == null || "".equals(peerName)) {
break;
}
peerUri = settings.get("/user/authentication/asynchronous/peers/peer[" + i + "]/uri");
i++;
if (!peerUri.startsWith("failover:")) {
peerUri = "failover:" + peerUri;
}
changeTracker.addPeer(peerName, URI.create(peerUri), changeApplicator);
// todo: log each peer we connect to
}
initializeCuftpdUserbaseActions();
break;
} catch (Exception e) {
shutdown();
throw new ConfigurationException("Asynchronous userbase failure", e);
}
case Userbase.DEFAULT:
default:
System.out.println("Initializing LOCAL userbase");
userbase = new LocalUserbase(settings.getDataDirectory(), true, new ChangeTracker() {