Alert Message at the start of every IM conversation

Hello

I would like to have the following message to be shown at the beginning of IM conversation irrespective of client application.

“IM Administrator: ALERT: This IM communication is being monitored and archived by a secure corporate network. Please be aware there is no presumption or expectation of privacy.”

How can I achieve this on the Wildfire server? Is there any plug-in already written to serve such functionality.

Please share your knowledge with me

Regards

GS

Hi GS,

Unfortunately there isn’‘t an easy way to detect when one user starts a conversation with another, but that’‘s not to say it can’‘t be done. Below are a couple snippets of code that are from another project I’‘ve worked on that could be expanded to do what you’'re looking for. The downside of this approach is that you need to keep track of who is talking to who and that you need to inspect each packet as it passes through Wildfire, both of which will result in a bit of performance hit. Another, simpilier, approach would be to use a session listener to detect when a user comes online (sessionCreated) and at that point tell them that their conversations are being monitored; this may not be as “in their face” as sending them the warning message each time they start a conversation but the implementation would be a lot simplier and without the performance problems.

Hope that helps,

Ryan

private Map<Key, Date> conversationMap = new ConcurrentHashMap<Key, Date>();     private class MessagePacketInterceptor implements PacketInterceptor {
        public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
            try {
                if ((packet instanceof Message) && incoming && !processed) {
                    Message msgPacket = (Message) packet;                     JID toJID = msgPacket.getTo();
                    JID fromJID = msgPacket.getFrom();
                                        String toNode = toJID.getNode();
                    String fromNode = fromJID.getNode();
                                        Key key = new Key(toNode, fromNode);
                                        if (!conversationMap.containsKey(key)) {
                        conversationMap.put(key, new Date());                         Message message = new Message();
                        message.setTo(fromJID);
                        message.setFrom(new JID(XMPPServer.getInstance().getServerInfo().getName()));
                        message.setBody("Big Brother is watching");                         XMPPServer.getInstance().getMessageRouter().route(message);
                    }
                }
            }
            catch (NullPointerException npe) {
                Log.error(npe);
            }
        }
    }
        private class UserSignedOutListener implements SessionEventListener {
        public void sessionCreated(Session session) {
           //ignore
        }         public void sessionDestroyed(Session session) {
           String username = session.getAddress().getNode();
           conversationMap.remove(username);
        }         public void anonymousSessionCreated(Session session) {
           //ignore
        }         public void anonymousSessionDestroyed(Session session) {
           //ignore
        }
     }
        private class Key {
        private String to;
        private String from;
                public Key(String to, String from) {
            this.to = to;
            this.from = from;
        }
                public boolean equals(Object aThat) {
            if (this == aThat) {
               return true;
            }             if (!(aThat instanceof Key)) {
               return false;
            }             Key that = (Key) aThat;
            return (this.to.equals(that.to) && this.from.equals(that.from)) ||
                   (this.to.equals(that.from) && this.from.equals(that.to));
                           }
                public int hashCode() {
            int hash = 7;
                        int ito = (to == null ? 0 : to.hashCode());
            int ifrom = (from == null ? 0 : from.hashCode());             hash = 31 * hash + ito + ifrom;
                        return hash;
         }
    }

Message was edited by: ryang - slight code correction

Hi Ryan

Thank You for your quick response. I understand your code and is keen to try it on my server.

However, I don’'t know the procedure to deploy this code on my server. Does this needs to be built as a Plug-in?

Actually, Wildfire has Content-Filter plug-in. My requirement is I think part of the Content-Filter’'s functionality. Do you think there is any way that I modify the functionality of Content-Filter plug-in?

Regards

GS

Hi GS,

However, I don’'t know the procedure to deploy this code on my server. Does this needs to be built as a Plug-in?

Yes, you’'ll have to make a plugin out of the code above (I apologize for not mentioning that). Take a look at the Plugin Developer Guide to see how to create all the pieces you need to create the plugin.

Actually, Wildfire has Content-Filter plug-in. My requirement is I think part of the Content-Filter’'s functionality. Do you think there is any way that I modify the functionality of Content-Filter plug-in?

The content filter (and subscription) pluginswould be helpful for you to look at for a point of reference but I think you’‘d be better starting from scratch, if you were to modify the content filter to suite your needs you’'d probably end up using just a small fraction of the original code.

Hope that helps,

Ryan

Hi Ryan

Thank you for your immediate reply again.

I understand…I will build my own plug-in using the code you sent.

Thank You once again,

Regards

GS

Hi GS,

You’'re welcome, please be sure to mark your question as being answered and award any points that you see fit to.

Cheers,

Ryan

PS - There’'s at least one bug in the code above (in the sessionDestroyed() method) so be sure to test it before deploying it into production.

Hi Ryan

I didn’'t try this code yet. I will mark the thread completed as soon as I test it.

Thank you for your support again

Regards

GS