SamlAttribute Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Representa um atributo associado ao sujeito de um SamlAttributeStatement.
public ref class SamlAttribute
public class SamlAttribute
type SamlAttribute = class
Public Class SamlAttribute
- Herança
-
SamlAttribute
Exemplos
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;
}
Protected Overrides Function GetIssuedClaims(ByVal RST As RequestSecurityToken) As Collection(Of SamlAttribute)
Dim rstAppliesTo As EndpointAddress = RST.AppliesTo
If rstAppliesTo Is Nothing Then
Throw New InvalidOperationException("No AppliesTo EndpointAddress in RequestSecurityToken")
End If
Dim bookName As String = rstAppliesTo.Headers.FindHeader(Constants.BookNameHeaderName, Constants.BookNameHeaderNamespace).GetValue(Of String)()
If String.IsNullOrEmpty(bookName) Then
Throw New FaultException("The book name was not specified in the RequestSecurityToken")
End If
EnsurePurchaseLimitSufficient(bookName)
Dim samlAttributes As New Collection(Of SamlAttribute)()
Dim claimSet As ClaimSet
For Each claimSet In ServiceSecurityContext.Current.AuthorizationContext.ClaimSets
' Copy Name claims from the incoming credentials into the set of claims we're going to issue
Dim nameClaims As IEnumerable(Of Claim) = claimSet.FindClaims(ClaimTypes.Name, Rights.PossessProperty)
If Not (nameClaims Is Nothing) Then
Dim nameClaim As Claim
For Each nameClaim In nameClaims
samlAttributes.Add(New SamlAttribute(nameClaim))
Next nameClaim
End If
Next claimSet
' add a purchase authorized claim
samlAttributes.Add(New SamlAttribute(New Claim(Constants.PurchaseAuthorizedClaim, bookName, Rights.PossessProperty)))
Return samlAttributes
End Function
Observações
A SamlAttribute classe corresponde ao <saml:Attribute> elemento XML definido na especificação OASIS SAML 1.1.
Uma SamlAttribute instância contém PossessProperty reivindicações para o sujeito de um SamlAttributeStatement. Por exemplo, um SamlAttribute pode conter uma Over21 reivindicação, cujo tipo seria especificado na Namespace propriedade e cujo recurso seria especificado como membro da coleção na AttributeValues propriedade. Quando o CreatePolicy método é chamado, esta Over21 reivindicação é adicionada à política de autorização que é devolvida por retornada de por .SamlAttributeStatement Quando a AttributeValues propriedade contém múltiplos elementos, uma reivindicação é devolvida para cada elemento.
SamlAttribute a posição na hierarquia de objetos SAML é:
Construtores
| Name | Description |
|---|---|
| SamlAttribute() |
Inicializa uma nova instância da SamlAttribute classe. |
| SamlAttribute(Claim) |
Inicializa uma nova instância da SamlAttribute classe usando a reivindicação especificada. |
| SamlAttribute(String, String, IEnumerable<String>) |
Inicializa uma nova instância da SamlAttribute classe usando o nome do atributo especificado, o espaço de nomes XML e os valores do atributo. |
Propriedades
| Name | Description |
|---|---|
| AttributeValues |
Obtém uma coleção de valores de atributos para o atributo SAML. |
| AttributeValueXsiType |
Obtém ou define o xsi:type dos valores contidos no atributo SAML. |
| IsReadOnly |
Obtém um valor que indica se as propriedades desta instância são de somente leitura. |
| Name |
Recebe ou define o nome do atributo SAML. |
| Namespace |
Obtém ou define o espaço de nomes XML onde o nome do atributo SAML está definido. |
| OriginalIssuer |
Obtém ou define a cadeia que representa o OriginalEmissor do atributo SAML. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| ExtractClaims() |
Recebe uma coleção de reivindicações que este atributo SAML representa. |
| GetHashCode() |
Serve como função de hash predefinida. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MakeReadOnly() |
Faz com que esta instância seja apenas de leitura. |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ReadXml(XmlDictionaryReader, SamlSerializer, SecurityTokenSerializer, SecurityTokenResolver) |
Lê o atributo SAML do leitor XML especificado. |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |
| WriteXml(XmlDictionaryWriter, SamlSerializer, SecurityTokenSerializer) |
Escreve o atributo SAML no serializador XML especificado. |