Package org.apache.vysper.xmpp.protocol

Examples of org.apache.vysper.xmpp.protocol.ResponseStanzaContainerImpl


            if(startTlsSupported(stanza) && serverRuntimeContext.getSslContext() != null) {
                // remote server support TLS and we got keys set up
                LOG.info("XMPP server connector to {} is starting TLS", otherServer);
                Stanza startTlsStanza = new StanzaBuilder("starttls", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_TLS).build();
               
                return new ResponseStanzaContainerImpl(startTlsStanza);
            } else if(dialbackSupported(stanza)) {
                Entity originating = serverRuntimeContext.getServerEnitity();

                String dailbackId = new DialbackIdGenerator().generate(otherServer, originating, sessionContext.getSessionId());
               
                Stanza dbResult = new StanzaBuilder("result", NamespaceURIs.JABBER_SERVER_DIALBACK, "db")
                    .addAttribute("from", originating.getDomain())
                    .addAttribute("to", otherServer.getDomain())
                    .addText(dailbackId)
                    .build();
               
                return new ResponseStanzaContainerImpl(dbResult);
            } else {
                // TODO how to handle
                throw new RuntimeException("Unsupported features");
            }
        }
View Full Code Here


            } catch (Exception e) {
                StanzaBuilder builder = new StanzaBuilder("result", NamespaceURIs.JABBER_SERVER_DIALBACK, "db");
                builder.addAttribute("from", originating.getDomain());
                builder.addAttribute("to", receiving.getDomain());
                builder.addAttribute("type", "invalid");
                return new ResponseStanzaContainerImpl(builder.build());
            }
        } else {
            // acting as the Originating server
            // receiving the result from the Receiving server
            if("valid".equals(type)) {
View Full Code Here

        }

        Entity to = stanza.getTo();
        if (sessionContext != null && sessionContext.isServerToServer() && to == null) {
            // "to" MUST be present for jabber:server
            return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                    StreamErrorCondition.IMPROPER_ADDRESSING, stanza.getXMLLang(), "missing to attribute", null));
        }

        if (to != null) {
            // TODO ensure, that RFC3920 9.1.1 "If the value of the 'to' attribute is invalid or cannot be contacted..." is enforced
        }

        Stanza responseStanza = executeCore(stanza, serverRuntimeContext, isOutboundStanza, sessionContext);

        if (responseStanza != null)
            return new ResponseStanzaContainerImpl(responseStanza);

        return null;
    }
View Full Code Here

            if(dailbackIdGenerator.verify(dailbackId, receiving, originating, id)) {
                builder.addAttribute("type", "valid");
            } else {
                builder.addAttribute("type", "invalid");
            }
            return new ResponseStanzaContainerImpl(builder.build());
        } 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");
View Full Code Here

        return executeWorker(stanza, sessionContext, sessionStateHolder);
    }

    protected ResponseStanzaContainer respondSASLFailure() {
        return new ResponseStanzaContainerImpl(ServerErrorResponses.getSASLFailure(
                SASLFailureType.MALFORMED_REQUEST));
    }
View Full Code Here

            String toValue = stanza.getAttributeValue("to");
            if (toValue != null) {
                try {
                    EntityImpl.parse(toValue);
                } catch (EntityFormatException e) {
                    return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                            StreamErrorCondition.IMPROPER_ADDRESSING, sessionContext.getXMLLang(),
                            "could not parse incoming stanza's TO attribute", null));

                }
                // TODO check if toEntity is served by this server
                // if (!server.doesServe(toEntity)) throw WhateverException();

                // TODO RFC3920: 'from' attribute SHOULD be silently ignored by the receiving entity
                // TODO RFC3920bis: 'from' attribute SHOULD be not ignored by the receiving entity and used as 'to' in responses
            }
            responseStanza = new ServerResponses().getStreamOpenerForClient(sessionContext.getServerJID(),
                    responseVersion, sessionContext);
        } else if (serverCall) {
            // RFC3920: 'from' attribute SHOULD be used by the receiving entity
            String fromValue = stanza.getAttributeValue("from");
            if (fromValue != null) {
                try {
                    EntityImpl.parse(fromValue);
                } catch (EntityFormatException e) {
                    return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                            StreamErrorCondition.INVALID_FROM, sessionContext.getXMLLang(),
                            "could not parse incoming stanza's FROM attribute", null));
                }
            }

            responseStanza = new ServerResponses().getStreamOpenerForServerAcceptor(sessionContext.getServerJID(),
                    responseVersion, sessionContext, serverRuntimeContext.getSslContext() != null);
        } else {
            String descriptiveText = "one of the two namespaces must be present: " + NamespaceURIs.JABBER_CLIENT
                    + " or " + NamespaceURIs.JABBER_SERVER;
            return respondIllegalNamespaceError(descriptiveText);
        }

        // if all is correct, go to next phase
        switch (sessionStateHolder.getState()) {

        case AUTHENTICATED:
        case ENCRYPTED:
            // do not change state!
            break;
        default:
            sessionStateHolder.setState(SessionState.STARTED);
        }

        if (responseStanza != null)
            return new ResponseStanzaContainerImpl(responseStanza);

        return null;
    }
View Full Code Here

        return null;
    }

    private ResponseStanzaContainer respondIllegalNamespaceError(String descriptiveText) {
        return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                StreamErrorCondition.INVALID_NAMESPACE, null, descriptiveText, null));
    }
View Full Code Here

        // if all is correct, go to next phase
        sessionStateHolder.setState(SessionState.ENCRYPTION_STARTED);

        sessionContext.switchToTLS(true, false);

        return new ResponseStanzaContainerImpl(responseStanza);
    }
View Full Code Here

        return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                StreamErrorCondition.INVALID_NAMESPACE, null, descriptiveText, null));
    }

    private ResponseStanzaContainer respondUnsupportedStanzaType(String descriptiveText) {
        return new ResponseStanzaContainerImpl(ServerErrorResponses.getStreamError(
                StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, null, descriptiveText, null));
    }
View Full Code Here

        return new ResponseStanzaContainerImpl(responseStanza);
    }

    private ResponseStanzaContainer respondTLSFailure() {
        return new ResponseStanzaContainerImpl(ServerErrorResponses.getTLSFailure());
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.protocol.ResponseStanzaContainerImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.