incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r463009 [4/4] - in /incubator/heraldry/libraries/csharp: ./ openid/ openid/trunk/ openid/trunk/Janrain.OpenId/ openid/trunk/Janrain.OpenId/Examples/ openid/trunk/Janrain.OpenId/Examples/Consumer/ openid/trunk/Janrain.OpenId/Examples/Consume...
Date Wed, 11 Oct 2006 22:24:54 GMT
Added: incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Security.Cryptography/DiffieHellmanManaged.cs
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Security.Cryptography/DiffieHellmanManaged.cs?view=auto&rev=463009
==============================================================================
--- incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Security.Cryptography/DiffieHellmanManaged.cs (added)
+++ incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Security.Cryptography/DiffieHellmanManaged.cs Wed Oct 11 15:24:51 2006
@@ -0,0 +1,273 @@
+//
+// DiffieHellmanManaged.cs: Implements the Diffie-Hellman key agreement algorithm
+//
+// Author:
+//	Pieter Philippaerts (Pieter@mentalis.org)
+//
+// (C) 2003 The Mentalis.org Team (http://www.mentalis.org/)
+//
+//   References:
+//     - PKCS#3  [http://www.rsasecurity.com/rsalabs/pkcs/pkcs-3/]
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+using Mono.Math;
+
+namespace Mono.Security.Cryptography {
+	/// <summary>
+	/// Implements the Diffie-Hellman algorithm.
+	/// </summary>
+	public sealed class DiffieHellmanManaged : DiffieHellman {
+		/// <summary>
+		/// Initializes a new <see cref="DiffieHellmanManaged"/> instance.
+		/// </summary>
+		/// <remarks>The default length of the shared secret is 1024 bits.</remarks>
+		public DiffieHellmanManaged() : this(1024, 160, DHKeyGeneration.Static) {}
+		/// <summary>
+		/// Initializes a new <see cref="DiffieHellmanManaged"/> instance.
+		/// </summary>
+		/// <param name="bitLength">The length, in bits, of the public P parameter.</param>
+		/// <param name="l">The length, in bits, of the secret value X. This parameter can be set to 0 to use the default size.</param>
+		/// <param name="method">One of the <see cref="DHKeyGeneration"/> values.</param>
+		/// <remarks>The larger the bit length, the more secure the algorithm is. The default is 1024 bits. The minimum bit length is 128 bits.<br/>The size of the private value will be one fourth of the bit length specified.</remarks>
+		/// <exception cref="ArgumentException">The specified bit length is invalid.</exception>
+		public DiffieHellmanManaged(int bitLength, int l, DHKeyGeneration method) {
+			if (bitLength < 256 || l < 0)
+				throw new ArgumentException();
+			BigInteger p, g;
+			GenerateKey (bitLength, method, out p, out g);
+			Initialize(p, g, null, l, false);
+		}
+		/// <summary>
+		/// Initializes a new <see cref="DiffieHellmanManaged"/> instance.
+		/// </summary>
+		/// <param name="p">The P parameter of the Diffie-Hellman algorithm. This is a public parameter.</param>
+		/// <param name="g">The G parameter of the Diffie-Hellman algorithm. This is a public parameter.</param>
+		/// <param name="x">The X parameter of the Diffie-Hellman algorithm. This is a private parameter. If this parameters is a null reference (<b>Nothing</b> in Visual Basic), a secret value of the default size will be generated.</param>
+		/// <exception cref="ArgumentNullException"><paramref name="p"/> or <paramref name="g"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
+		/// <exception cref="CryptographicException"><paramref name="p"/> or <paramref name="g"/> is invalid.</exception>
+		public DiffieHellmanManaged(byte[] p, byte[] g, byte[] x) {
+			if (p == null || g == null)
+				throw new ArgumentNullException();
+			if (x == null)
+				Initialize(new BigInteger(p), new BigInteger(g), null, 0, true);
+			else
+				Initialize(new BigInteger(p), new BigInteger(g), new BigInteger(x), 0, true);
+		}
+		/// <summary>
+		/// Initializes a new <see cref="DiffieHellmanManaged"/> instance.
+		/// </summary>
+		/// <param name="p">The P parameter of the Diffie-Hellman algorithm.</param>
+		/// <param name="g">The G parameter of the Diffie-Hellman algorithm.</param>
+		/// <param name="l">The length, in bits, of the private value. If 0 is specified, the default value will be used.</param>
+		/// <exception cref="ArgumentNullException"><paramref name="p"/> or <paramref name="g"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
+		/// <exception cref="ArgumentException"><paramref name="l"/> is invalid.</exception>
+		/// <exception cref="CryptographicException"><paramref name="p"/> or <paramref name="g"/> is invalid.</exception>
+		public DiffieHellmanManaged(byte[] p, byte[] g, int l) {
+			if (p == null || g == null)
+				throw new ArgumentNullException();
+			if (l < 0)
+				throw new ArgumentException();
+			Initialize(new BigInteger(p), new BigInteger(g), null, l, true);
+		}
+
+		// initializes the private variables (throws CryptographicException)
+		private void Initialize(BigInteger p, BigInteger g, BigInteger x, int secretLen, bool checkInput) {
+			if (checkInput) {
+				if (!p.IsProbablePrime() || g <= 0 || g >= p || (x != null && (x <= 0 || x > p - 2)))
+					throw new CryptographicException();
+			}
+			// default is to generate a number as large as the prime this
+			// is usually overkill, but it's the most secure thing we can
+			// do if the user doesn't specify a desired secret length ...
+			if (secretLen == 0)
+				secretLen = p.BitCount();
+			m_P = p;
+			m_G = g;
+			if (x == null) {
+				BigInteger pm1 = m_P - 1;
+				for(m_X = BigInteger.GenerateRandom(secretLen); m_X >= pm1 || m_X == 0; m_X = BigInteger.GenerateRandom(secretLen)) {}
+			} else {
+				m_X = x;
+			}
+		}
+		/// <summary>
+		/// Creates the key exchange data.
+		/// </summary>
+		/// <returns>The key exchange data to be sent to the intended recipient.</returns>
+		public override byte[] CreateKeyExchange() {
+			BigInteger y = m_G.ModPow(m_X, m_P);
+			byte[] ret = y.GetBytes();
+			y.Clear();
+			return ret;
+		}
+		/// <summary>
+		/// Extracts secret information from the key exchange data.
+		/// </summary>
+		/// <param name="keyEx">The key exchange data within which the shared key is hidden.</param>
+		/// <returns>The shared key derived from the key exchange data.</returns>
+		public override byte[] DecryptKeyExchange(byte[] keyEx) {
+			BigInteger pvr = new BigInteger(keyEx);
+			BigInteger z = pvr.ModPow(m_X, m_P);
+			byte[] ret = z.GetBytes();
+			z.Clear();
+			return ret;
+		}
+		/// <summary>
+		/// Gets the name of the key exchange algorithm.
+		/// </summary>
+		/// <value>The name of the key exchange algorithm.</value>
+		public override string KeyExchangeAlgorithm {
+			get {
+				return "1.2.840.113549.1.3"; // PKCS#3 OID
+			}
+		}
+		/// <summary>
+		/// Gets the name of the signature algorithm.
+		/// </summary>
+		/// <value>The name of the signature algorithm.</value>
+		public override string SignatureAlgorithm {
+			get {
+				return null;
+			}
+		}
+		// clear keys
+		protected override void Dispose(bool disposing) {
+			if (!m_Disposed) {
+				m_P.Clear();
+				m_G.Clear();
+				m_X.Clear();
+			}
+			m_Disposed = true;
+		}
+		/// <summary>
+		/// Exports the <see cref="DHParameters"/>.
+		/// </summary>
+		/// <param name="includePrivateParameters"><b>true</b> to include private parameters; otherwise, <b>false</b>.</param>
+		/// <returns>The parameters for <see cref="DiffieHellman"/>.</returns>
+		public override DHParameters ExportParameters(bool includePrivateParameters) {
+			DHParameters ret = new DHParameters();
+			ret.P = m_P.GetBytes();
+			ret.G = m_G.GetBytes();
+			if (includePrivateParameters) {
+				ret.X = m_X.GetBytes();
+			}
+			return ret;
+		}
+		/// <summary>
+		/// Imports the specified <see cref="DHParameters"/>.
+		/// </summary>
+		/// <param name="parameters">The parameters for <see cref="DiffieHellman"/>.</param>
+		/// <exception cref="CryptographicException"><paramref name="P"/> or <paramref name="G"/> is a null reference (<b>Nothing</b> in Visual Basic) -or- <paramref name="P"/> is not a prime number.</exception>
+		public override void ImportParameters(DHParameters parameters) {
+			if (parameters.P == null)
+				throw new CryptographicException("Missing P value.");
+			if (parameters.G == null)
+				throw new CryptographicException("Missing G value.");
+
+			BigInteger p = new BigInteger(parameters.P), g = new BigInteger(parameters.G), x = null;
+			if (parameters.X != null) {
+				x = new BigInteger(parameters.X);
+			}
+			Initialize(p, g, x, 0, true);
+		}
+		~DiffieHellmanManaged() {
+			Dispose(false);
+		}
+
+		//TODO: implement DH key generation methods
+		private void GenerateKey(int bitlen, DHKeyGeneration keygen, out BigInteger p, out BigInteger g) {
+			if (keygen == DHKeyGeneration.Static) {
+				if (bitlen == 768)
+					p = new BigInteger(m_OAKLEY768);
+				else if (bitlen == 1024)
+					p = new BigInteger(m_OAKLEY1024);
+				else if (bitlen == 1536)
+					p = new BigInteger(m_OAKLEY1536);
+				else
+					throw new ArgumentException("Invalid bit size.");
+				g = new BigInteger(22); // all OAKLEY keys use 22 as generator
+			//} else if (keygen == DHKeyGeneration.SophieGermain) {
+			//	throw new NotSupportedException(); //TODO
+			//} else if (keygen == DHKeyGeneration.DSA) {
+				// 1. Let j = (p - 1)/q.
+				// 2. Set h = any integer, where 1 < h < p - 1
+				// 3. Set g = h^j mod p
+				// 4. If g = 1 go to step 2
+			//	BigInteger j = (p - 1) / q;
+			} else { // random
+				p = BigInteger.GeneratePseudoPrime(bitlen);
+				g = new BigInteger(3); // always use 3 as a generator
+			}
+		}
+
+		private BigInteger m_P;
+		private BigInteger m_G;
+		private BigInteger m_X;
+		private bool m_Disposed;
+
+		private static byte[] m_OAKLEY768 = new byte[] {
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
+			0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
+			0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
+			0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
+			0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
+			0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
+			0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
+			0xA6, 0x3A, 0x36, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+		};
+		private static byte[] m_OAKLEY1024 = new byte[] {
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
+			0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
+			0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
+			0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
+			0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
+			0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
+			0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
+			0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
+			0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,
+			0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81,
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+		};
+		private static byte[] m_OAKLEY1536 = new byte[] {
+			0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
+			0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
+			0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
+			0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
+			0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
+			0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
+			0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
+			0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
+			0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,
+			0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D,
+			0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36,
+			0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,
+			0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56,
+			0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D,
+			0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08,
+			0xCA, 0x23, 0x73, 0x27, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+		};
+	}
+}
\ No newline at end of file

