WriteElementString() public method

public WriteElementString ( System localName, System namespaceUri, string value ) : void
localName System
namespaceUri System
value string
return void
 protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     writer.WriteElementString("type", ExceptionType.ToString());
     writer.WriteElementString("message", Message);
     writer.WriteElementString("stack", Stack);
     writer.WriteElementString("appversion", AppVersion);
 }
 protected override void OnWriteHeaderContents(System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     writer.WriteElementString(VeriBranchMessageHeaderNames.IsSuccess, this.IsSuccess.ToString().ToLower());
     writer.WriteElementString(VeriBranchMessageHeaderNames.Description, this.Description);
     writer.WriteElementString(VeriBranchMessageHeaderNames.DisplayMessage, this.DisplayMessage);
     writer.WriteElementString(VeriBranchMessageHeaderNames.ErrorCode, this.ErrorCode);
     writer.WriteElementString(VeriBranchMessageHeaderNames.ExceptionMessage, this.ExceptionMessage);
 }
Example #3
0
		protected override void OnWriteFilterElementContents(XmlDictionaryWriter writer)
		{
			writer.WriteStartElement("LdapQuery", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery");
			writer.WriteElementString("Filter", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.Filter);
			writer.WriteElementString("BaseObject", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.SearchBase);
			writer.WriteElementString("Scope", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.SearchScope);
			writer.WriteEndElement();
		}
        internal override void WriteContentsTo(XmlDictionaryWriter writer)
        {
            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");

            writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.KeyInfo, XD.XmlSignatureDictionary.Namespace);
            writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.RsaKeyValue, XD.XmlSignatureDictionary.Namespace);
            RSA rsa = (RSA)this.IdentityClaim.Resource;
            RSAParameters parameters = rsa.ExportParameters(false);
            writer.WriteElementString(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.Modulus, XD.XmlSignatureDictionary.Namespace, Convert.ToBase64String(parameters.Modulus));
            writer.WriteElementString(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.Exponent, XD.XmlSignatureDictionary.Namespace, Convert.ToBase64String(parameters.Exponent));
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     if (this.data != int.MinValue)
     {
         writer.WriteElementString("ID", this.data.ToString());
     }
 }
        internal override void WriteContentsTo(XmlDictionaryWriter writer)
        {
            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");

            writer.WriteElementString(XD.AddressingDictionary.Dns, XD.AddressingDictionary.IdentityExtensionNamespace, (string)this.IdentityClaim.Resource);
        }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     if ((this.data != null) && (this.data.Length > 0))
     {
         writer.WriteElementString("BODY", this.data);
     }
 }
Example #8
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            writer.WriteStartElement("html");
            writer.WriteStartElement("head");
            writer.WriteElementString("title", "Request Failed");
            writer.WriteRaw(@"<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } h1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana; font-size: 1em;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>");
            writer.WriteEndElement(); //head
            writer.WriteStartElement("body");
            writer.WriteRaw("<div id='content'>");

            writer.WriteElementString("h1", "Request Failed");
            writer.WriteElementString("h3", Message);

            writer.WriteRaw("</div>");
            writer.WriteEndElement(); //body
            writer.WriteEndElement(); //html
        }
Example #9
0
        protected override void OnWriteHeaderContents(
            System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ServiceHeader));
            StringWriter  textWriter = new StringWriter();

            serializer.Serialize(textWriter, _customData);
            textWriter.Close();

            string text = textWriter.ToString();

            writer.WriteElementString(CUSTOM_HEADER_NAME, "Key", text.Trim());
        }
