test_class.declarator: dialback = new Dialback() {
  
  		@Override
  		public boolean skipTLSForHost(String hostname) {
  			return true;
  		}
  
  		@Override
  		protected boolean wasVerifyRequested(S2SIOService serv, String domain) {
  			return true;
  		}
  		
  	}
test_class.modifier: private
test_class.original_string: private Dialback dialback = new Dialback() {
  
  		@Override
  		public boolean skipTLSForHost(String hostname) {
  			return true;
  		}
  
  		@Override
  		protected boolean wasVerifyRequested(S2SIOService serv, String domain) {
  			return true;
  		}
  		
  	};
test_class.type: Dialback
test_class.var_name: dialback
test_class.declarator: handler = null
test_class.modifier: private
test_class.original_string: private S2SConnectionHandlerIfc<S2SIOService> handler = null;
test_class.type: S2SConnectionHandlerIfc<S2SIOService>
test_class.var_name: handler
test_class.declarator: remote1 = "remote1.com"
test_class.modifier: private
test_class.original_string: private String remote1 = "remote1.com";
test_class.type: String
test_class.var_name: remote1
test_class.declarator: remote2 = "remote2.com"
test_class.modifier: private
test_class.original_string: private String remote2 = "remote2.com";
test_class.type: String
test_class.var_name: remote2
test_class.declarator: local = "local.com"
test_class.modifier: private
test_class.original_string: private String local = "local.com";
test_class.type: String
test_class.var_name: local
test_class.file: tigase-server 7.1.0/src/test/java/tigase/server/xmppserver/proc/DialbackTest.java
test_class.identifier: DialbackTest
test_class.superclass: extends TestCase
test_case.body: @Test
  	public void testAuthorizationForSingleDomain() throws TigaseStringprepException {
  		Queue<Packet> results = new ArrayDeque<>();
  		handler = new S2SConnectionHandlerImpl(results);
  		dialback.init(handler, new HashMap());
  		
  		String key = UUID.randomUUID().toString();
  		
  		S2SIOService serv = new S2SIOService();
  		serv.setSessionId("sess-id-1");
  		Map<String,Object> props = new HashMap<>();
  		props.put(PORT_TYPE_PROP_KEY, "accept");
  		serv.setSessionData(props);
  
  		Packet p = null;
  		
  		Element resultEl = new Element("db:result");
  		resultEl.setXMLNS(Dialback.XMLNS_DB_VAL);
  		resultEl.setAttribute("from", remote1);
  		resultEl.setAttribute("to", local);
  		resultEl.setCData(key);
  		p = Packet.packetInstance(resultEl);
  		dialback.process(p, serv, results);
  		
  		Packet r = results.poll();
  		resultEl = new Element("db:verify");
  		resultEl.setXMLNS(Dialback.XMLNS_DB_VAL);
  		resultEl.setAttribute("id", r.getAttributeStaticStr("id"));
  		resultEl.setAttribute("from", r.getAttributeStaticStr("to"));
  		resultEl.setAttribute("to", r.getAttributeStaticStr("from"));
  		resultEl.setAttribute("type", "valid");
  		p = Packet.packetInstance(resultEl);
  		dialback.process(p, serv, results);
  		
  		p = results.poll();
  		assertTrue(p.getType() == StanzaType.valid && remote1.equals(p.getStanzaTo().getDomain()));
  		
  		serv.getCIDs().forEach((CID cid) -> assertEquals(remote1, cid.getRemoteHost()));
  	}
