test_class.declarator: privacyFilter
test_class.modifier: private
test_class.original_string: private JabberIqPrivacy privacyFilter;
test_class.type: JabberIqPrivacy
test_class.var_name: privacyFilter
test_class.declarator: results
test_class.modifier: private
test_class.original_string: private ArrayDeque<Packet> results;
test_class.type: ArrayDeque<Packet>
test_class.var_name: results
test_class.file: tigase-server 7.1.0/src/test/java/tigase/xmpp/impl/JabberIqPrivacyTest.java
test_class.identifier: JabberIqPrivacyTest
test_class.superclass: extends ProcessorTestCase
test_case.body: @Test
  		public void testFilterPresenceOut() throws Exception {
  			JID jid = JID.jidInstance("test@example/res-1");
  			JID connId = JID.jidInstance("c2s@example.com/asdasd");
  			XMPPResourceConnection session = getSession(connId, jid);
  			
  			//List<Element> items = new ArrayList<Element>();
  			Element list = new Element("list", new String[] { "name" }, new String[] { "default" });
  			Element item = new Element("item", new String[]{"type", "value", "action", "order"},
  					new String[]{"jid", "test1.example.com", "deny", "100"});
  			item.addChild(new Element("presence-out"));
  			list.addChild(item);
  			list.addChild(new Element("item", new String[]{"action", "order"},
  					new String[]{"allow", "110"}));
  			
  			session.putSessionData("active-list", list);
  			
  			Packet presence = Packet.packetInstance(new Element("presence", 
  					new String[] { "from", "to" }, 
  					new String[] { "test@example/res-1", "test1.example.com" }));
  					
  			assertFalse(privacyFilter.allowed(presence, session));
  			
  			presence = Packet.packetInstance(new Element("presence", 
  					new String[] { "to", "from" }, 
  					new String[] { "test@example/res-1", "test1.example.com" }));			
  			
  			assertTrue(privacyFilter.allowed(presence, session));
  		}
test_case.class_method_signature: JabberIqPrivacyTest.testFilterPresenceOut()
test_case.full_signature: @Test public void testFilterPresenceOut()
test_case.identifier: testFilterPresenceOut
test_case.invocations: jidInstance jidInstance getSession addChild addChild addChild putSessionData packetInstance assertFalse allowed packetInstance assertTrue allowed
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFilterPresenceOut()
focal_class.declarator: ACTIVE_EL_NAME  = "active"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String     ACTIVE_EL_NAME  = "active";
focal_class.type: String
focal_class.var_name: ACTIVE_EL_NAME
focal_class.declarator: BLOCKED_ELEM = new Element("blocked", new String[] { "xmlns" }, new String[] { "urn:xmpp:blocking:errors" })
focal_class.modifier: protected static final
focal_class.original_string: protected static final Element     BLOCKED_ELEM = new Element("blocked", new String[] { "xmlns" }, new String[] { "urn:xmpp:blocking:errors" });
focal_class.type: Element
focal_class.var_name: BLOCKED_ELEM
focal_class.declarator: DEFAULT_EL_NAME = "default"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String     DEFAULT_EL_NAME = "default";
focal_class.type: String
focal_class.var_name: DEFAULT_EL_NAME
focal_class.declarator: ELEMENTS        = {
  		Iq.IQ_QUERY_PATH
  	}
focal_class.modifier: protected static final
focal_class.original_string: protected static final String[][] ELEMENTS        = {
  		Iq.IQ_QUERY_PATH
  	};