Example #10
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            writer.WriteStartElement(_operationName, _serviceNamespace);

            var values = _valueGetter();

            foreach (var value in values)
            {
                writer.WriteElementString("value", value);
            }

            writer.WriteEndElement();
        }
        internal override void WriteContentsTo(XmlDictionaryWriter writer)
        {
            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");

            writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.KeyInfo, XD.XmlSignatureDictionary.Namespace);
            writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509Data, XD.XmlSignatureDictionary.Namespace);
            for (int i = 0; i < certificateCollection.Count; ++i)
            {
                writer.WriteElementString(XD.XmlSignatureDictionary.X509Certificate, XD.XmlSignatureDictionary.Namespace, Convert.ToBase64String(certificateCollection[i].RawData));
            }
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
 void WriteUserNamePassword(XmlDictionaryWriter writer, string id, string userName, string password)
 {
     writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.UserNameTokenElement,
         XD.SecurityJan2004Dictionary.Namespace); // <wsse:UsernameToken
     writer.WriteAttributeString(XD.UtilityDictionary.Prefix.Value, XD.UtilityDictionary.IdAttribute,
         XD.UtilityDictionary.Namespace, id); // wsu:Id="..."
     writer.WriteElementString(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.UserNameElement,
         XD.SecurityJan2004Dictionary.Namespace, userName); // ><wsse:Username>...</wsse:Username>
     if (password != null)
     {
         writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.PasswordElement,
             XD.SecurityJan2004Dictionary.Namespace);
         if (this.tokenSerializer.EmitBspRequiredAttributes)
         {
             writer.WriteAttributeString(XD.SecurityJan2004Dictionary.TypeAttribute, null, SecurityJan2004Strings.UPTokenPasswordTextValue);
         }
         writer.WriteString(password); // <wsse:Password>...</wsse:Password>
         writer.WriteEndElement();
     }
     writer.WriteEndElement(); // </wsse:UsernameToken>
 }
 public static void SerializeClaim(Claim claim, SctClaimDictionary dictionary, XmlDictionaryWriter writer, XmlObjectSerializer serializer)
 {
     // the order in which known claim types are checked is optimized for use patterns
     if (claim == null)
     {
         writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
         return;
     }
     else if (ClaimTypes.Sid.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.DenyOnlySid.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.X500DistinguishedName.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] rawData = ((X500DistinguishedName)claim.Resource).RawData;
         writer.WriteBase64(rawData, 0, rawData.Length);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Thumbprint.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] thumbprint = (byte[])claim.Resource;
         writer.WriteBase64(thumbprint, 0, thumbprint.Length);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Name.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.NameClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string)claim.Resource);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Dns.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.DnsClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string)claim.Resource);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Rsa.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.RsaClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((RSA)claim.Resource).ToXmlString(false));
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Email.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.MailAddressClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((MailAddress)claim.Resource).Address);
         writer.WriteEndElement();
         return;
     }
     else if (claim == Claim.System)
     {
         writer.WriteElementString(dictionary.SystemClaim, dictionary.EmptyString, string.Empty);
         return;
     }
     else if (ClaimTypes.Hash.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.HashClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] hash = (byte[])claim.Resource;
         writer.WriteBase64(hash, 0, hash.Length);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Spn.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.SpnClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string)claim.Resource);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Upn.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.UpnClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string)claim.Resource);
         writer.WriteEndElement();
         return;
     }
     else if (ClaimTypes.Uri.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.UrlClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((Uri)claim.Resource).AbsoluteUri);
         writer.WriteEndElement();
         return;
     }
     else
     {
         // this is an extensible claim... need to delegate to xml object serializer
         serializer.WriteObject(writer, claim);
     }
 }