Added: incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/MiniParser.cs
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/MiniParser.cs?view=auto&rev=463009
==============================================================================
--- incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/MiniParser.cs (added)
+++ incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/MiniParser.cs Wed Oct 11 15:24:51 2006
@@ -0,0 +1,627 @@
+//
+// System.Security.Cryptography.MiniParser: Internal XML parser implementation
+//
+// Authors:
+//	Sergey Chaban
+//
+// Copyright (c) 2001, 2002 Wild West Software
+// Copyright (c) 2002 Sergey Chaban
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Globalization;
+
+namespace Mono.Xml {
+
+#if INSIDE_CORLIB
+	internal
+#else
+        [CLSCompliant(false)]    
+	public
+#endif
+class MiniParser {
+
+	public interface IReader {
+		int Read();
+	}
+
+	public interface IAttrList {
+		int Length {get;}
+		bool IsEmpty {get;}
+		string GetName(int i);
+		string GetValue(int i);
+		string GetValue(string name);
+		void ChangeValue(string name, string newValue);
+		string[] Names {get;}
+		string[] Values {get;}
+	}
+
+	public interface IMutableAttrList : IAttrList {
+		void Clear();
+		void Add(string name, string value);
+		void CopyFrom(IAttrList attrs);
+		void Remove(int i);
+		void Remove(string name);
+	}
+
+	public interface IHandler {
+		void OnStartParsing(MiniParser parser);
+		void OnStartElement(string name, IAttrList attrs);
+		void OnEndElement(string name);
+		void OnChars(string ch);
+		void OnEndParsing(MiniParser parser);
+	}
+
+	public class HandlerAdapter : IHandler {
+		public HandlerAdapter() {}
+		public void OnStartParsing(MiniParser parser) {}
+		public void OnStartElement(string name, IAttrList attrs) {}
+		public void OnEndElement(string name) {}
+		public void OnChars(string ch) {}
+		public void OnEndParsing(MiniParser parser) {}
+	}
+
+	private enum CharKind : byte {
+		LEFT_BR     = 0,
+		RIGHT_BR    = 1,
+		SLASH       = 2,
+		PI_MARK     = 3,
+		EQ          = 4,
+		AMP         = 5,
+		SQUOTE      = 6,
+		DQUOTE      = 7,
+		BANG        = 8,
+		LEFT_SQBR   = 9,
+		SPACE       = 0xA,
+		RIGHT_SQBR  = 0xB,
+		TAB         = 0xC,
+		CR          = 0xD,
+		EOL         = 0xE,
+		CHARS       = 0xF,
+		UNKNOWN = 0x1F
+	}
+
+	private enum ActionCode : byte {
+		START_ELEM               = 0,
+		END_ELEM                 = 1,
+		END_NAME                 = 2,
+		SET_ATTR_NAME            = 3,
+		SET_ATTR_VAL             = 4,
+		SEND_CHARS               = 5,
+		START_CDATA              = 6,
+		END_CDATA                = 7,
+		ERROR                    = 8,
+		STATE_CHANGE             = 9,
+		FLUSH_CHARS_STATE_CHANGE = 0xA,
+		ACC_CHARS_STATE_CHANGE   = 0xB,
+		ACC_CDATA                = 0xC,
+		PROC_CHAR_REF            = 0xD,
+		UNKNOWN = 0xF
+	}
+
+	public class AttrListImpl : IMutableAttrList {
+		protected ArrayList names;
+		protected ArrayList values;
+
+		public AttrListImpl() : this(0) {}
+
+		public AttrListImpl(int initialCapacity) {
+			if (initialCapacity <= 0) {
+				names = new ArrayList();
+				values = new ArrayList();
+			} else {
+				names = new ArrayList(initialCapacity);
+				values = new ArrayList(initialCapacity);
+			}
+		}
+
+		public AttrListImpl(IAttrList attrs)
+		: this(attrs != null ? attrs.Length : 0) {
+			if (attrs != null) this.CopyFrom(attrs);
+		}
+
+		public int Length {
+			get {return names.Count;}
+		}
+
+		public bool IsEmpty {
+			get {return this.Length != 0;}
+		}
+
+		public string GetName(int i) {
+			string res = null;
+			if (i >= 0 && i < this.Length) {
+				res = names[i] as string;
+			}
+			return res;
+		}
+
+		public string GetValue(int i) {
+			string res = null;
+			if (i >= 0 && i < this.Length) {
+				res = values[i] as string;
+			}
+			return res;
+		}
+
+		public string GetValue(string name) {
+			return this.GetValue(names.IndexOf(name));
+		}
+
+		public void ChangeValue(string name, string newValue) {
+			int i = names.IndexOf(name);
+			if (i >= 0 && i < this.Length) {
+				values[i] = newValue;
+			}
+		}
+
+		public string[] Names {
+			get {return names.ToArray(typeof(string)) as string[];}
+		}
+
+		public string[] Values {
+			get {return values.ToArray(typeof(string)) as string[];}
+		}
+
+		public void Clear() {
+			names.Clear();
+			values.Clear();
+		}
+
+		public void Add(string name, string value) {
+			names.Add(name);
+			values.Add(value);
+		}
+
+		public void Remove(int i) {
+			if (i >= 0) {
+				names.RemoveAt(i);
+				values.RemoveAt(i);
+			}
+		}
+
+		public void Remove(string name) {
+			this.Remove(names.IndexOf(name));
+		}
+
+		public void CopyFrom(IAttrList attrs) {
+			if (attrs != null && ((object)this == (object)attrs)) {
+				this.Clear();
+				int n = attrs.Length;
+				for (int i = 0; i < n; i++) {
+					this.Add(attrs.GetName(i), attrs.GetValue(i));
+				}
+			}
+		}
+	}
+
+	public class XMLError : Exception {
+		protected string descr;
+		protected int line, column;
+		public XMLError() : this("Unknown") {}
+		public XMLError(string descr) : this(descr, -1, -1) {}
+		public XMLError(string descr, int line, int column)
+		: base(descr) {
+			this.descr = descr;
+			this.line = line;
+			this.column = column;
+		}
+		public int Line {get {return line;}}
+		public int Column {get {return column;}}
+		public override string ToString() {
+			return (String.Format("{0} @ (line = {1}, col = {2})", descr, line, column));
+		}
+	}
+
+	private static readonly int INPUT_RANGE = 13;
+	private static readonly ushort[] tbl = {
+		(ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ER
 ROR << 8) | 128), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128),
+		(ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 133), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)Action
 Code.ERROR << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 4),
