Итак, у меня есть следующее зашифрованное утверждение SAML, которое я получил с сервера STS. Я вызываю конечную точку SOAP с этим токеном со следующим кодом, но он был успешным:
Это правильный способ сделать это?
var reader = new XmlTextReader(new StringReader(SAMLAssertionAsString));
SecurityTokenHandlerCollection handlers =
FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers;
var document = new XmlDocument { PreserveWhitespace = true };
document.Load(reader);
var encryptedAssertion = new SAML2.Saml20EncryptedAssertion((RSA)initiatingPartyKey.PrivateKey, document);
encryptedAssertion.Decrypt();
var decryptedContent = encryptedAssertion.Assertion.InnerXml;
// read the token
System.IdentityModel.Tokens.SecurityToken securityToken = handlers.ReadToken(decryptedContent );
ChannelFactory<IUSIService> _channelFactory;
_channelFactory = new ChannelFactory<IUSIService>("WS2007FederationHttpBinding_IUSIService");
IUSIService serviceChannel = _channelFactory.CreateChannelWithIssuedToken(securityToken);
_channelFactory.SomeService();
<saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="" Type="http://www.w3.org/2001/04/xmlenc#Element">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<xenc:EncryptedKey Id="">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
</xenc:EncryptionMethod>
<ds:KeyInfo>
<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<ds:X509Data>
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=,OU=,OU=,O=,C=AU</ds:X509IssuerName>
<ds:X509SerialNumber></ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue></xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedKey>
</ds:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue></xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</saml:EncryptedAssertion>