Package com.ongres.scram.common
Class ClientFirstMessage
java.lang.Object
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:
- Implementation Note:
extensionsare not supported.
-
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@NotNull StringReturn the client nonce.@NotNull Gs2HeaderReturn the Gs2Header.@NotNull StringReturn the username.booleanCheck to probe if gs2-cbind-flag is set to "p=".static @NotNull ClientFirstMessageConstruct aClientFirstMessageinstance from a message (String).final @NotNull StringtoString()String representation of the SCRAM message.
-
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
-
parseFrom
@NotNull public static @NotNull ClientFirstMessage parseFrom(@NotNull @NotNull String clientFirstMessage) throws ScramParseException Construct aClientFirstMessageinstance 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
-
toString
String representation of the SCRAM message.
-