Commit 03c05a79 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Added internet address so session summary won't crash.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/branches@5832 b35dd754-fafc-0310-a699-88a17e54d16e
parent 85cf4166
...@@ -542,11 +542,13 @@ public class SessionManager extends BasicModule { ...@@ -542,11 +542,13 @@ public class SessionManager extends BasicModule {
return session; return session;
} }
public HttpSession createClientHttpSession(StreamID id) throws UnauthorizedException { public HttpSession createClientHttpSession(InetAddress address, StreamID id)
throws UnauthorizedException
{
if (serverName == null) { if (serverName == null) {
throw new UnauthorizedException("Server not initialized"); throw new UnauthorizedException("Server not initialized");
} }
HttpSession session = new HttpSession(serverName, id); HttpSession session = new HttpSession(serverName, address, id);
Connection conn = session.getConnection(); Connection conn = session.getConnection();
conn.init(session); conn.init(session);
conn.registerCloseListener(clientSessionListener, session); conn.registerCloseListener(clientSessionListener, session);
......
...@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress;
/** /**
* Handles requests to the HTTP Bind service. * Handles requests to the HTTP Bind service.
...@@ -149,7 +150,8 @@ public class HttpBindServlet extends HttpServlet { ...@@ -149,7 +150,8 @@ public class HttpBindServlet extends HttpServlet {
try { try {
HttpConnection connection = new HttpConnection(rid, request.isSecure()); HttpConnection connection = new HttpConnection(rid, request.isSecure());
connection.setSession(sessionManager.createSession(rootNode, connection)); InetAddress address = InetAddress.getByName(request.getRemoteAddr());
connection.setSession(sessionManager.createSession(address, rootNode, connection));
respond(response, connection); respond(response, connection);
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
......
...@@ -48,9 +48,9 @@ public class HttpSession extends ClientSession { ...@@ -48,9 +48,9 @@ public class HttpSession extends ClientSession {
private boolean isClosed; private boolean isClosed;
private int inactivityTimeout; private int inactivityTimeout;
public HttpSession(String serverName, StreamID streamID) { public HttpSession(String serverName, InetAddress address, StreamID streamID) {
super(serverName, null, streamID); super(serverName, null, streamID);
conn = new HttpVirtualConnection(); conn = new HttpVirtualConnection(address);
} }
void addConnection(HttpConnection connection, boolean isPoll) throws HttpBindException, void addConnection(HttpConnection connection, boolean isPoll) throws HttpBindException,
...@@ -375,12 +375,18 @@ public class HttpSession extends ClientSession { ...@@ -375,12 +375,18 @@ public class HttpSession extends ClientSession {
*/ */
public static class HttpVirtualConnection extends VirtualConnection { public static class HttpVirtualConnection extends VirtualConnection {
private InetAddress address;
public HttpVirtualConnection(InetAddress address) {
this.address = address;
}
public void closeVirtualConnection() { public void closeVirtualConnection() {
((HttpSession)session).closeConnection(); ((HttpSession)session).closeConnection();
} }
public InetAddress getInetAddress() { public InetAddress getInetAddress() {
return null; return address;
} }
public void systemShutdown() { public void systemShutdown() {
......
...@@ -21,6 +21,7 @@ import org.dom4j.*; ...@@ -21,6 +21,7 @@ import org.dom4j.*;
import java.util.*; import java.util.*;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
/** /**
* *
...@@ -75,7 +76,8 @@ public class HttpSessionManager { ...@@ -75,7 +76,8 @@ public class HttpSessionManager {
return sessionMap.get(streamID); return sessionMap.get(streamID);
} }
public HttpSession createSession(Element rootNode, HttpConnection connection) public HttpSession createSession(InetAddress address, Element rootNode,
HttpConnection connection)
throws UnauthorizedException, HttpBindException throws UnauthorizedException, HttpBindException
{ {
// TODO Check if IP address is allowed to connect to the server // TODO Check if IP address is allowed to connect to the server
...@@ -89,7 +91,7 @@ public class HttpSessionManager { ...@@ -89,7 +91,7 @@ public class HttpSessionManager {
int wait = getIntAttribute(rootNode.attributeValue("wait"), 60); int wait = getIntAttribute(rootNode.attributeValue("wait"), 60);
int hold = getIntAttribute(rootNode.attributeValue("hold"), 1); int hold = getIntAttribute(rootNode.attributeValue("hold"), 1);
HttpSession session = createSession(); HttpSession session = createSession(address);
session.setWait(wait); session.setWait(wait);
session.setHold(hold); session.setHold(hold);
session.setSecure(connection.isSecure()); session.setSecure(connection.isSecure());
...@@ -112,11 +114,11 @@ public class HttpSessionManager { ...@@ -112,11 +114,11 @@ public class HttpSessionManager {
return session; return session;
} }
private HttpSession createSession() throws UnauthorizedException { private HttpSession createSession(InetAddress address) throws UnauthorizedException {
// Create a ClientSession for this user. // Create a ClientSession for this user.
StreamID streamID = SessionManager.getInstance().nextStreamID(); StreamID streamID = SessionManager.getInstance().nextStreamID();
// Send to the server that a new client session has been created // Send to the server that a new client session has been created
HttpSession session = sessionManager.createClientHttpSession(streamID); HttpSession session = sessionManager.createClientHttpSession(address, streamID);
// Register that the new session is associated with the specified stream ID // Register that the new session is associated with the specified stream ID
sessionMap.put(streamID.getID(), session); sessionMap.put(streamID.getID(), session);
session.addSessionCloseListener(new SessionListener() { session.addSessionCloseListener(new SessionListener() {
......
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