|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.message.SOCMessage soc.message.SOCAuthRequest
public class SOCAuthRequest
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
:
SOCStatusMessage.SV_OK
if the username and password were authenticated
SOCStatusMessage.SV_NOT_OK_GENERIC
if the auth scheme number is unknown
or if the client hasn't already sent SOCVersion
to the server
SOCStatusMessage.SV_PW_REQUIRED
if server settings require a password but none was given
SOCStatusMessage.SV_PW_WRONG
if the username and password are not a valid combination:
The password is wrong, or if the nickname is unknown at the server.
The server never replies to this message with SOCStatusMessage.SV_NAME_NOT_FOUND
.
SOCStatusMessage.SV_ACCT_NOT_CREATED_DENIED
if the auth request is for
ROLE_USER_ADMIN
but the requesting user isn't authorized to do that
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:
SOCNewGameWithOptionsRequest
,
Serialized FormField 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 |
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 |
---|
private static final long serialVersionUID
public static final int VERSION_FOR_AUTHREQUEST
public static final java.lang.String ROLE_GAME_PLAYER
role
for auth request: Play or watch games, join chat channels
public static final java.lang.String ROLE_USER_ADMIN
role
for auth request: Create users
public static final int SCHEME_CLIENT_PLAINTEXT
private static final java.lang.String NULLHOST
null
or "", to avoid adjacent delimiters
public final java.lang.String role
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.
public final java.lang.String nickname
public final java.lang.String password
public final int authScheme
SCHEME_CLIENT_PLAINTEXT
.
public final java.lang.String host
Constructor Detail |
---|
public SOCAuthRequest(java.lang.String ro, java.lang.String nn, java.lang.String pw, int sch, java.lang.String hn) throws java.lang.IllegalArgumentException
ro
- the role
they've connected to server for, such as ROLE_GAME_PLAYER
nn
- nicknamepw
- optional password, or ""; this is the last field of the message
so that it can contain delimiter charssch
- auth scheme number, such as SCHEME_CLIENT_PLAINTEXT
hn
- server host name, or null; "" is stored as null in the host
field
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 |
---|
public java.lang.String toCmd()
toCmd
in class SOCMessage
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
ro
- the role
they've connected to server for, such as ROLE_GAME_PLAYER
nn
- the nicknamepw
- the optional password, or ""; this is the last field of the message
so that it can contain delimiter charssch
- auth scheme number, such as SCHEME_CLIENT_PLAINTEXT
hn
- the server host name, or null
java.lang.IllegalArgumentException
- if ro
, nn
, or hn
contains a delimiter character
or is null or otherwise doesn't pass SOCMessage.isSingleLineAndSafe(String)
public static SOCAuthRequest parseDataStr(java.lang.String s)
The constructor called here checks received field contents against
SOCMessage.isSingleLineAndSafe(String)
to sanitize; if that
fails, null is returned.
s
- the string to parse, as output from toCmd()
public final int getMinimumVersion()
getMinimumVersion
in class SOCMessage
public final java.lang.String toString()
SOCMessage
toString
in class SOCMessage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |