Augmenting the AuthResponseData with server stuff turned out to be a bad
idea because that class is shared between the client and the server, so instead we provide a blank object reference in which the authenticator can provide whatever information it wants to the client services. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@723 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
//
|
||||
// $Id: CrowdClient.java,v 1.4 2001/12/03 20:14:51 mdb Exp $
|
||||
// $Id: CrowdClient.java,v 1.5 2001/12/03 22:01:57 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.server;
|
||||
|
||||
import com.threerings.presents.net.AuthResponseData;
|
||||
import com.threerings.presents.server.PresentsClient;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
/**
|
||||
@@ -14,9 +12,9 @@ import com.threerings.crowd.data.BodyObject;
|
||||
*/
|
||||
public class CrowdClient extends PresentsClient
|
||||
{
|
||||
protected void sessionWillStart (AuthResponseData rdata)
|
||||
protected void sessionWillStart (Object authInfo)
|
||||
{
|
||||
super.sessionWillStart(rdata);
|
||||
super.sessionWillStart(authInfo);
|
||||
|
||||
// cast our client object to a body object
|
||||
_bodobj = (BodyObject)_clobj;
|
||||
@@ -28,9 +26,9 @@ public class CrowdClient extends PresentsClient
|
||||
CrowdServer.mapBody(_username, _bodobj);
|
||||
}
|
||||
|
||||
protected void sessionWillResume (AuthResponseData rdata)
|
||||
protected void sessionWillResume (Object authInfo)
|
||||
{
|
||||
super.sessionWillResume(rdata);
|
||||
super.sessionWillResume(authInfo);
|
||||
|
||||
// nothing to do here presently
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AuthResponse.java,v 1.9 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: AuthResponse.java,v 1.10 2001/12/03 22:01:57 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
@@ -42,6 +42,27 @@ public class AuthResponse extends DownstreamMessage
|
||||
return _data;
|
||||
}
|
||||
|
||||
/**
|
||||
* The authenticator can stuff information into the auth response that
|
||||
* will be made available to the client management code on the server
|
||||
* after the authentication process has completed. This is provided
|
||||
* because the authenticator will likely end up doing things like
|
||||
* loading information from a database which it will want to pass
|
||||
* along to the running system once authentication is complete.
|
||||
*/
|
||||
public void setAuthInfo (Object authInfo)
|
||||
{
|
||||
_authInfo = authInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the auth info provided by the authenticator implementation.
|
||||
*/
|
||||
public Object getAuthInfo ()
|
||||
{
|
||||
return _authInfo;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
@@ -67,4 +88,7 @@ public class AuthResponse extends DownstreamMessage
|
||||
}
|
||||
|
||||
protected AuthResponseData _data;
|
||||
|
||||
/** Stores auth info provided by the authenticator. */
|
||||
protected Object _authInfo;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientManager.java,v 1.12 2001/12/03 20:14:51 mdb Exp $
|
||||
// $Id: ClientManager.java,v 1.13 2001/12/03 22:01:57 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ClientManager implements ConnectionObserver
|
||||
if (client != null) {
|
||||
Log.info("Session resumed [username=" + username +
|
||||
", conn=" + conn + "].");
|
||||
client.resumeSession(conn, rsp.getData());
|
||||
client.resumeSession(conn, rsp.getAuthInfo());
|
||||
|
||||
} else {
|
||||
Log.info("Session initiated [username=" + username +
|
||||
@@ -106,7 +106,7 @@ public class ClientManager implements ConnectionObserver
|
||||
// create a new client and stick'em in the table
|
||||
try {
|
||||
client = (PresentsClient)_clientClass.newInstance();
|
||||
client.startSession(this, username, conn, rsp.getData());
|
||||
client.startSession(this, username, conn, rsp.getAuthInfo());
|
||||
_usermap.put(username, client);
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failed to instantiate client instance to " +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: PresentsClient.java,v 1.25 2001/12/03 20:14:51 mdb Exp $
|
||||
// $Id: PresentsClient.java,v 1.26 2001/12/03 22:01:57 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
@@ -11,9 +11,31 @@ import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.dobj.*;
|
||||
import com.threerings.presents.net.*;
|
||||
import com.threerings.presents.server.net.*;
|
||||
|
||||
import com.threerings.presents.dobj.DEvent;
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.EventListener;
|
||||
import com.threerings.presents.dobj.ObjectAccessException;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
import com.threerings.presents.dobj.TypedEvent;
|
||||
|
||||
import com.threerings.presents.net.BootstrapData;
|
||||
import com.threerings.presents.net.BootstrapNotification;
|
||||
import com.threerings.presents.net.EventNotification;
|
||||
import com.threerings.presents.net.UpstreamMessage;
|
||||
|
||||
import com.threerings.presents.net.ForwardEventRequest;
|
||||
import com.threerings.presents.net.LogoffRequest;
|
||||
import com.threerings.presents.net.PingRequest;
|
||||
import com.threerings.presents.net.SubscribeRequest;
|
||||
import com.threerings.presents.net.UnsubscribeRequest;
|
||||
|
||||
import com.threerings.presents.net.FailureResponse;
|
||||
import com.threerings.presents.net.ObjectResponse;
|
||||
import com.threerings.presents.net.PongResponse;
|
||||
|
||||
import com.threerings.presents.server.net.Connection;
|
||||
import com.threerings.presents.server.net.MessageHandler;
|
||||
|
||||
/**
|
||||
* A client object represents a client session in the server. It is
|
||||
@@ -54,7 +76,7 @@ public class PresentsClient
|
||||
*/
|
||||
protected void startSession (
|
||||
ClientManager cmgr, String username, Connection conn,
|
||||
final AuthResponseData rdata)
|
||||
final Object authInfo)
|
||||
{
|
||||
_cmgr = cmgr;
|
||||
_username = username;
|
||||
@@ -67,7 +89,7 @@ public class PresentsClient
|
||||
public void objectAvailable (DObject object)
|
||||
{
|
||||
setClientObject((ClientObject)object);
|
||||
sessionWillStart(rdata);
|
||||
sessionWillStart(authInfo);
|
||||
sendBootstrap();
|
||||
}
|
||||
|
||||
@@ -97,8 +119,7 @@ public class PresentsClient
|
||||
* authenticates as this already established client. This must only be
|
||||
* called from the congmr thread.
|
||||
*/
|
||||
protected void resumeSession (
|
||||
Connection conn, final AuthResponseData rdata)
|
||||
protected void resumeSession (Connection conn, final Object authInfo)
|
||||
{
|
||||
Connection oldconn = getConnection();
|
||||
|
||||
@@ -124,7 +145,7 @@ public class PresentsClient
|
||||
{
|
||||
// now that we're on the dobjmgr thread we can resume our
|
||||
// session resumption
|
||||
finishResumeSession(rdata);
|
||||
finishResumeSession(authInfo);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -136,10 +157,10 @@ public class PresentsClient
|
||||
* resumption. We call some call backs and send the bootstrap info to
|
||||
* the client.
|
||||
*/
|
||||
protected void finishResumeSession (AuthResponseData rdata)
|
||||
protected void finishResumeSession (Object authInfo)
|
||||
{
|
||||
// let derived classes do any session resuming
|
||||
sessionWillResume(rdata);
|
||||
sessionWillResume(authInfo);
|
||||
|
||||
// send off a bootstrap notification immediately because we've
|
||||
// already got our client object
|
||||
@@ -240,10 +261,10 @@ public class PresentsClient
|
||||
* thread which means that object manipulations are OK, but client
|
||||
* instance manipulations must done carefully.
|
||||
*
|
||||
* @param rdata the data object delivered to the client during the
|
||||
* authentication phase.
|
||||
* @param authInfo optional information provided by the authenticator
|
||||
* that it obtained during the authentication phase.
|
||||
*/
|
||||
protected void sessionWillStart (AuthResponseData rdata)
|
||||
protected void sessionWillStart (Object authInfo)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -258,10 +279,10 @@ public class PresentsClient
|
||||
* thread which means that object manipulations are OK, but client
|
||||
* instance manipulations must done carefully.
|
||||
*
|
||||
* @param rdata the data object delivered to the client during the
|
||||
* authentication phase.
|
||||
* @param authInfo optional information provided by the authenticator
|
||||
* that it obtained during the authentication phase.
|
||||
*/
|
||||
protected void sessionWillResume (AuthResponseData rdata)
|
||||
protected void sessionWillResume (Object authInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user