Commit 5515e869 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

My little small refactoring.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8404 b35dd754-fafc-0310-a699-88a17e54d16e
parent ba699985
......@@ -11,9 +11,9 @@
package org.jivesoftware.openfire;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.session.Session;
import org.xmpp.packet.Packet;
import java.util.concurrent.LinkedBlockingQueue;
......@@ -86,7 +86,7 @@ public class Channel<T extends Packet> {
try {
Session session = SessionManager.getInstance().getSession(packet.getFrom());
session.getConnection().close();
session.close();
}
catch (Exception e1) {
Log.error(e1);
......
......@@ -12,10 +12,9 @@
package org.jivesoftware.openfire;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.session.LocalSession;
import org.xmpp.packet.Packet;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
......@@ -40,15 +39,53 @@ public interface Connection {
*
* @param session the session that owns this connection
*/
public void init(Session session);
public void init(LocalSession session);
/**
* Returns the InetAddress describing the connection.
* Returns the raw IP address of this <code>InetAddress</code>
* object. The result is in network byte order: the highest order
* byte of the address is in <code>getAddress()[0]</code>.
*
* @return the InetAddress describing the underlying connection properties.
* @return the raw IP address of this object.
* @throws java.net.UnknownHostException if IP address of host could not be determined.
*/
public InetAddress getInetAddress() throws UnknownHostException;
public byte[] getAddress() throws UnknownHostException;
/**
* Returns the IP address string in textual presentation.
*
* @return the raw IP address in a string format.
* @throws java.net.UnknownHostException if IP address of host could not be determined.
*/
public String getHostAddress() throws UnknownHostException;
/**
* Gets the host name for this IP address.
*
* <p>If this InetAddress was created with a host name,
* this host name will be remembered and returned;
* otherwise, a reverse name lookup will be performed
* and the result will be returned based on the system
* configured name lookup service. If a lookup of the name service
* is required, call
* {@link java.net.InetAddress#getCanonicalHostName() getCanonicalHostName}.
*
* <p>If there is a security manager, its
* <code>checkConnect</code> method is first called
* with the hostname and <code>-1</code>
* as its arguments to see if the operation is allowed.
* If the operation is not allowed, it will return
* the textual representation of the IP address.
*
* @return the host name for this IP address, or if the operation
* is not allowed by the security check, the textual
* representation of the IP address.
* @throws java.net.UnknownHostException if IP address of host could not be determined.
*
* @see java.net.InetAddress#getCanonicalHostName
* @see SecurityManager#checkConnect
*/
public String getHostName() throws UnknownHostException;
/**
* Close this session including associated socket connection. The order of
......
......@@ -12,7 +12,6 @@
package org.jivesoftware.openfire;
import org.dom4j.Element;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.interceptor.InterceptorManager;
......@@ -75,7 +74,8 @@ public class IQRouter extends BasicModule {
if (packet == null) {
throw new NullPointerException();
}
ClientSession session = sessionManager.getSession(packet.getFrom());
JID sender = packet.getFrom();
ClientSession session = sessionManager.getSession(sender);
try {
// Invoke the interceptors before we process the read packet
InterceptorManager.getInstance().invokeInterceptors(packet, session, true, false);
......@@ -87,7 +87,7 @@ public class IQRouter extends BasicModule {
IQ reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.bad_request);
sessionManager.getSession(packet.getFrom()).process(reply);
session.process(reply);
Log.warn("User tried to authenticate with this server using an unknown receipient: " +
packet);
}
......@@ -104,7 +104,7 @@ public class IQRouter extends BasicModule {
IQ reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.not_authorized);
sessionManager.getSession(packet.getFrom()).process(reply);
session.process(reply);
}
// Invoke the interceptors after we have processed the read packet
InterceptorManager.getInstance().invokeInterceptors(packet, session, true, true);
......@@ -305,10 +305,7 @@ public class IQRouter extends BasicModule {
Log.error(LocaleUtils.getLocalizedString("admin.error.routing"), e);
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
Connection conn = session.getConnection();
if (conn != null) {
conn.close();
}
session.close();
}
}
}
......@@ -328,11 +325,7 @@ public class IQRouter extends BasicModule {
return;
}
// Route the error packet to the original sender of the IQ.
try {
routingTable.routePacket(reply.getTo(), reply);
} catch (UnauthorizedException e) {
// Should never happen
}
routingTable.routePacket(reply.getTo(), reply);
}
private IQHandler getHandler(String namespace) {
......@@ -353,9 +346,10 @@ public class IQRouter extends BasicModule {
/**
* Notification message indicating that a packet has failed to be routed to the receipient.
*
* @param receipient address of the entity that failed to receive the packet.
* @param packet IQ packet that failed to be sent to the receipient.
*/
public void routingFailed(Packet packet) {
public void routingFailed(JID receipient, Packet packet) {
IQ iq = (IQ) packet;
// If a route to the target address was not found then try to answer a
// service_unavailable error code to the sender of the IQ packet
......
......@@ -33,7 +33,7 @@ public class GetNumberUserSessions extends AdHocCommand {
field.setLabel(getLabel());
field.setVariable("onlineuserssessionsnum");
SessionManager sessionManager = SessionManager.getInstance();
field.addValue(sessionManager.getUserSessionsCount() + sessionManager.getAnonymousSessionCount());
field.addValue(sessionManager.getUserSessionsCount());
command.add(form.getElement());
}
......
......@@ -11,13 +11,13 @@
package org.jivesoftware.openfire.component;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.component.ExternalComponentConfiguration.Permission;
import org.jivesoftware.openfire.session.ComponentSession;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -74,7 +74,7 @@ public class ExternalComponentManager {
String domain = subdomain + "." + XMPPServer.getInstance().getServerInfo().getName();
Session session = SessionManager.getInstance().getComponentSession(domain);
if (session != null) {
session.getConnection().close();
session.close();
}
}
......@@ -340,7 +340,7 @@ public class ExternalComponentManager {
for (ComponentSession session : SessionManager.getInstance().getComponentSessions()) {
for (String domain : session.getExternalComponent().getSubdomains()) {
if (!canAccess(domain)) {
session.getConnection().close();
session.close();
break;
}
}
......
......@@ -14,18 +14,19 @@ package org.jivesoftware.openfire.handler;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.auth.AuthToken;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......@@ -60,9 +61,10 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
private Element probeResponse;
private IQHandlerInfo info;
private String serverName;
private UserManager userManager;
private XMPPServer localServer;
private SessionManager sessionManager;
private RoutingTable routingTable;
/**
* Clients are not authenticated when accessing this handler.
......@@ -84,7 +86,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
}
public IQ handleIQ(IQ packet) throws UnauthorizedException, PacketException {
ClientSession session = sessionManager.getSession(packet.getFrom());
LocalClientSession session = (LocalClientSession) sessionManager.getSession(packet.getFrom());
// If no session was found then answer an error (if possible)
if (session == null) {
Log.error("Error during authentication. Session not found in " +
......@@ -160,7 +162,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
return null;
}
private IQ login(String username, Element iq, IQ packet, String password, ClientSession session, String digest)
private IQ login(String username, Element iq, IQ packet, String password, LocalClientSession session, String digest)
throws UnauthorizedException, UserNotFoundException {
// Verify that specified resource is not violating any string prep rule
String resource = iq.elementTextTrim("resource");
......@@ -195,21 +197,16 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
// Verify if there is a resource conflict between new resource and existing one.
// Check if a session already exists with the requested full JID and verify if
// we should kick it off or refuse the new connection
if (sessionManager.isActiveRoute(username, resource)) {
ClientSession oldSession;
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource));
if (oldSession != null) {
try {
String domain = localServer.getServerInfo().getName();
oldSession = sessionManager.getSession(username, domain, resource);
oldSession.incrementConflictCount();
int conflictLimit = sessionManager.getConflictKickLimit();
if (conflictLimit != SessionManager.NEVER_KICK && oldSession.getConflictCount() > conflictLimit) {
Connection conn = oldSession.getConnection();
if (conn != null) {
// Send a stream:error before closing the old connection
StreamError error = new StreamError(StreamError.Condition.conflict);
conn.deliverRawText(error.toXML());
conn.close();
}
// Send a stream:error before closing the old connection
StreamError error = new StreamError(StreamError.Condition.conflict);
oldSession.deliverRawText(error.toXML());
oldSession.close();
}
else {
IQ response = IQ.createResultIQ(packet);
......@@ -251,7 +248,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
return response;
}
private IQ anonymousLogin(ClientSession session, IQ packet) {
private IQ anonymousLogin(LocalClientSession session, IQ packet) {
IQ response = IQ.createResultIQ(packet);
if (anonymousAllowed) {
session.setAnonymousAuth();
......@@ -277,9 +274,10 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
public void initialize(XMPPServer server) {
super.initialize(server);
localServer = server;
userManager = server.getUserManager();
sessionManager = server.getSessionManager();
routingTable = server.getRoutingTable();
serverName = server.getServerInfo().getName();
}
public IQHandlerInfo getInfo() {
......
......@@ -12,15 +12,16 @@
package org.jivesoftware.openfire.handler;
import org.dom4j.Element;
import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.jivesoftware.openfire.RoutingTable;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.AuthToken;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......@@ -41,7 +42,8 @@ import org.xmpp.packet.StreamError;
public class IQBindHandler extends IQHandler {
private IQHandlerInfo info;
private XMPPServer localServer;
private String serverName;
private RoutingTable routingTable;
public IQBindHandler() {
super("Resource Binding handler");
......@@ -49,7 +51,7 @@ public class IQBindHandler extends IQHandler {
}
public IQ handleIQ(IQ packet) throws UnauthorizedException {
ClientSession session = sessionManager.getSession(packet.getFrom());
LocalClientSession session = (LocalClientSession) sessionManager.getSession(packet.getFrom());
// If no session was found then answer an error (if possible)
if (session == null) {
Log.error("Error during resource binding. Session not found in " +
......@@ -94,22 +96,16 @@ public class IQBindHandler extends IQHandler {
String username = authToken.getUsername().toLowerCase();
// If a session already exists with the requested JID, then check to see
// if we should kick it off or refuse the new connection
if (sessionManager.isActiveRoute(username, resource)) {
ClientSession oldSession;
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource));
if (oldSession != null) {
try {
String domain = localServer.getServerInfo().getName();
oldSession = sessionManager.getSession(username, domain, resource);
oldSession.incrementConflictCount();
int conflictLimit = sessionManager.getConflictKickLimit();
if (conflictLimit != SessionManager.NEVER_KICK &&
oldSession.getConflictCount() > conflictLimit) {
Connection conn = oldSession.getConnection();
if (conn != null) {
// Kick out the old connection that is conflicting with the new one
StreamError error = new StreamError(StreamError.Condition.conflict);
conn.deliverRawText(error.toXML());
conn.close();
}
if (conflictLimit != SessionManager.NEVER_KICK && oldSession.getConflictCount() > conflictLimit) {
// Kick out the old connection that is conflicting with the new one
StreamError error = new StreamError(StreamError.Condition.conflict);
oldSession.deliverRawText(error.toXML());
oldSession.close();
}
else {
reply.setChildElement(packet.getChildElement().createCopy());
......@@ -135,8 +131,9 @@ public class IQBindHandler extends IQHandler {
public void initialize(XMPPServer server) {
super.initialize(server);
localServer = server;
}
routingTable = server.getRoutingTable();
serverName = server.getServerInfo().getName();
}
public IQHandlerInfo getInfo() {
return info;
......
......@@ -11,11 +11,11 @@
package org.jivesoftware.openfire.handler;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
......@@ -60,7 +60,7 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
}
catch (Exception de) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), de);
sessionManager.getSession(iq.getFrom()).getConnection().close();
sessionManager.getSession(iq.getFrom()).close();
}
}
}
......
......@@ -13,8 +13,6 @@ package org.jivesoftware.openfire.handler;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.disco.*;
......@@ -22,8 +20,10 @@ import org.jivesoftware.openfire.forms.DataForm;
import org.jivesoftware.openfire.forms.FormField;
import org.jivesoftware.openfire.forms.spi.XDataFormImpl;
import org.jivesoftware.openfire.forms.spi.XFormFieldImpl;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
......@@ -49,6 +49,7 @@ public class IQOfflineMessagesHandler extends IQHandler implements ServerFeature
private IQDiscoInfoHandler infoHandler;
private IQDiscoItemsHandler itemsHandler;
private RoutingTable routingTable;
private SessionManager sessionManager;
private UserManager userManager;
private OfflineMessageStore messageStore;
......@@ -63,18 +64,17 @@ public class IQOfflineMessagesHandler extends IQHandler implements ServerFeature
IQ reply = IQ.createResultIQ(packet);
Element offlineRequest = packet.getChildElement();
JID from = packet.getFrom();
if (offlineRequest.element("purge") != null) {
// User requested to delete all offline messages
messageStore.deleteMessages(packet.getFrom().getNode());
messageStore.deleteMessages(from.getNode());
}
else if (offlineRequest.element("fetch") != null) {
// Mark that offline messages shouldn't be sent when the user becomes available
stopOfflineFlooding(packet.getFrom());
ClientSession session = sessionManager.getSession(packet.getFrom());
stopOfflineFlooding(from);
// User requested to receive all offline messages
for (OfflineMessage offlineMessage : messageStore.getMessages(
packet.getFrom().getNode(), false)) {
sendOfflineMessage(offlineMessage, session);
for (OfflineMessage offlineMessage : messageStore.getMessages(from.getNode(), false)) {
sendOfflineMessage(from, offlineMessage);
}
}
else {
......@@ -91,29 +91,27 @@ public class IQOfflineMessagesHandler extends IQHandler implements ServerFeature
}
if ("view".equals(item.attributeValue("action"))) {
// User requested to receive specific message
OfflineMessage offlineMsg = messageStore.getMessage(packet.getFrom().getNode(),
creationDate);
OfflineMessage offlineMsg = messageStore.getMessage(from.getNode(), creationDate);
if (offlineMsg != null) {
ClientSession session = sessionManager.getSession(packet.getFrom());
sendOfflineMessage(offlineMsg, session);
sendOfflineMessage(from, offlineMsg);
}
}
else if ("remove".equals(item.attributeValue("action"))) {
// User requested to delete specific message
messageStore.deleteMessage(packet.getFrom().getNode(), creationDate);
messageStore.deleteMessage(from.getNode(), creationDate);
}
}
}
return reply;
}
private void sendOfflineMessage(OfflineMessage offlineMessage, ClientSession session) {
private void sendOfflineMessage(JID receipient, OfflineMessage offlineMessage) {
Element offlineInfo = offlineMessage.addChildElement("offline", NAMESPACE);
synchronized (dateFormat) {
offlineInfo.addElement("item").addAttribute("node",
dateFormat.format(offlineMessage.getCreationDate()));
}
session.process(offlineMessage);
routingTable.routePacket(receipient, offlineMessage);
}
public IQHandlerInfo getInfo() {
......@@ -187,6 +185,7 @@ public class IQOfflineMessagesHandler extends IQHandler implements ServerFeature
messageStore = server.getOfflineMessageStore();
sessionManager = server.getSessionManager();
userManager = server.getUserManager();
routingTable = server.getRoutingTable();
}
public void start() throws IllegalStateException {
......@@ -202,7 +201,7 @@ public class IQOfflineMessagesHandler extends IQHandler implements ServerFeature
}
private void stopOfflineFlooding(JID senderJID) {
ClientSession session = sessionManager.getSession(senderJID);
LocalClientSession session = (LocalClientSession) sessionManager.getSession(senderJID);
if (session != null) {
session.setOfflineFloodStopped(true);
}
......
......@@ -358,12 +358,7 @@ public class IQPrivacyHandler extends IQHandler
IQ pushPacket = new IQ(IQ.Type.set);
Element child = pushPacket.setChildElement("query", "jabber:iq:privacy");
child.addElement("list").addAttribute("name", list.getName());
try {
sessionManager.userBroadcast(from.getNode(), pushPacket);
}
catch (UnauthorizedException e) {
// Ignore
}
sessionManager.userBroadcast(from.getNode(), pushPacket);
return result;
}
......
......@@ -14,8 +14,6 @@ package org.jivesoftware.openfire.handler;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.IQHandlerInfo;
import org.jivesoftware.openfire.PacketException;
import org.jivesoftware.openfire.SessionManager;
......@@ -34,6 +32,8 @@ 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.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......@@ -236,7 +236,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
// Take a quick nap so that the client can process the result
Thread.sleep(10);
// Close the user's connection
session.getConnection().close();
session.close();
// The reply has been sent so clean up the variable
reply = null;
}
......
......@@ -17,7 +17,7 @@ import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.roster.Roster;
import org.jivesoftware.openfire.roster.RosterItem;
import org.jivesoftware.openfire.roster.RosterManager;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.session.Session;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
......@@ -89,10 +89,10 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
}
public void process(Packet packet) throws UnauthorizedException, PacketException {
process((Presence) packet, sessionManager.getSession(packet.getFrom()));
process((Presence) packet, (LocalClientSession) sessionManager.getSession(packet.getFrom()));
}
public void process(Presence presence, ClientSession session) throws UnauthorizedException, PacketException {
private void process(Presence presence, LocalClientSession session) throws UnauthorizedException, PacketException {
try {
Presence.Type type = presence.getType();
// Available
......@@ -187,7 +187,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
* @param session The session being updated
* @throws UserNotFoundException If the user being updated does not exist
*/
private void initSession(ClientSession session) throws UserNotFoundException {
private void initSession(LocalClientSession session) throws UserNotFoundException {
// Only user sessions need to be authenticated
if (userManager.isRegisteredUser(session.getAddress().getNode())) {
......@@ -245,7 +245,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
*
* @param update The update to broadcast
*/
private void broadcastUpdate(Presence update) throws PacketException {
private void broadcastUpdate(Presence update) {
if (update.getFrom() == null) {
return;
}
......@@ -437,12 +437,7 @@ public class PresenceUpdateHandler extends BasicModule implements ChannelHandler
for (String jid : jids) {
Presence presence = update.createCopy();
presence.setTo(jid);
try {
routingTable.routePacket(handlerJID, presence);
}
catch (UnauthorizedException ue) {
Log.error(ue);
}
routingTable.routePacket(handlerJID, presence);
}
}
}
......
......@@ -15,21 +15,22 @@ import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.QName;
import org.jivesoftware.openfire.Connection;
import org.jivesoftware.openfire.StreamID;
import org.jivesoftware.openfire.PacketDeliverer;
import org.jivesoftware.openfire.SessionPacketRouter;
import org.jivesoftware.openfire.multiplex.UnknownStanzaException;
import org.jivesoftware.openfire.StreamID;
import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.multiplex.UnknownStanzaException;
import org.jivesoftware.openfire.net.SASLAuthentication;
import org.jivesoftware.openfire.net.VirtualConnection;
import org.jivesoftware.openfire.session.ClientSession;
import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.util.Log;
import org.xmpp.packet.Packet;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
import java.io.UnsupportedEncodingException;
/**
* A session represents a serious of interactions with an XMPP client sending packets using the HTTP
......@@ -39,7 +40,7 @@ import java.io.UnsupportedEncodingException;
*
* @author Alexander Wenckus
*/
public class HttpSession extends ClientSession {
public class HttpSession extends LocalClientSession {
private int wait;
private int hold = 0;
private String language;
......@@ -707,8 +708,16 @@ public class HttpSession extends ClientSession {
((HttpSession) session).closeConnection();
}
public InetAddress getInetAddress() {
return address;
public byte[] getAddress() throws UnknownHostException {
return address.getAddress();
}
public String getHostAddress() throws UnknownHostException {
return address.getHostAddress();
}
public String getHostName() throws UnknownHostException {
return address.getHostName();
}
public void systemShutdown() {
......
......@@ -204,7 +204,7 @@ public class MediaProxyService extends BasicModule
childElementCopy.remove(candidateElement);
Element publicIp = childElementCopy.addElement("publicip");
try {
String ip = sessionManager.getSession(iq.getFrom()).getConnection().getInetAddress().getHostAddress();
String ip = sessionManager.getSession(iq.getFrom()).getHostAddress();
if (ip != null) {
publicIp.addAttribute("ip", ip);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment