本文整理汇总了Java中org.apache.vysper.xmpp.authorization.Anonymous类的典型用法代码示例。如果您正苦于以下问题:Java Anonymous类的具体用法?Java Anonymous怎么用?Java Anonymous使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Anonymous类属于org.apache.vysper.xmpp.authorization包,在下文中一共展示了Anonymous类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EmbeddedXMPPServer
import org.apache.vysper.xmpp.authorization.Anonymous; //导入依赖的package包/类
public EmbeddedXMPPServer(int port) throws Exception {
StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();
AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);
Entity consumer = EntityImpl.parseUnchecked("[email protected]");
accountManagement.addUser(consumer, "secret");
Entity producer = EntityImpl.parseUnchecked("[email protected]");
accountManagement.addUser(producer, "secret");
TCPEndpoint endpoint = new TCPEndpoint();
endpoint.setPort(port);
InputStream stream = EmbeddedXMPPServer.class.getResourceAsStream("/xmpp/server.jks");
server = new XMPPServer("apache.camel");
server.setStorageProviderRegistry(providerRegistry);
server.addEndpoint(endpoint);
server.setTLSCertificateInfo(stream, "secret");
server.setSASLMechanisms(Arrays.asList(new SASLMechanism[]{new Anonymous()}));
}
示例2: run
import org.apache.vysper.xmpp.authorization.Anonymous; //导入依赖的package包/类
@Override
public void run(String... args) throws Exception {
xmppServer = new XMPPServer(domain);
xmppServer.setStorageProviderRegistry(storageProviderRegistry);
final TCPEndpoint endpoint = new TCPEndpoint();
endpoint.setPort(xmppPort);
xmppServer.addEndpoint(endpoint);
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);
xmppServer.setTLSCertificateInfo(is, keystorePassword);
// allow anonymous authentication
xmppServer.setSASLMechanisms(Arrays.asList(new SASLMechanism[]{new Anonymous()}));
xmppServer.start();
// add the multi-user chat module and create a room
Conference conference = new Conference("Conference");
conference.createRoom(EntityImpl.parseUnchecked("[email protected]" + domain), "Public Room", RoomType.Public);
xmppServer.addModule(new MUCModule("conference", conference));
xmppServer.addModule(new InBandRegistrationModule());
xmppServer.addModule(new XmppPingModule());
xmppServer.addModule(new PublishSubscribeModule());
xmppServer.addModule(new SoftwareVersionModule());
if (saveMessage) {
// add MessageHandler
HandlerDictionary handlerDictionary = new DefaultHandlerDictionary(myMessageHandler);
((DefaultServerRuntimeContext) xmppServer.getServerRuntimeContext()).addDictionary(handlerDictionary);
}
LOG.info("XMPP Server is running on port {}", xmppPort);
}