Include libs and dedicated server

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@505 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-06-20 04:03:32 +02:00
parent 338f2c1c42
commit f37219cfbf
13 changed files with 94 additions and 1 deletions

View file

@ -5,6 +5,15 @@
<classpathentry kind="src" path="mock"/> <classpathentry kind="src" path="mock"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Smack"/> <classpathentry kind="lib" path="lib/smack/smack.jar"/>
<classpathentry kind="lib" path="lib/smack/smackx.jar"/>
<classpathentry kind="lib" path="lib/vysper/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="lib/vysper/commons-lang-2.5.jar"/>
<classpathentry kind="lib" path="lib/vysper/mina-core-2.0.2.jar"/>
<classpathentry kind="lib" path="lib/vysper/nbxml-0.7.jar"/>
<classpathentry kind="lib" path="lib/vysper/slf4j-api-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/vysper/slf4j-simple-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/vysper/vysper-core-0.7.jar"/>
<classpathentry kind="lib" path="lib/vysper/xep0045-muc-0.7.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

BIN
lib/smack/smack.jar Normal file

Binary file not shown.

BIN
lib/smack/smackx.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/vysper/nbxml-0.7.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,84 @@
package jrummikub.server;
import java.io.IOException;
import java.net.InetAddress;
import org.apache.vysper.mina.TCPEndpoint;
import org.apache.vysper.storage.OpenStorageProviderRegistry;
import org.apache.vysper.xmpp.addressing.Entity;
import org.apache.vysper.xmpp.authorization.UserAuthorization;
import org.apache.vysper.xmpp.modules.extension.xep0045_muc.MUCModule;
import org.apache.vysper.xmpp.modules.extension.xep0045_muc.storage.InMemoryOccupantStorageProvider;
import org.apache.vysper.xmpp.modules.extension.xep0045_muc.storage.InMemoryRoomStorageProvider;
import org.apache.vysper.xmpp.modules.roster.persistence.MemoryRosterManager;
import org.apache.vysper.xmpp.server.XMPPServer;
@SuppressWarnings("deprecation")
public class DedicatedServer {
String serverPassword;
String hostName;
public DedicatedServer(String serverPassword) {
this.serverPassword = serverPassword;
try {
InetAddress addr = InetAddress.getLocalHost();
hostName = addr.getCanonicalHostName();
} catch (Exception e) {
hostName = "localhost";
}
}
public String getHostName() {
return hostName;
}
public void start() throws Exception {
XMPPServer server = new XMPPServer(hostName);
OpenStorageProviderRegistry providerRegistry = new OpenStorageProviderRegistry();
providerRegistry.add(new ServerPasswordAuthorization());
providerRegistry.add(new MemoryRosterManager());
providerRegistry.add(new InMemoryRoomStorageProvider());
providerRegistry.add(new InMemoryOccupantStorageProvider());
server.setStorageProviderRegistry(providerRegistry);
server.addEndpoint(new TCPEndpoint());
server.setTLSCertificateInfo(
getClass().getResource(
"/jrummikub/resource/bogus_mina_tls.cert").openStream(),
"boguspw");
server.start();
MUCModule muc = new MUCModule("play");
server.addModule(muc);
}
public class ServerPasswordAuthorization implements UserAuthorization {
@Override
public boolean verifyCredentials(Entity entity, String password,
Object credentials) {
return password.equals(serverPassword);
}
@Override
public boolean verifyCredentials(String entity, String password,
Object credentials) {
return password.equals(serverPassword);
}
}
public static void main(String[] args) {
DedicatedServer server = new DedicatedServer("password");
System.out.println("Server hostname is " + server.getHostName());
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}