Package com.ongres.scram.common
Class ClientFirstMessage
java.lang.Object
com.ongres.scram.common.StringWritable
com.ongres.scram.common.AbstractScramMessage
com.ongres.scram.common.ClientFirstMessage
Constructs and parses client-first-messages. Message contains a
gs2-header
, a username
and a
nonce.
client-first-message-bare | [reserved-mext ","] username "," nonce ["," extensions] |
client-first-message | gs2-header client-first-message-bare |
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientFirstMessage
(@NotNull Gs2CbindFlag gs2CbindFlag, @Nullable String cbindName, @Nullable String authzid, @NotNull String username, @NotNull String clientNonce) Constructs a client-first-message for the given parameters.ClientFirstMessage
(@NotNull Gs2Header gs2Header, @NotNull String username, @NotNull String clientNonce) Constructs a client-first-message for the given user, nonce and gs2Header.ClientFirstMessage
(@NotNull String username, @NotNull String clientNonce) Constructs a client-first-message for the given parameters, with no channel binding nor authzid. -
Method Summary
Modifier and TypeMethodDescription(package private) @NotNull StringBuilder
clientFirstMessageBare
(@NotNull StringBuilder sb) Limited version of the StringWritableCsv method, that doesn't write the GS2 header.@NotNull String
Return the client nonce.@NotNull Gs2Header
Return the Gs2Header.@NotNull String
Return the username.boolean
Check to probe if gs2-cbind-flag is set to "p=".static @NotNull ClientFirstMessage
Construct aClientFirstMessage
instance from a message (String).(package private) StringBuilder
writeTo
(StringBuilder sb) Write the class information to the given StringBuffer.Methods inherited from class com.ongres.scram.common.AbstractScramMessage
toString
-
Field Details
-
gs2Header
gs2-header = gs2-cbind-flag "," [ authzid ] ",". -
username
username = "n=" saslname. -
clientNonce
nonce= "r=" c-nonce [s-nonce].
-
-
Constructor Details
-
ClientFirstMessage
public ClientFirstMessage(@NotNull @NotNull Gs2Header gs2Header, @NotNull @NotNull String username, @NotNull @NotNull String clientNonce) 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
- The GSS-API headerusername
- The SCRAM usernameclientNonce
- The nonce for this session- Throws:
IllegalArgumentException
- If any of the arguments is null or empty
-
ClientFirstMessage
public ClientFirstMessage(@NotNull @NotNull Gs2CbindFlag gs2CbindFlag, @Nullable @Nullable String cbindName, @Nullable @Nullable String authzid, @NotNull @NotNull String username, @NotNull @NotNull String clientNonce) 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
- The channel-binding flagcbindName
- The optional channel binding nameauthzid
- The optional authzidusername
- The SCRAM userclientNonce
- The nonce for this session- Throws:
IllegalArgumentException
- If the flag, user or nonce are null or empty
-
ClientFirstMessage
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:
username
- The SCRAM userclientNonce
- The nonce for this session- Throws:
IllegalArgumentException
- If the user or nonce are null or empty
-
-
Method Details
-
isChannelBindingRequired
public boolean isChannelBindingRequired()Check to probe if gs2-cbind-flag is set to "p=".- Returns:
- true if the message requires channel binding
-
getGs2Header
Return the Gs2Header.- Returns:
- the
gs2-header
-
getUsername
Return the username.- Returns:
- the
"n=" saslname
-
getClientNonce
Return the client nonce.- Returns:
- the
c-nonce
-
clientFirstMessageBare
Limited version of the StringWritableCsv 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
- A StringBuffer where to write the data to.- Returns:
- The same StringBuffer
-
parseFrom
@NotNull public static @NotNull ClientFirstMessage parseFrom(@NotNull @NotNull String clientFirstMessage) throws ScramParseException Construct aClientFirstMessage
instance from a message (String).- Parameters:
clientFirstMessage
- The String representing the client-first-message- Returns:
- The instance
- Throws:
ScramParseException
- If the message is not a valid client-first-messageIllegalArgumentException
- If the message is null or empty
-
writeTo
Description copied from class:StringWritable
Write the class information to the given StringBuffer.- Specified by:
writeTo
in classStringWritable
- Parameters:
sb
- Where to write the data.- Returns:
- The same StringBuffer.
-