soc.message
Class SOCCreateAccount

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

public class SOCCreateAccount
extends SOCMessage

This message is a request to create an account

The server will respond with a SOCStatusMessage indicating whether the account was created, with status SOCStatusMessage.SV_ACCT_CREATED_OK or an error/rejection status and brief text.

In version 1.1.19 and higher, by default users must authenticate before creating user accounts. (See SOCServerFeatures.FEAT_OPEN_REG.) If the user needs to log in but hasn't before sending SOCCreateAccount, the server replies with SOCStatusMessage.SV_PW_WRONG.

In version 1.1.20 and higher, after creating the very first account the reply status is SOCStatusMessage.SV_ACCT_CREATED_OK_FIRST_ONE unless FEAT_OPEN_REG is active.

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
private  java.lang.String email
          Email address, optional; see getEmail().
private  java.lang.String host
          Host name, required; see getHost() for details and history.
private  java.lang.String nickname
          Nickname
private static java.lang.String NULLEMAIL
          symbol to represent a null email
private  java.lang.String password
          Password, required; see getPassword() for details and history.
private static long serialVersionUID
           
 
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
SOCCreateAccount(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String em)
          Create a CreateAccount message.
 
Method Summary
 java.lang.String getEmail()
          Optional email address for the requested new account.
 java.lang.String getHost()
          Host name for the requested new account.
 java.lang.String getNickname()
          Nickname (username) to give to requested account.
 java.lang.String getPassword()
          Password for the requested new account.
static SOCCreateAccount parseDataStr(java.lang.String s)
          Parse the command String into a CreateAccount message.
 java.lang.String toCmd()
          CREATEACCOUNT sep nickname sep2 password sep2 host sep2 email
static java.lang.String toCmd(java.lang.String nn, java.lang.String pw, java.lang.String hn, java.lang.String em)
          CREATEACCOUNT sep nickname sep2 password sep2 host sep2 email
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getMinimumVersion, 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

NULLEMAIL

private static java.lang.String NULLEMAIL
symbol to represent a null email


nickname

private java.lang.String nickname
Nickname


password

private java.lang.String password
Password, required; see getPassword() for details and history.


host

private java.lang.String host
Host name, required; see getHost() for details and history.


email

private java.lang.String email
Email address, optional; see getEmail().

Constructor Detail

SOCCreateAccount

public SOCCreateAccount(java.lang.String nn,
                        java.lang.String pw,
                        java.lang.String hn,
                        java.lang.String em)
                 throws java.lang.IllegalArgumentException
Create a CreateAccount message.

Parameters:
nn - nickname Nickname (username) to give to requested account. The name must pass SOCMessage.isSingleLineAndSafe(String) in server v1.1.19 and higher.
pw - password; must not be null or ""
hn - host name; must not be null or ""
em - email; can be "", should not be null
Throws:
java.lang.IllegalArgumentException - if pw or hn are null or empty ("")
Method Detail

getNickname

public java.lang.String getNickname()
Nickname (username) to give to requested account. The name must pass SOCMessage.isSingleLineAndSafe(String) in server v1.1.19 and higher.

Returns:
the nickname

getPassword

public java.lang.String getPassword()
Password for the requested new account. This won't be null or 0-length: Enforced in constructor, toCmd(String, String, String, String), and parseDataStr(String).

Before v1.1.19, those methods didn't check their parameters for a non-blank password; parseDataStr(String) has always rejected a message without a password because two adjacent field-separator tokens (if no password) would be treated as one, and not enough fields would be found in the message.

Returns:
the password

getHost

public java.lang.String getHost()
Host name for the requested new account. This won't be null or 0-length: Enforced in constructor, toCmd(String, String, String, String), and parseDataStr(String).

Before v1.1.19, those methods didn't check their parameters for a non-blank host; parseDataStr(String) has always rejected a message without a host because two adjacent field-separator tokens (if no host) would be treated as one, and not enough fields would be found in the message.

Returns:
the host name

getEmail

public java.lang.String getEmail()
Optional email address for the requested new account.

Returns:
the email address, or "" if none

toCmd

public java.lang.String toCmd()
CREATEACCOUNT sep nickname sep2 password sep2 host sep2 email

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

toCmd

public static java.lang.String toCmd(java.lang.String nn,
                                     java.lang.String pw,
                                     java.lang.String hn,
                                     java.lang.String em)
                              throws java.lang.IllegalArgumentException
CREATEACCOUNT sep nickname sep2 password sep2 host sep2 email

Parameters:
nn - the nickname
pw - the password; must not be null or ""
hn - the host name; must not be null or ""
em - the email; optional, can use null or ""
Returns:
the command string
Throws:
java.lang.IllegalArgumentException - if pw or hn are null or empty ("")

parseDataStr

public static SOCCreateAccount parseDataStr(java.lang.String s)
Parse the command String into a CreateAccount message. A blank email field becomes "" (not null).

Parameters:
s - the String to parse
Returns:
a CreateAccount message, or null of the data is garbled

toString

public 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