Beispiel #1
0
        protected void WriteBodyContentsCore(XmlDictionaryWriter w)
        {
            string ns = Constants.WstNamespace;

            w.WriteAttributeString("Context", Context);
            w.WriteElementString("t", "TokenType", ns, Constants.WsscContextToken);
            w.WriteElementString("t", "RequestType", ns, Constants.WstIssueRequest);
            w.WriteElementString("t", "KeySize", ns, XmlConvert.ToString(KeySize));
            if (BinaryExchange != null)
            {
                BinaryExchange.WriteTo(w);
            }
        }
Beispiel #2
0
        // it only supports negotiation so far ...
        protected override void OnWriteBodyContents(XmlDictionaryWriter w)
        {
            string ns  = Constants.WstNamespace;
            string nsu = Constants.WsuNamespace;

            w.WriteStartElement("t", "RequestSecurityTokenResponse", ns);
            w.WriteXmlnsAttribute("u", nsu);
            w.WriteAttributeString("Context", Context);
            if (Authenticator != null)
            {
                w.WriteStartElement("t", "Authenticator", ns);
                w.WriteStartElement("t", "CombinedHash", ns);
                w.WriteBase64(Authenticator, 0, Authenticator.Length);
                w.WriteEndElement();
                w.WriteEndElement();
            }
            if (TokenType != null)
            {
                w.WriteElementString("t", "TokenType", ns, TokenType);
            }
            if (RequestedSecurityToken != null)
            {
                w.WriteStartElement("t", "RequestedSecurityToken", ns);
                serializer.WriteToken(w, RequestedSecurityToken);
                w.WriteEndElement();
            }
            if (RequestedAttachedReference != null)
            {
                w.WriteStartElement("t", "RequestedAttachedReference", ns);
                serializer.WriteKeyIdentifierClause(w, RequestedAttachedReference);
                w.WriteEndElement();
            }
            if (RequestedUnattachedReference != null)
            {
                w.WriteStartElement("t", "RequestedUnattachedReference", ns);
                serializer.WriteKeyIdentifierClause(w, RequestedUnattachedReference);
                w.WriteEndElement();
            }
            if (RequestedProofToken != null)
            {
                w.WriteStartElement("t", "RequestedProofToken", ns);
                if (RequestedProofToken is SecurityToken)
                {
                    serializer.WriteToken(w, (SecurityToken)RequestedProofToken);
                }
                else if (RequestedProofToken is SecurityKeyIdentifierClause)
                {
                    serializer.WriteKeyIdentifierClause(w, (SecurityKeyIdentifierClause)RequestedProofToken);
                }
                else
                {
                    string ens = EncryptedXml.XmlEncNamespaceUrl;
                    w.WriteStartElement("e", "EncryptedKey", ens);
                    w.WriteStartElement("EncryptionMethod", ens);
                    w.WriteAttributeString("Algorithm", Constants.WstTlsnegoProofTokenType);
                    w.WriteEndElement();
                    w.WriteStartElement("CipherData", ens);
                    w.WriteStartElement("CipherValue", ens);
                    byte [] base64 = (byte [])RequestedProofToken;
                    w.WriteBase64(base64, 0, base64.Length);
                    w.WriteEndElement();
                    w.WriteEndElement();
                    w.WriteEndElement();
                }
                w.WriteEndElement();
            }
            if (Lifetime != null)
            {
                w.WriteStartElement("t", "Lifetime", ns);
                if (Lifetime.Created != DateTime.MinValue)
                {
                    w.WriteElementString("Created", nsu, XmlConvert.ToString(Lifetime.Created.ToUniversalTime(), Constants.LifetimeFormat));
                }
                if (Lifetime.Expires != DateTime.MaxValue)
                {
                    w.WriteElementString("Expires", nsu, XmlConvert.ToString(Lifetime.Expires.ToUniversalTime(), Constants.LifetimeFormat));
                }
                w.WriteEndElement();
            }
            //w.WriteElementString ("t", "KeySize", ns, XmlConvert.ToString (KeySize));
            if (BinaryExchange != null)
            {
                BinaryExchange.WriteTo(w);
            }
            w.WriteEndElement();
        }