soc.message
Class SOCAuthRequest

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCAuthRequest
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SOCAuthRequest
extends SOCMessage

Authentication request, to connect and check password without creating or joining a game or channel.

Before v1.1.19, the client needed to request joining or creating a game or channel in order to send a username and password. Games have a game option dialog before creation; if the password was wrong those older versions wouldn't reject the client until after they had filled out that dialog, which is less than ideal.

This message also has the password as its last field, to avoid imposing character restrictions from field delimiters.

The server responds to this message from the client with a SOCStatusMessage:

Bots don't need or use this message, they authenticate to the server with SOCImARobot.

This message includes an authScheme number field for future expansion. The only currently implemented auth scheme number is:

  1. SCHEME_CLIENT_PLAINTEXT

Since:
1.1.19
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
SOCNewGameWithOptionsRequest, Serialized Form

Field Summary
 int authScheme
          Authentication scheme number, such as SCHEME_CLIENT_PLAINTEXT.
 java.lang.String host
          Server host name to which the client is connecting, or null for client's local TCP server.
 java.lang.String nickname
          Nickname (username) of the joining client
private static java.lang.String NULLHOST
          Token to indicate host is null or "", to avoid adjacent delimiters
 java.lang.String password
          Optional password, or ""
 java.lang.String role
          Role that requester connected to server for, such as ROLE_GAME_PLAYER or ROLE_USER_ADMIN.
static java.lang.String ROLE_GAME_PLAYER
          Game Player role for auth request: Play or watch games, join chat channels
static java.lang.String ROLE_USER_ADMIN
          User Admin role for auth request: Create users
static int SCHEME_CLIENT_PLAINTEXT
          Scheme #1, for client to connect using a plaintext password
private static long serialVersionUID
           
static int VERSION_FOR_AUTHREQUEST
          Minimum version (1.1.19) of client/server which send and recognize AUTHREQUEST
 
Fields inherited from class soc.message.SOCMessage
ACCEPTOFFER, ADMINPING, ADMINRESET, AUTHREQUEST, BANKTRADE, BCASTTEXTMSG, BOARDLAYOUT, BOARDLAYOUT2, BOARDSPECIALEDGE, BUILDREQUEST, BUYCARDREQUEST, CANCELBUILDREQUEST, CHANGEFACE, CHANNELS, CHOOSEPLAYER, CHOOSEPLAYERREQUEST, CLEAROFFER, CLEARTRADEMSG, CREATEACCOUNT, DEBUGFREEPLACE, DELETECHANNEL, DELETEGAME, DEVCARDACTION, DEVCARDCOUNT, DICERESULT, DICERESULTRESOURCES, DISCARD, DISCARDREQUEST, DISCOVERYPICK, ENDTURN, FIRSTPLAYER, GAME_NONE, GAMEMEMBERS, GAMEOPTIONGETDEFAULTS, GAMEOPTIONGETINFOS, GAMEOPTIONINFO, GAMES, GAMESERVERTEXT, GAMESTATE, GAMESTATS, GAMESWITHOPTIONS, GAMETEXTMSG, IMAROBOT, INVENTORYITEMACTION, JOIN, JOINAUTH, JOINGAME, JOINGAMEAUTH, LARGESTARMY, LASTSETTLEMENT, LEAVE, LEAVEALL, LEAVEGAME, LEGALEDGES, LOCALIZEDSTRINGS, LONGESTROAD, MAKEOFFER, MEMBERS, messageType, MONOPOLYPICK, MOVEPIECE, MOVEPIECEREQUEST, MOVEROBBER, NEWCHANNEL, NEWGAME, NEWGAMEWITHOPTIONS, NEWGAMEWITHOPTIONSREQUEST, NULLMESSAGE, PICKRESOURCES, PICKRESOURCESREQUEST, PIECEVALUE, PLAYDEVCARDREQUEST, PLAYERELEMENT, PLAYERELEMENTS, PLAYERSTATS, POTENTIALSETTLEMENTS, PUTPIECE, REJECTCONNECTION, REJECTOFFER, REMOVEPIECE, RESETBOARDAUTH, RESETBOARDREJECT, RESETBOARDREQUEST, RESETBOARDVOTE, RESETBOARDVOTEREQUEST, RESOURCECOUNT, REVEALFOGHEX, ROBOTDISMISS, ROBOTJOINGAMEREQUEST, ROLLDICE, ROLLDICEPROMPT, ROLLDICEREQUEST, SCENARIOINFO, sep, sep_char, sep2, sep2_char, SERVERPING, SETPLAYEDDEVCARD, SETSEATLOCK, SETSPECIALITEM, SETTURN, SETUPDONE, SIMPLEACTION, SIMPLEREQUEST, SITDOWN, STARTGAME, STATUSMESSAGE, SVPTEXTMSG, TEXTMSG, TIMINGPING, TURN, UPDATEROBOTPARAMS, VERSION
 
Constructor Summary
SOCAuthRequest(java.lang.String ro, java.lang.String nn, java.lang.String pw, int sch, java.lang.String hn)
          Create an AuthRequest message.
 