+		(ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_ELEM << 8) | 0), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)Ac
 tionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
+		(ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 5), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)C
 harKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3),
+		(ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 4), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.END_NAME << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_NAME << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.END_NAME << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)Actio
 nCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
+		(ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)C
 harKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3),
+		(ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR 
 << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
+		(ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 7), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((
 ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10),
+		(ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((usho
 rt)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
+		(ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((us
 hort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130),
+		(ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 13), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.DQUOTE 
 << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10),
+		(ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 11), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)Acti
 onCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 132),
+		(ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCod
 e.ERROR << 8) | 130), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 130),
+		(ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.SEND_CHARS << 8) | 2), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ER
 ROR << 8) | 134), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 134),
+		(ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 14), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)Ch
 arKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14),
+		(ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 15), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)C
 harKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15),
+		(ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)C
 harKind.DQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19),
+		(ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 17), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ush
 ort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
+		(ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.END_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.DQUOTE << 12) 
 | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18),
+		(ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.DQUOTE << 12) 
 | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19),
+		(ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.UNKNOWN << 8) | 255),
+		0xFFFF
+	};
+
+	protected static string[] errors = {
+		/* 0 */ "Expected element",
+		/* 1 */ "Invalid character in tag",
+		/* 2 */ "No '='",
+		/* 3 */ "Invalid character entity",
+		/* 4 */ "Invalid attr value",
+		/* 5 */ "Empty tag",
+		/* 6 */ "No end tag",
+		/* 7 */ "Bad entity ref"
+	};
+
+	protected int line;
+	protected int col;
+	protected int[] twoCharBuff;
+	protected bool splitCData;
+
+	public MiniParser() {
+		twoCharBuff = new int[2];
+		splitCData = false;
+		Reset();
+	}
+
+	public void Reset() {
+		line = 0;
+		col = 0;
+	}
+
+	protected static bool StrEquals(string str, StringBuilder sb, int sbStart, int len) {
+		if (len != str.Length) return false;
+		for (int i = 0; i < len; i++) {
+			if (str[i] != sb[sbStart + i]) return false;
+		}
+		return true;
+	}
+
+	protected void FatalErr(string descr) {
+		throw new XMLError(descr, this.line, this.col);
+	}
+
+	protected static int Xlat(int charCode, int state) {
+		int p = state * INPUT_RANGE;
+		int n = System.Math.Min(tbl.Length - p, INPUT_RANGE);
+		for (;--n >= 0;) {
+			ushort code = tbl[p];
+			if (charCode == (code >> 12)) return (code & 0xFFF);
+			p++;
+		}
+		return 0xFFF;
+	}
+
+	public void Parse(IReader reader, IHandler handler) {
+		if (reader == null) throw new ArgumentNullException("reader");
+		if (handler == null) handler = new HandlerAdapter();
+
+		AttrListImpl attrList = new AttrListImpl();
+		string lastAttrName = null;
+		Stack tagStack = new Stack();
+		string elementName = null;
+		line = 1;
+		col = 0;
+		int currCh = 0;
+		int stateCode = 0;
+		StringBuilder sbChars = new StringBuilder();
+		bool seenCData = false;
+		bool isComment = false;
+		bool isDTD = false;
+		int bracketSwitch = 0;
+
+		handler.OnStartParsing(this);
+
+		while (true) {
+			++this.col;
+
+			currCh = reader.Read();
+
+			if (currCh == -1) {
+				if (stateCode != 0) {
+					FatalErr("Unexpected EOF");
+				}
+				break;
+			}
+
+			int charCode = "<>/?=&'\"![ ]\t\r\n".IndexOf((char)currCh) & 0xF;
+			if (charCode == (int)CharKind.CR) continue; // ignore
+			// whitepace ::= (#x20 | #x9 | #xd | #xa)+
+			if (charCode == (int)CharKind.TAB) charCode = (int)CharKind.SPACE; // tab == space
+			if (charCode == (int)CharKind.EOL) {
+				this.col = 0;
+				this.line++;
+				charCode = (int)CharKind.SPACE;
+			}
+
+			int actionCode = MiniParser.Xlat(charCode, stateCode);
+			stateCode = actionCode & 0xFF;
+			// Ignore newline inside attribute value.
+			if (currCh == '\n' && (stateCode == 0xE || stateCode == 0xF)) continue;
+			actionCode >>= 8;
+
+			if (stateCode >= 0x80) {
+				if (stateCode == 0xFF) {
+					FatalErr("State dispatch error.");
+				} else {
+					FatalErr(errors[stateCode ^ 0x80]);
+				}
+			}
+
+			switch (actionCode) {
+				case (int)ActionCode.START_ELEM:
+					handler.OnStartElement(elementName, attrList);
+					if (currCh != '/') {
+						tagStack.Push(elementName);
+					} else {
+						handler.OnEndElement(elementName);
+					}
+					attrList.Clear();
+					break;
+
+				case (int)ActionCode.END_ELEM:
+					elementName = sbChars.ToString();
+					sbChars = new StringBuilder();
+					string endName = null;
+					if (tagStack.Count == 0 ||
+						elementName != (endName = tagStack.Pop() as string)) {
+						if (endName == null) {
+							FatalErr("Tag stack underflow");
+						} else {
+							FatalErr(String.Format("Expected end tag '{0}' but found '{1}'", elementName, endName));
+						}
+					}
+					handler.OnEndElement(elementName);
+					break;
+
+				case (int)ActionCode.END_NAME:
+					elementName = sbChars.ToString();
+					sbChars = new StringBuilder();
+					if (currCh != '/' && currCh != '>') break;
+					goto case (int)ActionCode.START_ELEM;
+
+				case (int)ActionCode.SET_ATTR_NAME:
+					lastAttrName = sbChars.ToString();
+					sbChars = new StringBuilder();
+					break;
+
+				case (int)ActionCode.SET_ATTR_VAL:
+					if (lastAttrName == null) FatalErr("Internal error.");
+					attrList.Add(lastAttrName, sbChars.ToString());
+					sbChars = new StringBuilder();
+					lastAttrName = null;
+					break;
+
+				case (int)ActionCode.SEND_CHARS:
+					handler.OnChars(sbChars.ToString());
+					sbChars = new StringBuilder();
+					break;
+
+				case (int)ActionCode.START_CDATA:
+					string cdata = "CDATA[";
+					isComment = false;
+					isDTD = false;
+
+					if (currCh == '-') {
+						currCh = reader.Read();
+
+						if (currCh != '-') FatalErr("Invalid comment");
+
+						this.col++;
+						isComment = true;
+						twoCharBuff[0] = -1;
+						twoCharBuff[1] = -1;
+					} else {
+						if (currCh != '[') {
+							isDTD = true;
+							bracketSwitch = 0;
+							break;
+						}
+
+						for (int i = 0; i < cdata.Length; i++) {
+							if (reader.Read() != cdata[i]) {
+								this.col += i+1;
+								break;
+							}
+						}
+						this.col += cdata.Length;
+						seenCData = true;
+					}
+					break;
+
+				case (int)ActionCode.END_CDATA:
+					int n = 0;
+					currCh = ']';
+
+					while (currCh == ']') {
+						currCh = reader.Read();
+						n++;
+					}
+
+					if (currCh != '>') {
+						for (int i = 0; i < n; i++) sbChars.Append(']');
+						sbChars.Append((char)currCh);
+						stateCode = 0x12;
+					} else {
+						for (int i = 0; i < n-2; i++) sbChars.Append(']');
+						seenCData = false;
+					}
+
+					this.col += n;
+					break;
+
+				case (int)ActionCode.ERROR:
+					FatalErr(String.Format("Error {0}", stateCode));
+					break;
+
+				case (int)ActionCode.STATE_CHANGE:
+					break;
+
+				case (int)ActionCode.FLUSH_CHARS_STATE_CHANGE:
+					sbChars = new StringBuilder();
+					if (currCh != '<') goto case (int)ActionCode.ACC_CHARS_STATE_CHANGE;
+					break;
+
+				case (int)ActionCode.ACC_CHARS_STATE_CHANGE:
+					sbChars.Append((char)currCh);
+					break;
+
+				case (int)ActionCode.ACC_CDATA:
+					if (isComment) {
+						if (currCh == '>'
+							&& twoCharBuff[0] == '-'
+							&& twoCharBuff[1] == '-') {
+							isComment = false;
+							stateCode = 0;
+						} else {
+							twoCharBuff[0] = twoCharBuff[1];
+							twoCharBuff[1] = currCh;
+						}
+					} else if (isDTD) {
+						if (currCh == '<' || currCh == '>') bracketSwitch ^= 1;
+						if (currCh == '>' && bracketSwitch != 0) {
+							isDTD = false;
+							stateCode = 0;
+						}
+					} else {
+						if (this.splitCData
+							&& sbChars.Length > 0
+							&& seenCData) {
+							handler.OnChars(sbChars.ToString());
+							sbChars = new StringBuilder();
+						}
+						seenCData = false;
+						sbChars.Append((char)currCh);
+					}
+					break;
+
+				case (int)ActionCode.PROC_CHAR_REF:
+					currCh = reader.Read();
+					int cl = this.col + 1;
+					if (currCh == '#') {    // character reference
+						int r = 10;
+						int chCode = 0;
+						int nDigits = 0;
+						currCh = reader.Read();
+						cl++;
+
+						if (currCh == 'x') {
+							currCh = reader.Read();
+							cl++;
+							r=16;
+						}
+
+						NumberStyles style = r == 16 ? NumberStyles.HexNumber : NumberStyles.Integer;
+
+						while (true) {
+							int x = -1;
+							if (Char.IsNumber((char)currCh) || "abcdef".IndexOf(Char.ToLower((char)currCh)) != -1) {
+								try {
+									x = Int32.Parse(new string((char)currCh, 1), style);
+								} catch (FormatException) {x = -1;}
+							}
+							if (x == -1) break;
+							chCode *= r;
+							chCode += x;
+							nDigits++;
+							currCh = reader.Read();
+							cl++;
+						}
+
+						if (currCh == ';' && nDigits > 0) {
+							sbChars.Append((char)chCode);
+						} else {
+							FatalErr("Bad char ref");
+						}
+					} else {
+						// entity reference
+						string entityRefChars = "aglmopqstu"; // amp | apos | quot | gt | lt
+						string entities = "&'\"><";
+
+						int pos = 0;
+						int entIdx = 0xF;
+						int predShift = 0;
+
+						int sbLen = sbChars.Length;
+
+						while (true) {
+							if (pos != 0xF) pos = entityRefChars.IndexOf((char)currCh) & 0xF;
+							if (pos == 0xF) FatalErr(errors[7]);
+							sbChars.Append((char)currCh);
+
+							int path = "\uFF35\u3F8F\u4F8F\u0F5F\uFF78\uE1F4\u2299\uEEFF\uEEFF\uFF4F"[pos];
+							int lBr = (path >> 4) & 0xF;
+							int rBr = path & 0xF;
+							int lPred = path >> 12;
+							int rPred = (path >> 8) & 0xF;
+							currCh = reader.Read();
+							cl++;
+							pos = 0xF;
+							if (lBr != 0xF && currCh == entityRefChars[lBr]) {
+								if (lPred < 0xE) entIdx = lPred;
+//								pred = lPred;
+								predShift = 12; // left
+							} else if (rBr != 0xF && currCh == entityRefChars[rBr]) {
+								if (rPred < 0xE) entIdx = rPred;
+//								pred = rPred;
+								predShift = 8; // right
+							} else if (currCh == ';') {
+								if (entIdx != 0xF
+									&& predShift != 0
+									&& ((path >> predShift) & 0xF) == 0xE) break;
+								continue; // pos == 0xF
+							}
+
+							pos=0;
+
+						}
+
+						int l = cl - this.col - 1;
+
+						if ((l > 0 && l < 5)
+							&&(StrEquals("amp", sbChars, sbLen, l)
+							|| StrEquals("apos", sbChars, sbLen, l)
+							|| StrEquals("quot", sbChars, sbLen, l)
+							|| StrEquals("lt", sbChars, sbLen, l)
+							|| StrEquals("gt", sbChars, sbLen, l))
+							) {
+								sbChars.Length = sbLen;
+								sbChars.Append(entities[entIdx]);
+						} else FatalErr(errors[7]);
+					}
+
+					this.col = cl;
+					break;
+
+				default:
+					FatalErr(String.Format("Unexpected action code - {0}.", actionCode));
+					break;
+			}
+		} // while (true)
+
+		handler.OnEndParsing(this);
+
+	} // Parse
+
+}
+
+}

