Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Kumar <sunilk@mono-cvs.ximian.com>2003-11-24 06:54:00 +0300
committerSunil Kumar <sunilk@mono-cvs.ximian.com>2003-11-24 06:54:00 +0300
commit4d207c1c3a4db0e63ed444862451d2fa4c58acc8 (patch)
tree65842f537506a02906ba3d0070ced476cbf2b12f /mcs/class/Novell.Directory.Ldap
parent8e04da8dd3b618c29fd056bc408d4ba2cce9a423 (diff)
Class files Representing Various ASN1 Structures
svn path=/trunk/mcs/; revision=20363
Diffstat (limited to 'mcs/class/Novell.Directory.Ldap')
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs122
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs149
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs194
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs174
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs119
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs327
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs123
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs142
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs89
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs77
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs123
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs181
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs124
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs125
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs106
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs102
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs214
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs172
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs277
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs305
20 files changed, 3245 insertions, 0 deletions
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs
new file mode 100755
index 00000000000..32928bd898a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Boolean.cs
@@ -0,0 +1,122 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Boolean.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 BOOLEAN type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Boolean:Asn1Object
+ {
+
+ private bool content;
+
+ /// <summary> ASN.1 BOOLEAN tag definition.</summary>
+ public const int TAG = 0x01;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Boolean
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Boolean
+ /// object from a boolean value.
+ ///
+ /// </summary>
+ /// <param name="content">The boolean value to be contained in the
+ /// this Asn1Boolean object
+ /// </param>
+ public Asn1Boolean(bool content):base(ID)
+ {
+ this.content = content;
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Boolean object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Boolean(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ content = ((System.Boolean) dec.decodeBoolean(in_Renamed, len));
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Boolean specific methods
+ */
+
+ /// <summary> Returns the content of this Asn1Boolean as a boolean.</summary>
+ public bool booleanValue()
+ {
+ return content;
+ }
+
+ /// <summary> Returns a String representation of this Asn1Boolean object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "BOOLEAN: " + content;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs
new file mode 100755
index 00000000000..71cb109e35a
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Choice.cs
@@ -0,0 +1,149 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Choice.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Choice object represents the choice of any Asn1Object. All
+ /// Asn1Object methods are delegated to the object this Asn1Choice contains.
+ /// </summary>
+ /* Can a CHOICE contain anything BUT a TAGGED Type?
+ */
+ [CLSCompliantAttribute(true)]
+ public class Asn1Choice:Asn1Object
+ {
+ /// <summary> Sets the CHOICE value stored in this Asn1Choice.
+ ///
+ /// </summary>
+ /// <param name="content">The Asn1Object that this Asn1Choice will
+ /// encode. Since all Asn1 objects are derived from Asn1Object
+ /// any basic type can be passed in.
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ virtual protected internal Asn1Object ChoiceValue
+ {
+ set
+ {
+ this.content = value;
+ return ;
+ }
+
+ }
+
+ private Asn1Object content;
+
+ /* Constructors for Asn1Choice
+ */
+
+ /// <summary> Constructs an Asn1Choice object using an Asn1Object value.
+ ///
+ /// </summary>
+ /// <param name="content">The Asn1Object that this Asn1Choice will
+ /// encode. Since all Asn1 objects are derived from Asn1Object
+ /// any basic type can be passed in.
+ /// </param>
+ public Asn1Choice(Asn1Object content):base(null)
+ {
+ this.content = content;
+ return ;
+ }
+
+ /// <summary> No arg Constructor. This is used by Filter, who subsequently sets the
+ /// content after parsing the RFC 2254 Search Filter String.
+ /// </summary>
+ protected internal Asn1Choice():base(null)
+ {
+ this.content = null;
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+
+ /// <summary> Call this method to encode the contents of this Asn1Choice
+ /// instance into the specified output stream using the
+ /// specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ content.encode(enc, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Choice specific methods
+ */
+
+ /// <summary> Returns the CHOICE value stored in this Asn1Choice
+ /// as an Asn1Object.
+ /// </summary>
+ public Asn1Object choiceValue()
+ {
+ return content;
+ }
+
+ /// <summary> This method will return the Asn1Identifier of the
+ /// encoded Asn1Object.We override the parent method
+ /// as the identifier of an Asn1Choice depends on the
+ /// type of the object encoded by this Asn1Choice.
+ /// </summary>
+ public override Asn1Identifier getIdentifier()
+ {
+ return content.getIdentifier();
+ }
+
+ /// <summary> Sets the identifier of the contained Asn1Object. We
+ /// override the parent method as the identifier of
+ /// an Asn1Choice depends on the type of the object
+ /// encoded by this Asn1Choice.
+ /// </summary>
+ public override void setIdentifier(Asn1Identifier id)
+ {
+ content.setIdentifier(id);
+ return ;
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ return content.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs
new file mode 100755
index 00000000000..4136d056589
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Decoder.cs
@@ -0,0 +1,194 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Decoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This interface defines the methods for decoding each of the ASN.1 types.
+ ///
+ /// Decoders which implement this interface may be used to decode any of the
+ /// Asn1Object data types.
+ ///
+ /// <p>This package also provides the BERDecoder class that can be used to
+ /// BER decode ASN.1 classes. However an application might chose to use
+ /// its own decoder class.
+ ///
+ /// <p>This interface thus allows an application to use this package to
+ /// decode ASN.1 objects using other decoding rules if needed.
+ ///
+ /// <p>Note that Ldap packets are required to be BER encoded. Since this package
+ /// includes a BER decoder no application provided decoder is needed for
+ /// building Ldap packets.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public interface Asn1Decoder : System.Runtime.Serialization.ISerializable
+ {
+
+ /// <summary> Decode an encoded value into an Asn1Object from a byte array.
+ ///
+ /// </summary>
+ /// <param name="value">A byte array that points to the encoded Asn1 data
+ /// </param>
+ Asn1Object decode(sbyte[] value_Renamed);
+
+
+ /// <summary> Decode an encoded value into an Asn1Object from an InputStream.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ /// </param>
+ Asn1Object decode(System.IO.Stream in_Renamed);
+
+
+ /// <summary> Decode an encoded value into an Asn1Object from an InputStream.
+ ///
+ /// </summary>
+ /// <param name="length">The decoded components encoded length. This value is
+ /// handy when decoding structured types. It allows you to accumulate
+ /// the number of bytes decoded, so you know when the structured
+ /// type has decoded all of its components.<br>
+ ///
+ /// </param>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ /// </param>
+ Asn1Object decode(System.IO.Stream in_Renamed, int[] length);
+
+ /* Decoders for ASN.1 simple types
+ */
+
+ /// <summary> Decode a BOOLEAN directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a BOOLEAN
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeBoolean(System.IO.Stream in_Renamed, int len);
+
+ /// <summary> Decode a Numeric value directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a Numeric
+ ///
+ /// <p>Can be used to decodes INTEGER and ENUMERATED types.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeNumeric(System.IO.Stream in_Renamed, int len);
+
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a REAL directly from a stream.
+ * public Object decodeReal(InputStream in, int len)
+ * throws IOException;
+ */
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a BIT_STRING directly from a stream.
+ * public Object decodeBitString(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+
+ /// <summary> Decode an OCTET_STRING directly from a stream. Call this method when you
+ /// know that the next ASN.1 encoded element is a OCTET_STRING.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.<br>
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeOctetString(System.IO.Stream in_Renamed, int len);
+
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an OBJECT_IDENTIFIER directly from a stream.
+ * public Object decodeObjectIdentifier(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+
+ /// <summary> Decode a CharacterString directly from a stream.
+ ///
+ /// Decodes any of the specialized character strings.
+ ///
+ /// </summary>
+ /// <param name="in">An input stream containig the encoded ASN.1 data.
+ ///
+ /// </param>
+ /// <param name="len">Length in bytes
+ /// </param>
+ System.Object decodeCharacterString(System.IO.Stream in_Renamed, int len);
+
+ /* No Decoders for ASN.1 structured types. A structured type's value is a
+ * collection of other types.
+ */
+
+
+ /* Decoders for ASN.1 useful types
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a GENERALIZED_TIME directly from a stream.
+ * public Object decodeGeneralizedTime(InputStream in, int len)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode a UNIVERSAL_TIME directly from a stream.
+ * public Object decodeUniversalTime(InputStream in, int len)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an EXTERNAL directly from a stream.
+ * public Object decodeExternal(InputStream in, int len)
+ * throws IOException;
+ */
+
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Decode an OBJECT_DESCRIPTOR directly from a stream.
+ * public Object decodeObjectDescriptor(InputStream in, int len)
+ * throws IOException;
+ */
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs
new file mode 100755
index 00000000000..f587bf10eca
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Encoder.cs
@@ -0,0 +1,174 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Encoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This interface defines the methods for encoding each of the ASN.1 types.
+ ///
+ /// Encoders which implement this interface may be used to encode any of the
+ /// Asn1Object data types.
+ ///
+ /// <p>This package also provides the BEREncoder class that can be used to
+ /// BER encode ASN.1 classes. However an application might chose to use
+ /// its own encoder class.
+ ///
+ /// <p>This interface thus allows an application to use this package to
+ /// encode ASN.1 objects using other encoding rules if needed.
+ ///
+ /// <p>Note that Ldap packets are required to be BER encoded. Since this package
+ /// includes a BER encoder no application provided encoder is needed for
+ /// building Ldap packets.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public interface Asn1Encoder : System.Runtime.Serialization.ISerializable
+ {
+
+ /* Encoders for ASN.1 simple types */
+
+ /// <summary> Encode an Asn1Boolean directly into the provided output stream.
+ ///
+ /// </summary>
+ /// <param name="b">The Asn1Boolean object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Boolean b, System.IO.Stream out_Renamed);
+
+ /// <summary> Encode an Asn1Numeric directly to a stream.
+ ///
+ /// <p>Use a two's complement representation in the fewest number of octets
+ /// possible.
+ ///
+ /// Can be used to encode both INTEGER and ENUMERATED values.<br>
+ ///
+ /// </summary>
+ /// <param name="n">The Asn1Numeric object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Numeric n, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1Real directly to a stream.
+ * public void encode(Asn1Real r, OutputStream out)
+ * throws IOException;
+ */
+
+ /// <summary> Encode an Asn1Null directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="n">The Asn1Null object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Null n, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1BitString directly to a stream.
+ * public void encode(Asn1BitString bs, OutputStream out)
+ * throws IOException;
+ */
+
+ /// <summary> Encode an Asn1OctetString directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="os">The Asn1OctetString object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1OctetString os, System.IO.Stream out_Renamed);
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1ObjectIdentifier directly to a stream.
+ * public void encode(Asn1ObjectIdentifier oi, OutputStream out)
+ * throws IOException;
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1CharacterString directly to a stream.
+ * public void encode(Asn1CharacterString cs, OutputStream out)
+ * throws IOException;
+ */
+
+ /* Encoder for ASN.1 structured types
+ */
+
+ /// <summary> Encode an Asn1Structured directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="c">The Asn1Structured object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Structured c, System.IO.Stream out_Renamed);
+
+ /// <summary> Encode an Asn1Tagged directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="t">The Asn1Tagged object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Tagged t, System.IO.Stream out_Renamed);
+
+ /* Encoders for ASN.1 useful types
+ */
+
+ /* Encoder for ASN.1 Identifier
+ */
+
+ /// <summary> Encode an Asn1Identifier directly to a stream.
+ ///
+ /// </summary>
+ /// <param name="id">The Asn1Identifier object to encode<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the ASN.1 object is
+ /// to be encoded<br>
+ /// </param>
+ void encode(Asn1Identifier id, System.IO.Stream out_Renamed);
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs
new file mode 100755
index 00000000000..febe0a298a1
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Enumerated.cs
@@ -0,0 +1,119 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Enumerated.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 ENUMERATED type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Enumerated:Asn1Numeric
+ {
+
+ /// <summary> ASN.1 tag definition for ENUMERATED</summary>
+ public const int TAG = 0x0a;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Enumerated
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Enumerated
+ /// object from an integer value.
+ ///
+ /// </summary>
+ /// <param name="content">The integer value to be contained in the
+ /// this Asn1Enumerated object
+ /// </param>
+ public Asn1Enumerated(int content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Call this constructor to construct an Asn1Enumerated
+ /// object from a long value.
+ ///
+ /// </summary>
+ /// <param name="content">The long value to be contained in the
+ /// this Asn1Enumerated object
+ /// </param>
+ public Asn1Enumerated(long content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Enumerated object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Enumerated(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID, (System.Int64) dec.decodeNumeric(in_Renamed, len))
+ {
+ return ;
+ }
+
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /// <summary> Return a String representation of this Asn1Enumerated.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "ENUMERATED: " + longValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs
new file mode 100755
index 00000000000..7e31802f1f8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Identifier.cs
@@ -0,0 +1,327 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Identifier.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class is used to encapsulate an ASN.1 Identifier.
+ ///
+ /// <p>An Asn1Identifier is composed of three parts:
+ /// <li> a class type,
+ /// <li> a form, and
+ /// <li> a tag.</p>
+ ///
+ /// <p>The class type is defined as:</p>
+ /// <pre>
+ /// bit 8 7 TAG CLASS
+ /// ------- -----------
+ /// 0 0 UNIVERSAL
+ /// 0 1 APPLICATION
+ /// 1 0 CONTEXT
+ /// 1 1 PRIVATE
+ /// </pre>
+ /// <p> The form is defined as:</p>
+ /// <pre>
+ /// bit 6 FORM
+ /// ----- --------
+ /// 0 PRIMITIVE
+ /// 1 CONSTRUCTED
+ /// </pre>
+ ///
+ /// <p> Note: CONSTRUCTED types are made up of other CONSTRUCTED or PRIMITIVE
+ /// types.</p>
+ ///
+ /// <p> The tag is defined as:</p>
+ /// <pre>
+ /// bit 5 4 3 2 1 TAG
+ /// ------------- ---------------------------------------------
+ /// 0 0 0 0 0
+ /// . . . . .
+ /// 1 1 1 1 0 (0-30) single octet tag
+ ///
+ /// 1 1 1 1 1 (> 30) multiple octet tag, more octets follow
+ /// </pre>
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Identifier:System.Object, System.ICloneable
+ {
+ /// <summary> Returns the CLASS of this Asn1Identifier as an int value.
+ ///
+ /// </summary>
+ /// <seealso cref="#UNIVERSAL">
+ /// </seealso>
+ /// <seealso cref="#APPLICATION">
+ /// </seealso>
+ /// <seealso cref="#CONTEXT">
+ /// </seealso>
+ /// <seealso cref="#PRIVATE">
+ /// </seealso>
+ virtual public int Asn1Class
+ {
+ get
+ {
+ return tagClass;
+ }
+
+ }
+ /// <summary> Return a boolean indicating if the constructed bit is set.
+ ///
+ /// </summary>
+ /// <returns> true if constructed and false if primitive.
+ /// </returns>
+ virtual public bool Constructed
+ {
+ get
+ {
+ return constructed;
+ }
+
+ }
+ /// <summary> Returns the TAG of this Asn1Identifier.</summary>
+ virtual public int Tag
+ {
+ get
+ {
+ return tag;
+ }
+
+ }
+ /// <summary> Returns the encoded length of this Asn1Identifier.</summary>
+ virtual public int EncodedLength
+ {
+ get
+ {
+ return encodedLength;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of UNIVERSAL.
+ ///
+ /// </summary>
+ /// <seealso cref="#UNIVERSAL">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Universal
+ {
+ get
+ {
+ return tagClass == UNIVERSAL;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of APPLICATION.
+ ///
+ /// </summary>
+ /// <seealso cref="#APPLICATION">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Application
+ {
+ get
+ {
+ return tagClass == APPLICATION;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of CONTEXT-SPECIFIC.
+ ///
+ /// </summary>
+ /// <seealso cref="#CONTEXT">
+ /// </seealso>
+ [CLSCompliantAttribute(false)]
+ virtual public bool Context
+ {
+ get
+ {
+ return tagClass == CONTEXT;
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating whether or not this Asn1Identifier
+ /// has a TAG CLASS of PRIVATE.
+ ///
+ /// </summary>
+ /// <seealso cref="#PRIVATE">
+ [CLSCompliantAttribute(false)]
+ virtual public bool Private
+ {
+ get
+ {
+ return tagClass == PRIVATE;
+ }
+
+ }
+
+ /// <summary> Universal tag class.
+ ///
+ /// <p> UNIVERSAL = 0 </p>
+ /// </summary>
+ public const int UNIVERSAL = 0;
+
+ /// <summary> Application-wide tag class.
+ ///
+ /// <p> APPLICATION = 1 </p>
+ /// </summary>
+ public const int APPLICATION = 1;
+
+ /// <summary> Context-specific tag class.
+ ///
+ /// <p> CONTEXT = 2 </p>
+ /// </summary>
+ public const int CONTEXT = 2;
+
+ /// <summary> Private-use tag class.
+ ///
+ /// <p> PRIVATE = 3 </p>
+ /// </summary>
+ public const int PRIVATE = 3;
+
+
+ /* Private variables
+ */
+
+ private int tagClass;
+ private bool constructed;
+ private int tag;
+ private int encodedLength;
+
+ /* Constructors for Asn1Identifier
+ */
+
+ /// <summary> Constructs an Asn1Identifier using the classtype, form and tag.
+ ///
+ /// </summary>
+ /// <param name="tagClass">As defined above.
+ ///
+ /// </param>
+ /// <param name="constructed">Set to true if constructed and false if primitive.
+ ///
+ /// </param>
+ /// <param name="tag">The tag of this identifier
+ /// </param>
+ public Asn1Identifier(int tagClass, bool constructed, int tag)
+ {
+ this.tagClass = tagClass;
+ this.constructed = constructed;
+ this.tag = tag;
+ }
+
+ /// <summary> Decode an Asn1Identifier directly from an InputStream and
+ /// save the encoded length of the Asn1Identifier.
+ ///
+ /// </summary>
+ /// <param name="in">The input stream to decode from.
+ /// </param>
+ public Asn1Identifier(System.IO.Stream in_Renamed)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Identifier");
+ tagClass = r >> 6;
+ constructed = (r & 0x20) != 0;
+ tag = r & 0x1F; // if tag < 30 then its a single octet identifier.
+ if (tag == 0x1F)
+ // if true, its a multiple octet identifier.
+ tag = decodeTagNumber(in_Renamed);
+ return ;
+ }
+
+ public Asn1Identifier()
+ {
+ return ;
+ }
+
+ /// <summary> Decode an Asn1Identifier directly from an InputStream and
+ /// save the encoded length of the Asn1Identifier, but reuse the object.
+ ///
+ /// </summary>
+ /// <param name="in">The input stream to decode from.
+ /// </param>
+ public void reset(System.IO.Stream in_Renamed)
+ {
+ encodedLength = 0;
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Identifier");
+ tagClass = r >> 6;
+ constructed = (r & 0x20) != 0;
+ tag = r & 0x1F; // if tag < 30 then its a single octet identifier.
+ if (tag == 0x1F)
+ // if true, its a multiple octet identifier.
+ tag = decodeTagNumber(in_Renamed);
+ }
+
+ /// <summary> In the case that we have a tag number that is greater than 30, we need
+ /// to decode a multiple octet tag number.
+ /// </summary>
+ private int decodeTagNumber(System.IO.Stream in_Renamed)
+ {
+ int n = 0;
+ while (true)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in tag number");
+ n = (n << 7) + (r & 0x7F);
+ if ((r & 0x80) == 0)
+ break;
+ }
+ return n;
+ }
+
+ /* Convenience methods
+ */
+
+ /// <summary> Creates a duplicate, not a true clone, of this object and returns
+ /// a reference to the duplicate.
+ ///
+ /// </summary>
+ public System.Object Clone()
+ {
+ try
+ {
+ return base.MemberwiseClone();
+ }
+ catch (System.Exception ce)
+ {
+ throw new System.SystemException("Internal error, cannot create clone");
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs
new file mode 100755
index 00000000000..4b581664add
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Integer.cs
@@ -0,0 +1,123 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Integer.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the ASN.1 INTEGER type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Integer:Asn1Numeric
+ {
+
+ /// <summary> ASN.1 INTEGER tag definition.</summary>
+ public const int TAG = 0x02;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1Integer
+ */
+
+ /// <summary> Call this constructor to construct an Asn1Integer
+ /// object from an integer value.
+ ///
+ /// </summary>
+ /// <param name="content">The integer value to be contained in the
+ /// this Asn1Integer object
+ /// </param>
+ public Asn1Integer(int content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Call this constructor to construct an Asn1Integer
+ /// object from a long value.
+ ///
+ /// </summary>
+ /// <param name="content">The long value to be contained in the
+ /// this Asn1Integer object
+ /// </param>
+ public Asn1Integer(long content):base(ID, content)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Integer object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Integer(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID, (System.Int64) dec.decodeNumeric(in_Renamed, len))
+ {
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Integer specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1Integer object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "INTEGER: " + longValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs
new file mode 100755
index 00000000000..0951ea907ea
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Length.cs
@@ -0,0 +1,142 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Length.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides a means to manipulate ASN.1 Length's. It will
+ /// be used by Asn1Encoder's and Asn1Decoder's by composition.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Length
+ {
+ /// <summary> Returns the length of this Asn1Length.</summary>
+ virtual public int Length
+ {
+ get
+ {
+ return length;
+ }
+
+ }
+ /// <summary> Returns the encoded length of this Asn1Length.</summary>
+ virtual public int EncodedLength
+ {
+ get
+ {
+ return encodedLength;
+ }
+
+ }
+
+ /* Private variables
+ */
+
+ private int length;
+ private int encodedLength;
+
+ /* Constructors for Asn1Length
+ */
+
+ /// <summary> Constructs an empty Asn1Length. Values are added by calling reset</summary>
+ public Asn1Length()
+ {
+ }
+ /// <summary> Constructs an Asn1Length</summary>
+ public Asn1Length(int length)
+ {
+ this.length = length;
+ }
+
+ /// <summary> Constructs an Asn1Length object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ public Asn1Length(System.IO.Stream in_Renamed)
+ {
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r == 0x80)
+ length = - 1;
+ else if (r < 0x80)
+ length = r;
+ else
+ {
+ length = 0;
+ for (r = r & 0x7F; r > 0; r--)
+ {
+ int part = in_Renamed.ReadByte();
+ encodedLength++;
+ if (part < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Asn1Length");
+ length = (length << 8) + part;
+ }
+ }
+ }
+
+ /// <summary> Resets an Asn1Length object by decoding data from an
+ /// input stream.
+ ///
+ /// Note: this was added for optimization of Asn1.LBERdecoder.decode()
+ ///
+ /// </summary>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ public void reset(System.IO.Stream in_Renamed)
+ {
+ encodedLength = 0;
+ int r = in_Renamed.ReadByte();
+ encodedLength++;
+ if (r == 0x80)
+ length = - 1;
+ else if (r < 0x80)
+ length = r;
+ else
+ {
+ length = 0;
+ for (r = r & 0x7F; r > 0; r--)
+ {
+ int part = in_Renamed.ReadByte();
+ encodedLength++;
+ if (part < 0)
+ throw new System.IO.EndOfStreamException("BERDecoder: decode: EOF in Asn1Length");
+ length = (length << 8) + part;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs
new file mode 100755
index 00000000000..bea0649d4f2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Null.cs
@@ -0,0 +1,89 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Null.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class represents the ASN.1 NULL type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Null:Asn1Object
+ {
+
+ /// <summary> ASN.1 NULL tag definition.</summary>
+ public const int TAG = 0x05;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructor for Asn1Null
+ */
+
+ /// <summary> Call this constructor to construct a new Asn1Null
+ /// object.
+ /// </summary>
+ public Asn1Null():base(ID)
+ {
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Null specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1Null object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "NULL: \"\"";
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs
new file mode 100755
index 00000000000..468a3e2f9e8
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Numeric.cs
@@ -0,0 +1,77 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Numeric.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This abstract class is the base class
+ /// for all Asn1 numeric (integral) types. These include
+ /// Asn1Integer and Asn1Enumerated.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public abstract class Asn1Numeric:Asn1Object
+ {
+
+ private System.Int64 content;
+
+ internal Asn1Numeric(Asn1Identifier id, int value_Renamed):base(id)
+ {
+ content = (System.Int64) value_Renamed;
+ return ;
+ }
+
+ internal Asn1Numeric(Asn1Identifier id, long value_Renamed):base(id)
+ {
+ content = (System.Int64) value_Renamed;
+ return ;
+ }
+
+/* internal Asn1Numeric(Asn1Identifier id, System.Int64 value_Renamed):base(id)
+ {
+ content = value_Renamed;
+ return ;
+ }
+*/
+ /// <summary> Returns the content of this Asn1Numeric object as an int.</summary>
+ public int intValue()
+ {
+ return (int) content;
+ }
+
+ /// <summary> Returns the content of this Asn1Numeric object as a long.</summary>
+ public long longValue()
+ {
+ return (long) content;
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs
new file mode 100755
index 00000000000..323f95ccefe
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Object.cs
@@ -0,0 +1,123 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Object.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This is the base class for all other Asn1 types.</summary>
+ [CLSCompliantAttribute(true)]
+ [Serializable]
+ public abstract class Asn1Object : System.Runtime.Serialization.ISerializable
+ {
+
+ private Asn1Identifier id;
+
+ public Asn1Object(Asn1Identifier id)
+ {
+ this.id = id;
+ return ;
+ }
+
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+
+ /// <summary> Abstract method that must be implemented by each child
+ /// class to encode itself ( an Asn1Object) directly intto
+ /// a output stream.
+ ///
+ /// </summary>
+ /// <param name="out">The output stream onto which the encoded
+ /// Asn1Object will be placed.
+ /// </param>
+ abstract public void encode(Asn1Encoder enc, System.IO.Stream out_Renamed);
+
+ /// <summary> Returns the identifier for this Asn1Object as an Asn1Identifier.
+ /// This Asn1Identifier object will include the CLASS, FORM and TAG
+ /// for this Asn1Object.
+ /// </summary>
+ public virtual Asn1Identifier getIdentifier()
+ {
+ return id;
+ }
+
+ /// <summary> Sets the identifier for this Asn1Object. This is helpful when
+ /// creating implicit Asn1Tagged types.
+ ///
+ /// </summary>
+ /// <param name="id">An Asn1Identifier object representing the CLASS,
+ /// FORM and TAG)
+ /// </param>
+ public virtual void setIdentifier(Asn1Identifier id)
+ {
+ this.id = id;
+ return ;
+ }
+
+ /// <summary> This method returns a byte array representing the encoded
+ /// Asn1Object. It in turn calls the encode method that is
+ /// defined in Asn1Object but will usually be implemented
+ /// in the child Asn1 classses.
+ /// </summary>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] getEncoding(Asn1Encoder enc)
+ {
+ System.IO.MemoryStream out_Renamed = new System.IO.MemoryStream();
+ try
+ {
+ encode(enc, out_Renamed);
+ }
+ catch (System.IO.IOException e)
+ {
+ // Should never happen - the current Asn1Object does not have
+ // a encode method.
+ throw new System.SystemException("IOException while encoding to byte array: " + e.ToString());
+ }
+ return SupportClass.ToSByteArray(out_Renamed.ToArray());
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ System.String[] classTypes = new System.String[]{"[UNIVERSAL ", "[APPLICATION ", "[", "[PRIVATE "};
+
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ Asn1Identifier id = getIdentifier(); // could be overridden.
+
+ sb.Append(classTypes[id.Asn1Class]).Append(id.Tag).Append("] ");
+
+ return sb.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs
new file mode 100755
index 00000000000..e3a70b530ba
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1OctetString.cs
@@ -0,0 +1,181 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1OctetString.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class encapsulates the OCTET STRING type.</summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1OctetString:Asn1Object
+ {
+
+ private sbyte[] content;
+
+ /// <summary> ASN.1 OCTET STRING tag definition.</summary>
+ public const int TAG = 0x04;
+
+ /// <summary> ID is added for Optimization.
+ /// <p>Id needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ protected internal static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, false, TAG);
+ /* Constructors for Asn1OctetString
+ */
+
+ /// <summary> Call this constructor to construct an Asn1OctetString
+ /// object from a byte array.
+ ///
+ /// </summary>
+ /// <param name="content">A byte array representing the string that
+ /// will be contained in the this Asn1OctetString object
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1OctetString(sbyte[] content):base(ID)
+ {
+ this.content = content;
+ return ;
+ }
+
+
+ /// <summary> Call this constructor to construct an Asn1OctetString
+ /// object from a String object.
+ ///
+ /// </summary>
+ /// <param name="content">A string value that will be contained
+ /// in the this Asn1OctetString object
+ /// </param>
+ public Asn1OctetString(System.String content):base(ID)
+ {
+ try
+ {
+/* System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding();
+ byte[] bytes = utf8.GetBytes (content);
+ sbyte[] sbytes = new sbyte[bytes.Length+1]; //signed bytes
+ sbytes[0] = 0; //set sign byte to zero.
+ for(int i=1; i<sbytes.Length; i++)
+ sbytes[i] = (sbyte) bytes[i-1]; //cast byte-->sbyte
+*/
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ byte[] ibytes = encoder.GetBytes(content);
+ sbyte[] sbytes=SupportClass.ToSByteArray(ibytes);
+
+ this.content = sbytes;
+// this.content = content.getBytes("UTF8");
+ }
+ catch (System.IO.IOException uee)
+ {
+ throw new System.SystemException(uee.ToString());
+ }
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1OctetString object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1OctetString(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ content = (len > 0)?(sbyte[]) dec.decodeOctetString(in_Renamed, len):new sbyte[0];
+ return ;
+ }
+
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+
+ /*Asn1OctetString specific methods
+ */
+
+ /// <summary> Returns the content of this Asn1OctetString as a byte array.</summary>
+ [CLSCompliantAttribute(false)]
+ public sbyte[] byteValue()
+ {
+ return content;
+ }
+
+
+ /// <summary> Returns the content of this Asn1OctetString as a String.</summary>
+ public System.String stringValue()
+ {
+ System.String s = null;
+ try
+ {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray(content));
+ s = new String(dchar);
+// sbyte *sb=content;
+// s = new String(sb,0,content.Length, new System.Text.UTF8Encoding());
+ }
+ catch (System.IO.IOException uee)
+ {
+ throw new System.SystemException(uee.ToString());
+ }
+
+ return s;
+ }
+
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ return base.ToString() + "OCTET STRING: " + stringValue();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs
new file mode 100755
index 00000000000..152ba64e537
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Sequence.cs
@@ -0,0 +1,124 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Sequence.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Sequence class can hold an ordered collection of components with
+ /// distinct type.
+ ///
+ /// This class inherits from the Asn1Structured class which
+ /// provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Sequence:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SEQUENCE tag definition.</summary>
+ public const int TAG = 0x10;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// id needs only be one Value for every instance Thus we create it only once.
+ /// </summary>
+ private static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1Sequence
+ */
+
+ /// <summary> Constructs an Asn1Sequence object with no actual Asn1Objects in it.
+ ///
+ /// Assumes a default size of 10 elements.
+ /// </summary>
+ public Asn1Sequence():base(ID, 10)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object with the specified
+ /// number of placeholders for Asn1Objects.
+ ///
+ /// It should be noted there are no actual Asn1Objects in this
+ /// SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1Sequence(int size):base(ID, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object with an array representing an
+ /// Asn1 sequence.
+ ///
+ /// </summary>
+ /// <param name="newContent">the array containing the Asn1 data for the sequence
+ ///
+ /// </param>
+ /// <param name="size">Specifies the number of items in the array
+ /// </param>
+ public Asn1Sequence(Asn1Object[] newContent, int size):base(ID, newContent, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Sequence object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Sequence(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Sequence specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1Sequence.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SEQUENCE: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs
new file mode 100755
index 00000000000..a3ecd9e7850
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SequenceOf.cs
@@ -0,0 +1,125 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1SequenceOf.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1SequenceOf class is used to hold an ordered collection
+ /// of components with identical type. This class inherits
+ /// from the Asn1Structured class which already provides
+ /// functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1SequenceOf:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SEQUENCE OF tag definition.</summary>
+ public const int TAG = 0x10;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+
+ /* Constructors for Asn1SequenceOf
+ */
+
+ /// <summary> Constructs an Asn1SequenceOf object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1SequenceOf():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SequenceOf object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1SequenceOf(int size):base(ID, size)
+ {
+ return ;
+ }
+
+
+ /// <summary> A copy constructor which creates an Asn1SequenceOf from an
+ /// instance of Asn1Sequence.
+ ///
+ /// Since SEQUENCE and SEQUENCE_OF have the same identifier, the decoder
+ /// will always return a SEQUENCE object when it detects that identifier.
+ /// In order to take advantage of the Asn1SequenceOf type, we need to be
+ /// able to construct this object when knowingly receiving an
+ /// Asn1Sequence.
+ /// </summary>
+ public Asn1SequenceOf(Asn1Sequence sequence):base(ID, sequence.toArray(), sequence.size())
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SequenceOf object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1SequenceOf(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+
+ /* Asn1SequenceOf specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1SequenceOf object</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SEQUENCE OF: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs
new file mode 100755
index 00000000000..0e18172be74
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Set.cs
@@ -0,0 +1,106 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Set.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Set class can hold an unordered collection of components with
+ /// distinct type. This class inherits from the Asn1Structured class
+ /// which already provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Set:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SET tag definition.</summary>
+ public const int TAG = 0x11;
+
+ /// <summary> ID is added for Optimization.</summary>
+ /// <summary> <p>ID needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1Set
+ */
+
+ /// <summary> Constructs an Asn1Set object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1Set():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1Set object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1Set(int size):base(ID, size)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Set object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Set(Asn1Decoder dec, System.IO.Stream in_Renamed, int len):base(ID)
+ {
+ decodeStructured(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Set specific methods
+ */
+
+ /// <summary> Returns a String representation of this Asn1Set.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SET: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs
new file mode 100755
index 00000000000..a31fcc08cf2
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1SetOf.cs
@@ -0,0 +1,102 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1SetOf.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Set class can hold an unordered collection of components with
+ /// identical type. This class inherits from the Asn1Structured class
+ /// which already provides functionality to hold multiple Asn1 components.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1SetOf:Asn1Structured
+ {
+
+ /// <summary> ASN.1 SET OF tag definition.</summary>
+ public const int TAG = 0x11;
+
+ /// <summary> ID is added for Optimization.
+ ///
+ /// <p>Id needs only be one Value for every instance,
+ /// thus we create it only once.</p>
+ /// </summary>
+ public static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.UNIVERSAL, true, TAG);
+ /* Constructors for Asn1SetOf
+ */
+
+ /// <summary> Constructs an Asn1SetOf object with no actual
+ /// Asn1Objects in it. Assumes a default size of 5 elements.
+ /// </summary>
+ public Asn1SetOf():base(ID)
+ {
+ return ;
+ }
+
+
+ /// <summary> Constructs an Asn1SetOf object with the specified
+ /// number of placeholders for Asn1Objects. However there
+ /// are no actual Asn1Objects in this SequenceOf object.
+ ///
+ /// </summary>
+ /// <param name="size">Specifies the initial size of the collection.
+ /// </param>
+ public Asn1SetOf(int size):base(ID, size)
+ {
+ return ;
+ }
+
+
+ /// <summary> A copy constructor that creates an Asn1SetOf from an instance of Asn1Set.
+ ///
+ /// <p>Since SET and SET_OF have the same identifier, the decoder
+ /// will always return a SET object when it detects that identifier.
+ /// In order to take advantage of the Asn1SetOf type, we need to be
+ /// able to construct this object when knowingly receiving an
+ /// Asn1Set.</p>
+ /// </summary>
+ public Asn1SetOf(Asn1Set set_Renamed):base(ID, set_Renamed.toArray(), set_Renamed.size())
+ {
+ return ;
+ }
+
+ /* Asn1SetOf specific methods
+ */
+
+ /// <summary> Return a String representation of this Asn1SetOf.</summary>
+ [CLSCompliantAttribute(false)]
+ public override System.String ToString()
+ {
+ return base.toString("SET OF: { ");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs
new file mode 100755
index 00000000000..f6dadd4d050
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Structured.cs
@@ -0,0 +1,214 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Structured.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class serves as the base type for all ASN.1
+ /// structured types.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public abstract class Asn1Structured:Asn1Object
+ {
+ private Asn1Object[] content;
+
+ private int contentIndex = 0;
+
+ /*
+ * Create a an Asn1 structured type with default size of 10
+ *
+ * @param the Asn1Identifier containing the tag for this structured type
+ */
+ protected internal Asn1Structured(Asn1Identifier id):this(id, 10)
+ {
+ return ;
+ }
+
+ /*
+ * Create a an Asn1 structured type with the designated size
+ *
+ * @param id the Asn1Identifier containing the tag for this structured type
+ *
+ * @param size the size to allocate
+ */
+ protected internal Asn1Structured(Asn1Identifier id, int size):base(id)
+ {
+ content = new Asn1Object[size];
+ return ;
+ }
+
+ /*
+ * Create a an Asn1 structured type with default size of 10
+ *
+ * @param id the Asn1Identifier containing the tag for this structured type
+ *
+ * @param content an array containing the content
+ *
+ * @param size the number of items of content in the array
+ */
+ protected internal Asn1Structured(Asn1Identifier id, Asn1Object[] newContent, int size):base(id)
+ {
+ content = newContent;
+ contentIndex = size;
+ return ;
+ }
+
+ /// <summary> Encodes the contents of this Asn1Structured directly to an output
+ /// stream.
+ /// </summary>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /// <summary> Decode an Asn1Structured type from an InputStream.</summary>
+ [CLSCompliantAttribute(false)]
+ protected internal void decodeStructured(Asn1Decoder dec, System.IO.Stream in_Renamed, int len)
+ {
+ int[] componentLen = new int[1]; // collects length of component
+
+ while (len > 0)
+ {
+ add(dec.decode(in_Renamed, componentLen));
+ len -= componentLen[0];
+ }
+ return ;
+ }
+
+ /// <summary> Returns an array containing the individual ASN.1 elements
+ /// of this Asn1Structed object.
+ ///
+ /// </summary>
+ /// <returns> an array of Asn1Objects
+ /// </returns>
+ public Asn1Object[] toArray()
+ {
+ Asn1Object[] cloneArray = new Asn1Object[contentIndex];
+ Array.Copy((System.Array) content, 0, (System.Array) cloneArray, 0, contentIndex);
+ return cloneArray;
+ }
+
+ /// <summary> Adds a new Asn1Object to the end of this Asn1Structured
+ /// object.
+ ///
+ /// </summary>
+ /// <param name="value">The Asn1Object to add to this Asn1Structured
+ /// object.
+ /// </param>
+ public void add(Asn1Object value_Renamed)
+ {
+ if (contentIndex == content.Length)
+ {
+ // Array too small, need to expand it, double length
+ int newSize = contentIndex + contentIndex;
+ Asn1Object[] newArray = new Asn1Object[newSize];
+ Array.Copy((System.Array) content, 0, (System.Array) newArray, 0, contentIndex);
+ content = newArray;
+ }
+ content[contentIndex++] = value_Renamed;
+ return ;
+ }
+
+ /// <summary> Replaces the Asn1Object in the specified index position of
+ /// this Asn1Structured object.
+ ///
+ /// </summary>
+ /// <param name="index">The index into the Asn1Structured object where
+ /// this new ANS1Object will be placed.
+ ///
+ /// </param>
+ /// <param name="value">The Asn1Object to set in this Asn1Structured
+ /// object.
+ /// </param>
+ public void set_Renamed(int index, Asn1Object value_Renamed)
+ {
+ if ((index >= contentIndex) || (index < 0))
+ {
+ throw new System.IndexOutOfRangeException("Asn1Structured: get: index " + index + ", size " + contentIndex);
+ }
+ content[index] = value_Renamed;
+ return ;
+ }
+
+ /// <summary> Gets a specific Asn1Object in this structred object.
+ ///
+ /// </summary>
+ /// <param name="index">The index of the Asn1Object to get from
+ /// this Asn1Structured object.
+ /// </param>
+ public Asn1Object get_Renamed(int index)
+ {
+ if ((index >= contentIndex) || (index < 0))
+ {
+ throw new System.IndexOutOfRangeException("Asn1Structured: set: index " + index + ", size " + contentIndex);
+ }
+ return content[index];
+ }
+
+ /// <summary> Returns the number of Asn1Obejcts that have been encoded
+ /// into this Asn1Structured class.
+ /// </summary>
+ public int size()
+ {
+ return contentIndex;
+ }
+
+ /// <summary> Creates a String representation of this Asn1Structured.
+ /// object.
+ ///
+ /// </summary>
+ /// <param name="type">the Type to put in the String representing this structured object
+ ///
+ /// </param>
+ /// <returns> the String representation of this object.
+ /// </returns>
+ [CLSCompliantAttribute(false)]
+ public virtual System.String toString(System.String type)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+
+ sb.Append(type);
+
+ for (int i = 0; i < contentIndex; i++)
+ {
+ sb.Append(content[i]);
+ if (i != contentIndex - 1)
+ sb.Append(", ");
+ }
+ sb.Append(" }");
+
+ return base.ToString() + sb.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs
new file mode 100755
index 00000000000..e638727ed04
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/Asn1Tagged.cs
@@ -0,0 +1,172 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.Asn1Tagged.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> The Asn1Tagged class can hold a base Asn1Object with a distinctive tag
+ /// describing the type of that base object. It also maintains a boolean value
+ /// indicating whether the value should be encoded by EXPLICIT or IMPLICIT
+ /// means. (Explicit is true by default.)
+ ///
+ /// If the type is encoded IMPLICITLY, the base types form, length and content
+ /// will be encoded as usual along with the class type and tag specified in
+ /// the constructor of this Asn1Tagged class.
+ ///
+ /// If the type is to be encoded EXPLICITLY, the base type will be encoded as
+ /// usual after the Asn1Tagged identifier has been encoded.
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class Asn1Tagged:Asn1Object
+ {
+ /// <summary> Sets the Asn1Object tagged value</summary>
+ [CLSCompliantAttribute(false)]
+ virtual public Asn1Object TaggedValue
+ {
+ set
+ {
+ this.content = value;
+ if (!explicit_Renamed && value != null)
+ {
+ // replace object's id with new tag.
+ value.setIdentifier(this.getIdentifier());
+ }
+ }
+
+ }
+ /// <summary> Returns a boolean value indicating if this object uses
+ /// EXPLICIT tagging.
+ /// </summary>
+ virtual public bool Explicit
+ {
+ get
+ {
+ return explicit_Renamed;
+ }
+
+ }
+
+ private bool explicit_Renamed;
+ private Asn1Object content;
+
+ /* Constructors for Asn1Tagged
+ */
+
+ /// <summary> Constructs an Asn1Tagged object using the provided
+ /// AN1Identifier and the Asn1Object.
+ ///
+ /// The explicit flag defaults to true as per the spec.
+ /// </summary>
+ public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed):this(identifier, object_Renamed, true)
+ {
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Tagged object.</summary>
+ public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed, bool explicit_Renamed):base(identifier)
+ {
+ this.content = object_Renamed;
+ this.explicit_Renamed = explicit_Renamed;
+
+ if (!explicit_Renamed && content != null)
+ {
+ // replace object's id with new tag.
+ content.setIdentifier(identifier);
+ }
+ return ;
+ }
+
+ /// <summary> Constructs an Asn1Tagged object by decoding data from an
+ /// input stream.
+ ///
+ /// </summary>
+ /// <param name="dec">The decoder object to use when decoding the
+ /// input stream. Sometimes a developer might want to pass
+ /// in his/her own decoder object<br>
+ ///
+ /// </param>
+ /// <param name="in">A byte stream that contains the encoded ASN.1
+ ///
+ /// </param>
+ [CLSCompliantAttribute(false)]
+ public Asn1Tagged(Asn1Decoder dec, System.IO.Stream in_Renamed, int len, Asn1Identifier identifier):base(identifier)
+ {
+
+ // If we are decoding an implicit tag, there is no way to know at this
+ // low level what the base type really is. We can place the content
+ // into an Asn1OctetString type and pass it back to the application who
+ // will be able to create the appropriate ASN.1 type for this tag.
+ content = new Asn1OctetString(dec, in_Renamed, len);
+ return ;
+ }
+
+ /* Asn1Object implementation
+ */
+
+ /// <summary> Call this method to encode the current instance into the
+ /// specified output stream using the specified encoder object.
+ ///
+ /// </summary>
+ /// <param name="enc">Encoder object to use when encoding self.<br>
+ ///
+ /// </param>
+ /// <param name="out">The output stream onto which the encoded byte
+ /// stream is written.
+ /// </param>
+ public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed)
+ {
+ enc.encode(this, out_Renamed);
+ return ;
+ }
+
+ /* Asn1Tagged specific methods
+ */
+
+ /// <summary> Returns the Asn1Object stored in this Asn1Tagged object</summary>
+ public Asn1Object taggedValue()
+ {
+ return content;
+ }
+
+ /// <summary> Return a String representation of this Asn1Object.</summary>
+ public override System.String ToString()
+ {
+ if (explicit_Renamed)
+ {
+ return base.ToString() + content.ToString();
+ }
+ // implicit tagging
+ return content.ToString();
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs
new file mode 100755
index 00000000000..0cf4847a7d3
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBERDecoder.cs
@@ -0,0 +1,277 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.LBERDecoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides LBER decoding routines for ASN.1 Types. LBER is a
+ /// subset of BER as described in the following taken from 5.1 of RFC 2251:
+ ///
+ /// <p>5.1. Mapping Onto BER-based Transport Services
+ ///
+ /// The protocol elements of Ldap are encoded for exchange using the
+ /// Basic Encoding Rules (BER) [11] of ASN.1 [3]. However, due to the
+ /// high overhead involved in using certain elements of the BER, the
+ /// following additional restrictions are placed on BER-encodings of Ldap
+ /// protocol elements:
+ ///
+ /// <li>(1) Only the definite form of length encoding will be used.
+ ///
+ /// <li>(2) OCTET STRING values will be encoded in the primitive form only.
+ ///
+ /// <li>(3) If the value of a BOOLEAN type is true, the encoding MUST have
+ /// its contents octets set to hex "FF".
+ ///
+ /// <li>(4) If a value of a type is its default value, it MUST be absent.
+ /// Only some BOOLEAN and INTEGER types have default values in this
+ /// protocol definition.
+ ///
+ /// <p>These restrictions do not apply to ASN.1 types encapsulated inside of
+ /// OCTET STRING values, such as attribute values, unless otherwise
+ /// noted.
+ ///
+ /// <p>[3] ITU-T Rec. X.680, "Abstract Syntax Notation One (ASN.1) -
+ /// Specification of Basic Notation", 1994.
+ ///
+ /// <p>[11] ITU-T Rec. X.690, "Specification of ASN.1 encoding rules: Basic,
+ /// Canonical, and Distinguished Encoding Rules", 1994.
+ ///
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class LBERDecoder : Asn1Decoder
+ {
+ public LBERDecoder()
+ {
+ InitBlock();
+ }
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+
+ private void InitBlock()
+ {
+ asn1ID = new Asn1Identifier();
+ asn1Len = new Asn1Length();
+ }
+ //used to speed up decode, so it doesn't need to recreate an identifier every time
+ //instead just reset is called CANNOT be static for multiple connections
+ private Asn1Identifier asn1ID;
+ private Asn1Length asn1Len;
+
+
+ /* Generic decode routines
+ */
+
+ /// <summary> Decode an LBER encoded value into an Asn1Type from a byte array.</summary>
+ [CLSCompliantAttribute(false)]
+ public virtual Asn1Object decode(sbyte[] value_Renamed)
+ {
+ Asn1Object asn1 = null;
+
+ System.IO.MemoryStream in_Renamed = new System.IO.MemoryStream(SupportClass.ToByteArray(value_Renamed));
+ try
+ {
+ asn1 = decode(in_Renamed);
+ }
+ catch (System.IO.IOException ioe)
+ {
+ }
+ return asn1;
+ }
+
+ /// <summary> Decode an LBER encoded value into an Asn1Type from an InputStream.</summary>
+ public virtual Asn1Object decode(System.IO.Stream in_Renamed)
+ {
+ int[] len = new int[1];
+ return decode(in_Renamed, len);
+ }
+
+ /// <summary> Decode an LBER encoded value into an Asn1Object from an InputStream.
+ ///
+ /// <p> This method also returns the total length of this encoded
+ /// Asn1Object (length of type + length of length + length of content)
+ /// in the parameter len. This information is helpful when decoding
+ /// structured types.
+ /// </summary>
+ public virtual Asn1Object decode(System.IO.Stream in_Renamed, int[] len)
+ {
+ asn1ID.reset(in_Renamed);
+ asn1Len.reset(in_Renamed);
+
+ int length = asn1Len.Length;
+ len[0] = asn1ID.EncodedLength + asn1Len.EncodedLength + length;
+
+ if (asn1ID.Universal)
+ {
+ switch (asn1ID.Tag)
+ {
+
+ case Asn1Sequence.TAG:
+ return new Asn1Sequence(this, in_Renamed, length);
+
+ case Asn1Set.TAG:
+ return new Asn1Set(this, in_Renamed, length);
+
+ case Asn1Boolean.TAG:
+ return new Asn1Boolean(this, in_Renamed, length);
+
+ case Asn1Integer.TAG:
+ return new Asn1Integer(this, in_Renamed, length);
+
+ case Asn1OctetString.TAG:
+ return new Asn1OctetString(this, in_Renamed, length);
+
+ case Asn1Enumerated.TAG:
+ return new Asn1Enumerated(this, in_Renamed, length);
+
+ case Asn1Null.TAG:
+ return new Asn1Null(); // has no content to decode.
+ /* Asn1 TYPE NOT YET SUPPORTED
+ case Asn1BitString.TAG:
+ return new Asn1BitString(this, in, length);
+ case Asn1ObjectIdentifier.TAG:
+ return new Asn1ObjectIdentifier(this, in, length);
+ case Asn1Real.TAG:
+ return new Asn1Real(this, in, length);
+ case Asn1NumericString.TAG:
+ return new Asn1NumericString(this, in, length);
+ case Asn1PrintableString.TAG:
+ return new Asn1PrintableString(this, in, length);
+ case Asn1TeletexString.TAG:
+ return new Asn1TeletexString(this, in, length);
+ case Asn1VideotexString.TAG:
+ return new Asn1VideotexString(this, in, length);
+ case Asn1IA5String.TAG:
+ return new Asn1IA5String(this, in, length);
+ case Asn1GraphicString.TAG:
+ return new Asn1GraphicString(this, in, length);
+ case Asn1VisibleString.TAG:
+ return new Asn1VisibleString(this, in, length);
+ case Asn1GeneralString.TAG:
+ return new Asn1GeneralString(this, in, length);
+ */
+
+
+ default:
+ throw new System.IO.EndOfStreamException("Unknown tag"); // !!! need a better exception
+
+ }
+ }
+ else
+ {
+ // APPLICATION or CONTEXT-SPECIFIC tag
+ return new Asn1Tagged(this, in_Renamed, length, (Asn1Identifier) asn1ID.Clone());
+ }
+ }
+
+ /* Decoders for ASN.1 simple type Contents
+ */
+
+ /// <summary> Decode a boolean directly from a stream.</summary>
+ public System.Object decodeBoolean(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] lber = new sbyte[len];
+
+ int i = SupportClass.ReadInput(in_Renamed, ref lber, 0, lber.Length);
+
+ if (i != len)
+ throw new System.IO.EndOfStreamException("LBER: BOOLEAN: decode error: EOF");
+
+ return (lber[0] == 0x00)?false:true;
+ }
+
+ /// <summary> Decode a Numeric type directly from a stream. Decodes INTEGER
+ /// and ENUMERATED types.
+ /// </summary>
+ public System.Object decodeNumeric(System.IO.Stream in_Renamed, int len)
+ {
+ long l = 0;
+ int r = in_Renamed.ReadByte();
+
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("LBER: NUMERIC: decode error: EOF");
+
+ if ((r & 0x80) != 0)
+ {
+ // check for negative number
+ l = - 1;
+ }
+
+ l = (l << 8) | r;
+
+ for (int i = 1; i < len; i++)
+ {
+ r = in_Renamed.ReadByte();
+ if (r < 0)
+ throw new System.IO.EndOfStreamException("LBER: NUMERIC: decode error: EOF");
+ l = (l << 8) | r;
+ }
+ return (System.Int64) l;
+ }
+
+ /// <summary> Decode an OctetString directly from a stream.</summary>
+ public System.Object decodeOctetString(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] octets = new sbyte[len];
+ int totalLen = 0;
+
+ while (totalLen < len)
+ {
+ // Make sure we have read all the data
+ int inLen = SupportClass.ReadInput(in_Renamed, ref octets, totalLen, len - totalLen);
+ totalLen += inLen;
+ }
+
+ return octets;
+ }
+
+ /// <summary> Decode a CharacterString directly from a stream.</summary>
+ public System.Object decodeCharacterString(System.IO.Stream in_Renamed, int len)
+ {
+ sbyte[] octets = new sbyte[len];
+
+ for (int i = 0; i < len; i++)
+ {
+ int ret = in_Renamed.ReadByte(); // blocks
+ if (ret == - 1)
+ throw new System.IO.EndOfStreamException("LBER: CHARACTER STRING: decode error: EOF");
+ octets[i] = (sbyte) ret;
+ }
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8");
+ char[] dchar = encoder.GetChars(SupportClass.ToByteArray(octets));
+ string rval = new String(dchar);
+
+ return rval;//new String( "UTF8");
+ }
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs
new file mode 100755
index 00000000000..ad265efe10b
--- /dev/null
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Asn1/LBEREncoder.cs
@@ -0,0 +1,305 @@
+/******************************************************************************
+* The MIT License
+* Copyright (c) 2003 Novell Inc. 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.
+*******************************************************************************/
+//
+// Novell.Directory.Ldap.Asn1.LBEREncoder.cs
+//
+// Author:
+// Sunil Kumar (Sunilk@novell.com)
+//
+// (C) 2003 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+
+namespace Novell.Directory.Ldap.Asn1
+{
+
+ /// <summary> This class provides LBER encoding routines for ASN.1 Types. LBER is a
+ /// subset of BER as described in the following taken from 5.1 of RFC 2251:
+ ///
+ /// <p>5.1. Mapping Onto BER-based Transport Services
+ ///
+ /// The protocol elements of Ldap are encoded for exchange using the
+ /// Basic Encoding Rules (BER) [11] of ASN.1 [3]. However, due to the
+ /// high overhead involved in using certain elements of the BER, the
+ /// following additional restrictions are placed on BER-encodings of Ldap
+ /// protocol elements:
+ ///
+ /// <li>(1) Only the definite form of length encoding will be used.
+ ///
+ /// <li>(2) OCTET STRING values will be encoded in the primitive form only.
+ ///
+ /// <li>(3) If the value of a BOOLEAN type is true, the encoding MUST have
+ /// its contents octets set to hex "FF".
+ ///
+ /// <li>(4) If a value of a type is its default value, it MUST be absent.
+ /// Only some BOOLEAN and INTEGER types have default values in this
+ /// protocol definition.
+ ///
+ /// <p>These restrictions do not apply to ASN.1 types encapsulated inside of
+ /// OCTET STRING values, such as attribute values, unless otherwise
+ /// noted.
+ ///
+ /// <p>[3] ITU-T Rec. X.680, "Abstract Syntax Notation One (ASN.1) -
+ /// Specification of Basic Notation", 1994.
+ ///
+ /// <p>[11] ITU-T Rec. X.690, "Specification of ASN.1 encoding rules: Basic,
+ /// Canonical, and Distinguished Encoding Rules", 1994.
+ ///
+ /// </summary>
+ [CLSCompliantAttribute(true)]
+ public class LBEREncoder : Asn1Encoder
+ {
+
+ /* Encoders for ASN.1 simple type Contents
+ */
+ public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
+ {
+ }
+ /// <summary> BER Encode an Asn1Boolean directly into the specified output stream.</summary>
+ public virtual void encode(Asn1Boolean b, System.IO.Stream out_Renamed)
+ {
+ /* Encode the id */
+ encode(b.getIdentifier(), out_Renamed);
+
+ /* Encode the length */
+ out_Renamed.WriteByte((System.Byte) 0x01);
+
+ /* Encode the boolean content*/
+ out_Renamed.WriteByte((byte) (b.booleanValue()?(sbyte) SupportClass.Identity(0xff):(sbyte) 0x00));
+
+ return ;
+ }
+
+ /// <summary> Encode an Asn1Numeric directly into the specified outputstream.
+ ///
+ /// <p>Use a two's complement representation in the fewest number of octets
+ /// possible.
+ ///
+ /// <p>Can be used to encode INTEGER and ENUMERATED values.
+ /// </summary>
+ public void encode(Asn1Numeric n, System.IO.Stream out_Renamed)
+ {
+ sbyte[] octets = new sbyte[8];
+ sbyte len;
+ long value_Renamed = n.longValue();
+ long endValue = (value_Renamed < 0)?- 1:0;
+ long endSign = endValue & 0x80;
+
+ for (len = 0; len == 0 || value_Renamed != endValue || (octets[len - 1] & 0x80) != endSign; len++)
+ {
+ octets[len] = (sbyte) (value_Renamed & 0xFF);
+ value_Renamed >>= 8;
+ }
+
+ encode(n.getIdentifier(), out_Renamed);
+ out_Renamed.WriteByte((byte) len); // Length
+ for (int i = len - 1; i >= 0; i--)
+ // Content
+ out_Renamed.WriteByte((byte) octets[i]);
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1Real directly to a stream.
+ public void encode(Asn1Real r, OutputStream out)
+ throws IOException
+ {
+ throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ }
+ */
+
+ /// <summary> Encode an Asn1Null directly into the specified outputstream.</summary>
+ public void encode(Asn1Null n, System.IO.Stream out_Renamed)
+ {
+ encode(n.getIdentifier(), out_Renamed);
+ out_Renamed.WriteByte((System.Byte) 0x00); // Length (with no Content)
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1BitString directly to a stream.
+ public void encode(Asn1BitString bs, OutputStream out)
+ throws IOException
+ {
+ throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ }
+ */
+
+ /// <summary> Encode an Asn1OctetString directly into the specified outputstream.</summary>
+ public void encode(Asn1OctetString os, System.IO.Stream out_Renamed)
+ {
+ encode(os.getIdentifier(), out_Renamed);
+ encodeLength(os.byteValue().Length, out_Renamed);
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = os.byteValue();
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;
+ return ;
+ }
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1ObjectIdentifier directly to a stream.
+ * public void encode(Asn1ObjectIdentifier oi, OutputStream out)
+ * throws IOException
+ * {
+ * throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ * }
+ */
+
+ /* Asn1 TYPE NOT YET SUPPORTED
+ * Encode an Asn1CharacterString directly to a stream.
+ * public void encode(Asn1CharacterString cs, OutputStream out)
+ * throws IOException
+ * {
+ * throw new IOException("LBEREncoder: Encode to a stream not implemented");
+ * }
+ */
+
+ /* Encoders for ASN.1 structured types
+ */
+
+ /// <summary> Encode an Asn1Structured into the specified outputstream. This method
+ /// can be used to encode SET, SET_OF, SEQUENCE, SEQUENCE_OF
+ /// </summary>
+ public void encode(Asn1Structured c, System.IO.Stream out_Renamed)
+ {
+ encode(c.getIdentifier(), out_Renamed);
+
+ Asn1Object[] value_Renamed = c.toArray();
+
+ System.IO.MemoryStream output = new System.IO.MemoryStream();
+
+ /* Cycle through each element encoding each element */
+ for (int i = 0; i < value_Renamed.Length; i++)
+ {
+ (value_Renamed[i]).encode(this, output);
+ }
+
+ /* Encode the length */
+ encodeLength((int)output.Length, out_Renamed);
+
+ /* Add each encoded element into the output stream */
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = SupportClass.ToSByteArray(output.ToArray());
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;
+ return ;
+ }
+
+ /// <summary> Encode an Asn1Tagged directly into the specified outputstream.</summary>
+ public void encode(Asn1Tagged t, System.IO.Stream out_Renamed)
+ {
+ if (t.Explicit)
+ {
+ encode(t.getIdentifier(), out_Renamed);
+
+ /* determine the encoded length of the base type. */
+ System.IO.MemoryStream encodedContent = new System.IO.MemoryStream();
+ t.taggedValue().encode(this, encodedContent);
+
+ encodeLength((int)encodedContent.Length, out_Renamed);
+ sbyte[] temp_sbyteArray;
+ temp_sbyteArray = SupportClass.ToSByteArray(encodedContent.ToArray());
+ out_Renamed.Write(SupportClass.ToByteArray(temp_sbyteArray), 0, temp_sbyteArray.Length);;;;
+ }
+ else
+ {
+ t.taggedValue().encode(this, out_Renamed);
+ }
+ return ;
+ }
+
+ /* Encoders for ASN.1 useful types
+ */
+ /* Encoder for ASN.1 Identifier
+ */
+
+ /// <summary> Encode an Asn1Identifier directly into the specified outputstream.</summary>
+ public void encode(Asn1Identifier id, System.IO.Stream out_Renamed)
+ {
+ int c = id.Asn1Class;
+ int t = id.Tag;
+ sbyte ccf = (sbyte) ((c << 6) | (id.Constructed?0x20:0));
+
+ if (t < 30)
+ {
+ /* single octet */
+ out_Renamed.WriteByte((System.Byte) (ccf | t));
+ }
+ else
+ {
+ /* multiple octet */
+ out_Renamed.WriteByte((System.Byte) (ccf | 0x1F));
+ encodeTagInteger(t, out_Renamed);
+ }
+ return ;
+ }
+
+ /* Private helper methods
+ */
+
+ /*
+ * Encodes the specified length into the the outputstream
+ */
+ private void encodeLength(int length, System.IO.Stream out_Renamed)
+ {
+ if (length < 0x80)
+ {
+ out_Renamed.WriteByte((System.Byte) length);
+ }
+ else
+ {
+ sbyte[] octets = new sbyte[4]; // 4 bytes sufficient for 32 bit int.
+ sbyte n;
+ for (n = 0; length != 0; n++)
+ {
+ octets[n] = (sbyte) (length & 0xFF);
+ length >>= 8;
+ }
+
+ out_Renamed.WriteByte((System.Byte) (0x80 | n));
+
+ for (int i = n - 1; i >= 0; i--)
+ out_Renamed.WriteByte((byte) octets[i]);
+ }
+ return ;
+ }
+
+ /// <summary> Encodes the provided tag into the outputstream.</summary>
+ private void encodeTagInteger(int value_Renamed, System.IO.Stream out_Renamed)
+ {
+ sbyte[] octets = new sbyte[5];
+ int n;
+ for (n = 0; value_Renamed != 0; n++)
+ {
+ octets[n] = (sbyte) (value_Renamed & 0x7F);
+ value_Renamed = value_Renamed >> 7;
+ }
+ for (int i = n - 1; i > 0; i--)
+ {
+ out_Renamed.WriteByte((System.Byte) (octets[i] | 0x80));
+ }
+ out_Renamed.WriteByte((byte) octets[0]);
+ return ;
+ }
+ }
+}