Example #14
0
		protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
		{
			writer.WriteStartElement("Pull", "http://schemas.xmlsoap.org/ws/2004/09/enumeration");
			if (this._enumerationContext != null)
			{
				writer.WriteElementString("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration", this._enumerationContext);
			}
			if (this._timeout.HasValue)
			{
				writer.WriteStartElement("MaxTime", "http://schemas.xmlsoap.org/ws/2004/09/enumeration");
				writer.WriteValue(this._timeout.Value);
				writer.WriteEndElement();
			}
			if (this._maxElements.HasValue)
			{
				writer.WriteStartElement("MaxElements", "http://schemas.xmlsoap.org/ws/2004/09/enumeration");
				writer.WriteValue(this._maxElements.Value);
				writer.WriteEndElement();
			}
			if (this._controls != null)
			{
				DirectoryControlSerializer.Serialize(writer, this._controls);
			}
			writer.WriteEndElement();
		}
 public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
 {
     EncryptedKeyIdentifierClause clause = keyIdentifierClause as EncryptedKeyIdentifierClause;
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptedKey, this.NamespaceUri);
     if (clause.EncryptionMethod != null)
     {
         writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptionMethod, this.NamespaceUri);
         writer.WriteAttributeString(XD.XmlEncryptionDictionary.AlgorithmAttribute, null, clause.EncryptionMethod);
         if (clause.EncryptionMethod == XD.SecurityAlgorithmDictionary.RsaOaepKeyWrap.Value)
         {
             writer.WriteStartElement("", XD.XmlSignatureDictionary.DigestMethod, XD.XmlSignatureDictionary.Namespace);
             writer.WriteAttributeString(XD.XmlSignatureDictionary.Algorithm, null, "http://www.w3.org/2000/09/xmldsig#sha1");
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
     }
     if (clause.EncryptingKeyIdentifier != null)
     {
         this.tokenSerializer.WriteKeyIdentifier(writer, clause.EncryptingKeyIdentifier);
     }
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherData, this.NamespaceUri);
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherValue, this.NamespaceUri);
     byte[] encryptedKey = clause.GetEncryptedKey();
     writer.WriteBase64(encryptedKey, 0, encryptedKey.Length);
     writer.WriteEndElement();
     writer.WriteEndElement();
     if (clause.CarriedKeyName != null)
     {
         writer.WriteElementString(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CarriedKeyName, this.NamespaceUri, clause.CarriedKeyName);
     }
     writer.WriteEndElement();
 }
        public static void SerializeClaimSet(ClaimSet claimSet, SctClaimDictionary dictionary, XmlDictionaryWriter writer, XmlObjectSerializer serializer, XmlObjectSerializer claimSerializer)
        {
            if (claimSet is X509CertificateClaimSet)
            {
                X509CertificateClaimSet x509ClaimSet = (X509CertificateClaimSet)claimSet;
                writer.WriteStartElement(dictionary.X509CertificateClaimSet, dictionary.EmptyString);
                byte[] rawData = x509ClaimSet.X509Certificate.RawData;
                writer.WriteBase64(rawData, 0, rawData.Length);
                writer.WriteEndElement();
            }
            else if (claimSet == ClaimSet.System)
            {
                writer.WriteElementString(dictionary.SystemClaimSet, dictionary.EmptyString, String.Empty);
            }
            else if (claimSet == ClaimSet.Windows)
            {
                writer.WriteElementString(dictionary.WindowsClaimSet, dictionary.EmptyString, String.Empty);
            }
            else if (claimSet == ClaimSet.Anonymous)
            {
                writer.WriteElementString(dictionary.AnonymousClaimSet, dictionary.EmptyString, String.Empty);
            }
            else if (claimSet is WindowsClaimSet || claimSet is DefaultClaimSet)
            {
                writer.WriteStartElement(dictionary.ClaimSet, dictionary.EmptyString);
                writer.WriteStartElement(dictionary.PrimaryIssuer, dictionary.EmptyString);
                if (claimSet.Issuer == claimSet)
                {
                    writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
                }
                else
                {
                    SerializeClaimSet(claimSet.Issuer, dictionary, writer, serializer, claimSerializer);
                }
                writer.WriteEndElement();

                foreach (Claim claim in claimSet)
                {
                    writer.WriteStartElement(dictionary.Claim, dictionary.EmptyString);
                    SerializeClaim(claim, dictionary, writer, claimSerializer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            else
            {
                serializer.WriteObject(writer, claimSet);
            }
        }
 public virtual void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
 {
     this.CheckObjectValidity();
     if (writer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     writer.WriteStartElement(samlDictionary.PreferredPrefix.Value, samlDictionary.Subject, samlDictionary.Namespace);
     if (this.name != null)
     {
         writer.WriteStartElement(samlDictionary.PreferredPrefix.Value, samlDictionary.NameIdentifier, samlDictionary.Namespace);
         if (this.nameFormat != null)
         {
             writer.WriteStartAttribute(samlDictionary.NameIdentifierFormat, null);
             writer.WriteString(this.nameFormat);
             writer.WriteEndAttribute();
         }
         if (this.nameQualifier != null)
         {
             writer.WriteStartAttribute(samlDictionary.NameIdentifierNameQualifier, null);
             writer.WriteString(this.nameQualifier);
             writer.WriteEndAttribute();
         }
         writer.WriteString(this.name);
         writer.WriteEndElement();
     }
     if (this.confirmationMethods.Count > 0)
     {
         writer.WriteStartElement(samlDictionary.PreferredPrefix.Value, samlDictionary.SubjectConfirmation, samlDictionary.Namespace);
         foreach (string str in this.confirmationMethods)
         {
             writer.WriteElementString(samlDictionary.SubjectConfirmationMethod, samlDictionary.Namespace, str);
         }
         if (!string.IsNullOrEmpty(this.confirmationData))
         {
             writer.WriteElementString(samlDictionary.SubjectConfirmationData, samlDictionary.Namespace, this.confirmationData);
         }
         if (this.securityKeyIdentifier != null)
         {
             SamlSerializer.WriteSecurityKeyIdentifier(XmlDictionaryWriter.CreateDictionaryWriter(writer), this.securityKeyIdentifier, keyInfoSerializer);
         }
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
Example #18
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            string title = string.Format(CultureInfo.InvariantCulture, "{0} Service", this.serviceName);
            writer.WriteStartElement("HTML");
            writer.WriteStartElement("HEAD");
            writer.WriteElementString("TITLE", title);
            writer.WriteEndElement(); // HEAD

            writer.WriteStartElement("BODY");
            writer.WriteStartElement("H1");
            writer.WriteString(title);
            writer.WriteEndElement(); // H1

            writer.WriteStartElement("B");
            writer.WriteString(string.Format(CultureInfo.InvariantCulture, "The service '{0}' at address:", this.serviceName));
            writer.WriteStartElement("UL");
            writer.WriteStartElement("A");
            writer.WriteAttributeString("href", this.serviceUrl);
            writer.WriteString(this.serviceUrl);
            writer.WriteEndElement(); // A
            writer.WriteEndElement(); // UL
            writer.WriteString(" has been compiled successfully.");
            writer.WriteEndElement(); // B
            writer.WriteEndElement(); // HTML
            writer.WriteEndElement(); // BODY
        }
            public override void WriteKeyIdentifierClauseCore( XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause )
            {
                X509RawDataKeyIdentifierClause x509Clause = keyIdentifierClause as X509RawDataKeyIdentifierClause;

                if ( x509Clause != null )
                {
                    writer.WriteStartElement( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509Data, NamespaceUri );

                    writer.WriteStartElement( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509Certificate, NamespaceUri );
                    byte[] certBytes = x509Clause.GetX509RawData();
                    writer.WriteBase64( certBytes, 0, certBytes.Length );
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }

                X509IssuerSerialKeyIdentifierClause issuerSerialClause = keyIdentifierClause as X509IssuerSerialKeyIdentifierClause;
                if ( issuerSerialClause != null )
                {                    
                    writer.WriteStartElement( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509Data, XD.XmlSignatureDictionary.Namespace );
                    writer.WriteStartElement( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509IssuerSerial, XD.XmlSignatureDictionary.Namespace );
                    writer.WriteElementString( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509IssuerName, XD.XmlSignatureDictionary.Namespace, issuerSerialClause.IssuerName );
                    writer.WriteElementString( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509SerialNumber, XD.XmlSignatureDictionary.Namespace, issuerSerialClause.IssuerSerialNumber );
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    return;
                }

                X509SubjectKeyIdentifierClause skiClause = keyIdentifierClause as X509SubjectKeyIdentifierClause;
                if ( skiClause != null )
                {
                    writer.WriteStartElement( XmlSignatureConstants.Prefix, XmlSignatureConstants.Elements.X509Data, XmlSignatureConstants.Namespace );
                    writer.WriteStartElement( XmlSignatureConstants.Prefix, XmlSignatureConstants.Elements.X509SKI, XmlSignatureConstants.Namespace );
                    byte[] ski = skiClause.GetX509SubjectKeyIdentifier();
                    writer.WriteBase64( ski, 0, ski.Length );
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    return;
                }
            }
        public virtual void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
        {
            CheckObjectValidity();

            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            writer.WriteStartElement(dictionary.PreferredPrefix.Value, dictionary.Attribute, dictionary.Namespace);

            writer.WriteStartAttribute(dictionary.AttributeName, null);
            writer.WriteString(this.name);
            writer.WriteEndAttribute();
            writer.WriteStartAttribute(dictionary.AttributeNamespace, null);
            writer.WriteString(this.nameSpace);
            writer.WriteEndAttribute();

            for (int i = 0; i < this.attributeValues.Count; i++)
            {
                if (this.attributeValues[i] == null)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.SAMLAttributeValueCannotBeNull));

                writer.WriteElementString(dictionary.PreferredPrefix.Value, dictionary.AttributeValue, dictionary.Namespace, this.attributeValues[i]);
            }

            writer.WriteEndElement();
        }
		private static void InternalSerialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, string ns, string property, object value)
		{
			string str = writer.LookupPrefix(ns);
			writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory");
			if (ChangeOperation != ChangeOperation.None)
			{
				writer.WriteStartElement("Change", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
				ChangeOperation changeOperation = ChangeOperation;
				switch (changeOperation)
				{
					case ChangeOperation.Add:
					{
						writer.WriteAttributeString("Operation", "add");
						break;
					}
					case ChangeOperation.Delete:
					{
						writer.WriteAttributeString("Operation", "delete");
						break;
					}
					case ChangeOperation.Replace:
					{
						writer.WriteAttributeString("Operation", "replace");
						break;
					}
				}
			}
			else
			{
				writer.WriteStartElement("AttributeTypeAndValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
			}
			writer.WriteElementString("AttributeType", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", AttributeTypeAndValueSerializer.FormatAttributeName(str, property));
			if (value != null)
			{
				if (value as ICollection == null)
				{
					writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
					if (value as DirectoryAttributeModification == null)
					{
						ADValueSerializer.Serialize(writer, value);
					}
					else
					{
						DirectoryAttributeModification directoryAttributeModification = (DirectoryAttributeModification)value;
						ADValueSerializer.Serialize(writer, directoryAttributeModification[0]);
					}
					writer.WriteEndElement();
				}
				else
				{
					ICollection collections = (ICollection)value;
					if (collections.Count > 0)
					{
						writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
						foreach (object obj in collections)
						{
							ADValueSerializer.Serialize(writer, obj);
						}
						writer.WriteEndElement();
					}
				}
			}
			writer.WriteEndElement();
		}
            public override void WriteKeyIdentifierClauseCore( XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause )
            {
                KeyNameIdentifierClause nameClause = keyIdentifierClause as KeyNameIdentifierClause;

                writer.WriteElementString( XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.KeyName, NamespaceUri, nameClause.KeyName );
            }
 private void WriteUserNamePassword(XmlDictionaryWriter writer, string id, string userName, string password)
 {
     writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.UserNameTokenElement, XD.SecurityJan2004Dictionary.Namespace);
     writer.WriteAttributeString(XD.UtilityDictionary.Prefix.Value, XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace, id);
     writer.WriteElementString(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.UserNameElement, XD.SecurityJan2004Dictionary.Namespace, userName);
     if (password != null)
     {
         writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.PasswordElement, XD.SecurityJan2004Dictionary.Namespace);
         if (this.tokenSerializer.EmitBspRequiredAttributes)
         {
             writer.WriteAttributeString(XD.SecurityJan2004Dictionary.TypeAttribute, null, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
         }
         writer.WriteString(password);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
 public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
 {
     X509IssuerSerialKeyIdentifierClause clause2 = clause as X509IssuerSerialKeyIdentifierClause;
     writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509Data, XD.XmlSignatureDictionary.Namespace);
     writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509IssuerSerial, XD.XmlSignatureDictionary.Namespace);
     writer.WriteElementString(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509IssuerName, XD.XmlSignatureDictionary.Namespace, clause2.IssuerName);
     writer.WriteElementString(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.X509SerialNumber, XD.XmlSignatureDictionary.Namespace, clause2.IssuerSerialNumber);
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
 public static void SerializeClaim(Claim claim, SctClaimDictionary dictionary, XmlDictionaryWriter writer, XmlObjectSerializer serializer)
 {
     if (claim == null)
     {
         writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
     }
     else if (ClaimTypes.Sid.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         SerializeSid((SecurityIdentifier) claim.Resource, dictionary, writer);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.DenyOnlySid.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         SerializeSid((SecurityIdentifier) claim.Resource, dictionary, writer);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.X500DistinguishedName.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] rawData = ((X500DistinguishedName) claim.Resource).RawData;
         writer.WriteBase64(rawData, 0, rawData.Length);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Thumbprint.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] resource = (byte[]) claim.Resource;
         writer.WriteBase64(resource, 0, resource.Length);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Name.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.NameClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string) claim.Resource);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Dns.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.DnsClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string) claim.Resource);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Rsa.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.RsaClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((RSA) claim.Resource).ToXmlString(false));
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Email.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.MailAddressClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((MailAddress) claim.Resource).Address);
         writer.WriteEndElement();
     }
     else if (claim == Claim.System)
     {
         writer.WriteElementString(dictionary.SystemClaim, dictionary.EmptyString, string.Empty);
     }
     else if (ClaimTypes.Hash.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.HashClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         byte[] buffer = (byte[]) claim.Resource;
         writer.WriteBase64(buffer, 0, buffer.Length);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Spn.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.SpnClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string) claim.Resource);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Upn.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.UpnClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString((string) claim.Resource);
         writer.WriteEndElement();
     }
     else if (ClaimTypes.Uri.Equals(claim.ClaimType))
     {
         writer.WriteStartElement(dictionary.UrlClaim, dictionary.EmptyString);
         WriteRightAttribute(claim, dictionary, writer);
         writer.WriteString(((Uri) claim.Resource).AbsoluteUri);
         writer.WriteEndElement();
     }
     else
     {
         serializer.WriteObject(writer, claim);
     }
 }
 public override void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
 {
     this.CheckObjectValidity();
     if (writer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     writer.WriteStartElement(samlDictionary.PreferredPrefix.Value, samlDictionary.AudienceRestrictionCondition, samlDictionary.Namespace);
     for (int i = 0; i < this.audiences.Count; i++)
     {
         writer.WriteElementString(samlDictionary.Audience, samlDictionary.Namespace, this.audiences[i].AbsoluteUri);
     }
     writer.WriteEndElement();
 }
            public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
            {
                EncryptedKeyIdentifierClause encryptedKeyClause = keyIdentifierClause as EncryptedKeyIdentifierClause;

                writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptedKey, NamespaceUri);

                if (encryptedKeyClause.EncryptionMethod != null)
                {
                    writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptionMethod, NamespaceUri);
                    writer.WriteAttributeString(XD.XmlEncryptionDictionary.AlgorithmAttribute, null, encryptedKeyClause.EncryptionMethod);
                    if (encryptedKeyClause.EncryptionMethod == XD.SecurityAlgorithmDictionary.RsaOaepKeyWrap.Value)
                    {
                        writer.WriteStartElement(XmlSignatureStrings.Prefix, XD.XmlSignatureDictionary.DigestMethod, XD.XmlSignatureDictionary.Namespace);
                        writer.WriteAttributeString(XD.XmlSignatureDictionary.Algorithm, null, SecurityAlgorithms.Sha1Digest);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                if (encryptedKeyClause.EncryptingKeyIdentifier != null)
                {
                    this.securityTokenSerializer.WriteKeyIdentifier(writer, encryptedKeyClause.EncryptingKeyIdentifier);
                }

                writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherData, NamespaceUri);
                writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherValue, NamespaceUri);
                byte[] encryptedKey = encryptedKeyClause.GetEncryptedKey();
                writer.WriteBase64(encryptedKey, 0, encryptedKey.Length);
                writer.WriteEndElement();
                writer.WriteEndElement();

                if (encryptedKeyClause.CarriedKeyName != null)
                {
                    writer.WriteElementString(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CarriedKeyName, NamespaceUri, encryptedKeyClause.CarriedKeyName);
                }

                writer.WriteEndElement();
            }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     writer.WriteElementString("SQLStatement", SQLStatement);
 }
