//
// $Id: Rejector.java,v 1.1 2004/10/13 01:02:19 mdb Exp $

package com.threerings.presents.server;

import com.threerings.util.MessageBundle;

import com.threerings.presents.Log;
import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.AuthResponseData;
import com.threerings.presents.server.net.AuthingConnection;

/**
 * A simple server that does nothing more than spit out a canned error
 * response to everyone who logs in.
 */
public class Rejector extends PresentsServer
{
    // documentation inherited
    public void init ()
        throws Exception
    {
        super.init();
        conmgr.setAuthenticator(new RejectingAuthenticator());
    }

    public static void main (String[] args)
    {
        if (args.length < 1) {
            System.err.println("Usage: Rejector error_msg [args]");
            System.exit(-1);
        }

        _errmsg = args[0];
        if (args.length > 1) {
            String[] eargs = new String[args.length-1];
            System.arraycopy(args, 1, eargs, 0, eargs.length);
            _errmsg = MessageBundle.tcompose(_errmsg, eargs);
        }

        Rejector server = new Rejector();
        try {
            server.init();
            server.run();
        } catch (Exception e) {
            Log.warning("Unable to initialize server.");
            Log.logStackTrace(e);
        }
    }

    /**
     * An authenticator implementation that refuses all authentication
     * requests.
     */
    protected class RejectingAuthenticator extends Authenticator
    {
        /**
         * Accept all authentication requests.
         */
        public void authenticateConnection (AuthingConnection conn)
        {
            Log.info("Accepting request: " + conn.getAuthRequest());
            AuthResponseData rdata = new AuthResponseData();
            rdata.code = _errmsg;
            connectionWasAuthenticated(conn, new AuthResponse(rdata));
        }
    }

    protected static String _errmsg;
}

@@ -22,17 +22,17 @@
 ava,v 1.
-1
+2
  2004/10
@@ -43,12 +43,12 @@
 01:0
-2:19
+9:14
  mdb
@@ -1558,25 +1558,14 @@
  /**
-%0A         * Accep
+ Rejec
 t al
@@ -1590,25 +1590,16 @@
 equests.
-%0A        
  */%0A    
@@ -1698,13 +1698,13 @@
 fo(%22
-Accep
+Rejec
 ting

Make the comments and logging consistent with what we're doing.