class Socks5IqHandler extends DefaultIQHandler {

    @Override
    protected List<Stanza> handleSet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext, StanzaBroker stanzaBroker) {
        /*
            C: <iq from='requester@example.com/foo'
                    id='oqx6t1c9'
                    to='streamer.example.com'
                    type='set'>
                  <query xmlns='http://jabber.org/protocol/bytestreams'
                     sid='vxf9n471bn46'>
                    <activate>target@example.org/bar</activate>
                  </query>
               </iq>
               
            S: <iq from='streamer.example.com'
                    id='oqx6t1c9'
                    to='requester@example.com/foo'
                    type='result'/>
                    
                    
            SHA1 Hash of: (SID + Requester JID + Target JID)
         */
        
        try {
            XMLElement queryElm = stanza.getSingleInnerElementsNamed("query", NamespaceURIs.XEP0065_SOCKS5_BYTESTREAMS);
            XMLElement activateElm = queryElm.getSingleInnerElementsNamed("activate", NamespaceURIs.XEP0065_SOCKS5_BYTESTREAMS);
            
            String sid = queryElm.getAttributeValue("sid");
            
            Entity target = EntityImpl.parse(activateElm.getInnerText().getText());
            
            Entity requester = stanza.getFrom();
            
            String hash = DigestUtils.shaHex(sid + requester.getFullQualifiedName() + target.getFullQualifiedName());
            
            if(connections.activate(hash)) {
                Stanza result = StanzaBuilder.createIQStanza(jid, requester, IQStanzaType.RESULT, stanza.getID()).build();
                return Collections.singletonList(result);
            } else {
                throw new RuntimeException("Pair not found");
            }
        } catch(Exception e) {
            return Collections.singletonList(ServerErrorResponses.getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza, StanzaErrorType.CANCEL, null, null, null));
        }
    }

    public  Socks5IqHandler(Entity jid, InetSocketAddress proxyAddress, Socks5ConnectionsRegistry connections);

}