Top Description Fields Constructors Methods
com.ongres.scram.common.message

public Class ClientFirstMessage

extends Object
implements StringWritable
Class Inheritance
All Implemented Interfaces
com.ongres.scram.common.util.StringWritable
Imports
com.ongres.scram.common.ScramAttributeValue, .ScramAttributes, .ScramStringFormatting, com.ongres.scram.common.exception.ScramParseException, com.ongres.scram.common.gssapi.Gs2CbindFlag, .Gs2Header, com.ongres.scram.common.util.StringWritable, .StringWritableCsv

Constructs and parses client-first-messages. Message contains a Gs2Header, a username and a nonce. Formal syntax is: client-first-message-bare = [reserved-mext ","] username "," nonce ["," extensions] client-first-message = gs2-header client-first-message-bare Note that extensions are not supported.
See Also
[RFC5802] Section 7

Field Summary

Modifier and TypeField and Description
private final Gs2Header
private final String
private final String

Constructor Summary

AccessConstructor and Description
public
ClientFirstMessage(Gs2Header
The GSS-API header
gs2Header
,
String
The SCRAM user
user
,
String
The nonce for this session
nonce
)

Constructs a client-first-message for the given user, nonce and gs2Header.

public
ClientFirstMessage(Gs2CbindFlag
The channel-binding flag
gs2CbindFlag
,
String
The optional authzid
authzid
,
String
The optional channel binding name
cbindName
,
String
The SCRAM user
user
,
String
The nonce for this session
nonce
)

Constructs a client-first-message for the given parameters.

public
ClientFirstMessage(String
The SCRAM user
user
,
String
The nonce for this session
nonce
)

Constructs a client-first-message for the given parameters, with no channel binding nor authzid.

Method Summary

Modifier and TypeMethod and Description
public String
public Gs2CbindFlag
public String
public Gs2Header
public String
public String
private static Gs2Header
gs2Header(Gs2CbindFlag gs2CbindFlag, String authzid, String cbindName)

public boolean
public static ClientFirstMessage

Returns:

The instance
parseFrom
(String
The String representing the client-first-message
clientFirstMessage
)

Construct a ClientFirstMessage instance from a message (String)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public StringBuffer
writeTo(StringBuffer
Where to write the data.
sb
)

Implements com.ongres.scram.common.util.StringWritable.writeTo.

Write the class information to the given StringBuffer.
public StringBuffer

Returns:

The same StringBuffer
writeToWithoutGs2Header
(StringBuffer
A StringBuffer where to write the data to.
sb
)

Limited version of the StringWritableCsv#toString() method, that doesn't write the GS2 header.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

gs2Headerback to summary
private final Gs2Header gs2Header
nonceback to summary
private final String nonce
userback to summary
private final String user

Constructor Detail

ClientFirstMessageback to summary
public ClientFirstMessage(Gs2Header gs2Header, String user, String nonce) throws IllegalArgumentException

Constructs a client-first-message for the given user, nonce and gs2Header. This constructor is intended to be instantiated by a scram client, and not directly. The client should be providing the header, and nonce (and probably the user too).

Parameters
gs2Header:Gs2Header

The GSS-API header

user:String

The SCRAM user

nonce:String

The nonce for this session

Exceptions
IllegalArgumentException:
If any of the arguments is null or empty
ClientFirstMessageback to summary
public ClientFirstMessage(Gs2CbindFlag gs2CbindFlag, String authzid, String cbindName, String user, String nonce)

Constructs a client-first-message for the given parameters. Under normal operation, this constructor is intended to be instantiated by a scram client, and not directly. However, this constructor is more user- or test-friendly, as the arguments are easier to provide without building other indirect object parameters.

Parameters
gs2CbindFlag:Gs2CbindFlag

The channel-binding flag

authzid:String

The optional authzid

cbindName:String

The optional channel binding name

user:String

The SCRAM user

nonce:String

The nonce for this session

Exceptions
IllegalArgumentException:
If the flag, user or nonce are null or empty
ClientFirstMessageback to summary
public ClientFirstMessage(String user, String nonce)

Constructs a client-first-message for the given parameters, with no channel binding nor authzid. Under normal operation, this constructor is intended to be instantiated by a scram client, and not directly. However, this constructor is more user- or test-friendly, as the arguments are easier to provide without building other indirect object parameters.

Parameters
user:String

The SCRAM user

nonce:String

The nonce for this session

Exceptions
IllegalArgumentException:
If the user or nonce are null or empty

Method Detail

getAuthzidback to summary
public String getAuthzid()
getChannelBindingFlagback to summary
public Gs2CbindFlag getChannelBindingFlag()
getChannelBindingNameback to summary
public String getChannelBindingName()
getGs2Headerback to summary
public Gs2Header getGs2Header()
getNonceback to summary
public String getNonce()
getUserback to summary
public String getUser()
gs2Headerback to summary
private static Gs2Header gs2Header(Gs2CbindFlag gs2CbindFlag, String authzid, String cbindName)
isChannelBindingback to summary
public boolean isChannelBinding()
parseFromback to summary
public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException

Construct a ClientFirstMessage instance from a message (String)

Parameters
clientFirstMessage:String

The String representing the client-first-message

Returns:ClientFirstMessage

The instance

Exceptions
ScramParseException:
If the message is not a valid client-first-message
IllegalArgumentException:
If the message is null or empty
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeToback to summary
public StringBuffer writeTo(StringBuffer sb)

Implements com.ongres.scram.common.util.StringWritable.writeTo.

Doc from com.ongres.scram.common.util.StringWritable.writeTo.

Write the class information to the given StringBuffer.

Parameters
sb:StringBuffer

Where to write the data.

Returns:StringBuffer

The same StringBuffer.

Annotations
@Override
writeToWithoutGs2Headerback to summary
public StringBuffer writeToWithoutGs2Header(StringBuffer sb)

Limited version of the StringWritableCsv#toString() method, that doesn't write the GS2 header. This method is useful to construct the auth message used as part of the SCRAM algorithm.

Parameters
sb:StringBuffer

A StringBuffer where to write the data to.

Returns:StringBuffer

The same StringBuffer