Package org.apache.vysper.xmpp.addressing

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


            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


    protected void setUp() throws Exception {
        super.setUp();

        protocolWorker = new ProtocolWorker();
        sessionStateHolder = new SessionStateHolder();
        Entity serverEnitity = new EntityImpl(null, "vysper-server.org", null);
        StanzaReceiverRelay receiverRelay = new StanzaReceiverRelay();
        DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(serverEnitity, receiverRelay);
        receiverRelay.setServerRuntimeContext(serverRuntimeContext);
        serverRuntimeContext.addDictionary(new BaseStreamStanzaDictionary());
        sessionStateHolder = new SessionStateHolder();
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

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

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

        RosterItem setRosterItem;
        try {
            setRosterItem = RosterUtils.parseRosterItem(stanza);
        } catch (RosterBadRequestException e) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza,
                    StanzaErrorType.MODIFY, e.getMessage(), null, null);
        } catch (RosterNotAcceptableException e) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.NOT_ACCEPTABLE, stanza,
                    StanzaErrorType.MODIFY, e.getMessage(), null, null);
        }

        Entity contactJid = setRosterItem.getJid().getBareJID();

        RosterItem existingItem;
        try {
            existingItem = rosterManager.getContact(user.getBareJID(), contactJid);
        } catch (RosterException e) {
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

        // TODO: either use the resource associated with the session
        // (initiatingEntity)
        // or in case of multiple resources, use the from attribute or return an
        // error if the from attribute is not present.
        Entity initiatingEntity = sessionContext == null ? null : sessionContext.getInitiatingEntity();
        XMPPCoreStanzaVerifier verifier = presenceStanza.getCoreVerifier();
        ResourceRegistry registry = serverRuntimeContext.getResourceRegistry();

        PresenceStanzaType type = presenceStanza.getPresenceType();

        if (isOutboundStanza) {
            // this is an outbound subscription
            // request/approval/cancellation/unsubscription
            // stamp it with the bare JID of the user
            Entity user = initiatingEntity;
            PresenceStanza stampedStanza = buildPresenceStanza(user.getBareJID(), presenceStanza.getTo().getBareJID(),
                    presenceStanza.getPresenceType(), null);

            switch (type) {

            case SUBSCRIBE:
View Full Code Here

    @SpecCompliance(compliant = {
            @SpecCompliant(spec = "RFC3921bis-05", section = "3.3.3", status = IN_PROGRESS, comment = "current impl based hereupon"),
            @SpecCompliant(spec = "RFC3921bis-08", section = "3.3.3", status = NOT_STARTED, comment = "substantial additions from bis-05 not yet taken into account") })
    protected void handleInboundUnsubscription(PresenceStanza stanza, ServerRuntimeContext serverRuntimeContext,
            SessionContext sessionContext, ResourceRegistry registry, RosterManager rosterManager) {
        Entity contact = stanza.getFrom();
        Entity user = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

        if (rosterItem == null)
            return;

        RosterSubscriptionMutator.Result result = RosterSubscriptionMutator.getInstance().remove(rosterItem, FROM);

        if (result != OK) {
            // TODO
            return;
        }

        // send roster push to all interested resources
        // TODO do this only once, since inbound is multiplexed on DeliveringInboundStanzaRelay level already
        List<String> resources = registry.getInterestedResources(user);
        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

    @SpecCompliance(compliant = {
            @SpecCompliant(spec = "RFC3921bis-05", section = "3.3.2", status = IN_PROGRESS, comment = "current impl based hereupon"),
            @SpecCompliant(spec = "RFC3921bis-08", section = "3.3.2", status = NOT_STARTED, comment = "rephrasing from bis-05 not yet taken into account") })
    protected void handleOutboundUnsubscription(PresenceStanza stanza, ServerRuntimeContext serverRuntimeContext,
            SessionContext sessionContext, ResourceRegistry registry, RosterManager rosterManager) {
        Entity user = stanza.getFrom();
        Entity contact = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        relayStanza(contact, stanza, sessionContext);

        RosterItem rosterItem = null;
        try {
View Full Code Here

    protected void sendRosterUpdate(SessionContext sessionContext, ResourceRegistry registry, Entity user,
            RosterItem rosterItem) {
        List<String> resources = registry.getInterestedResources(user);

        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

            @SpecCompliant(spec = "RFC3921bis-08", section = "3.2.3", status = NOT_STARTED, comment = "additions from bis-05 not yet taken into account") })
    protected void handleInboundSubscriptionCancellation(PresenceStanza stanza,
            ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext, ResourceRegistry registry,
            RosterManager rosterManager) {

        Entity contact = stanza.getFrom();
        Entity user = stanza.getTo();

        Entity userBareJid = user.getBareJID();
        Entity contactBareJid = contact.getBareJID();

        RosterItem rosterItem;
        try {
            rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
        } catch (RosterException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

        if (rosterItem == null)
            return;

        RosterSubscriptionMutator.Result result = RosterSubscriptionMutator.getInstance().remove(rosterItem, TO);

        if (result != OK) {
            // TODO
            return;
        }

        // send roster push to all interested resources
        // TODO do this only once, since inbound is multiplexed on DeliveringInboundStanzaRelay level already
        List<String> resources = registry.getInterestedResources(user);
        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

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.