Provide a mechanism for the authenticator to pass information to the

client object by way of passing the auth response data up to the client
after the completion of the authentication phase. This allows information
loaded by an authenticator (like a user record) to make its way into the
real world.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@722 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-12-03 20:14:51 +00:00
parent 1c823ae349
commit a0ba41c31d
7 changed files with 83 additions and 61 deletions
@@ -1,5 +1,5 @@
//
// $Id: AuthManager.java,v 1.5 2001/10/11 04:07:53 mdb Exp $
// $Id: AuthManager.java,v 1.6 2001/12/03 20:14:51 mdb Exp $
package com.threerings.presents.server.net;
@@ -72,8 +72,13 @@ public class AuthManager extends LoopingThread
// now ship the response back
aconn.postMessage(rsp);
// stuff a reference to the auth response into the connection
// so that we have access to it later in the authentication
// process
aconn.setAuthResponse(rsp);
// if the authentication request was granted, let the
// connection manager know that we just authed a connection
// connection manager know that we just authed
_conmgr.connectionDidAuthenticate(aconn);
} catch (Exception e) {
@@ -1,5 +1,5 @@
//
// $Id: AuthingConnection.java,v 1.4 2001/10/11 04:07:53 mdb Exp $
// $Id: AuthingConnection.java,v 1.5 2001/12/03 20:14:51 mdb Exp $
package com.threerings.presents.server.net;
@@ -7,8 +7,9 @@ import java.io.IOException;
import ninja2.core.io_core.nbio.NonblockingSocket;
import com.threerings.presents.Log;
import com.threerings.presents.net.UpstreamMessage;
import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.UpstreamMessage;
/**
* The authing connection manages the client connection until
@@ -58,14 +59,30 @@ public class AuthingConnection
return _authreq;
}
/**
* Returns the auth response delivered to the client (only valid after
* the auth request has been processed.
*/
public AuthResponse getAuthResponse ()
{
return _authrsp;
}
/**
* Stores a reference to the auth response delivered to this
* connection. This is called by the auth manager after delivering the
* auth response to the client.
*/
public void setAuthResponse (AuthResponse authrsp)
{
_authrsp = authrsp;
}
public String toString ()
{
return "[mode=AUTHING, addr=" + _socket.getInetAddress() + "]";
}
protected int _state = AWAITING_AUTH_REQUEST;
protected AuthRequest _authreq;
protected static final int AWAITING_AUTH_REQUEST = 0;
protected static final int PROCESSING_AUTH_REQUEST = 1;
protected AuthResponse _authrsp;
}
@@ -1,5 +1,5 @@
//
// $Id: ConnectionManager.java,v 1.13 2001/10/25 23:37:13 mdb Exp $
// $Id: ConnectionManager.java,v 1.14 2001/12/03 20:14:51 mdb Exp $
package com.threerings.presents.server.net;
@@ -14,7 +14,8 @@ import com.threerings.presents.Log;
import com.threerings.presents.client.Client;
import com.threerings.presents.io.FramingOutputStream;
import com.threerings.presents.io.TypedObjectFactory;
import com.threerings.presents.net.Credentials;
import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.DownstreamMessage;
import com.threerings.presents.server.PresentsServer;
@@ -104,7 +105,8 @@ public class ConnectionManager extends LoopingThread
* Notifies the connection observers of a connection event. Used
* internally.
*/
protected void notifyObservers (int code, Connection conn, Object arg)
protected void notifyObservers (
int code, Connection conn, Object arg1, Object arg2)
{
synchronized (_observers) {
for (int i = 0; i < _observers.size(); i++) {
@@ -112,10 +114,11 @@ public class ConnectionManager extends LoopingThread
(ConnectionObserver)_observers.get(i);
switch (code) {
case CONNECTION_ESTABLISHED:
obs.connectionEstablished(conn, (Credentials)arg);
obs.connectionEstablished(conn, (AuthRequest)arg1,
(AuthResponse)arg2);
break;
case CONNECTION_FAILED:
obs.connectionFailed(conn, (IOException)arg);
obs.connectionFailed(conn, (IOException)arg1);
break;
case CONNECTION_CLOSED:
obs.connectionClosed(conn);
@@ -171,7 +174,7 @@ public class ConnectionManager extends LoopingThread
// and let our observers know about our new connection
notifyObservers(CONNECTION_ESTABLISHED, rconn,
conn.getAuthRequest().getCredentials());
conn.getAuthRequest(), conn.getAuthResponse());
} catch (IOException ioe) {
Log.warning("Failure upgrading authing connection to " +
@@ -279,7 +282,7 @@ public class ConnectionManager extends LoopingThread
_selset.remove(conn.getSelectItem());
// let our observers know what's up
notifyObservers(CONNECTION_FAILED, conn, ioe);
notifyObservers(CONNECTION_FAILED, conn, ioe, null);
}
/**
@@ -293,7 +296,7 @@ public class ConnectionManager extends LoopingThread
_selset.remove(conn.getSelectItem());
// let our observers know what's up
notifyObservers(CONNECTION_CLOSED, conn, null);
notifyObservers(CONNECTION_CLOSED, conn, null, null);
}
/**
@@ -1,10 +1,11 @@
//
// $Id: ConnectionObserver.java,v 1.5 2001/10/11 04:07:53 mdb Exp $
// $Id: ConnectionObserver.java,v 1.6 2001/12/03 20:14:51 mdb Exp $
package com.threerings.presents.server.net;
import java.io.IOException;
import com.threerings.presents.net.Credentials;
import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse;
/**
* A connection observer can be registered with the connection manager to
@@ -24,10 +25,11 @@ public interface ConnectionObserver
* the connection observer.
*
* @param conn The newly established connection.
* @param creds The credentials with which this connection
* (successfully) authenticated.
* @param req The auth request provided by the client.
* @param rsp The auth response provided to the client.
*/
public void connectionEstablished (Connection conn, Credentials creds);
public void connectionEstablished (
Connection conn, AuthRequest req, AuthResponse rsp);
/**
* Called if a connection fails for any reason. If a connection fails,