Examples of PrivacyList


Examples of org.jivesoftware.openfire.privacy.PrivacyList

        if (lists.size() > 1) {
            result.setError(PacketError.Condition.bad_request);
        }
        else {
            String listName = lists.get(0).attributeValue("name");
            PrivacyList list = null;
            if (listName != null) {
                // A list name was specified so get it
                list = manager.getPrivacyList(from.getNode(), listName);
            }
            if (list != null) {
                // Add the privacy list to the result
                childElement = result.setChildElement("query", "jabber:iq:privacy");
                childElement.add(list.asElement());
            }
            else {
                // List not found
                result.setError(PacketError.Condition.item_not_found);
            }
View Full Code Here

Examples of org.jivesoftware.openfire.privacy.PrivacyList

        IQ result = IQ.createResultIQ(packet);
        Element childElement = packet.getChildElement().createCopy();
        result.setChildElement(childElement);

        // Get the list
        PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
        if (list != null) {
            // Get the user session
            ClientSession session = sessionManager.getSession(from);
            if (session != null) {
                // Set the new active list for this session
View Full Code Here

Examples of org.jivesoftware.openfire.privacy.PrivacyList

            // Current default list is being used by more than one session
            result.setError(PacketError.Condition.conflict);
        }
        else {
            // Get the list
            PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
            if (list != null) {
                // Get the user session
                ClientSession session = sessionManager.getSession(from);
                PrivacyList oldDefaultList = session.getDefaultList();
                manager.changeDefaultList(from.getNode(), list, oldDefaultList);
                // Set the new default list for this session (the only existing session)
                session.setDefaultList(list);
            }
            else {
View Full Code Here

Examples of org.jivesoftware.openfire.privacy.PrivacyList

        IQ result = IQ.createResultIQ(packet);
        Element childElement = packet.getChildElement().createCopy();
        result.setChildElement(childElement);

        String listName = listElement.attributeValue("name");
        PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
        if (list == null) {
            list = manager.createPrivacyList(from.getNode(), listName, listElement);
        }
        else {
            // Update existing list
            list.updateList(listElement);
            provider.updatePrivacyList(from.getNode(), list);
            // Make sure that existing user sessions that are using the updated list are poining
            // to the updated instance. This may happen since PrivacyListManager uses a Cache that
            // may expire so it's possible to have many instances representing the same privacy
            // list. Therefore, if a list is modified then we need to make sure that all
            // instances are replaced with the updated instance. An OR Mapping Tool would have
            // avoided this issue since identity is ensured.
            for (ClientSession session : sessionManager.getSessions(from.getNode())) {
                if (list.equals(session.getDefaultList())) {
                    session.setDefaultList(list);
                }
                if (list.equals(session.getActiveList())) {
                    session.setActiveList(list);
                }
            }
        }
        // Send a "privacy list push" to all connected resources
        IQ pushPacket = new IQ(IQ.Type.set);
        Element child = pushPacket.setChildElement("query", "jabber:iq:privacy");
        child.addElement("list").addAttribute("name", list.getName());
        sessionManager.userBroadcast(from.getNode(), pushPacket);

        return result;
    }
View Full Code Here

Examples of org.jivesoftware.openfire.privacy.PrivacyList

        ClientSession currentSession;
        IQ result = IQ.createResultIQ(packet);
        Element childElement = packet.getChildElement().createCopy();
        result.setChildElement(childElement);
        // Get the list to delete
        PrivacyList list = manager.getPrivacyList(from.getNode(), listName);

        if (list == null) {
            // List to delete was not found
            result.setError(PacketError.Condition.item_not_found);
            return result;
        }
        else {
            currentSession = sessionManager.getSession(from);
            // Check if the list is being used by another session
            for (ClientSession session : sessionManager.getSessions(from.getNode())) {
                if (currentSession == session) {
                    // Ignore the active session for this checking
                    continue;
                }
                if (list.equals(session.getDefaultList()) || list.equals(session.getActiveList())) {
                    // List to delete is being used by another session so return a conflict error
                    result.setError(PacketError.Condition.conflict);
                    return result;
                }
            }
        }
        // Remove the list from the active session (if it was being used)
        if (list.equals(currentSession.getDefaultList())) {
            currentSession.setDefaultList(null);
        }
        if (list.equals(currentSession.getActiveList())) {
            currentSession.setActiveList(null);
        }
        manager.deletePrivacyList(from.getNode(), listName);
        return result;
    }
View Full Code Here

Examples of org.jivesoftware.smack.PrivacyList

           
            Thread.sleep(500);
                       
            // Assert the list composition.
            PrivacyList[] privacyLists = privacyManager.getPrivacyLists();
            PrivacyList receivedList1 = null;
            PrivacyList receivedList2 = null;
            for (PrivacyList privacyList : privacyLists) {
                if (listName1.equals(privacyList.toString())) {
                    receivedList1 = privacyList;
                }
                if (listName2.equals(privacyList.toString())) {
                    receivedList2 = privacyList;
                }
            }
           
           
            PrivacyItem receivedItem;
            // Assert on the list 1
            assertNotNull(receivedList1);
            assertEquals(1, receivedList1.getItems().size());
            receivedItem = receivedList1.getItems().get(0);
            assertEquals(1, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
            assertEquals(true, receivedItem.isAllow());
            assertEquals(getConnection(0).getUser(), receivedItem.getValue());
           
            // Assert on the list 2
            assertNotNull(receivedList2);
            assertEquals(1, receivedList2.getItems().size());
            receivedItem = receivedList2.getItems().get(0);
            assertEquals(2, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.group, receivedItem.getType());
            assertEquals(groupName, receivedItem.getValue());
            assertEquals(false, receivedItem.isAllow());
            assertEquals(groupName, receivedItem.getValue());
View Full Code Here

Examples of org.jivesoftware.smack.PrivacyList

            privacyManager.updatePrivacyList(listName, items);
           
            Thread.sleep(500);
                       
            // Assert the list composition.
            PrivacyList list = privacyManager.getPrivacyList(listName);
            assertEquals(1, list.getItems().size());

            // Assert the privacy item composition
            PrivacyItem receivedItem = list.getItems().get(0);
            assertEquals(2, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
            assertEquals(false, receivedItem.isAllow());
            assertEquals(user, receivedItem.getValue());
            assertEquals(false, receivedItem.isFilterEverything());
View Full Code Here

Examples of org.jivesoftware.smack.PrivacyList

           
            Thread.sleep(500);
                       
            // Assert the list composition.
            PrivacyList[] privacyLists = privacyManager.getPrivacyLists();
            PrivacyList receivedList1 = null;
            PrivacyList receivedList2 = null;
            for (PrivacyList privacyList : privacyLists) {
                if (listName1.equals(privacyList.toString())) {
                    receivedList1 = privacyList;
                }
                if (listName2.equals(privacyList.toString())) {
                    receivedList2 = privacyList;
                }
            }
           
           
            PrivacyItem receivedItem;
            // Assert on the list 1
            assertNotNull(receivedList1);
            assertEquals(1, receivedList1.getItems().size());
            receivedItem = receivedList1.getItems().get(0);
            assertEquals(1, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
            assertEquals(true, receivedItem.isAllow());
            assertEquals(getConnection(0).getUser(), receivedItem.getValue());
           
            // Assert on the list 2
            assertNotNull(receivedList2);
            assertEquals(1, receivedList2.getItems().size());
            receivedItem = receivedList2.getItems().get(0);
            assertEquals(2, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.group, receivedItem.getType());
            assertEquals(groupName, receivedItem.getValue());
            assertEquals(false, receivedItem.isAllow());
            assertEquals(groupName, receivedItem.getValue());
View Full Code Here

Examples of org.jivesoftware.smack.PrivacyList

            privacyManager.updatePrivacyList(listName, items);
           
            Thread.sleep(500);
                       
            // Assert the list composition.
            PrivacyList list = privacyManager.getPrivacyList(listName);
            assertEquals(1, list.getItems().size());

            // Assert the privacy item composition
            PrivacyItem receivedItem = list.getItems().get(0);
            assertEquals(2, receivedItem.getOrder());
            assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
            assertEquals(false, receivedItem.isAllow());
            assertEquals(user, receivedItem.getValue());
            assertEquals(false, receivedItem.isFilterEverything());
View Full Code Here

Examples of rocks.xmpp.extensions.privacy.model.PrivacyList

        Assert.assertEquals(privacy.getPrivacyLists().get(2).getName(), "special");
    }

    @Test
    public void marshalPrivacyListRequest() throws XMLStreamException, JAXBException {
        IQ iq = new IQ(IQ.Type.GET, new Privacy(new PrivacyList("public")));
        iq.setFrom(Jid.valueOf("romeo@example.net/orchard"));
        iq.setId("getlist1");
        String xml = marshal(iq);
        Assert.assertEquals(xml, "<iq from=\"romeo@example.net/orchard\" id=\"getlist1\" type=\"get\"><query xmlns=\"jabber:iq:privacy\"><list name=\"public\"></list></query></iq>");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.