Package org.apache.vysper.xmpp.addressing

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


                    StanzaErrorType.CANCEL,
                    "cannot retrieve IQ-get-items result from internal components",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        Entity to = stanza.getTo();
        boolean isServerInfoRequest = false;
        boolean isComponentInfoRequest = false;
        if (to == null) {
            isServerInfoRequest = true; // this can only be meant to query the server
        } else if (!to.isNodeSet()) {
            isServerInfoRequest = serverRuntimeContext.getServerEnitity().equals(to);
            isComponentInfoRequest = serverRuntimeContext.getComponentStanzaProcessor(to.getDomain()) != null;
            if (!isServerInfoRequest && !isComponentInfoRequest) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND, stanza,
                        StanzaErrorType.CANCEL,
                        "server does not handle items query requests for " + to.getFullQualifiedName(),
                        getErrorLanguage(serverRuntimeContext, sessionContext), null);
            }
        }

        XMLElement queryElement = stanza.getFirstInnerElement();
View Full Code Here


        return verifyInnerElementWorker(stanza, "vCard");
    }

    @Override
    protected Stanza handleSet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        Entity from = stanza.getFrom();
        if (from == null) {
            from = sessionContext.getInitiatingEntity();
        }

        XMLElement vCardElement = null;
View Full Code Here

    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {

        Entity to = stanza.getTo();
        Entity from = stanza.getFrom();

        if (from == null) {
            from = sessionContext.getInitiatingEntity();
        }

        Entity requestedCard = to != null ? to.getBareJID() : from.getBareJID(); // no from? return own vcard

        String vcardXml = null;
        if (persistenceManager != null) {
            vcardXml =  persistenceManager.getVcard(requestedCard);
        }
View Full Code Here

            , @SpecCompliant(spec="xep-0060", section="6.1.3.11", status= SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE)
        })
    protected Stanza handleSet(IQStanza stanza,
            ServerRuntimeContext serverRuntimeContext,
            SessionContext sessionContext) {
        Entity serverJID = serviceConfiguration.getServerJID();
        CollectionNode root = serviceConfiguration.getRootNode();
       
        Entity sender = extractSenderJID(stanza, sessionContext);
        Entity subJID = null;

        String iqStanzaID = stanza.getAttributeValue("id");

        StanzaBuilder sb = StanzaBuilder.createIQStanza(serverJID, sender, IQStanzaType.RESULT, iqStanzaID);
        sb.startInnerElement("pubsub", NamespaceURIs.XEP0060_PUBSUB);

        XMLElement sub = stanza.getFirstInnerElement().getFirstInnerElement(); // pubsub/subscribe
        String strSubJID = sub.getAttributeValue("jid"); // MUST

        try {
            subJID = EntityImpl.parse(strSubJID);
        } catch (EntityFormatException e) {
            return errorStanzaGenerator.generateJIDMalformedErrorStanza(sender, serverJID, stanza);
        }

        if(!sender.getBareJID().equals(subJID.getBareJID())) {
            // error condition 1 (6.1.3)
            return errorStanzaGenerator.generateJIDDontMatchErrorStanza(sender, serverJID, stanza);
        }

        String nodeName = extractNodeName(stanza);
View Full Code Here

     * @param subscriptionID the subscription ID of the JID.
     * @param subscriber the JID of the subscriber.
     * @return true if the subscription has been removed, false otherwise.
     */
    public boolean unsubscribe(String subscriptionID, Entity subscriber) {
        Entity sub = storage.getSubscriber(name, subscriptionID);

        if(sub != null && sub.equals(subscriber)) {
            return storage.removeSubscription(name, subscriptionID);
        }
        return false;
    }
View Full Code Here

            if (!serverRuntimeContext.getServerFeatures().isRelayingMessages() ||
                (sessionContext != null && sessionContext.getAttribute(SessionContext.SESSION_ATTRIBUTE_MESSAGE_STANZA_NO_RECEIVE) != null)) {
                return null;
            }

            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);
                }
                stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
                for (XMLElement preparedElement : stanza.getInnerElements()) {
                    stanzaBuilder.addPreparedElement(preparedElement);
                }
                stanza = XMPPCoreStanza.getWrapper(stanzaBuilder.build());
            }
View Full Code Here

     * Add the entity to the owner list of the given node.
     * The owner is stored as bare JID.
     */
    public void setAffiliation(String nodeName, Entity entity, PubSubAffiliation affiliation) throws LastOwnerResignedException {
        Map<Entity, PubSubAffiliation> affils = this.nodeAffiliations.get(nodeName);
        Entity bareJID = entity.getBareJID();

        if(getAffiliation(nodeName, bareJID).equals(PubSubAffiliation.OWNER)
                && !affiliation.equals(PubSubAffiliation.OWNER)
                && countAffiliations(nodeName, PubSubAffiliation.OWNER) == 1) {
            throw new LastOwnerResignedException(bareJID.getFullQualifiedName() + " tried to resign from " + nodeName);
        }

        if(affiliation.equals(PubSubAffiliation.NONE)) {
            affils.remove(bareJID); // NONE affiliations are not stored.
        } else {
View Full Code Here

    protected AbstractStanzaGenerator getDefaultStanzaGenerator() {
        return new DefaultRetrieveAffiliationsStanzaGenerator();
    }

    public void testNoAffiliations() {
        Entity client2 = new EntityImpl("yoda", "starwars.com", null);
       
        AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
        Stanza stanza = sg.getStanza(client2, pubsubService, "id123", null);
        ResponseStanzaContainer result = sendStanza(stanza, true);
       
View Full Code Here

        assertEquals(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS, errorContent.get(0).getNamespaceURI());
    }

    public void testUnsubscribeNoSuchNode() {
        DefaultUnsubscribeStanzaGenerator sg = new DefaultUnsubscribeStanzaGenerator();
        Entity pubsubWrongNode = new EntityImpl(null, "pubsub.vysper.org", null);

        ResponseStanzaContainer result = sendStanza(sg.getStanza(client, pubsubWrongNode, "id123", "doesnotexsist"), true);
        assertTrue(result.hasResponse());
        IQStanza response = new IQStanza(result.getResponseStanza());
        assertEquals(IQStanzaType.ERROR.value(),response.getType());
View Full Code Here

    protected LeafNode n1 = null;

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

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

TOP

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

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.