Method Summary
 int getMinimumVersion()
          Minimum version where this message type is used.
static SOCAuthRequest parseDataStr(java.lang.String s)
          Parse the command string into an AuthRequest message.
 java.lang.String toCmd()
          AUTHREQUEST sep role sep2 nickname sep2 authScheme sep2 host sep2 password
static java.lang.String toCmd(java.lang.String ro, java.lang.String nn, java.lang.String pw, int sch, java.lang.String hn)
          AUTHREQUEST sep role sep2 nickname sep2 authScheme sep2 host sep2 password
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getType, isSingleLineAndSafe, isSingleLineAndSafe, toMsg
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

VERSION_FOR_AUTHREQUEST

public static final int VERSION_FOR_AUTHREQUEST
Minimum version (1.1.19) of client/server which send and recognize AUTHREQUEST

See Also:
Constant Field Values

ROLE_GAME_PLAYER

public static final java.lang.String ROLE_GAME_PLAYER
Game Player role for auth request: Play or watch games, join chat channels

See Also:
Constant Field Values

ROLE_USER_ADMIN

public static final java.lang.String ROLE_USER_ADMIN
User Admin role for auth request: Create users

See Also:
Constant Field Values

SCHEME_CLIENT_PLAINTEXT

public static final int SCHEME_CLIENT_PLAINTEXT
Scheme #1, for client to connect using a plaintext password

See Also:
Constant Field Values

NULLHOST

private static final java.lang.String NULLHOST
Token to indicate host is null or "", to avoid adjacent delimiters

See Also:
Constant Field Values

role

public final java.lang.String role
Role that requester connected to server for, such as ROLE_GAME_PLAYER or ROLE_USER_ADMIN.

This is an untrusted field that's here for convenience. Later messages will always check whether the authenticated user has authorization to (for example) create users. By sending ROLE_USER_ADMIN with this message instead of that later one, the server can tell a client at login that they aren't authorized instead of telling them only after they've filled out the account creation form.


nickname

public final java.lang.String nickname
Nickname (username) of the joining client


password

public final java.lang.String password
Optional password, or ""


authScheme

public final int authScheme
Authentication scheme number, such as SCHEME_CLIENT_PLAINTEXT.


host

public final java.lang.String host
Server host name to which the client is connecting, or null for client's local TCP server. Since the client is already connected when it sends the message, this is only informational. The empty string "" is stored as null here.

Constructor Detail

SOCAuthRequest

public SOCAuthRequest(java.lang.String ro,
                      java.lang.String nn,
                      java.lang.String pw,
                      int sch,
                      java.lang.String hn)
               throws java.lang.IllegalArgumentException
Create an AuthRequest message.

Parameters:
ro - the role they've connected to server for, such as ROLE_GAME_PLAYER
nn - nickname
pw - optional password, or ""; this is the last field of the message so that it can contain delimiter chars
sch - auth scheme number, such as SCHEME_CLIENT_PLAINTEXT
hn - server host name, or null; "" is stored as null in the host field
Throws:
java.lang.IllegalArgumentException - if ro, nn, or hn contains a delimiter character or is null or otherwise doesn't pass SOCMessage.isSingleLineAndSafe(String)
Method Detail

toCmd

public java.lang.String toCmd()
AUTHREQUEST sep role sep2 nickname sep2 authScheme sep2 host sep2 password

Specified by:
toCmd in class SOCMessage
Returns:
the command String

toCmd

public static java.lang.String toCmd(java.lang.String ro,
                                     java.lang.String nn,
                                     java.lang.String pw,
                                     int sch,
                                     java.lang.String hn)
                              throws java.lang.IllegalArgumentException
AUTHREQUEST sep role sep2 nickname sep2 authScheme sep2 host sep2 password

Parameters:
ro - the role they've connected to server for, such as ROLE_GAME_PLAYER
nn - the nickname
pw - the optional password, or ""; this is the last field of the message so that it can contain delimiter chars
sch - auth scheme number, such as SCHEME_CLIENT_PLAINTEXT
hn - the server host name, or null
Returns:
the command string
Throws:
java.lang.IllegalArgumentException - if ro, nn, or hn contains a delimiter character or is null or otherwise doesn't pass SOCMessage.isSingleLineAndSafe(String)

parseDataStr

public static SOCAuthRequest parseDataStr(java.lang.String s)
Parse the command string into an AuthRequest message.

The constructor called here checks received field contents against SOCMessage.isSingleLineAndSafe(String) to sanitize; if that fails, null is returned.

Parameters:
s - the string to parse, as output from toCmd()
Returns:
an AuthRequest message, or null of the data is garbled

getMinimumVersion

public final int getMinimumVersion()
Minimum version where this message type is used. AUTHREQUEST was introduced in 1.1.19.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1119 for JSettlers 1.1.19.

toString

public final java.lang.String toString()
Description copied from class: SOCMessage
Simple human-readable representation, used for debug purposes.

Specified by:
toString in class SOCMessage
Returns:
a human readable form of the message; indicates whether password is empty or set, but obscures its value