Examples of EntityImpl


Examples of org.apache.vysper.xmpp.addressing.EntityImpl

    protected AbstractStanzaGenerator getDefaultStanzaGenerator() {
        return new DefaultModifyAffiliationsStanzaGenerator("Node1", client3, PubSubAffiliation.PUBLISHER);
    }

    public void testModifyAffiliationsNoAuth() {
        Entity client2 = new EntityImpl("yoda", "starwars.com", null);

        AbstractStanzaGenerator sg = new DefaultModifyAffiliationsStanzaGenerator("Node1", client, PubSubAffiliation.MEMBER);
        Stanza stanza = sg.getStanza(client2, pubsubService, "id123", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

        String testNode = "test";
        LeafNode node = new LeafNode(serviceConfiguration, testNode, client);
        root.add(node);
       
        node.subscribe("someid", client); // make the owner subscriber
        node.subscribe("otherid1", new EntityImpl("yoda", "starwars.com", "spaceship"));
        node.subscribe("otherid2", new EntityImpl("r2d2", "starwars.com", "desert"));
        node.subscribe("otherid3", new EntityImpl("anakin", "starwars.com", "deathstar"));
       
        assertNotNull(root.find(testNode));
        // make sure we have 4 subscribers
        assertEquals(4, node.countSubscriptions());
       
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

    public void testDeleteNotAuth() throws Exception {
        String testNode = "test";
        root.add(new LeafNode(serviceConfiguration, testNode, client));
       
        assertNotNull(root.find(testNode));
        Entity clientNotAuthorized = new EntityImpl("darthvader", "deathstar.tld", null);
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(clientNotAuthorized, pubsubService, "id123", testNode);
        ResponseStanzaContainer result = sendStanza(stanza, true);
        assertTrue(result.hasResponse());
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

     * @return The JID of the sender, either from the stanza or the context. A bare JID is returned if no, or more than one resource is bound.
     */
    public static Entity extractSenderJID(XMPPCoreStanza stanza, SessionContext sessionContext) {
        Entity from = stanza.getFrom();
        if (from == null) {
            from = new EntityImpl(sessionContext.getInitiatingEntity(),
                    sessionContext.getServerRuntimeContext().getResourceRegistry().getUniqueResourceForSession(sessionContext));
        }
        return from;
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

        if (resourceId == null) {
            logger.warn("no 'from' attribute, and cannot uniquely determine sending resource for initiating entity {} in session {}", initiatingEntity.getFullQualifiedName(), sessionContext.getSessionId());
            return null;
        }
       
        return new EntityImpl(initiatingEntity, resourceId);
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

            resourceId = sessionContext.bindResource();
        } catch (BindException e) {
            return bindError(stanza, sessionContext);
        }

        Entity entity = new EntityImpl(sessionContext.getInitiatingEntity(), resourceId);

        StanzaBuilder stanzaBuilder =
            StanzaBuilder.createIQStanza(null, null, IQStanzaType.RESULT, stanza.getID()).
            startInnerElement("bind", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND).
                    startInnerElement("jid", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND).
                    addText(entity.getFullQualifiedName()).endInnerElement().
            endInnerElement();

        return stanzaBuilder.build();
    }
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

        Stanza responseStanza = null;
        if (clientCall) {
            // RFC3920: 'to' attribute SHOULD be used by the initiating entity
            String toValue = stanza.getAttributeValue("to");
            if (toValue != null) {
                EntityImpl toEntity = null;
                try {
                    toEntity = EntityImpl.parse(toValue);
                } catch (EntityFormatException e) {
                    return new ResponseStanzaContainerImpl(
                            ServerErrorResponses.getInstance().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().getStreamOpener(clientCall,
                    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) {
                EntityImpl entity = null;
                try {
                    entity = EntityImpl.parse(fromValue);
                } catch (EntityFormatException e) {
                    return new ResponseStanzaContainerImpl(
                                ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.INVALID_FROM,
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

        dictionaries.add(new org.apache.vysper.xmpp.modules.core.session.SessionStanzaDictionary());
        dictionaries.add(new org.apache.vysper.xmpp.modules.core.compatibility.jabber_iq_auth.JabberIQAuthDictionary());
        dictionaries.add(new org.apache.vysper.xmpp.modules.roster.RosterDictionary());
       
        DefaultServerRuntimeContext serverContext = new DefaultServerRuntimeContext(
                new EntityImpl(null, "test", null),
                relay,
                new ServerFeatures(),
                dictionaries,
                new ResourceRegistry());
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

            Entity from = stanza.getFrom();
            if (from == null || !from.isResourceSet()) {
                // rewrite stanza with new from
                String resource = serverRuntimeContext.getResourceRegistry().getUniqueResourceForSession(sessionContext);
                if (resource == null) throw new IllegalStateException("could not determine unique resource");
                from = new EntityImpl(sessionContext.getInitiatingEntity(), resource);
                StanzaBuilder stanzaBuilder = new StanzaBuilder(stanza.getName());
                for (Attribute attribute : stanza.getAttributes()) {
                    if ("from".equals(attribute.getName())) continue;
                    stanzaBuilder.addAttribute(attribute);
                }
View Full Code Here

Examples of org.apache.vysper.xmpp.addressing.EntityImpl

    public void testSimpleRelay() throws EntityFormatException, XMLSemanticError, DeliveryException {
        DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(null, null);
        stanzaRelay.setServerRuntimeContext(serverRuntimeContext);
       
        EntityImpl fromEntity = EntityImpl.parse("userFrom@vysper.org");
        EntityImpl toEntity = EntityImpl.parse("userTo@vysper.org");
        TestSessionContext sessionContext = TestSessionContext.createSessionContext(toEntity);
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        resourceRegistry.bindSession(sessionContext);

        Stanza stanza = StanzaBuilder.createMessageStanza(fromEntity, toEntity, "en", "Hello").build();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.