Example #29
0
 protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     writer.WriteElementString("token", this.Token);
     writer.WriteElementString("lan", this.Lan);
 }
Example #30
0
		public static void SerializeAttributeList(XmlDictionaryWriter writer, string xmlAttribute, string ns, string syntheticPrefix, string attrPrefix, IList<string> attributes)
		{
			string str;
			bool flag = false;
			foreach (string attribute in attributes)
			{
				if (!AttributeNs.IsSynthetic(attribute, SyntheticAttributeOperation.Read, ref flag))
				{
					string str1 = null;
					string str2 = null;
					if (!XmlUtility.SplitLdapAttributeOnOption(attribute, ref str1, ref str2))
					{
						writer.WriteElementString(xmlAttribute, ns, XmlUtility.AddPrefix(attrPrefix, attribute));
					}
					else
					{
						writer.WriteStartElement(xmlAttribute, ns);
						XmlUtility.SerializeLdapAttributeOption(writer, str2);
						writer.WriteValue(XmlUtility.AddPrefix(attrPrefix, str1));
						writer.WriteEndElement();
					}
				}
				else
				{
					XmlDictionaryWriter xmlDictionaryWriter = writer;
					string str3 = xmlAttribute;
					string str4 = ns;
					if (flag)
					{
						str = attribute;
					}
					else
					{
						str = XmlUtility.AddPrefix(syntheticPrefix, attribute);
					}
					xmlDictionaryWriter.WriteElementString(str3, str4, str);
				}
			}
		}
Example #31
0
		public virtual void WriteXml (XmlDictionaryWriter writer,
			SamlSerializer samlSerializer,
			SecurityTokenSerializer keyInfoTokenSerializer)
		{
			writer.WriteStartElement ("saml", "Attribute", SamlConstants.Namespace);
			writer.WriteAttributeString ("AttributeName", Name);
			writer.WriteAttributeString ("AttributeNamespace", Namespace);
			foreach (string s in AttributeValues)
				writer.WriteElementString ("saml", "AttributeValue", SamlConstants.Namespace, s);
			writer.WriteEndElement ();
		}
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     writer.WriteElementString(Fault, Namespace, "Sender");
 }
Example #33
0
		public static void SerializeEnumerationContext(XmlDictionaryWriter writer, string context)
		{
			writer.WriteElementString("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration", context);
		}