Package com.ongres.scram.common.message
Class ClientFirstMessage
java.lang.Object
com.ongres.scram.common.message.ClientFirstMessage
- All Implemented Interfaces:
StringWritable
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientFirstMessage(Gs2CbindFlag gs2CbindFlag, String authzid, String cbindName, String user, String nonce) Constructs a client-first-message for the given parameters.ClientFirstMessage(Gs2Header gs2Header, String user, String nonce) Constructs a client-first-message for the given user, nonce and gs2Header.ClientFirstMessage(String user, String nonce) Constructs a client-first-message for the given parameters, with no channel binding nor authzid. -
Method Summary
Modifier and TypeMethodDescriptiongetNonce()getUser()private static Gs2Headergs2Header(Gs2CbindFlag gs2CbindFlag, String authzid, String cbindName) booleanstatic ClientFirstMessageConstruct aClientFirstMessageinstance from a message (String)toString()writeTo(StringBuffer sb) Write the class information to the given StringBuffer.Limited version of theObject.toString()method, that doesn't write the GS2 header.
-
Field Details
-
gs2Header
-
user
-
nonce
-
-
Constructor Details
-
ClientFirstMessage
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- The GSS-API headeruser- The SCRAM usernonce- The nonce for this session- Throws:
IllegalArgumentException- If any of the arguments is null or empty
-
ClientFirstMessage
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- The channel-binding flagauthzid- The optional authzidcbindName- The optional channel binding nameuser- The SCRAM usernonce- 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:
user- The SCRAM usernonce- The nonce for this session- Throws:
IllegalArgumentException- If the user or nonce are null or empty
-
-
Method Details
-
gs2Header
-
getChannelBindingFlag
-
isChannelBinding
public boolean isChannelBinding() -
getChannelBindingName
-
getAuthzid
-
getGs2Header
-
getUser
-
getNonce
-
writeToWithoutGs2Header
Limited version of theObject.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- A StringBuffer where to write the data to.- Returns:
- The same StringBuffer
-
writeTo
Description copied from interface:StringWritableWrite the class information to the given StringBuffer.- Specified by:
writeToin interfaceStringWritable- Parameters:
sb- Where to write the data.- Returns:
- The same StringBuffer.
-
parseFrom
public static ClientFirstMessage parseFrom(String clientFirstMessage) throws ScramParseException, IllegalArgumentException 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
-