public boolean authenticateDomain(OutgoingServerSocketReader socketReader, String id) {

        final Logger log = LoggerFactory.getLogger( Log.getName() + "[Acting as Originating Server: Authenticate domain: " + domainPair.getLocal() + " with a RS in the domain of: " + domainPair.getRemote() + " (id: " + id + ")]" );

        log.debug( "Authenticating domain ..." );

        if (!ServerDialback.isEnabled() && !ServerDialback.isEnabledForSelfSigned()) {
            log.info("Failed to authenticate domain: Dialback has been disabled by configuration.");
            return false;
        }

        String key = AuthFactory.createDigest( id, getSecretkey() );

        synchronized (socketReader) {
            log.debug( "Sending dialback key and wait for the validation response..." );
            sendDialbackKey(key);

            // Process the answer from the Receiving Server
            try {
                while (socketReader.isOpen()) {
                    Element doc = socketReader.getElement(RemoteServerManager.getSocketTimeout(), TimeUnit.MILLISECONDS);
                    if (doc == null) {
                        log.debug( "Failed to authenticate domain: Time out waiting for validation response." );
                        return false;
                    }
                    else if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) {
                        if ( "valid".equals(doc.attributeValue("type")) ) {
                            log.debug( "Authenticated succeeded!" );
                            return true;
                        } else {
                            log.debug( "Failed to authenticate domain: the validation response was received, but did not grant authentication." );
                            return false;
                        }
                    }
                    else {
                        log.warn( "Ignoring unexpected answer while waiting for dialback validation: " + doc.asXML() );
                    }
                }
            }
            catch (InterruptedException e) {
                log.debug( "Failed to authenticate domain: An interrupt was received while waiting for validation response (is Openfire shutting down?)" );
                return false;
            }
            return false;
        }
    }
Authenticates the Originating Server domain with the Receiving Server. Once the domain has
been authenticated the Receiving Server will start accepting packets from the Originating
Server.<p>

The Receiving Server will connect to the Authoritative Server to verify the dialback key.
Most probably the Originating Server machine will be the Authoritative Server too.

@param socketReader the reader to use for reading the answer from the Receiving Server.
@param id the stream id to be used for creating the dialback key.
@return true if the Receiving Server authenticated the domain with the Authoritative Server.
xmppserver/src/main/java/org/jivesoftware/openfire/server/ServerDialback.java