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


Java NotAuthorizedException类代码示例

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


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

示例1: setAllowed

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
private static void setAllowed(XMPPResourceConnection session, Set<JID> allowed)
				throws NotAuthorizedException, TigaseDBException {

	// Save set of allowed jids
	StringBuilder buf = new StringBuilder(1024);

	session.putCommonSessionData("remote-roster-allowed", allowed);

	boolean first = true;

	for (JID jid : allowed) {
		if (!first) {
			buf.append("/");
		} else {
			first = false;
		}
		buf.append(jid.toString());
	}
	session.setData("remote-roster-management", "allowed", buf.toString());
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:RemoteRosterManagement.java

示例2: updateBuddyChange

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * Method description
 *
 *
 * @param session
 * @param item
 * @param update
 * @param results
 *
 * @throws NotAuthorizedException
 * @throws TigaseDBException
 */
public static void updateBuddyChange(XMPPResourceConnection session, Element item,
				Element update, Queue<Packet> results)
				throws NotAuthorizedException, TigaseDBException {
	JID jid = JID.jidInstanceNS(item.getAttributeStaticStr("jid"));

	if (jid.getLocalpart() == null) {
		return;
	}
	jid = JID.jidInstanceNS(jid.getDomain());
	if (isRemoteAllowed(jid, session)) {
		Element iq = update.clone();

		iq.setAttribute("from", session.getBareJID().toString());
		iq.setAttribute("to", jid.getDomain());
		iq.setAttribute("id", "rst" + session.nextStanzaId());
		results.offer(Packet.packetInstance(iq, JID.jidInstance(session.getBareJID()),
						jid));
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:32,代码来源:RemoteRosterManagement.java

示例3: getUserRoster

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
protected Map<BareJID, RosterElement> getUserRoster(XMPPResourceConnection session)
				throws NotAuthorizedException, TigaseDBException {
	Map<BareJID, RosterElement> roster = null;

	// The method can be called from different plugins concurrently.
	// If the roster is not yet loaded from DB this causes concurent
	// access problems
	synchronized (session) {
		roster = (Map<BareJID, RosterElement>) session.getCommonSessionData(ROSTER);
		if (roster == null) {
			roster = loadUserRoster(session);
		}
	}

	return roster;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:18,代码来源:RosterFlat.java

示例4: setActiveList

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * Method description
 *
 *
 * @param session
 * @param lName
 *
 * @throws NotAuthorizedException
 * @throws TigaseDBException
 */
public static void setActiveList(XMPPResourceConnection session, String lName)
				throws NotAuthorizedException, TigaseDBException {
	if (lName == null) {

		// User declines to use current actiev list
		session.removeSessionData( ACTIVE );
	} else {

		// User selects a different active list
		Element list = getList(session, lName);

		if (list != null) {
			session.putSessionData(ACTIVE, list);
		} else {
			log.log(
					Level.INFO,
					"Setting active list to null, do something better than that, perhaps notify user.");
		}
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:31,代码来源:Privacy.java

示例5: testRecipientDisabledFor2ResourcesMessage

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
@Test
public void testRecipientDisabledFor2ResourcesMessage() throws TigaseStringprepException, NotAuthorizedException {
	String recipient = "[email protected]";
	JID recp1 = JID.jidInstanceNS(recipient + "/res1");
	JID recp2 = JID.jidInstanceNS(recipient + "/res2");
	JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
	JID connId2 = JID.jidInstanceNS("[email protected]/recipient1-res2");
	XMPPResourceConnection session1 = getSession(connId1, recp1);
	getSession(connId2, recp2);
	Packet p = Packet.packetInstance("message", "[email protected]/res1", recp1.toString(), StanzaType.chat);
	p.setPacketTo(connId1);
	ArrayDeque<Packet> results = new ArrayDeque<Packet>();
	results.offer(p);
	Packet[] expected = results.toArray(new Packet[0]);
	mobileV3.filter(p, session1, null, results);
	Packet[] processed = results.toArray(new Packet[0]);
	Assert.assertArrayEquals(expected, processed);
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:19,代码来源:MobileV3Test.java

示例6: unblock

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
public static boolean unblock(XMPPResourceConnection session, String jid) throws NotAuthorizedException, TigaseDBException {
	String name = getDefaultListName(session);
	Element list = getList(session,name);
	if(list == null)
		return false;
	
	Element list_new = new Element(LIST,new String[]{NAME},new String[]{name});	
	List<Element> items = list.findChildren(item -> !jid.equals(item.getAttributeStaticStr(VALUE)) || !isBlockItem(item));
	if (items != null) {
		Collections.sort(items, JabberIqPrivacy.compar);
		for (int i = 0; i < items.size(); i++) {
			items.get(i).setAttribute(ORDER, "" + (i + 1));
		}
		list_new.addChildren(items);
	}

	updateList(session, name, list_new);
	
	return false;		
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:Privacy.java

示例7: unblockAll

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
public static List<String> unblockAll(XMPPResourceConnection session) throws NotAuthorizedException, TigaseDBException {
	String name = getDefaultListName(session);
	Element list = getList(session,name);
	if(list == null)
		return null;

	List<String> ulist = list.mapChildren(item -> isBlockItem(item), item -> item.getAttributeStaticStr(VALUE));
	
	Element list_new = new Element(LIST,new String[]{NAME},new String[]{name});			
	List<Element> items = list.findChildren(item -> !isBlockItem(item));
	if (items != null) {
		Collections.sort(items, JabberIqPrivacy.compar);
		for (int i = 0; i < items.size(); i++) {
			items.get(i).setAttribute(ORDER, "" + (i + 1));
		}
		list_new.addChildren(items);
	}

	updateList(session, name, list_new);
	
	return ulist;				
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:23,代码来源:Privacy.java

示例8: testFilterAllPolicy

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
@Test
public void testFilterAllPolicy() throws NotAuthorizedException, TigaseStringprepException {
	session = getSession( connId1, recp1, DomainFilterPolicy.ALL, null );

	filterPacket( session, sameDomainUser );
	Assert.assertFalse( "ALL policy, message between same domains",
											results.pop().getType().equals( StanzaType.error ) );

	// two local domains
	filterPacket( session, localDomainUser );
	Assert.assertFalse( "ALL policy, message between different local domains",
											results.pop().getType().equals( StanzaType.error ) );

	filterPacket( session, externalDomainUser );
	Assert.assertFalse( "ALL policy, message to external domain",
											results.pop().getType().equals( StanzaType.error ) );

	session.logout();

}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:21,代码来源:DomainFilterTest.java

示例9: setEnabled

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * Add/Remove session JID to set of JIDs with enabled carbon copy protocol
 * 
 * @param session
 * @param value
 * @throws NotAuthorizedException 
 */
private static void setEnabled(XMPPResourceConnection session, boolean value, Queue<Packet> results) throws NotAuthorizedException {
	session.putSessionData(ENABLED_KEY, value);

	Map<JID,Boolean> resources = (Map<JID,Boolean>) session.getCommonSessionData(ENABLED_RESOURCES_KEY);
	
	if (log.isLoggable(Level.FINER)) {
		log.log(Level.FINER, "session = {0}" + " enabling " + XMLNS + 
				", resources to notify = {1}", new Object[]{
					session, resources == null ? "null" : resources.size()});
	}
	
	if (resources != null) {
		JID fromJid = session.getJID();
		for (JID jid : resources.keySet()) {
			
			if (jid.equals(fromJid))
				continue;
			
			notifyStateChanged(fromJid, jid, value, results);
		}
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:30,代码来源:MessageCarbons.java

示例10: broadcastOffline

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * <code>sendPresenceBroadcast</code> method broadcasts given presence to all
 * buddies from roster and to all users to which direct presence was sent.
 *
 * @param session     user session which keeps all the user session data and
 *                    also gives an access to the user's repository data.
 * @param results     this a collection with packets which have been generated
 *                    as input packet processing results.
 * @param settings    this map keeps plugin specific settings loaded from the
 *                    Tigase server configuration.
 * @param roster_util instance of class implementing {@link RosterAbstract}.
 *
 * @exception NotAuthorizedException if an error occurs
 * @throws TigaseDBException
 */
public static void broadcastOffline(XMPPResourceConnection session,
		Queue<Packet> results, Map<String, Object> settings, RosterAbstract roster_util)
				throws NotAuthorizedException, TigaseDBException {

	// Preventing sending offline notifications more than once
	if (session.getSessionData(OFFLINE_BUD_SENT) != null) {
		return;
	}
	session.putSessionData(OFFLINE_BUD_SENT, OFFLINE_BUD_SENT);

	Element pres = session.getPresence();

	if (pres != null) {
		sendPresenceBroadcast(StanzaType.unavailable, session, FROM_SUBSCRIBED, results,
				pres, settings, roster_util);
	} else {
		broadcastDirectPresences(StanzaType.unavailable, session, results, pres);
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:35,代码来源:PresenceState.java

示例11: broadcastDirectPresences

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * {@code broadcastDirectPresences} broadcast a direct Presence from provided
 * {@code pres} {@link Element} object to the collection of JIDs stored in
 * temporary session data under key {@code DIRECT_PRESENCE}.
 *
 *
 * @param t       specifies type of the presence to be send.
 * @param session user session which keeps all the user session data and also
 *                gives an access to the user's repository data.
 * @param results this a collection with packets which have been generated as
 *                input packet processing results.
 * @param pres    an Object of type {@link Element} holding Presence stanza to
 *                be sent.
 *
 * @throws NotAuthorizedException
 * @throws TigaseDBException
 */
@SuppressWarnings({ "unchecked" })
protected static void broadcastDirectPresences(StanzaType t,
		XMPPResourceConnection session, Queue<Packet> results, Element pres)
				throws NotAuthorizedException, TigaseDBException {
	Set<JID> direct_presences = (Set<JID>) session.getSessionData(DIRECT_PRESENCE);

	if ((direct_presences != null) && (t != null) && (t == StanzaType.unavailable)) {
		for (JID buddy : direct_presences) {
			if (log.isLoggable(Level.FINEST)) {
				log.log(Level.FINEST, "Updating direct presence for: {0}", buddy);
			}

			Packet pack = sendPresence(t, session.getJID(), buddy, results, pres);

			pack.setPriority(Priority.LOW);
		}    // end of for (String buddy: buddies)
	}      // end of if (direct_presence != null)
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:36,代码来源:PresenceState.java

示例12: rebroadcastPresence

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
public static void rebroadcastPresence(XMPPResourceConnection session, Queue<Packet> results) throws NotAuthorizedException, TigaseDBException {
		if (session.getPresence() == null ) {
			// user has not sent initial presence yet, ignore
			return;
		}

		Element presence = session.getPresence().clone();

		for ( ExtendedPresenceProcessorIfc processor : extendedPresenceProcessors ) {
			Element extendContent = processor.extend( session, results );
			if ( extendContent != null ){
				// avoid duplicate
				Element child = presence.getChild( extendContent.getName(), extendContent.getXMLNS() );
				if ( child != null ){
					presence.removeChild( child );
				}
				presence.addChild( extendContent );
			}
		}
		
		sendPresenceBroadcast(StanzaType.available, session, FROM_SUBSCRIBED, results, presence, null, getRosterUtil());

		updateUserResources(presence, session, results, false);

//		sendPresenceBroadcast( StanzaType.get, session, SUB_TO, results, presence, null, null );
	}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:27,代码来源:PresenceState.java

示例13: processError

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
/**
 * Process presence stanza of type Error. Allows errors sent from server to
 * user and ignore presence errors sent from the user.
 *
 *
 * @param packet       packet is which being processed.
 * @param session      user session which keeps all the user session data and
 *                     also gives an access to the user's repository data.
 * @param results      this a collection with packets which have been
 *                     generated as input packet processing results.
 * @param settings     this map keeps plugin specific settings loaded from the
 *                     Tigase server configuration.
 * @param presenceType specifies type of the presence
 *
 * @throws NoConnectionIdException
 * @throws NotAuthorizedException
 * @throws TigaseDBException
 */
protected void processError(Packet packet, XMPPResourceConnection session,
		Queue<Packet> results, Map<String, Object> settings, RosterAbstract.PresenceType presenceType)
				throws NotAuthorizedException, TigaseDBException, NoConnectionIdException {

	// Strategy change.
	// Now we allow all error presences sent to the user, but we just ignore
	// presence errors sent from the user
	if (session.isUserId(packet.getStanzaTo().getBareJID())) {
		Packet result = packet.copyElementOnly();

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

		// Ignore....
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:37,代码来源:PresenceState.java

示例14: testFilterWhielistPolicy

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
@Test
public void testFilterWhielistPolicy() throws NotAuthorizedException, TigaseStringprepException {
	String[] whitelistDomains = new String[] { "domain1", externalDomainUser.getDomain() };

	session = getSession( connId1, recp1, DomainFilterPolicy.LIST, whitelistDomains );

	filterPacket( session, sameDomainUser );
	Assert.assertFalse( "WHITELIST policy, message between same domains (both whitelist)",
											results.pop().getType().equals( StanzaType.error ) );

	filterPacket( session, localDomainUser );
	Assert.assertTrue( "WHITELIST policy, message between different local domains (only sender whitelist)",
										 results.pop().getType().equals( StanzaType.error ) );

	filterPacket( session, externalDomainUser );
	Assert.assertFalse( "WHITELIST policy, message to external domain (whitelisted)",
											results.pop().getType().equals( StanzaType.error ) );

	session.logout();

}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:22,代码来源:DomainFilterTest.java

示例15: testRecipientDisabledFor2ResourcesPresence

import tigase.xmpp.NotAuthorizedException; //导入依赖的package包/类
@Test
public void testRecipientDisabledFor2ResourcesPresence() throws TigaseStringprepException, NotAuthorizedException {
	String recipient = "[email protected]";
	JID recp1 = JID.jidInstanceNS(recipient + "/res1");
	JID recp2 = JID.jidInstanceNS(recipient + "/res2");
	JID connId1 = JID.jidInstanceNS("[email protected]/recipient1-res1");
	JID connId2 = JID.jidInstanceNS("[email protected]/recipient1-res2");
	XMPPResourceConnection session1 = getSession(connId1, recp1);
	getSession(connId2, recp2);
	Packet p = Packet.packetInstance("presence", "[email protected]/res1", recp1.toString(), StanzaType.chat);
	p.setPacketTo(connId1);
	ArrayDeque<Packet> results = new ArrayDeque<Packet>();
	results.offer(p);
	Packet[] expected = results.toArray(new Packet[0]);
	mobileV3.filter(p, session1, null, results);
	Packet[] processed = results.toArray(new Packet[0]);
	Assert.assertArrayEquals(expected, processed);
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:19,代码来源:MobileV3Test.java


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