Package org.apache.vysper.xmpp.addressing

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


//          <delay xmlns='urn:xmpp:delay'
//             from='wiccarocks@shakespeare.lit/laptop'
//             stamp='2002-10-13T23:58:43Z'/>
//        </message>
       
        Entity roomJid = message.getTo();
        StanzaBuilder builder = StanzaBuilder.createForward(message, new EntityImpl(roomJid, fromNick), receiver.getJid());

        Entity delayFrom;
        if(includeJid) {
            delayFrom = message.getFrom();
        } else {
            delayFrom = new EntityImpl(roomJid, fromNick);
        }
View Full Code Here


    public void testCreateStanza() throws Exception {
        StanzaBuilder builder = StanzaBuilder.createMessageStanza(FROM, ROOM_JID, MessageStanzaType.GROUPCHAT, null, BODY);
        Stanza inStanza = builder.build();
        DiscussionMessage item = new DiscussionMessage(inStanza, FROM_OCCUPANT, TIMESTAMP);
       
        Entity to = TestUtil.parseUnchecked("user2@vysper.org/res");
        Occupant toOccupant = new Occupant(to, "nick 2", Affiliation.None, Role.Visitor);
        MessageStanza outStanza = (MessageStanza) MessageStanza.getWrapper(item.createStanza(toOccupant, true));
       
        assertEquals(to, outStanza.getTo());
        assertEquals(new EntityImpl(ROOM_JID, NICK), outStanza.getFrom());
View Full Code Here

     * Makes this modules available via disco#items and returns the associated nodes.
     *
     * @see ItemRequestListener#getItemsFor(InfoRequest)
     */
    public List<Item> getItemsFor(InfoRequest request) throws ServiceDiscoveryRequestException {
        Entity to = request.getTo();
        if (to.getNode() == null) {
            // react on request send to server domain or this subdomain, but not to others
            if(fullDomain.equals(to)) {
                List<Item> conferenceItems = conference.getItemsFor(request);
                return conferenceItems;
            } else if (serverRuntimeContext.getServerEnitity().equals(to)) {
                List<Item> componentItem = new ArrayList<Item>();
                componentItem.add(new Item(fullDomain));
                return componentItem;
            }
            return null;
        } else if (fullDomain.getDomain().equals(to.getDomain())) {
            // might be an items request on a room
            Room room = conference.findRoom(to.getBareJID());
            if (room != null) {
                if (to.getResource() != null) {
                    // request for an occupant
                    Occupant occupant = room.findOccupantByNick(to.getResource());
                    // request for occupant, relay
                    if (occupant != null) {
                        relayDiscoStanza(occupant.getJid(), request, NamespaceURIs.XEP0030_SERVICE_DISCOVERY_ITEMS);
                    }
                } else {
View Full Code Here

                synchronized (sessionResources) {
                    // record session for the resource id
                    boundResources.put(resourceId, new SessionData(sessionContext,
                            CONNECTED, 0));

                    Entity initiatingEntity = sessionContext.getInitiatingEntity();
                    List<String> resourceForEntityList = getResourceList(initiatingEntity);
                    if (resourceForEntityList == null) {
                        resourceForEntityList = new ArrayList<String>(1);
                        entityResources.put(getBareEntity(initiatingEntity),
                                resourceForEntityList);
                    }
                    resourceForEntityList.add(resourceId);
                    logger.info("added resource no. " + resourceForEntityList.size() + " to entity {} <- {}",
                                initiatingEntity.getFullQualifiedName(), resourceId);

                    List<String> resourcesForSessionList = sessionResources.get(sessionContext);
                    if (resourcesForSessionList == null) {
                        resourcesForSessionList = new ArrayList<String>(1);
                        sessionResources.put(sessionContext, resourcesForSessionList);
View Full Code Here

        super(NamespaceURIs.XEP0045_MUC, "item", null,
                createAttributes(jid, nick, affiliation, role), null);
    }

    private static List<Attribute> createAttributes(Occupant occupant, boolean includeJid, boolean includeNick) {
        Entity jid = includeJid ? occupant.getJid() : null;
        String nick = includeNick ? occupant.getName() : null;
       
        return createAttributes(jid, nick, occupant.getAffiliation(), occupant.getRole());
    }
View Full Code Here

                        return; // silently ignore
                    }
                    // TODO what happens with PROBE? 8.1 is silent here, but see 4.3
                    if (presenceStanzaType == SUBSCRIBE) {
                        // return UNSUBSCRIBED
                        final Entity from = failedToDeliverStanza.getTo(); // reverse from/to
                        final Entity to = failedToDeliverStanza.getFrom(); // reverse from/to
                        StanzaBuilder builder = StanzaBuilder.createPresenceStanza(from, to, null, UNSUBSCRIBED, null, null);
                        final Stanza finalStanza = builder.build();
                        stanzaRelay.relay(to, finalStanza, IgnoreFailureStrategy.IGNORE_FAILURE_STRATEGY);
                        return;
                    }
View Full Code Here

        if (jid == null) throw new RosterException("jid not provided");
        if (rosterItem.getJid() == null) throw new RosterException("contact jid not provided");

        // TODO think about concurrent updates

        Entity contactJid = rosterItem.getJid().getBareJID();
        Node contactNode = getOrCreateContactNode(jid, contactJid);
        try {
            setOrRemoveAttribute(contactNode, "name", rosterItem.getName());
            String subscriptionTypeValue = rosterItem.getSubscriptionType() == null ? null : rosterItem.getSubscriptionType().value();
            setOrRemoveAttribute(contactNode, "type", subscriptionTypeValue);
View Full Code Here

        }

        // make sure that 'from' (if present) matches the bare authorized entity
        // else repond with a stanza error 'unknown-sender'
        // see rfc3920_draft-saintandre-rfc3920bis-04.txt#8.5.4
        Entity from = stanza.getFrom();
        if (from != null && sessionContext.getInitiatingEntity() != null) {
            Entity fromBare = from.getBareJID();
            Entity initiatingEntity = sessionContext.getInitiatingEntity();
            if (!initiatingEntity.equals(fromBare)) {
                responseWriter.handleWrongFromJID(sessionContext, stanza);
                return;
            }
        }
        // make sure that there is a bound resource entry for that from's resource id attribute!
View Full Code Here

        if (parseSubscriptionTypes) {
            askSubscriptionType = verifier.attributePresent("ask") ? AskSubscriptionType.valueOf("ASK_" + itemElement.getAttribute("ask").getValue().toUpperCase()) : AskSubscriptionType.NOT_SET;
        }

        String contactJid = attributeJID.getValue();
        Entity contact;
        try {
            contact = EntityImpl.parse(contactJid);
        } catch (EntityFormatException e) {
            throw new RosterNotAcceptableException("jid cannot be parsed: " + contactJid);
        }
View Full Code Here

        if (rosterManager == null) {
            return handleCannotRetrieveRoster(stanza, sessionContext);
        }

        Entity from = extractUniqueSenderJID(stanza, sessionContext);
        if (from == null || !from.isResourceSet()) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.UNKNOWN_SENDER, stanza, StanzaErrorType.MODIFY, "sender info insufficient: " + ((from == null) ? "no from" : from.getFullQualifiedName()), null, null);
        }
        String resourceId = from.getResource();

        ResourceState currentState = registry.getResourceState(resourceId);
        if (currentState != null) {
            registry.setResourceState(resourceId, ResourceState.makeInterested(currentState));
        }

        Roster roster = null;
        try {
            roster = rosterManager.retrieve(from.getBareJID());
            if (roster == null) return handleCannotRetrieveRoster(stanza, sessionContext);
        } catch (RosterException e) {
            return handleCannotRetrieveRoster(stanza, sessionContext);
        }
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.