Added: incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/SecurityParser.cs
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/SecurityParser.cs?view=auto&rev=463009
==============================================================================
--- incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/SecurityParser.cs (added)
+++ incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Xml/SecurityParser.cs Wed Oct 11 15:24:51 2006
@@ -0,0 +1,117 @@
+//
+// Mono.Xml.SecurityParser.cs class implementation
+//
+// Author:
+//	Sebastien Pouliot (spouliot@motus.com)
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Security;
+
+namespace Mono.Xml {
+
+	// convert an XML document into SecurityElement objects
+	[CLSCompliant(false)]
+#if INSIDE_CORLIB
+	internal
+#else
+	public
+#endif
+	class SecurityParser : MiniParser, MiniParser.IHandler, MiniParser.IReader {
+
+		private SecurityElement root;
+
+		public SecurityParser () : base () 
+		{
+			stack = new Stack ();
+		}
+
+		public void LoadXml (string xml) 
+		{
+			root = null;
+			xmldoc = xml;
+			pos = 0;
+			stack.Clear ();
+			Parse (this, this);
+		}
+
+		public SecurityElement ToXml () 
+		{
+			return root;
+		}
+
+		// IReader
+
+		private string xmldoc;
+		private int pos;
+
+		public int Read () 
+		{
+			if (pos >= xmldoc.Length)
+				return -1;
+			return (int) xmldoc [pos++];
+		}
+
+		// IHandler
+
+		private SecurityElement current;
+		private Stack stack;
+
+		public void OnStartParsing (MiniParser parser) {}
+
+		public void OnStartElement (string name, MiniParser.IAttrList attrs) 
+		{
+			SecurityElement newel = new SecurityElement (name); 
+			if (root == null) {
+				root = newel;
+				current = newel;
+			}
+			else {
+				SecurityElement parent = (SecurityElement) stack.Peek ();
+				parent.AddChild (newel);
+			}
+			stack.Push (newel);
+			current = newel;
+			// attributes
+			int n = attrs.Length;
+			for (int i=0; i < n; i++)
+				current.AddAttribute (attrs.GetName (i), attrs.GetValue (i));
+		}
+
+		public void OnEndElement (string name) 
+		{
+			current = (SecurityElement) stack.Pop ();
+		}
+
+		public void OnChars (string ch) 
+		{
+			current.Text = ch;
+		}
+
+		public void OnEndParsing (MiniParser parser) {}
+	}
+}

Added: incubator/heraldry/libraries/csharp/openid/trunk/Mono/licence.txt
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/csharp/openid/trunk/Mono/licence.txt?view=auto&rev=463009
==============================================================================
--- incubator/heraldry/libraries/csharp/openid/trunk/Mono/licence.txt (added)
+++ incubator/heraldry/libraries/csharp/openid/trunk/Mono/licence.txt Wed Oct 11 15:24:51 2006
@@ -0,0 +1,65 @@
+The C# source code files in the mono directory are distributed under the
+MIT X11 license. All other source files are distributed under the
+Mentalis.org Source Code License. A copy of both licenses follows:
+
+
+
+
+MIT X11 License:
+~~~~~~~~~~~~~~~~
+
+Copyright (c) 2001, 2002, 2003 Ximian, Inc and the individuals listed
+on the ChangeLog entries.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+
+
+Mentalis.org Source Code License:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Copyright © 2002-2003, The KPD-Team
+All rights reserved.
+http://www.mentalis.org/
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+- Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer. 
+
+- Neither the name of the KPD-Team, nor the names of its contributors
+may be used to endorse or promote products derived from this
+software without specific prior written permission. 
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file



Mime
View raw message