Package org.xmpp.packet

Examples of org.xmpp.packet.Packet


            reply.setChildElement(((IQ) packet).getChildElement().createCopy());
            reply.setError(error);
            router.route(reply);
        }
        else {
            Packet reply = packet.createCopy();
            reply.setError(error);
            reply.setFrom(packet.getTo());
            reply.setTo(packet.getFrom());
            router.route(reply);
        }
    }
View Full Code Here


            public void run() {
                while (!shutdown) {
                    try {
                        if (threadPool.getActiveCount() < threadPool.getMaximumPoolSize()) {
                            // Wait until a packet is available
                            final Packet packet = packets.take();

                            boolean newProcessor = false;
                            PacketsProcessor packetsProcessor;
                            String domain = packet.getTo().getDomain();
                            synchronized (domain.intern()) {
                                packetsProcessor = packetsProcessors.get(domain);
                                if (packetsProcessor == null) {
                                    packetsProcessor =
                                            new PacketsProcessor(OutgoingSessionPromise.this, domain);
View Full Code Here

            this.domain = domain;
        }

        public void run() {
            while (!isDone()) {
                Packet packet = packetQueue.poll();
                if (packet != null) {
                    // Check if s2s already failed
                    if (failureTimestamp > 0) {
                        // Check if enough time has passed to attempt a new s2s
                        if (System.currentTimeMillis() - failureTimestamp < 5000) {
View Full Code Here

                return null;
            }
            List<Packet> answer = new ArrayList<Packet>();
            for (String packetXML : packets) {
                try {
                    Packet packet = null;
                    // Parse the XML stanza
                    Element element = localParser.get().read(new StringReader(packetXML)).getRootElement();
                    String tag = element.getName();
                    if ("message".equals(tag)) {
                        packet = new Message(element, true);
View Full Code Here

    public void interceptPacket(Packet packet, Session session, boolean read,
            boolean processed) throws PacketRejectedException {

        if (isValidTargetPacket(packet, read, processed)) {

            Packet original = packet;

            if (Log.isDebugEnabled()) {
                Log.debug("Content filter: intercepted packet:"
                        + original.toString());
            }

            // make a copy of the original packet only if required,
            // as it's an expensive operation
            if (violationNotificationEnabled
View Full Code Here

    private WorkgroupCompatibleClient() {
        super();
    }

    public void notifyQueueStatus(JID sender, JID receiver, UserRequest request, boolean isPolling) {
        Packet statusPacket;
        if (isPolling) {
            statusPacket = new IQ();
        }
        else {
            statusPacket = new Message();
        }
        statusPacket.setFrom(sender);
        statusPacket.setTo(receiver);

        // Add Queue Status Packet to IQ
        Element status = statusPacket.getElement().addElement("queue-status",
                "http://jabber.org/protocol/workgroup");

        // Add Time Element
        Element time = status.addElement("time");
        time.setText(Integer.toString(request.getTimeStatus()));
View Full Code Here

    @Override
  public Packet doAction(Packet packet) throws PacketRejectedException {
        SessionManager sessionManager = SessionManager.getInstance();
        ClientSession clientSession = sessionManager.getSession(packet.getFrom());
        Packet rejectPacket;
        String pfFrom = JiveGlobals.getProperty("pf.From", "packetfilter");


        if (packet instanceof Message) {
            Message in = (Message) packet.createCopy();
            if (clientSession != null && in.getBody() != null) {

                in.setFrom(new JID(pfFrom));
                String rejectMessage = JiveGlobals.getProperty("pf.rejectMessage", "Your message was rejected by the packet filter");
                in.setBody(rejectMessage);
                in.setType(Message.Type.error);
                in.setTo(packet.getFrom());
                String rejectSubject = JiveGlobals.getProperty("pf.rejectSubject", "Rejected");
                in.setSubject(rejectSubject);
                clientSession.process(in);

            }

        } else if (packet instanceof Presence) {
            rejectPacket = new Presence();
            rejectPacket.setTo(packet.getFrom());
            rejectPacket.setError(PacketError.Condition.forbidden);

        } else if (packet instanceof IQ) {
            rejectPacket = new IQ();
            rejectPacket.setTo(packet.getFrom());
            rejectPacket.setError(PacketError.Condition.forbidden);

        }
        if (doLog()) {
            Log.info("Rejecting packet from " + packet.getFrom() + " to " + packet.getTo());
        }
View Full Code Here

        Log.debug("Robot Olympics with packet ["+packet.getElement().getName()+"] from "+packet.getFrom() );

        if (!challengeManager.isChallengeMet(packet)) {
            if (!challengeManager.hasBeenChallenged(packet)) {
                Packet challenge = challengeManager.createChallenge(packet, session);
                route(challenge);
               
                challengeManager.appendPacket(packet);
                throw new PacketRejectedException("Robot Olympics: Must meet challenge.");
            }
View Full Code Here

    public void testHasBeenChallengedFalse() {
        assertFalse("hasBeenChallenged was not false but it should be when no challenge has been issued", challengeManager.hasBeenChallenged(message));
    }
   
    public void testCreateChallenge() {
        Packet challengePacket = challengeManager.createChallenge(message, session);
        String packetBody = ((Message)challengePacket).getBody();
       
        String challengeId = challengeManager.makeChallengeId(message);
        Challenge challenge = challengeManager.getChallenge( message );
        String challengeString = challenge.getChallenge();
       
        assertEquals( "The chalenge must come from the original recipient", message.getTo(), challengePacket.getFrom() );
       
        assertNotNull( "Challenge does not have extension", challengePacket.getExtension( ChallengeExtension.ELEMENT_NAME, ChallengeExtension.NAMESPACE ) );
       
        assertTrue( "There was no challenge ID present in the challenge message", packetBody.indexOf(challengeId) > -1 );
        assertTrue( "There was no question present in the challenge message", packetBody.indexOf(challengeString) > -1 );
       
        assertTrue( "Challenge has been issued but hasBeenChallenged says it hasn't", challengeManager.hasBeenChallenged(message));
View Full Code Here

   
    public void testCreateChallengeNullPacketId() {
        message.setID(null);
       
        try {
            Packet challenge = challengeManager.createChallenge(message, session);
        } catch( NullPointerException e ) {
            fail( "Should not fail with null packet ID" );
        }
       
    }
View Full Code Here

TOP

Related Classes of org.xmpp.packet.Packet

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.