SamlAttribute Class

 

Represents an attribute that is associated with the subject of a SamlAttributeStatement.

Namespace:   System.IdentityModel.Tokens
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

System.Object
  System.IdentityModel.Tokens.SamlAttribute

public class SamlAttribute

NameDescription
System_CAPS_pubmethodSamlAttribute()

Initializes a new instance of the SamlAttribute class.

System_CAPS_pubmethodSamlAttribute(Claim)

Initializes a new instance of the SamlAttribute class using the specified claim.

System_CAPS_pubmethodSamlAttribute(String, String, IEnumerable<String>)

Initializes a new instance of the SamlAttribute class using the specified attribute name, XML namespace, and attribute values.

NameDescription
System_CAPS_pubpropertyAttributeValues

Gets a collection of attribute values for the SAML attribute.

System_CAPS_pubpropertyAttributeValueXsiType

Gets or sets the xsi:type of the values contained in the SAML Attribute.

System_CAPS_pubpropertyIsReadOnly

Gets a value that indicates whether the properties of this instance are read-only.

System_CAPS_pubpropertyName

Gets or sets the name of the SAML attribute.

System_CAPS_pubpropertyNamespace

Gets or sets the XML namespace in which the name of the SAML attribute is defined.

System_CAPS_pubpropertyOriginalIssuer

Gets or sets the string that represents the OriginalIssuer of the SAML attribute.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodExtractClaims()

Gets a collection of claims that this SAML attribute represents.

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodMakeReadOnly()

Causes this instance to be read-only.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodReadXml(XmlDictionaryReader, SamlSerializer, SecurityTokenSerializer, SecurityTokenResolver)

Reads the SAML attribute from the specified XML reader.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWriteXml(XmlDictionaryWriter, SamlSerializer, SecurityTokenSerializer)

Writes the SAML attribute into the specified XML serializer.

The SamlAttribute class corresponds to the <saml:Attribute> XML element that is defined in the OASIS SAML 1.1 specification.

A SamlAttribute instance contains PossessProperty claims for the subject of a SamlAttributeStatement. For example, a SamlAttribute might contain an Over21 claim, whose type would be specified in the Namespace property and whose resource would be specified as a member of the collection in the AttributeValues property. When the CreatePolicy method is called, this Over21 claim is added to the authorization policy that is returned by returned from by the SamlAttributeStatement. When the AttributeValues property contains multiple elements then one claim is returned for each element.

SamlAttribute position in the SAML object hierarchy is:

SamlSecurityToken

  SamlAssertion

    SamlAttributeStatement

      SamlAttribute

protected override Collection<SamlAttribute> GetIssuedClaims(RequestSecurityToken RST)
{
    EndpointAddress rstAppliesTo = RST.AppliesTo;

    if (rstAppliesTo == null)
    {
        throw new InvalidOperationException("No AppliesTo EndpointAddress in RequestSecurityToken");
    }

    string bookName = rstAppliesTo.Headers.FindHeader(Constants.BookNameHeaderName, Constants.BookNameHeaderNamespace).GetValue<string>();
    if (string.IsNullOrEmpty(bookName))
        throw new FaultException("The book name was not specified in the RequestSecurityToken");

    EnsurePurchaseLimitSufficient(bookName);

    Collection<SamlAttribute> samlAttributes = new Collection<SamlAttribute>();

    foreach (ClaimSet claimSet in ServiceSecurityContext.Current.AuthorizationContext.ClaimSets)
    {
        // Copy Name claims from the incoming credentials into the set of claims to be issued.
        IEnumerable<Claim> nameClaims = claimSet.FindClaims(ClaimTypes.Name, Rights.PossessProperty);
        if (nameClaims != null)
        {
            foreach (Claim nameClaim in nameClaims)
            {
                samlAttributes.Add(new SamlAttribute(nameClaim));
            }
        }
    }
    // Add a purchase authorized claim.
    samlAttributes.Add(new SamlAttribute(new Claim(Constants.PurchaseAuthorizedClaim, bookName, Rights.PossessProperty)));
    return samlAttributes;
}

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: