// Path: openfire-websockets/src/com/ifsoft/websockets/plugin/WebSocketsPlugin.java
// public class WebSocketsPlugin implements Plugin  {
// 
// 	private static Logger Log = LoggerFactory.getLogger("WebSocketsPlugin");
// 	private static final String NAME 		= "ws";
// 	private static final String DESCRIPTION = "WebSockets Plugin for Openfire";
// 
// 	private PluginManager manager;
//     private File pluginDirectory;
// 
//     private ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> sockets = new ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket>();
// 
// 
// //-------------------------------------------------------
// //
// //
// //
// //-------------------------------------------------------
// 
// 	public void initializePlugin(PluginManager manager, File pluginDirectory) {
// 		Log.info( "["+ NAME + "] initialize " + NAME + " plugin resources");
// 
// 		String appName = JiveGlobals.getProperty("websockets.webapp.name", NAME);
// 
// 		try {
// 
// 			ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
// 
// 			try {
// 				Log.info( "["+ NAME + "] initialize " + NAME + " initialize Websockets " + appName);
// 				ServletContextHandler context = new ServletContextHandler(contexts, "/" + appName, ServletContextHandler.SESSIONS);
// 				context.addServlet(new ServletHolder(new XMPPServlet()),"/server");
// 
// 				WebAppContext context2 = new WebAppContext(contexts, pluginDirectory.getPath(), "/websockets");
// 				context.setWelcomeFiles(new String[]{"index.html"});
// 
// 			}
// 			catch(Exception e) {
// 				Log.error( "An error has occurred", e );
//         	}
// 		}
// 		catch (Exception e) {
// 			Log.error("Error initializing WebSockets Plugin", e);
// 		}
// 	}
// 
// 	public void destroyPlugin() {
// 		Log.info( "["+ NAME + "] destroy " + NAME + " plugin resources");
// 
// 		try {
// 
// 			for (XMPPServlet.XMPPWebSocket socket : sockets.values())
// 			{
// 				try {
// 					LocalClientSession session = socket.getSession();
// 					session.close();
// 					SessionManager.getInstance().removeSession( session );
// 					session = null;
// 
// 				} catch ( Exception e ) { }
// 			}
// 
// 			sockets.clear();
// 
// 		}
// 		catch (Exception e) {
// 			Log.error("["+ NAME + "] destroyPlugin exception " + e);
// 		}
// 	}
// 
// 	public String getName() {
// 		 return NAME;
// 	}
// 
// 	public String getDescription() {
// 		return DESCRIPTION;
// 	}
// 
// 	public int getCount() {
// 		return this.sockets.size();
// 	}
// 
// 	public ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> getSockets() {
// 		return sockets;
// 	}
// }


import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.security.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.security.cert.Certificate;
import java.util.concurrent.ConcurrentHashMap;
import java.math.BigInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.jivesoftware.util.ParamUtils;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.StreamID;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.net.VirtualConnection;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.auth.AuthToken;
import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserAlreadyExistsException;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.openfire.SessionPacketRouter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.component.InternalComponentManager;
import com.ifsoft.websockets.plugin.WebSocketsPlugin;
import com.ifsoft.websockets.*;
import org.xmpp.packet.*;
import org.dom4j.*;

package com.ifsoft.websockets.servlet;










public final class XMPPServlet extends WebSocketServlet
{
    private static Logger Log = LoggerFactory.getLogger( "XMPPServlet" );

    private ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> sockets;
    private String remoteAddr;

// Path: openfire-websockets/src/com/ifsoft/websockets/plugin/WebSocketsPlugin.java
// public class WebSocketsPlugin implements Plugin  {
// 
// 	private static Logger Log = LoggerFactory.getLogger("WebSocketsPlugin");
// 	private static final String NAME 		= "ws";
// 	private static final String DESCRIPTION = "WebSockets Plugin for Openfire";
// 
// 	private PluginManager manager;
//     private File pluginDirectory;
// 
//     private ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> sockets = new ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket>();
// 
// 
// //-------------------------------------------------------
// //
// //
// //
// //-------------------------------------------------------
// 
// 	public void initializePlugin(PluginManager manager, File pluginDirectory) {
// 		Log.info( "["+ NAME + "] initialize " + NAME + " plugin resources");
// 
// 		String appName = JiveGlobals.getProperty("websockets.webapp.name", NAME);
// 
// 		try {
// 
// 			ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
// 
// 			try {
// 				Log.info( "["+ NAME + "] initialize " + NAME + " initialize Websockets " + appName);
// 				ServletContextHandler context = new ServletContextHandler(contexts, "/" + appName, ServletContextHandler.SESSIONS);
// 				context.addServlet(new ServletHolder(new XMPPServlet()),"/server");
// 
// 				WebAppContext context2 = new WebAppContext(contexts, pluginDirectory.getPath(), "/websockets");
// 				context.setWelcomeFiles(new String[]{"index.html"});
// 
// 			}
// 			catch(Exception e) {
// 				Log.error( "An error has occurred", e );
//         	}
// 		}
// 		catch (Exception e) {
// 			Log.error("Error initializing WebSockets Plugin", e);
// 		}
// 	}
// 
// 	public void destroyPlugin() {
// 		Log.info( "["+ NAME + "] destroy " + NAME + " plugin resources");
// 
// 		try {
// 
// 			for (XMPPServlet.XMPPWebSocket socket : sockets.values())
// 			{
// 				try {
// 					LocalClientSession session = socket.getSession();
// 					session.close();
// 					SessionManager.getInstance().removeSession( session );
// 					session = null;
// 
// 				} catch ( Exception e ) { }
// 			}
// 
// 			sockets.clear();
// 
// 		}
// 		catch (Exception e) {
// 			Log.error("["+ NAME + "] destroyPlugin exception " + e);
// 		}
// 	}
// 
// 	public String getName() {
// 		 return NAME;
// 	}
// 
// 	public String getDescription() {
// 		return DESCRIPTION;
// 	}
// 
// 	public int getCount() {
// 		return this.sockets.size();
// 	}
// 
// 	public ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> getSockets() {
// 		return sockets;
// 	}
// }


// Path: openfire-websockets/src/com/ifsoft/websockets/servlet/XMPPServlet.java
import org.jivesoftware.util.JiveGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.security.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.security.cert.Certificate;
import java.util.concurrent.ConcurrentHashMap;
import java.math.BigInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.jivesoftware.util.ParamUtils;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.StreamID;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.net.VirtualConnection;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.auth.AuthToken;
import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserAlreadyExistsException;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.openfire.SessionPacketRouter;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.openfire.component.InternalComponentManager;
import com.ifsoft.websockets.plugin.WebSocketsPlugin;
import com.ifsoft.websockets.*;
import org.xmpp.packet.*;
import org.dom4j.*;

package com.ifsoft.websockets.servlet;










public final class XMPPServlet extends WebSocketServlet
{
    private static Logger Log = LoggerFactory.getLogger( "XMPPServlet" );

    private ConcurrentHashMap<String, XMPPServlet.XMPPWebSocket> sockets;
    private String remoteAddr;

    private WebSocketsPlugin plugin;
