Package com.ongres.scram.common
Class Gs2Header
java.lang.Object
com.ongres.scram.common.StringWritable
com.ongres.scram.common.Gs2Header
GS2 header for SCRAM.
gs2-cbind-flag | ("p=" cb-name) / "n" / "y" ;; "n" -> client doesn't support channel binding. ;; "y" -> client does support channel binding ;; but thinks the server does not. ;; "p" -> client requires channel binding. ;; The selected channel binding follows "p=". |
gs2-header | gs2-cbind-flag "," [ authzid ] "," ;; GS2 header for SCRAM ;; (the actual GS2 header includes an optional ;; flag to indicate that the GSS mechanism is not ;; "standard", but since SCRAM is "standard", we ;; don't include that flag). |
authzid | "a=" saslname |
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @Nullable Gs2AttributeValue
private final @NotNull Gs2AttributeValue
-
Constructor Summary
ConstructorsConstructorDescriptionGs2Header
(@NotNull Gs2CbindFlag cbindFlag) Construct and validates a Gs2Header with no authzid nor channel binding.Gs2Header
(@NotNull Gs2CbindFlag cbindFlag, @Nullable String cbName) Construct and validates a Gs2Header with no authzid.Gs2Header
(@NotNull Gs2CbindFlag cbindFlag, @Nullable String cbName, @Nullable String authzid) Construct and validates a Gs2Header. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkChannelBinding
(@NotNull Gs2CbindFlag cbindFlag, @Nullable String cbName) @Nullable String
Return the authzid.@NotNull Gs2CbindFlag
Return the channel binding flag.@Nullable String
Return the channel binding type.static @NotNull Gs2Header
Read a Gs2Header from a String.private static void
validateChannelBindingType
(@NotNull String cbname) Checks that the channel binding name is valid.(package private) StringBuilder
writeTo
(StringBuilder sb) Write the class information to the given StringBuffer.
-
Field Details
-
gs2CbindFlag
-
authzid
-
-
Constructor Details
-
Gs2Header
public Gs2Header(@NotNull @NotNull Gs2CbindFlag cbindFlag, @Nullable @Nullable String cbName, @Nullable @Nullable String authzid) Construct and validates a Gs2Header. Only provide the channel binding name if the channel binding flag is set to required.- Parameters:
cbindFlag
- The channel binding flagcbName
- The channel-binding name. Should be not null if channel binding is requiredauthzid
- The optional SASL authorization identity- Throws:
IllegalArgumentException
- If the channel binding flag and argument are invalid
-
Gs2Header
Construct and validates a Gs2Header with no authzid. Only provide the channel binding name if the channel binding flag is set to required.- Parameters:
cbindFlag
- The channel binding flagcbName
- The channel-binding name. Should be not null iif channel binding is required- Throws:
IllegalArgumentException
- If the channel binding flag and argument are invalid
-
Gs2Header
Construct and validates a Gs2Header with no authzid nor channel binding.- Parameters:
cbindFlag
- The channel binding flag- Throws:
IllegalArgumentException
- If the channel binding is supported (no cbname can be provided here)
-
-
Method Details
-
getChannelBindingFlag
Return the channel binding flag.- Returns:
- the
gs2-cbind-flag
-
getChannelBindingName
Return the channel binding type.- Returns:
- the
cb-name
-
getAuthzid
Return the authzid.- Returns:
- the
"a=" saslname
-
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.
-
parseFrom
Read a Gs2Header from a String. String may contain trailing fields that will be ignored.- Parameters:
message
- The String containing the Gs2Header- Returns:
- The parsed Gs2Header object
- Throws:
IllegalArgumentException
- If the format/values of the String do not conform to a Gs2Header
-
checkChannelBinding
private static void checkChannelBinding(@NotNull @NotNull Gs2CbindFlag cbindFlag, @Nullable @Nullable String cbName) -
validateChannelBindingType
Checks that the channel binding name is valid.cb-name = 1*(ALPHA / DIGIT / "." / "-") ;; See RFC 5056, Section 7.
- Parameters:
cbname
- Channel Binding Name- Throws:
IllegalArgumentException
- If the name is not a valid channel binding type.- See Also:
-