focal_class.type: String[][]
focal_class.var_name: ELEMENTS
focal_class.declarator: LIST_EL_NAME    = "list"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String     LIST_EL_NAME    = "list";
focal_class.type: String
focal_class.var_name: LIST_EL_NAME
focal_class.declarator: log = Logger.getLogger(JabberIqPrivacy.class.getName())
focal_class.modifier: protected static
focal_class.original_string: protected static Logger          log = Logger.getLogger(JabberIqPrivacy.class.getName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: ERROR_EL_NAME        = "error"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    ERROR_EL_NAME        = "error";
focal_class.type: String
focal_class.var_name: ERROR_EL_NAME
focal_class.declarator: PRESENCE_EL_NAME     = "presence"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    PRESENCE_EL_NAME     = "presence";
focal_class.type: String
focal_class.var_name: PRESENCE_EL_NAME
focal_class.declarator: PRESENCE_IN_EL_NAME  = "presence-in"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    PRESENCE_IN_EL_NAME  = "presence-in";
focal_class.type: String
focal_class.var_name: PRESENCE_IN_EL_NAME
focal_class.declarator: PRESENCE_OUT_EL_NAME = "presence-out"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    PRESENCE_OUT_EL_NAME = "presence-out";
focal_class.type: String
focal_class.var_name: PRESENCE_OUT_EL_NAME
focal_class.declarator: XMLNS                = "jabber:iq:privacy"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    XMLNS                = "jabber:iq:privacy";
focal_class.type: String
focal_class.var_name: XMLNS
focal_class.declarator: ID                   = XMLNS
focal_class.modifier: protected static final
focal_class.original_string: protected static final String    ID                   = XMLNS;
focal_class.type: String
focal_class.var_name: ID
focal_class.declarator: XMLNSS               = { XMLNS }
focal_class.modifier: protected static final
focal_class.original_string: protected static final String[]  XMLNSS               = { XMLNS };
focal_class.type: String[]
focal_class.var_name: XMLNSS
focal_class.declarator: roster_util = RosterFactory.getRosterImplementation(
  			true)
focal_class.modifier: protected static
focal_class.original_string: protected static RosterAbstract  roster_util = RosterFactory.getRosterImplementation(
  			true);
focal_class.type: RosterAbstract
focal_class.var_name: roster_util
focal_class.declarator: DISCO_FEATURES = { new Element("feature", new String[] {
  			"var" }, new String[] { XMLNS }) }
focal_class.modifier: protected static final
focal_class.original_string: protected static final Element[] DISCO_FEATURES = { new Element("feature", new String[] {
  			"var" }, new String[] { XMLNS }) };
focal_class.type: Element[]
focal_class.var_name: DISCO_FEATURES
focal_class.declarator: compar = new Comparator<Element>() {
  		@Override
  		public int compare(Element el1, Element el2) {
  			String or1 = el1.getAttributeStaticStr(ORDER);
  			String or2 = el2.getAttributeStaticStr(ORDER);
  			if (or1.length() != or2.length())
  				return Integer.compare(or1.length(), or2.length());
  
  			return or1.compareTo(or2);
  		}
  	}
focal_class.modifier: protected static final
focal_class.original_string: protected static final Comparator<Element> compar = new Comparator<Element>() {
  		@Override
  		public int compare(Element el1, Element el2) {
  			String or1 = el1.getAttributeStaticStr(ORDER);
  			String or2 = el2.getAttributeStaticStr(ORDER);
  			if (or1.length() != or2.length())
  				return Integer.compare(or1.length(), or2.length());
  
  			return or1.compareTo(or2);
  		}
  	};
focal_class.type: Comparator<Element>
focal_class.var_name: compar
focal_class.file: tigase-server 7.1.0/src/main/java/tigase/xmpp/impl/JabberIqPrivacy.java
focal_class.identifier: JabberIqPrivacy
focal_class.interfaces: implements XMPPProcessorIfc, XMPPPreprocessorIfc, XMPPPacketFilterIfc
focal_class.class_method_signature: JabberIqPrivacy.filter(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results)
focal_class.full_signature: @Override public void filter(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results)
focal_class.identifier: filter
focal_class.modifiers: @Override public
focal_class.parameters: (Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results)
focal_class.return: void
focal_class.signature: void filter(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results)
focal_class.class_method_signature: JabberIqPrivacy.id()
focal_class.full_signature: @Override public String id()
focal_class.identifier: id
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String id()
focal_class.class_method_signature: JabberIqPrivacy.preProcess(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
focal_class.full_signature: @Override public boolean preProcess(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
focal_class.identifier: preProcess
focal_class.modifiers: @Override public
focal_class.parameters: (Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
focal_class.return: boolean
focal_class.signature: boolean preProcess(Packet packet, XMPPResourceConnection session,
  			NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings)
focal_class.class_method_signature: JabberIqPrivacy.process(final Packet packet, final XMPPResourceConnection session,
  			final NonAuthUserRepository repo, final Queue<Packet> results, final Map<String,
  			Object> settings)
focal_class.full_signature: @Override public void process(final Packet packet, final XMPPResourceConnection session,
  			final NonAuthUserRepository repo, final Queue<Packet> results, final Map<String,
  			Object> settings)
focal_class.identifier: process
focal_class.modifiers: @Override public
focal_class.parameters: (final Packet packet, final XMPPResourceConnection session,
  			final NonAuthUserRepository repo, final Queue<Packet> results, final Map<String,
  			Object> settings)
focal_class.return: void
focal_class.signature: void process(final Packet packet, final XMPPResourceConnection session,
  			final NonAuthUserRepository repo, final Queue<Packet> results, final Map<String,
  			Object> settings)
focal_class.class_method_signature: JabberIqPrivacy.supDiscoFeatures(final XMPPResourceConnection session)
focal_class.full_signature: @Override public Element[] supDiscoFeatures(final XMPPResourceConnection session)
focal_class.identifier: supDiscoFeatures
focal_class.modifiers: @Override public
focal_class.parameters: (final XMPPResourceConnection session)
focal_class.return: Element[]
focal_class.signature: Element[] supDiscoFeatures(final XMPPResourceConnection session)
focal_class.class_method_signature: JabberIqPrivacy.supElementNamePaths()
focal_class.full_signature: @Override public String[][] supElementNamePaths()
focal_class.identifier: supElementNamePaths
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String[][]
focal_class.signature: String[][] supElementNamePaths()
focal_class.class_method_signature: JabberIqPrivacy.supNamespaces()
focal_class.full_signature: @Override public String[] supNamespaces()
focal_class.identifier: supNamespaces
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String[]
focal_class.signature: String[] supNamespaces()
focal_class.class_method_signature: JabberIqPrivacy.allowed(Packet packet, XMPPResourceConnection session)
focal_class.full_signature: protected boolean allowed(Packet packet, XMPPResourceConnection session)
focal_class.identifier: allowed
focal_class.modifiers: protected
focal_class.parameters: (Packet packet, XMPPResourceConnection session)
focal_class.return: boolean
focal_class.signature: boolean allowed(Packet packet, XMPPResourceConnection session)
focal_class.class_method_signature: JabberIqPrivacy.allowedByDefault(Packet packet, XMPPResourceConnection session)
focal_class.full_signature: protected boolean allowedByDefault(Packet packet, XMPPResourceConnection session)
focal_class.identifier: allowedByDefault
focal_class.modifiers: protected
focal_class.parameters: (Packet packet, XMPPResourceConnection session)
focal_class.return: boolean
focal_class.signature: boolean allowedByDefault(Packet packet, XMPPResourceConnection session)
focal_class.class_method_signature: JabberIqPrivacy.matchToPrivacyListElement(boolean packetIn, Packet packet, Element elem, ITEM_ACTION action)
focal_class.full_signature: protected boolean matchToPrivacyListElement(boolean packetIn, Packet packet, Element elem, ITEM_ACTION action)
focal_class.identifier: matchToPrivacyListElement
focal_class.modifiers: protected
focal_class.parameters: (boolean packetIn, Packet packet, Element elem, ITEM_ACTION action)
focal_class.return: boolean
focal_class.signature: boolean matchToPrivacyListElement(boolean packetIn, Packet packet, Element elem, ITEM_ACTION action)
focal_class.class_method_signature: JabberIqPrivacy.prepareError(Packet packet, XMPPResourceConnection session)
focal_class.full_signature: protected Packet prepareError(Packet packet, XMPPResourceConnection session)
focal_class.identifier: prepareError
focal_class.modifiers: protected
focal_class.parameters: (Packet packet, XMPPResourceConnection session)
focal_class.return: Packet
focal_class.signature: Packet prepareError(Packet packet, XMPPResourceConnection session)
focal_class.class_method_signature: JabberIqPrivacy.processGetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.full_signature: protected void processGetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.identifier: processGetRequest
focal_class.modifiers: protected
focal_class.parameters: (final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.return: void
focal_class.signature: void processGetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.class_method_signature: JabberIqPrivacy.processSetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.full_signature: protected void processSetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.identifier: processSetRequest
focal_class.modifiers: protected
focal_class.parameters: (final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.return: void
focal_class.signature: void processSetRequest(final Packet packet,
  			final XMPPResourceConnection session, final Queue<Packet> results)
focal_class.class_method_signature: JabberIqPrivacy.validateList(final XMPPResourceConnection session,
  			final List<Element> items)
focal_class.full_signature: public static Authorization validateList(final XMPPResourceConnection session,
  			final List<Element> items)
focal_class.identifier: validateList
focal_class.modifiers: public static
focal_class.parameters: (final XMPPResourceConnection session,
  			final List<Element> items)
focal_class.return: Authorization
focal_class.signature: Authorization validateList(final XMPPResourceConnection session,
  			final List<Element> items)
focal_class.superclass: extends XMPPProcessor
focal_method.body: protected boolean allowed(Packet packet, XMPPResourceConnection session) {
  		try {
  			if (allowedByDefault(packet, session))
  				return true;
  
  			Element list = Privacy.getActiveList(session);
  
  			if ((list == null) ) {
  				list = Privacy.getDefaultList( session );
  			}                  // end of if (lName == null)
  			if (log.isLoggable(Level.FINEST)) {
  				log.log(Level.FINEST, "Using privcy list: {0}", list);
  			}
  			if (list != null) {
  				List<Element> items = list.getChildren();
  
  				if (items != null) {
  					BareJID sessionUserId = session.getBareJID();
  					JID jid = packet.getStanzaFrom();
  					boolean packetIn = true;
  
  					if ((jid == null) || sessionUserId.equals(jid.getBareJID())) {
  						jid = packet.getStanzaTo();
  						packetIn = false;
  					}
  
  					Collections.sort(items, compar);
  					for (Element item : items) {
  						final ITEM_ACTION action = ITEM_ACTION.valueOf(item.getAttributeStaticStr(ACTION));
  						boolean   type_matched = false;
  						boolean   elem_matched = false;
  						ITEM_TYPE type         = ITEM_TYPE.all;
  
  						if (item.getAttributeStaticStr(TYPE) != null) {
  							type = ITEM_TYPE.valueOf(item.getAttributeStaticStr(TYPE));
  						}            // end of if (item.getAttribute(TYPE) != null)
  
  						String  value         = item.getAttributeStaticStr(VALUE);
  						if (jid != null) {
  							switch (type) {
  							case jid :
  								type_matched = jid.toString().contains(value);
  
  								break;
  
  							case group :
  								String[] groups = roster_util.getBuddyGroups(session, jid);
  
  								if (groups != null) {
  									for (String group : groups) {
  										if (type_matched = group.equals(value)) {
  											break;
  										}    // end of if (group.equals(value))
  									}      // end of for (String group: groups)
  								}
  
  								break;
  
  							case subscription :
  								ITEM_SUBSCRIPTIONS subscr = ITEM_SUBSCRIPTIONS.valueOf(value);
  
  								switch (subscr) {
  								case to :
  									type_matched = roster_util.isSubscribedTo(session, jid);
  
  									break;
  
  								case from :
  									type_matched = roster_util.isSubscribedFrom(session, jid);
  
  									break;
  
  								case none :
  									type_matched = (!roster_util.isSubscribedFrom(session, jid) &&
  											!roster_util.isSubscribedTo(session, jid));
  
  									break;
  
  								case both :
  									type_matched = (roster_util.isSubscribedFrom(session, jid) &&
  											roster_util.isSubscribedTo(session, jid));
  
  									break;
  
  								default :
  									break;
  								}    // end of switch (subscr)
  
  								break;
  
  							case all :
  							default :
  								type_matched = true;
  
  								break;
  							}      // end of switch (type)
  						} else {
  							if (type == ITEM_TYPE.all) {
  								type_matched = true;
  							}
  						}        // end of if (from != null) else
  						if (!type_matched) {
  							continue;
  						}        // end of if (!type_matched)
  
  						List<Element> elems = item.getChildren();
  
  						if ((elems == null) || (elems.size() == 0)) {
  							elem_matched = true;
  						} else {
  							for (Element elem : elems) {
  								if (matchToPrivacyListElement(packetIn, packet, elem, action)) {
  									elem_matched = true;
  									break;
  								}
  							}
  						} // end of else
  						if (!elem_matched) {
  							break;
  						}        // end of if (!elem_matched)
  
  						switch (action) {
  						case allow :
  							return true;
  
  						case deny :
  							return false;
  
  						default :
  							break;
  						}        // end of switch (action)
  					}          // end of for (Element item: items)
  				}            // end of if (items != null)
  			}              // end of if (lName != null)
  			// there is no active nor default list, as per XEP-0016 2.2 Business rules
  			// such stanza should be processed normally
  			else {
  				return true;
  			}
  		} catch (NoConnectionIdException e) {
  
  			// Always allow, this is server dummy session
  		} catch (NotAuthorizedException e) {
  
  //    results.offer(Authorization.NOT_AUTHORIZED.getResponseMessage(packet,
  //        "You must authorize session first.", true));
  		} catch (TigaseDBException e) {
  			log.log(Level.WARNING, "Database problem, please notify the admin. {0}", e);
  		}
  
  		return true;
  	}
focal_method.class_method_signature: JabberIqPrivacy.allowed(Packet packet, XMPPResourceConnection session)
focal_method.full_signature: protected boolean allowed(Packet packet, XMPPResourceConnection session)
focal_method.identifier: allowed
focal_method.invocations: allowedByDefault getActiveList getDefaultList isLoggable log getChildren getBareJID getStanzaFrom equals getBareJID getStanzaTo sort valueOf getAttributeStaticStr getAttributeStaticStr valueOf getAttributeStaticStr getAttributeStaticStr contains toString getBuddyGroups equals valueOf isSubscribedTo isSubscribedFrom isSubscribedFrom isSubscribedTo isSubscribedFrom isSubscribedTo getChildren size matchToPrivacyListElement log
focal_method.modifiers: protected
focal_method.parameters: (Packet packet, XMPPResourceConnection session)
focal_method.return: boolean
focal_method.signature: boolean allowed(Packet packet, XMPPResourceConnection session)