Class ChannelAttribute
- Namespace
- Ubiety.Scram.Core.Attributes
- Assembly
- Ubiety.Scram.Core.dll
Represents a SCRAM 'Channel' attribute, used to specify a channel binding type during SCRAM authentication.
public class ChannelAttribute : ScramAttribute
- Inheritance
-
ChannelAttribute
- Inherited Members
Remarks
The channel binding information is encoded as a base64 string when creating the attribute.
Constructors
ChannelAttribute()
Initializes a new instance of the ChannelAttribute class with no header and no binding token.
public ChannelAttribute()
Remarks
Nothing in the library constructs the attribute this way - a channel attribute is only meaningful alongside the GS2 header it encodes. Kept because removing it would break the public API; a candidate for removal in the next major version.
ChannelAttribute(string, byte[]?)
Initializes a new instance of the ChannelAttribute class.
public ChannelAttribute(string header, byte[]? token = null)
Parameters
headerstringString representation of the GS2 header, including its trailing separators - "n,,", "y,,", or "p=<cb-name>,,". This is the unencoded header; to build the attribute from the base64 value on the wire, use FromWire(string).
tokenbyte[]Channel binding token.
Properties
Header
Gets the string representation of the GS2 header.
[UsedImplicitly]
public string Header { get; }
Property Value
Token
Gets the token representing the channel for binding.
[UsedImplicitly]
public byte[]? Token { get; }
Property Value
- byte[]
Methods
FromWire(string)
Builds a ChannelAttribute from the base64 value carried on the wire.
public static ChannelAttribute FromWire(string value)
Parameters
valuestringBase64 value of the attribute, without the leading "c=".
Returns
- ChannelAttribute
The parsed attribute.
Remarks
RFC 5802 defines the attribute as base64(gs2-header + cbind-data), and the header is "gs2-cbind-flag ',' [authzid] ','" - so the second comma ends the header and everything after it is the binding data. Splitting the two apart is what lets a peer verify the binding: the header has to match what the client committed to in its first message, and the data has to match the token the TLS connection produced.
Exceptions
- FormatException
Thrown when the value is not valid base64 or does not contain a complete GS2 header.
ToString()
Converts instance to a string.
public override string ToString()
Returns
- string
String representation of the attribute.
Operators
implicit operator string(ChannelAttribute)
Implicitly converts a ChannelAttribute to a string.
public static implicit operator string(ChannelAttribute attribute)
Parameters
attributeChannelAttributeAttribute to convert.
Returns
- string
String representation of the ChannelAttribute.