当前位置: 首页>>代码示例>>Java>>正文


Java XMPPException类代码示例

本文整理汇总了Java中tigase.xmpp.XMPPException的典型用法代码示例。如果您正苦于以下问题:Java XMPPException类的具体用法?Java XMPPException怎么用?Java XMPPException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMPPException类属于tigase.xmpp包,在下文中一共展示了XMPPException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Override
public void process(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings) throws XMPPException {
    Integer appId = getAppIdFromJID(packet.getStanzaFrom());
    if (appId == null || !packet.getPacketFrom().getLocalpart().equals("c2s")) {
        return;
    }

    ProcessPacket[] processors;
    try {
        //retrieve corresponding processors for incoming element
        processors = processorsContainers.get(packet.getElemName()).getProcessors();
    } catch (Exception e) {
        log.warning("An error occured : " + e.getMessage());
        log.warning("Setting processors to an empty array.");
        processors = new ProcessPacket[0];
    }
    for (ProcessPacket processor : processors) {
        processor.execute(packet, String.valueOf(appId), eventBus);
    }
}
 
开发者ID:QuickBlox,项目名称:QuickBlox-Tigase-CustomFeatures,代码行数:21,代码来源:QBStatsCollector.java

示例2: processGet

import tigase.xmpp.XMPPException; //导入依赖的package包/类
private void processGet(Packet packet, XMPPResourceConnection session, Queue<Packet> results) throws XMPPException, NotAuthorizedException, TigaseDBException {
	if (packet.getElement().getChild(BLOCKLIST, XMLNS) != null) {
		Element list = new Element(BLOCKLIST);
		list.setXMLNS(XMLNS);
		List<String> jids = Privacy.getBlocked(session);
		if (jids != null) {
			for (String jid : jids) {
				list.addChild(new Element(ITEM, new String[]{_JID}, new String[]{jid}));
			}
		}
		session.putSessionData(ID, ID);
		results.offer(packet.okResult(list, 0));
	} else {
		results.offer(Authorization.BAD_REQUEST.getResponseMessage(packet, "Bad request", true));
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:17,代码来源:BlockingCommand.java

示例3: process

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Override
public void process(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
		throws XMPPException {
	if (log.isLoggable(Level.FINEST))
		log.log(Level.FINEST, "Processing packet: {0}", packet);

	if (packet.getElemName() == Iq.ELEM_NAME) {
		super.process(packet, session, repo, results, settings);
	} else {
		if ((session != null && (packet.getStanzaFrom() != null) && session.isAuthorized() && session.getBareJID().equals(packet.getStanzaFrom().getBareJID()))) {
			final long time = System.currentTimeMillis();

			if (log.isLoggable(Level.FINEST)) {
				log.finest("Updating last:activity of user " + session.getUserName() + " to " + time);
			}

			setLastActivity(session, time);
		}
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:LastActivity.java

示例4: testMessagesToInactive

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testMessagesToInactive() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    enableCSI(session1);

    ArrayDeque<Packet> results = new ArrayDeque<>();
    Packet p = Packet.packetInstance("message", "[email protected]/res1", recp1.toString(), StanzaType.chat);
    p.setPacketTo(connId1);
    results.offer(p);
    Packet[] expected = results.toArray(new Packet[results.size()]);
    csi.filter(p, session1, null, results);
    Packet[] processed = results.toArray(new Packet[results.size()]);
    Assert.assertArrayEquals(expected, processed);
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:19,代码来源:ClientStateIndicationTest.java

示例5: testPresenceToInactive

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testPresenceToInactive() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    enableCSI(session1);

    ArrayDeque<Packet> results = new ArrayDeque<>();
    Packet p = Packet.packetInstance("presence", "[email protected]/res1", recp1.toString(), StanzaType.available);
    p.setPacketTo(connId1);
    results.offer(p);
    Packet[] expected = new Packet[0];
    csi.filter(p, session1, null, results);
    Packet[] processed = results.toArray(new Packet[results.size()]);
    Assert.assertArrayEquals(expected, processed);
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:19,代码来源:ClientStateIndicationTest.java

示例6: process

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Override
public void process(final Packet packet, final XMPPResourceConnection session,
		final NonAuthUserRepository repo, final Queue<Packet> results, final Map<String,
		Object> settings)
				throws XMPPException {
	if (session == null) {
		return;
	}    // end of if (session == null)
	if (!session.isAuthorized()) {
		results.offer(session.getAuthState().getResponseMessage(packet,
				"Session is not yet authorized.", false));

		return;
	}    // end of if (!session.isAuthorized())

	// Element request = packet.getElement();
	StanzaType type = packet.getType();

	switch (type) {
	case set :
		session.putSessionData(SESSION_KEY, "true");
		results.offer(packet.okResult((String) null, 0));

		break;

	default :
		results.offer(Authorization.BAD_REQUEST.getResponseMessage(packet,
				"Session type is incorrect", false));

		break;
	}    // end of switch (type)
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:33,代码来源:SessionBind.java

示例7: forward

import tigase.xmpp.XMPPException; //导入依赖的package包/类
private void forward(Packet packet, XMPPResourceConnection session,
		NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
				throws XMPPException {
	String pubSubComponentUrl = (settings == null)
			? null
			: (String) settings.get(PUBSUB_COMPONENT_URL);

	if ((session == null) || (pubSubComponentUrl == null)) {
		if (log.isLoggable(Level.FINE)) {
			log.fine("Packet reject. No Session or PubSub Component URL.");
		}

		return;
	}    // end of if (session == null)
	try {
		packet.getElement().setAttribute("to", pubSubComponentUrl);

		BareJID id = packet.getStanzaTo().getBareJID();

		if (session.isUserId(id)) {

			// Yes this is message to 'this' client
			Packet result = packet.copyElementOnly();

			result.setPacketTo(session.getConnectionId());
			result.setPacketFrom(packet.getTo());
			results.offer(result);
		} else {

			// This is message to some other client
			results.offer(packet.copyElementOnly());
		}    // end of else
	} catch (NotAuthorizedException e) {
		log.warning("NotAuthorizedException for packet: " + packet);
		results.offer(Authorization.NOT_AUTHORIZED.getResponseMessage(packet,
				"You must authorize session first.", true));
	}    // end of try-catch
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:39,代码来源:PepPlugin.java

示例8: process

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Override
public void process(Packet packet, XMPPResourceConnection session,
		NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
				throws XMPPException {
	if (session == null) {
		return;
	}    // end of if (session == null)
	if (packet.isElement("compress", XMLNS)) {
		if (session.getSessionData(ID) != null) {

			// Somebody tries to activate multiple TLS layers.
			// This is possible and can even work but this can also be
			// a DOS attack. Blocking it now, unless someone requests he wants
			// to have multiple layers of TLS for his connection
			log.log(Level.WARNING,
					"Multiple ZLib requests, possible DOS attack, closing connection: {0}",
					packet);
			results.offer(packet.swapFromTo(failure, null, null));
			results.offer(Command.CLOSE.getPacket(packet.getTo(), packet.getFrom(), StanzaType
					.set, session.nextStanzaId()));

			return;
		}
		session.putSessionData(ID, "true");

		Packet result = Command.STARTZLIB.getPacket(packet.getTo(), packet.getFrom(),
				StanzaType.set, session.nextStanzaId(), Command.DataType.submit);

		Command.setData(result, compressed);
		results.offer(result);
	} else {
		log.log(Level.WARNING, "Unknown ZLIB element: {0}", packet);
		results.offer(packet.swapFromTo(failure, null, null));
		results.offer(Command.CLOSE.getPacket(packet.getTo(), packet.getFrom(), StanzaType
				.set, session.nextStanzaId()));
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:38,代码来源:StartZLib.java

示例9: process

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Override
public void process(Packet packet, XMPPResourceConnection session,
		NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
				throws XMPPException {
	if (session == null) {
		return;
	}    // end of if (session == null)
	try {
		BareJID id = packet.getStanzaTo().getBareJID();

		if (session.isUserId(id)) {

			// Yes this is message to 'this' client
			Packet result = packet.copyElementOnly();

			result.setPacketTo(session.getConnectionId(packet.getStanzaTo()));
			result.setPacketFrom(packet.getTo());
			results.offer(result);
		} else {

			// This is message to some other client
			results.offer(packet.copyElementOnly());
		}    // end of else
	} catch (NotAuthorizedException e) {
		log.warning("NotAuthorizedException for packet: " + packet);
		results.offer(Authorization.NOT_AUTHORIZED.getResponseMessage(packet,
				"You must authorize session first.", true));
	}    // end of try-catch
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:30,代码来源:SimpleForwarder.java

示例10: getBlocked

import tigase.xmpp.XMPPException; //导入依赖的package包/类
private List<String> getBlocked(XMPPResourceConnection sess) throws XMPPException, TigaseStringprepException {
	Element iq = new Element("iq", new String[] { "type" }, new String[] { "get" });
	Element blocklist = new Element("blocklist", new String[] { "xmlns" }, new String[] { BlockingCommand.XMLNS });
	iq.addChild(blocklist);
	
	Packet p = Packet.packetInstance(iq);
	blockingCommand.process(p, sess, null, results, null);
	assertEquals(1, results.size());
	Packet result = results.poll();
	assertEquals(Iq.ELEM_NAME, result.getElemName());
	return result.getElement().getChild("blocklist").mapChildren(c -> c.getName() == "item", c -> c.getAttributeStaticStr("jid"));
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:13,代码来源:BlockingCommandTest.java

示例11: testEnable

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testEnable() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    enableCSI(session1);
    assertTrue(session1.getSessionData(ClientStateIndication.SESSION_QUEUE) instanceof ClientStateIndication.InternalQueue);
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:11,代码来源:ClientStateIndicationTest.java

示例12: testEnableDisable

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testEnableDisable() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    enableCSI(session1);
    assertTrue(session1.getSessionData(ClientStateIndication.SESSION_QUEUE) instanceof ClientStateIndication.InternalQueue);
    disableCSI(session1);
    assertNull(session1.getSessionData(ClientStateIndication.SESSION_QUEUE));
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:13,代码来源:ClientStateIndicationTest.java

示例13: testDisable

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testDisable() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    disableCSI(session1);
    assertNull(session1.getSessionData(ClientStateIndication.SESSION_QUEUE));
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:11,代码来源:ClientStateIndicationTest.java

示例14: testFlushStopping

import tigase.xmpp.XMPPException; //导入依赖的package包/类
@Test
public void testFlushStopping() throws XMPPException, TigaseStringprepException {
    String recipient = "[email protected]";
    JID recp1 = JID.jidInstanceNS(recipient + "/res1");
    JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
    XMPPResourceConnection session1 = getSession(connId1, recp1);

    enableCSI(session1);

    ArrayDeque<Packet> results = new ArrayDeque<>();
    Packet p = Packet.packetInstance("presence", "[email protected]/res1", recp1.toString(), StanzaType.available);
    p.setPacketTo(connId1);
    csi.filter(p, session1, null, results);

    results.clear();
    Packet m = Packet.packetInstance("message", "[email protected]t/res1", recp1.toString(), StanzaType.chat);
    m.getElement().addChild(new Element("received", new String[]{ "xmlns" }, new String[] { "urn:xmpp:receipts" }));
    m.setPacketTo(connId1);
    results.offer(m);
    csi.filter(m, session1, null, results);

    results.clear();
    results.offer(m);
    Packet[] expected = results.toArray(new Packet[results.size()]);
    results.clear();
    csi.stopped(session1, results, new HashMap<>());
    Packet[] processed = results.toArray(new Packet[results.size()]);
    Assert.assertArrayEquals(expected, processed);
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:30,代码来源:ClientStateIndicationTest.java

示例15: enableCSI

import tigase.xmpp.XMPPException; //导入依赖的package包/类
private Queue<Packet> enableCSI(XMPPResourceConnection session) throws TigaseStringprepException, XMPPException {
    Packet p = Packet.packetInstance(new Element(ClientStateIndication.ELEM_INACTIVE,
            new String[] { "xmlns" }, new String[] { ClientStateIndication.XMLNS }));
    ArrayDeque<Packet> results = new ArrayDeque<>();
    csi.processFromUserToServerPacket(session.getConnectionId(), p, session, null, results, null);
    return results;
}
 
开发者ID:kontalk,项目名称:tigase-extension,代码行数:8,代码来源:ClientStateIndicationTest.java


注:本文中的tigase.xmpp.XMPPException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。