test_case.class_method_signature: DialbackTest.testAuthorizationForSingleDomain()
test_case.full_signature: @Test public void testAuthorizationForSingleDomain()
test_case.identifier: testAuthorizationForSingleDomain
test_case.invocations: init toString randomUUID setSessionId put setSessionData setXMLNS setAttribute setAttribute setCData packetInstance process poll setXMLNS setAttribute getAttributeStaticStr setAttribute getAttributeStaticStr setAttribute getAttributeStaticStr setAttribute packetInstance process poll assertTrue getType equals getDomain getStanzaTo forEach getCIDs assertEquals getRemoteHost
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAuthorizationForSingleDomain()
focal_class.declarator: log                =
  		Logger.getLogger(Dialback.class.getName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log                =
  		Logger.getLogger(Dialback.class.getName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: features_required =
  		new Element("dialback", new Element[] { new Element("required") },
  								new String[] { "xmlns" }, new String[] { "urn:xmpp:features:dialback" })
focal_class.modifier: private static final
focal_class.original_string: private static final Element features_required =
  		new Element("dialback", new Element[] { new Element("required") },
  								new String[] { "xmlns" }, new String[] { "urn:xmpp:features:dialback" });
focal_class.type: Element
focal_class.var_name: features_required
focal_class.declarator: features = new Element("dialback",
  																						new String[] { "xmlns" },
  																						new String[] {
  																							"urn:xmpp:features:dialback" })
focal_class.modifier: private static final
focal_class.original_string: private static final Element features = new Element("dialback",
  																						new String[] { "xmlns" },
  																						new String[] {
  																							"urn:xmpp:features:dialback" });
focal_class.type: Element
focal_class.var_name: features
focal_class.declarator: REQUESTED_RESULT_DOMAINS_KEY =
  		"requested-result-domains-key"
focal_class.modifier: private static final
focal_class.original_string: private static final String REQUESTED_RESULT_DOMAINS_KEY =
  		"requested-result-domains-key";
focal_class.type: String
focal_class.var_name: REQUESTED_RESULT_DOMAINS_KEY
focal_class.declarator: authenticationTimeOut = 30
focal_class.modifier: private
focal_class.original_string: private long authenticationTimeOut = 30;
focal_class.type: long
focal_class.var_name: authenticationTimeOut
focal_class.declarator: ejabberd_bug_workaround_active = false
focal_class.modifier: private
focal_class.original_string: private boolean ejabberd_bug_workaround_active = false;
focal_class.type: boolean
focal_class.var_name: ejabberd_bug_workaround_active
focal_class.file: tigase-server 7.1.0/src/main/java/tigase/server/xmppserver/proc/Dialback.java
focal_class.identifier: Dialback
focal_class.class_method_signature: Dialback.Dialback()
focal_class.full_signature: public  Dialback()
focal_class.identifier: Dialback
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  Dialback()
focal_class.class_method_signature: Dialback.order()
focal_class.full_signature: @Override public int order()
focal_class.identifier: order
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int order()
focal_class.class_method_signature: Dialback.process(Packet p, S2SIOService serv, Queue<Packet> results)
focal_class.full_signature: @Override public boolean process(Packet p, S2SIOService serv, Queue<Packet> results)
focal_class.identifier: process
focal_class.modifiers: @Override public
focal_class.parameters: (Packet p, S2SIOService serv, Queue<Packet> results)
focal_class.return: boolean
focal_class.signature: boolean process(Packet p, S2SIOService serv, Queue<Packet> results)
focal_class.class_method_signature: Dialback.serviceStarted(S2SIOService serv)
focal_class.full_signature: @Override public void serviceStarted(S2SIOService serv)
focal_class.identifier: serviceStarted
focal_class.modifiers: @Override public
focal_class.parameters: (S2SIOService serv)
focal_class.return: void
focal_class.signature: void serviceStarted(S2SIOService serv)
focal_class.class_method_signature: Dialback.streamFeatures(S2SIOService serv, List<Element> results)
focal_class.full_signature: @Override public void streamFeatures(S2SIOService serv, List<Element> results)
focal_class.identifier: streamFeatures
focal_class.modifiers: @Override public
focal_class.parameters: (S2SIOService serv, List<Element> results)
focal_class.return: void
focal_class.signature: void streamFeatures(S2SIOService serv, List<Element> results)
focal_class.class_method_signature: Dialback.streamOpened(S2SIOService serv, Map<String, String> attribs)
focal_class.full_signature: @Override public String streamOpened(S2SIOService serv, Map<String, String> attribs)
focal_class.identifier: streamOpened
focal_class.modifiers: @Override public
focal_class.parameters: (S2SIOService serv, Map<String, String> attribs)
focal_class.return: String
focal_class.signature: String streamOpened(S2SIOService serv, Map<String, String> attribs)
focal_class.class_method_signature: Dialback.initDialback(S2SIOService serv, String remote_id)
focal_class.full_signature: private void initDialback(S2SIOService serv, String remote_id)
focal_class.identifier: initDialback
focal_class.modifiers: private
focal_class.parameters: (S2SIOService serv, String remote_id)
focal_class.return: void
focal_class.signature: void initDialback(S2SIOService serv, String remote_id)
focal_class.class_method_signature: Dialback.processDialback(Packet p, S2SIOService serv)
focal_class.full_signature: private void processDialback(Packet p, S2SIOService serv)
focal_class.identifier: processDialback
focal_class.modifiers: private
focal_class.parameters: (Packet p, S2SIOService serv)
focal_class.return: void
focal_class.signature: void processDialback(Packet p, S2SIOService serv)
focal_class.class_method_signature: Dialback.addToResultRequested(S2SIOService serv, String domain)
focal_class.full_signature: @SuppressWarnings("unchecked") private void addToResultRequested(S2SIOService serv, String domain)
focal_class.identifier: addToResultRequested
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (S2SIOService serv, String domain)
focal_class.return: void
focal_class.signature: void addToResultRequested(S2SIOService serv, String domain)
focal_class.class_method_signature: Dialback.wasResultRequested(S2SIOService serv, String domain)
focal_class.full_signature: @SuppressWarnings("unchecked") protected boolean wasResultRequested(S2SIOService serv, String domain)
focal_class.identifier: wasResultRequested
focal_class.modifiers: @SuppressWarnings("unchecked") protected
focal_class.parameters: (S2SIOService serv, String domain)
focal_class.return: boolean
focal_class.signature: boolean wasResultRequested(S2SIOService serv, String domain)
focal_class.class_method_signature: Dialback.wasVerifyRequested(S2SIOService serv, String domain)
focal_class.full_signature: protected boolean wasVerifyRequested(S2SIOService serv, String domain)
focal_class.identifier: wasVerifyRequested
focal_class.modifiers: protected
focal_class.parameters: (S2SIOService serv, String domain)
focal_class.return: boolean
focal_class.signature: boolean wasVerifyRequested(S2SIOService serv, String domain)
focal_class.superclass: extends S2SAbstractProcessor
focal_method.body: @Override
  	public boolean process(Packet p, S2SIOService serv, Queue<Packet> results) {
  		CID cid         = (CID) serv.getSessionData().get("cid");
  		boolean skipTLS = (cid == null)
  											? false
  											: skipTLSForHost(cid.getRemoteHost());
  
  		// If this is a dialback packet, process it accordingly
  		if (p.getXMLNS() == XMLNS_DB_VAL) {
  			if (log.isLoggable(Level.FINEST)) {
  				log.log(Level.FINEST, "{0}, Processing dialback packet: {1}", new Object[] { serv,
  								p });
  			}
  			processDialback(p, serv);
  
  			return true;
  		}
  
  		// If this is stream features, then it depends....
  		if (p.isElement(FEATURES_EL, FEATURES_NS)) {
  			if (log.isLoggable(Level.FINEST)) {
  				log.log(Level.FINEST, "{0}, Stream features received packet: {1}",
  								new Object[] { serv,
  															 p });
  			}
  
  			CertCheckResult certCheckResult =
  				(CertCheckResult) serv.getSessionData().get(S2SIOService.CERT_CHECK_RESULT);
  
  			if (log.isLoggable(Level.FINEST)) {
  				log.log(Level.FINEST, "{0}, TLS Certificate check: {1}, packet: {2}",
  								new Object[] { serv,
  															 certCheckResult, p });
  			}
  
  			// If TLS is not yet started (announced in stream features) then it is not
  			// the right time for dialback yet
  			// Some servers send starttls in stream features, even if TLS is already
  			// initialized....
  			if (p.isXMLNSStaticStr(FEATURES_STARTTLS_PATH, START_TLS_NS) &&
  					(certCheckResult == null) &&!skipTLS) {
  				if (log.isLoggable(Level.FINEST)) {
  					log.log(Level.FINEST, "{0}, Waiting for starttls, packet: {1}",
  									new Object[] { serv,
  																 p });
  				}
  
  				return true;
  			}
  
  			// If TLS has been started and it is a trusted peer, we do not need
  			// dialback here
  			// but... sometimes the remote server may request dialback anyway,
  			// especially if they
  			// do not trust us.
  			if ((certCheckResult == CertCheckResult.trusted) &&
  					!(p.isXMLNSStaticStr(FEATURES_DIALBACK_PATH, DIALBACK_NS))) {
  				if (ejabberd_bug_workaround_active) {
  					if (log.isLoggable(Level.FINEST)) {
  						log.log(
  								Level.FINEST,
  								"{0}, Ejabberd bug workaround active, proceeding to dialback anyway, packet: {1}",
  								new Object[] { serv,
  															 p });
  					}
  				} else {
  					if (log.isLoggable(Level.FINEST)) {
  						log.log(
  								Level.FINEST,
  								"{0}, TLS trusted peer, no dialback needed or requested, packet: {1}",
  								new Object[] { serv,
  															 p });
  					}
  
  					CIDConnections cid_conns;
  
  					try {
  						cid_conns = handler.getCIDConnections(cid, true);
  						cid_conns.connectionAuthenticated(serv, cid);
  					} catch (NotLocalhostException ex) {
  
  						// Should not happen....
  						log.log(Level.INFO, "{0}, Incorrect local hostname, packet: {1}",
  										new Object[] { serv,
  																	 p });
  						serv.forceStop();
  					} catch (LocalhostException ex) {
  
  						// Should not happen....
  						log.log(Level.INFO, "{0}, Incorrect remote hostname name, packet: {1}",
  										new Object[] { serv,
  																	 p });
  						serv.stop();
  					}
  
  					return true;
  				}
  			}
  
  			// we need to check if TLS is required
  			if (!skipTLS && cid != null && !serv.getSessionData().containsKey("TLS") 
  					&& handler.isTlsRequired(cid.getLocalHost())) {
  				log.log(Level.FINER, "{0}, TLS is required for domain {1} but STARTTLS was not "
  						+ "offered by {2} - policy-violation", new Object[] { serv, 
  							cid.getLocalHost(), cid.getRemoteHost() });
  				serv.forceStop();
  				return true;
  			}
  			
  			// Nothing else can be done right now except the dialback
  			if (log.isLoggable(Level.FINEST)) {
  				log.log(Level.FINEST, "{0}, Initializing dialback, packet: {1}",
  								new Object[] { serv,
  															 p });
  			}
  			initDialback(serv, serv.getSessionId());
  		}
  
  		return false;
  	}
focal_method.class_method_signature: Dialback.process(Packet p, S2SIOService serv, Queue<Packet> results)
focal_method.full_signature: @Override public boolean process(Packet p, S2SIOService serv, Queue<Packet> results)
focal_method.identifier: process
focal_method.invocations: get getSessionData skipTLSForHost getRemoteHost getXMLNS isLoggable log processDialback isElement isLoggable log get getSessionData isLoggable log isXMLNSStaticStr isLoggable log isXMLNSStaticStr isLoggable log isLoggable log getCIDConnections connectionAuthenticated log forceStop log stop containsKey getSessionData isTlsRequired getLocalHost log getLocalHost getRemoteHost forceStop isLoggable log initDialback getSessionId
focal_method.modifiers: @Override public
focal_method.parameters: (Packet p, S2SIOService serv, Queue<Packet> results)
focal_method.return: boolean
focal_method.signature: boolean process(Packet p, S2SIOService serv, Queue<Packet> results)