12 private enum SerializationMask
19 OriginalIssuerEqualsIssuer = 0x10,
25 private string m_issuer;
27 private string m_originalIssuer;
29 private string m_type;
31 private string m_value;
33 private string m_valueType;
36 private byte[] m_userSerializationData;
41 private object m_propertyLock =
new object();
64 if (m_properties ==
null)
68 if (m_properties ==
null)
94 public string Type => m_type;
120 Initialize(reader, subject);
128 public Claim(
string type,
string value)
129 : this(type, value,
"http://www.w3.org/2001/XMLSchema#string",
"LOCAL AUTHORITY",
"LOCAL AUTHORITY", null)
139 public Claim(
string type,
string value,
string valueType)
140 : this(type, value, valueType,
"LOCAL AUTHORITY",
"LOCAL AUTHORITY", null)
151 public Claim(
string type,
string value,
string valueType,
string issuer)
152 : this(type, value, valueType, issuer, issuer, null)
164 public Claim(
string type,
string value,
string valueType,
string issuer,
string originalIssuer)
165 : this(type, value, valueType, issuer, originalIssuer, null)
178 public Claim(
string type,
string value,
string valueType,
string issuer,
string originalIssuer,
ClaimsIdentity subject)
179 : this(type, value, valueType, issuer, originalIssuer, subject, null, null)
183 internal Claim(
string type,
string value,
string valueType,
string issuer,
string originalIssuer,
ClaimsIdentity subject,
string propertyKey,
string propertyValue)
195 if (
string.IsNullOrEmpty(valueType))
197 m_valueType =
"http://www.w3.org/2001/XMLSchema#string";
201 m_valueType = valueType;
203 if (
string.IsNullOrEmpty(issuer))
205 m_issuer =
"LOCAL AUTHORITY";
211 if (
string.IsNullOrEmpty(originalIssuer))
213 m_originalIssuer = m_issuer;
217 m_originalIssuer = originalIssuer;
220 if (propertyKey !=
null)
229 : this(other, other?.m_subject)
242 m_issuer = other.m_issuer;
243 m_originalIssuer = other.m_originalIssuer;
245 m_type = other.m_type;
246 m_value = other.m_value;
247 m_valueType = other.m_valueType;
248 if (other.m_properties !=
null)
251 foreach (
string key
in other.m_properties.
Keys)
253 m_properties.
Add(key, other.m_properties[key]);
256 if (other.m_userSerializationData !=
null)
258 m_userSerializationData = (other.m_userSerializationData.Clone() as
byte[]);
265 m_propertyLock =
new object();
280 return new Claim(
this, identity);
290 SerializationMask serializationMask = (SerializationMask)reader.
ReadInt32();
294 if ((serializationMask & SerializationMask.NameClaimType) == SerializationMask.NameClaimType)
296 m_type =
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name";
298 else if ((serializationMask & SerializationMask.RoleClaimType) == SerializationMask.RoleClaimType)
300 m_type =
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role";
307 if ((serializationMask & SerializationMask.StringType) == SerializationMask.StringType)
314 m_valueType =
"http://www.w3.org/2001/XMLSchema#string";
316 if ((serializationMask & SerializationMask.Issuer) == SerializationMask.Issuer)
323 m_issuer =
"LOCAL AUTHORITY";
325 if ((serializationMask & SerializationMask.OriginalIssuerEqualsIssuer) == SerializationMask.OriginalIssuerEqualsIssuer)
327 m_originalIssuer = m_issuer;
329 else if ((serializationMask & SerializationMask.OriginalIssuer) == SerializationMask.OriginalIssuer)
336 m_originalIssuer =
"LOCAL AUTHORITY";
338 if ((serializationMask & SerializationMask.HasProperties) == SerializationMask.HasProperties)
341 for (
int i = 0; i < num3; i++)
346 if ((serializationMask & SerializationMask.UserData) == SerializationMask.UserData)
349 m_userSerializationData = reader.
ReadBytes(count);
352 for (
int j = num; j < num2; j++)
375 SerializationMask serializationMask = SerializationMask.None;
376 if (
string.Equals(m_type,
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"))
378 serializationMask |= SerializationMask.NameClaimType;
380 else if (
string.Equals(m_type,
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"))
382 serializationMask |= SerializationMask.RoleClaimType;
388 if (!
string.Equals(m_valueType,
"http://www.w3.org/2001/XMLSchema#string",
StringComparison.Ordinal))
391 serializationMask |= SerializationMask.StringType;
396 serializationMask |= SerializationMask.Issuer;
400 serializationMask |= SerializationMask.OriginalIssuerEqualsIssuer;
402 else if (!
string.Equals(m_originalIssuer,
"LOCAL AUTHORITY",
StringComparison.Ordinal))
405 serializationMask |= SerializationMask.OriginalIssuer;
410 serializationMask |= SerializationMask.HasProperties;
412 if (userData !=
null && userData.Length != 0)
415 serializationMask |= SerializationMask.UserData;
417 writer.
Write((
int)serializationMask);
419 writer.
Write(m_value);
420 if ((serializationMask & SerializationMask.NameClaimType) != SerializationMask.NameClaimType && (serializationMask & SerializationMask.RoleClaimType) != SerializationMask.RoleClaimType)
422 writer.
Write(m_type);
424 if ((serializationMask & SerializationMask.StringType) == SerializationMask.StringType)
426 writer.
Write(m_valueType);
428 if ((serializationMask & SerializationMask.Issuer) == SerializationMask.Issuer)
430 writer.
Write(m_issuer);
432 if ((serializationMask & SerializationMask.OriginalIssuer) == SerializationMask.OriginalIssuer)
434 writer.
Write(m_originalIssuer);
436 if ((serializationMask & SerializationMask.HasProperties) == SerializationMask.HasProperties)
445 if ((serializationMask & SerializationMask.UserData) == SerializationMask.UserData)
447 writer.
Write(userData.Length);
448 writer.
Write(userData);
Claim(Claim other, ClaimsIdentity subject)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified security cl...
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
string OriginalIssuer
Gets the original issuer of the claim.
Claim(string type, string value, string valueType, string issuer)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified claim type,...
virtual void WriteTo(BinaryWriter writer, byte[] userData)
Writes this T:System.Security.Claims.Claim to the writer.
virtual int ReadInt32()
Reads a 4-byte signed integer from the current stream and advances the current position of the stream...
virtual void WriteTo(BinaryWriter writer)
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
virtual void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
No initialization action.
Claim(string type, string value)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified claim type,...
ICollection< TKey > Keys
Gets an T:System.Collections.Generic.ICollection`1 containing the keys of the T:System....
virtual Claim Clone(ClaimsIdentity identity)
Returns a new T:System.Security.Claims.Claim object copied from this object. The subject of the new c...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
string Value
Gets the value of the claim.
IDictionary< string, string > Properties
Gets a dictionary that contains additional properties associated with this claim.
Claim(string type, string value, string valueType, string issuer, string originalIssuer)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified claim type,...
KeyCollection Keys
Gets a collection containing the keys in the T:System.Collections.Generic.Dictionary`2.
virtual byte [] ReadBytes(int count)
Reads the specified number of bytes from the current stream into a byte array and advances the curren...
Claim(string type, string value, string valueType)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified claim type,...
Reads primitive data types as binary values in a specific encoding.
Claim(BinaryReader reader, ClaimsIdentity subject)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified reader,...
Claim(BinaryReader reader)
Represents a claims-based identity.
Represents type declarations: class types, interface types, array types, value types,...
virtual void Write(bool value)
Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing t...
override string ToString()
Returns a string representation of this T:System.Security.Claims.Claim object.
ClaimsIdentity Subject
Gets the subject of the claim.
string Issuer
Gets the issuer of the claim.
void Add(TKey key, TValue value)
Adds an element with the provided key and value to the T:System.Collections.Generic....
virtual byte [] CustomSerializationData
Claim(string type, string value, string valueType, string issuer, string originalIssuer, ClaimsIdentity subject)
Initializes a new instance of the T:System.Security.Claims.Claim class with the specified claim type,...
void Add(TKey key, TValue value)
Adds the specified key and value to the dictionary.
virtual Claim Clone()
Returns a new T:System.Security.Claims.Claim object copied from this object. The new claim does not h...
virtual string ReadString()
Reads a string from the current stream. The string is prefixed with the length, encoded as an integer...
Provides information about a specific culture (called a locale for unmanaged code development)....
Writes primitive types in binary to a stream and supports writing strings in a specific encoding.
Provides the base class for value types.