public void execute()

in server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0220_server_dailback/DbVerifyHandler.java [62:125]


    public void execute(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza,
            SessionContext sessionContext, SessionStateHolder sessionStateHolder, StanzaBroker stanzaBroker) {

        String type = stanza.getAttributeValue("type");
        String id = stanza.getAttributeValue("id");
        Entity receiving = EntityImpl.parseUnchecked(stanza.getAttributeValue("from"));
        Entity originating = serverRuntimeContext.getServerEntity();
        if (type == null) {
            // acting as a Authoritative server
            // getting asked for verification from the Receiving server
            String dailbackId = stanza.getInnerText().getText();

            StanzaBuilder builder = new StanzaBuilder("verify", NamespaceURIs.JABBER_SERVER_DIALBACK, "db");
            builder.addAttribute("from", originating.getDomain());
            builder.addAttribute("to", receiving.getDomain());
            builder.addAttribute("id", id);

            if (dailbackIdGenerator.verify(dailbackId, receiving, originating, id)) {
                builder.addAttribute("type", "valid");
            } else {
                builder.addAttribute("type", "invalid");
            }
            stanzaBroker.writeToSession(builder.build());
            return;
        } else {
            // acting as a Receiving server
            // getting a response from the Authoritative server
            SessionStateHolder dialbackSessionStateHolder = (SessionStateHolder) sessionContext
                    .getAttribute("DIALBACK_SESSION_STATE_HOLDER");
            SessionContext dialbackSessionContext = (SessionContext) sessionContext
                    .getAttribute("DIALBACK_SESSION_CONTEXT");

            // XMPPServerConnector connector =
            // serverRuntimeContext.getServerConnectorRegistry().getConnectorBySessionId(id);

            // if(connector != null) {
            // SessionStateHolder dialbackSessionStateHolder =
            // connector.getSessionStateHolder();
            // SessionContext dialbackSessionContext = connector.getSessionContext();

            Entity otherServer = sessionContext.getInitiatingEntity();
            String resultType = "invalid";
            // dialbackSessionContext must be non-null or someone is trying to send this
            // stanza in the wrong state
            if ("valid".equals(type)) {
                dialbackSessionStateHolder.setState(SessionState.AUTHENTICATED);
                dialbackSessionContext.setInitiatingEntity(otherServer);
                resultType = "valid";
            }

            // <db:result xmlns:db="jabber:server:dialback" to="xmpp.protocol7.com"
            // from="jabber.org" type="valid"></db:result>
            StanzaBuilder builder = new StanzaBuilder("result", NamespaceURIs.JABBER_SERVER_DIALBACK, "db");
            builder.addAttribute("from", originating.getDomain());
            builder.addAttribute("to", otherServer.getDomain());
            builder.addAttribute("type", resultType);

            stanzaBroker.writeToSession(builder.build());
            // }

            // close this session as we are now done checking dialback
            sessionContext.endSession(SessionTerminationCause.CLIENT_BYEBYE);
        }
    }