Package org.apache.vysper.xmpp.addressing

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


        assertNull(resourceRegistry.getSessionContext(resourceId1));
        assertEquals(0, resourceRegistry.getBoundResources(entity).size());
    }

    public void testUnbindSessionSimple() throws EntityFormatException {
        EntityImpl entity = EntityImpl.parse("me@test");

        TestSessionContext sessionContext1 = TestSessionContext.createSessionContext(entity);
        String resourceId1 = resourceRegistry.bindSession(sessionContext1);
        assertEquals(sessionContext1, resourceRegistry.getSessionContext(resourceId1));
View Full Code Here


        assertNull(resourceRegistry.getSessionContext(resourceId1));
        assertEquals(0, resourceRegistry.getBoundResources(entity).size());
    }

    public void testUniqueResourceIsConsistent() throws EntityFormatException {
        EntityImpl entity = EntityImpl.parse("me@test");
        TestSessionContext sessionContext = TestSessionContext.createSessionContext(entity);
        String resourceId1 = resourceRegistry.bindSession(sessionContext);

        String first1 = resourceRegistry.getUniqueResourceForSession(sessionContext);
        assertEquals(resourceId1, first1);
View Full Code Here

    }

    public Stanza started(SessionContext sessionContext, SessionStateHolder sessionStateHolder, Stanza authStanza) {

        // assign a self-created node name
        EntityImpl initiatingEntity = new EntityImpl(uuidGenerator.create(), sessionContext.getServerJID().getDomain(),
                null);
        sessionContext.setInitiatingEntity(initiatingEntity);

        sessionStateHolder.setState(SessionState.AUTHENTICATED);
        return new AuthorizationResponses().getSuccess();
View Full Code Here

    public void testDetectWrongFromAddress() throws XMLSemanticError {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'mark'
        sessionContext.setInitiatingEntity(new EntityImpl("mark", server.getDomain(), null));

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("iq");
        namespaceHandlerDictionary.register(stanzaHandler);

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        // we set a different from user name 'ernest'!
        stanzaBuilder.addAttribute("from", new EntityImpl("ernest", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "jabber:iq:roster").endInnerElement();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
View Full Code Here

    public void testAllowProperFromResourceId() throws XMLSemanticError, BindException {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'charlotte'
        sessionContext.setInitiatingEntity(new EntityImpl("charlotte", server.getDomain(), null));

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("iq", "testNSURI");
        namespaceHandlerDictionary.register(stanzaHandler);

        String onlyBoundResource = sessionContext.bindResource();

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("charlotte", server.getDomain(), onlyBoundResource)
                .getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
View Full Code Here

    public void testDetectWrongFromResourceId() throws XMLSemanticError, BindException {

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'charlotte'
        sessionContext.setInitiatingEntity(new EntityImpl("charlotte", server.getDomain(), null));

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("iq", "testNSURI");
        namespaceHandlerDictionary.register(stanzaHandler);

        String onlyBoundResource = sessionContext.bindResource();
        String arbitraryUnboundResource = "unboundResourceID";

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");

        stanzaBuilder.addAttribute("from", new EntityImpl("charlotte", server.getDomain(), arbitraryUnboundResource)
                .getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
View Full Code Here

        // fully qualified, e.g. from="client@vysper.org/resourceId"

        Entity server = sessionContext.getServerRuntimeContext().getServerEnitity();
        sessionContext.setSessionState(SessionState.AUTHENTICATED);
        // the session is running for 'lea'
        sessionContext.setInitiatingEntity(new EntityImpl("lea", server.getDomain(), null));

        CallTestStanzaHandler stanzaHandler = new CallTestStanzaHandler("iq", "testNSURI");
        namespaceHandlerDictionary.register(stanzaHandler);

        String firstBoundResource = sessionContext.bindResource();
        String secondBoundResource = sessionContext.bindResource();

        StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();

        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
        Stanza recordedResponse = sessionContext.getNextRecordedResponse();
        assertUnknownSenderError(recordedResponse); // not allowed, bare id without resource and two resources bound
        sessionContext.reset();

        // unbind second resource, leaving only one
        boolean noResourceRemains = sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(
                secondBoundResource);
        assertFalse(noResourceRemains);

        // bare id allowed, only one resource is bound
        stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
        stanzaHandler.assertHandlerCalled();
        sessionContext.reset();

        // second resource is now invalid and cannot be used anymore in a full qualified entity
        stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
        stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), secondBoundResource)
                .getFullQualifiedName());
        stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
        protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(),
                sessionStateHolder);
        recordedResponse = sessionContext.getNextRecordedResponse();
View Full Code Here

        List<NamespaceHandlerDictionary> dictionaries = new ArrayList<NamespaceHandlerDictionary>();
        addCoreDictionaries(dictionaries);

        ResourceRegistry resourceRegistry = new ResourceRegistry();

        EntityImpl serverEntity = new EntityImpl(null, serverDomain, null);

        AccountManagement accountManagement = (AccountManagement) storageProviderRegistry
                .retrieve(AccountManagement.class);
        DeliveringInboundStanzaRelay internalStanzaRelay = new DeliveringInboundStanzaRelay(serverEntity,
                resourceRegistry, accountManagement);
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

    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

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.