Poznámka
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
V rozhraní .NET Framework 3.0 obsahovala zpráva klienta pouze jeden token libovolného typu. Klientské zprávy teď můžou obsahovat více tokenů typu. Toto téma ukazuje, jak do zprávy klienta zahrnout více tokenů stejného typu.
Všimněte si, že službu nelze tímto způsobem nakonfigurovat: Služba může obsahovat pouze jeden podpůrný token.
Použití více tokenů zabezpečení stejného typu
Vytvořte prázdnou kolekci elementů vazby, která se má naplnit.
// Create an empty BindingElementCollection to populate, // then create a custom binding from it. BindingElementCollection bec = new BindingElementCollection();
Vytvoření voláním SecurityBindingElementCreateMutualCertificateBindingElement.
SecurityBindingElement sbe = SecurityBindingElement.CreateMutualCertificateBindingElement();
Vytvořte kolekci SupportingTokenParameters .
SupportingTokenParameters supportParams = new SupportingTokenParameters();
Přidejte do kolekce tokeny SAML.
// Two supporting SAML tokens are being added. supportParams.SignedEndorsing.Add(new IssuedSecurityTokenParameters("samlTokenType", issuerEndpointAddress1, issuerBinding1)); supportParams.SignedEndorsing.Add(new IssuedSecurityTokenParameters("samlTokenType", issuerEndpointAddress2, issuerBinding2));
Přidejte kolekci do souboru SecurityBindingElement.
((SymmetricSecurityBindingElement)sbe).OperationSupportingTokenParameters.Add("*", supportParams);
Přidejte prvky vazby do kolekce elementů vazby.
bec.Add(sbe); bec.Add(new TextMessageEncodingBindingElement()); bec.Add(new HttpTransportBindingElement());
Vrátí novou vlastní vazbu vytvořenou z kolekce elementů vazby.
// Create a CustomBinding and return it; otherwise, return null. return new CustomBinding(bec);
Příklad
Následuje celá metoda popsaná předchozím postupem.
// This method creates a CustomBinding that includes two tokens of a given type.
public static Binding CreateCustomBinding(EndpointAddress issuerEndpointAddress1, Binding issuerBinding1, EndpointAddress issuerEndpointAddress2, Binding issuerBinding2)
{
// Create an empty BindingElementCollection to populate,
// then create a custom binding from it.
BindingElementCollection bec = new BindingElementCollection();
SecurityBindingElement sbe = SecurityBindingElement.CreateMutualCertificateBindingElement();
SupportingTokenParameters supportParams = new SupportingTokenParameters();
// Two supporting SAML tokens are being added.
supportParams.SignedEndorsing.Add(new IssuedSecurityTokenParameters("samlTokenType", issuerEndpointAddress1, issuerBinding1));
supportParams.SignedEndorsing.Add(new IssuedSecurityTokenParameters("samlTokenType", issuerEndpointAddress2, issuerBinding2));
((SymmetricSecurityBindingElement)sbe).OperationSupportingTokenParameters.Add("*", supportParams);
bec.Add(sbe);
bec.Add(new TextMessageEncodingBindingElement());
bec.Add(new HttpTransportBindingElement());
// Create a CustomBinding and return it; otherwise, return null.
return new CustomBinding(bec);
}