Package org.apache.vysper.xmpp.addressing

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


                contactJidString = node.getName();
            } catch (RepositoryException e) {
                logger.warn("when loading roster for user {} cannot read node name for node id = " + node.toString());
            }
            logger.warn("try now loading contact " + contactJidString + " from node " + node.toString());
            EntityImpl contactJid = null;
            if (contactJidString != null) {
                try {
                    contactJid = EntityImpl.parse(contactJidString);
                } catch (EntityFormatException e) {
                    logger.warn("when loading roster for user {} parsing  contact jid {}", bareJid, contactJidString);
                }
            }
            if (contactJid == null) {
                logger.warn("when loading roster for user {}, skipping a contact due to missing or unparsable jid", bareJid);
                continue;
            }

            String name = readAttribute(node, "name");
            String typeString = readAttribute(node, "type");
            SubscriptionType subscriptionType = null;
            try {
                subscriptionType = SubscriptionType.valueOf(typeString == null ? "NONE" : typeString.toUpperCase());
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid + ", contact " + contactJid + " misses a subscription type", bareJid, contactJid);
            }
            String askTypeString = readAttribute(node, "askType");
            AskSubscriptionType askSubscriptionType = AskSubscriptionType.NOT_SET;
            try {
                if (askTypeString != null) askSubscriptionType = AskSubscriptionType.valueOf(askTypeString);
            } catch (IllegalArgumentException e) {
                logger.warn("when loading roster for user " + bareJid.getFullQualifiedName() + ", contact " + contactJid.getFullQualifiedName() + ", the ask subscription type is unparsable. skipping!");
                continue; // don't return it, don't set a default!
            }

            List<RosterGroup> groups = new ArrayList<RosterGroup>();
            // TODO read groups
View Full Code Here


    private void pushRosterItemToInterestedResources(SessionContext sessionContext, Entity user, RosterItem rosterItem) {
        ResourceRegistry registry = sessionContext.getServerRuntimeContext().getResourceRegistry();
        List<String> resources = registry.getInterestedResources(user.getBareJID());
        for (String resource : resources) {
            Entity userResource = new EntityImpl(user, resource);
            Stanza push = RosterStanzaUtils.createRosterItemPushIQ(userResource, sessionContext.nextSequenceValue(), rosterItem);
            LocalDeliveryUtils.relayToResourceDirectly(registry, resource, push);
        }
    }
View Full Code Here

    protected Entity client3 = null;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        client2 = new EntityImpl("user1", "vysper.org", null);
        client3 = new EntityImpl("user2", "vysper.org", null);

        n1 = new LeafNode(serviceConfiguration, "Node1", "Node 1 used for testing purposes", client);
        n1.setAffiliation(client2, PubSubAffiliation.MEMBER);
       
        root.add(n1);
View Full Code Here

    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

        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

    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

     * @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

        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

            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

        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

TOP

Related Classes of org.apache.vysper.xmpp.addressing.EntityImpl

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.