コード例 #1
0
        protected Asn1Sequence getTaggedSequence(Asn1Tagged tagvalue, GeneralEventField tagid)
        {
            Asn1Object obj = tagvalue.taggedValue();

            if ((int)tagid != tagvalue.getIdentifier().Tag)
            {
                throw new IOException("Unknown Tagged Data");
            }

            byte[]       dbytes = SupportClass.ToByteArray(((Asn1OctetString)obj).byteValue());
            MemoryStream data   = new MemoryStream(dbytes);

            LBERDecoder dec    = new LBERDecoder();
            int         length = dbytes.Length;

            return(new Asn1Sequence(dec, data, length));
        }
コード例 #2
0
        protected string getTaggedStringValue(Asn1Tagged tagvalue, GeneralEventField tagid)
        {
            var obj = tagvalue.taggedValue();

            if ((int)tagid != tagvalue.getIdentifier().Tag)
            {
                throw new IOException("Unknown Tagged Data");
            }

            var dbytes = SupportClass.ToByteArray(((Asn1OctetString)obj).byteValue());
            var data   = new MemoryStream(dbytes);

            var dec = new LBERDecoder();

            var length = dbytes.Length;

            return((string)dec.decodeCharacterString(data, length));
        }
コード例 #3
0
        /// <summary> Constructs an object from the responseValue which contains the bind dn.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        /// identity   OCTET STRING
        ///
        /// </summary>
        /// <exception> IOException The return value could not be decoded.
        /// </exception>
        public GetBindDNResponse(RfcLdapMessage rfcMessage)
            : base(rfcMessage)
        {
            if (ResultCode == LdapException.SUCCESS)
            {
                // parse the contents of the reply
                sbyte[] returnedValue = this.Value;
                if (returnedValue == null)
                {
                    throw new IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new IOException("Decoding error");
                }

                // The only parameter returned should be an octet string
                Asn1OctetString asn1_identity = (Asn1OctetString)decoder.decode(returnedValue);
                if (asn1_identity == null)
                {
                    throw new IOException("Decoding error");
                }

                // Convert to normal string object
                identity = asn1_identity.stringValue();
                if (identity == null)
                {
                    throw new IOException("Decoding error");
                }
            }
            else
            {
                identity = "";
            }
        }
コード例 #4
0
        public LdapSortResponse(System.String oid, bool critical, sbyte[] values) : base(oid, critical, values)
        {
            // Create a decoder object
            LBERDecoder decoder = new LBERDecoder();

            if (decoder == null)
            {
                throw new System.IO.IOException("Decoding error");
            }

            // We should get back an enumerated type
            Asn1Object asnObj = decoder.decode(values);

            if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
            {
                throw new System.IO.IOException("Decoding error");
            }


            Asn1Object asn1Enum = ((Asn1Sequence)asnObj).get_Renamed(0);

            if ((asn1Enum != null) && (asn1Enum is Asn1Enumerated))
            {
                resultCode = ((Asn1Enumerated)asn1Enum).intValue();
            }

            // Second element is the attributeType
            if (((Asn1Sequence)asnObj).size() > 1)
            {
                Asn1Object asn1String = ((Asn1Sequence)asnObj).get_Renamed(1);
                if ((asn1String != null) && (asn1String is Asn1OctetString))
                {
                    failedAttribute = ((Asn1OctetString)asn1String).stringValue();
                }
            }
            return;
        }
コード例 #5
0
ファイル: LdapEntryChangeControl.cs プロジェクト: cmsd2/oidc
        public LdapEntryChangeControl(String oid, bool critical, sbyte[] value_Renamed) : base(oid, critical, value_Renamed)
        {
            // Create a decoder objet
            LBERDecoder decoder = new LBERDecoder();

            if (decoder == null)
            {
                throw new System.IO.IOException("Decoding error.");
            }

            // We should get a sequence initially
            Asn1Object asnObj = decoder.decode(value_Renamed);

            if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
            {
                throw new System.IO.IOException("Decoding error.");
            }

            Asn1Sequence sequence = (Asn1Sequence)asnObj;


            // The first element in the sequence should be an enumerated type
            Asn1Object asn1Obj = sequence.get_Renamed(0);

            if ((asn1Obj == null) || (!(asn1Obj is Asn1Enumerated)))
            {
                throw new System.IO.IOException("Decoding error.");
            }

            m_changeType = ((Asn1Enumerated)asn1Obj).intValue();

            //check for optional elements
            if ((sequence.size() > 1) && (m_changeType == 8))
            //8 means modifyDN
            {
                // get the previous DN - it is encoded as an octet string
                asn1Obj = sequence.get_Renamed(1);
                if ((asn1Obj == null) || (!(asn1Obj is Asn1OctetString)))
                {
                    throw new System.IO.IOException("Decoding error get previous DN");
                }

                m_previousDN = ((Asn1OctetString)asn1Obj).stringValue();
            }
            else
            {
                m_previousDN = "";
            }

            //check for change number
            if (sequence.size() == 3)
            {
                asn1Obj = sequence.get_Renamed(2);
                if ((asn1Obj == null) || (!(asn1Obj is Asn1Integer)))
                {
                    throw new System.IO.IOException("Decoding error getting change number");
                }

                m_changeNumber    = ((Asn1Integer)asn1Obj).intValue();
                m_hasChangeNumber = true;
            }
            else
            {
                m_hasChangeNumber = false;
            }
            return;
        }
コード例 #6
0
ファイル: GetReplicaInfoResponse.cs プロジェクト: cmsd2/oidc
        /// <summary> Constructs an object from the responseValue which contains the
        /// replica information.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///  partitionID         INTEGER
        ///  replicaState        INTEGER
        ///  modificationTime    INTEGER
        ///  purgeTime           INTEGER
        ///  localPartitionID    INTEGER
        ///  partitionDN       OCTET STRING
        ///  replicaType         INTEGER
        ///  flags               INTEGER
        ///
        /// </summary>
        /// <exception> IOException The response value could not be decoded.
        /// </exception>
        public GetReplicaInfoResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            if (ResultCode == LdapException.SUCCESS)
            {
                // parse the contents of the reply
                sbyte[] returnedValue = Value;
                if (returnedValue == null)
                {
                    throw new System.IO.IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                // Parse the parameters in the order

                System.IO.MemoryStream currentPtr = new System.IO.MemoryStream(SupportClass.ToByteArray(returnedValue));

                // Parse partitionID
                Asn1Integer asn1_partitionID = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_partitionID == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                partitionID = asn1_partitionID.intValue();


                // Parse replicaState
                Asn1Integer asn1_replicaState = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_replicaState == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                replicaState = asn1_replicaState.intValue();

                // Parse modificationTime
                Asn1Integer asn1_modificationTime = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_modificationTime == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                modificationTime = asn1_modificationTime.intValue();

                // Parse purgeTime
                Asn1Integer asn1_purgeTime = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_purgeTime == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                purgeTime = asn1_purgeTime.intValue();

                // Parse localPartitionID
                Asn1Integer asn1_localPartitionID = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_localPartitionID == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                localPartitionID = asn1_localPartitionID.intValue();

                // Parse partitionDN
                Asn1OctetString asn1_partitionDN = (Asn1OctetString)decoder.decode(currentPtr);
                if (asn1_partitionDN == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                partitionDN = asn1_partitionDN.stringValue();
                if ((object)partitionDN == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }


                // Parse replicaType
                Asn1Integer asn1_replicaType = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_replicaType == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                replicaType = asn1_replicaType.intValue();


                // Parse flags
                Asn1Integer asn1_flags = (Asn1Integer)decoder.decode(currentPtr);
                if (asn1_flags == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                flags = asn1_flags.intValue();
            }
            else
            {
                partitionID      = 0;
                replicaState     = 0;
                modificationTime = 0;
                purgeTime        = 0;
                localPartitionID = 0;
                partitionDN      = "";
                replicaType      = 0;
                flags            = 0;
            }
        }
コード例 #7
0
ファイル: LdapBackupResponse.cs プロジェクト: cmsd2/oidc
        /**
         * Constructs an object from the responseValue which contains the backup data.
         *  <p>The constructor parses the responseValue which has the following
         *  format:<br>
         *  responseValue ::=<br>
         *  <p>databufferLength ::= INTEGER <br>
         *  mts(modification time stamp) ::= INTEGER<br>
         *  revision ::= INTEGER<br>
         *  returnedBuffer ::= OCTET STRING<br>
         *  dataChunkSizes ::= <br>
         *  SEQUENCE{<br>
         *  noOfChunks INTEGER<br>
         *  SET of [<br>
         *  SEQUENCE of {eachChunksize INTEGER}]<br>
         *  }</p>
         *
         * @exception IOException The responseValue could not be decoded.
         */

        public LdapBackupResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            int modificationTime = 0;     // Modifaction timestamp of the Object
            int revision         = 0;     // Revision number of the Object
            int chunksSize       = 0;

            int[] chunks = null;             //Holds size of each chunks returned from server

            //Verify if returned ID is not proper
            if (ID == null || !(ID.Equals(BackupRestoreConstants.NLDAP_LDAP_BACKUP_RESPONSE)))
            {
                throw new IOException("LDAP Extended Operation not supported");
            }

            if (ResultCode == LdapException.SUCCESS)
            {
                // Get the contents of the reply

                byte[] returnedValue = SupportClass.ToByteArray(Value);
                if (returnedValue == null)
                {
                    throw new Exception("LDAP Operations error. No returned value.");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();

                if (decoder == null)
                {
                    throw new Exception("Decoding error");
                }

                // Parse the parameters in the order
                MemoryStream currentPtr = new MemoryStream(returnedValue);

                // Parse bufferLength
                Asn1Integer asn1_bufferLength = (Asn1Integer)decoder
                                                .decode(currentPtr);
                if (asn1_bufferLength == null)
                {
                    throw new IOException("Decoding error");
                }
                bufferLength = asn1_bufferLength.intValue();

                // Parse modificationTime
                Asn1Integer asn1_modificationTime = (Asn1Integer)decoder
                                                    .decode(currentPtr);
                if (asn1_modificationTime == null)
                {
                    throw new IOException("Decoding error");
                }
                modificationTime = asn1_modificationTime.intValue();

                // Parse revision
                Asn1Integer asn1_revision = (Asn1Integer)decoder
                                            .decode(currentPtr);
                if (asn1_revision == null)
                {
                    throw new IOException("Decoding error");
                }
                revision = asn1_revision.intValue();

                //Format stateInfo to contain both modificationTime and revision
                stateInfo = modificationTime + "+" + revision;

                // Parse returnedBuffer
                Asn1OctetString asn1_returnedBuffer = (Asn1OctetString)decoder.decode(currentPtr);
                if (asn1_returnedBuffer == null)
                {
                    throw new IOException("Decoding error");
                }

                returnedBuffer = SupportClass.ToByteArray(asn1_returnedBuffer.byteValue());


                /*
                 * Parse chunks array
                 * Chunks returned from server is encoded as shown below::
                 * SEQUENCE{
                 *          chunksSize	INTEGER
                 *          SET of [
                 *              SEQUENCE of {eacChunksize        INTEGER}]
                 *         }
                 */

                Asn1Sequence asn1_chunksSeq = (Asn1Sequence)decoder
                                              .decode(currentPtr);
                if (asn1_chunksSeq == null)
                {
                    throw new IOException("Decoding error");
                }

                //Get number of chunks returned from server
                chunksSize = ((Asn1Integer)asn1_chunksSeq.get_Renamed(0)).intValue();

                //Construct chunks array
                chunks = new int[chunksSize];

                Asn1Set asn1_chunksSet = (Asn1Set)asn1_chunksSeq.get_Renamed(1);
                //Iterate through asn1_chunksSet and put each size into chunks array

                for (int index = 0; index < chunksSize; index++)
                {
                    Asn1Sequence asn1_eachSeq = (Asn1Sequence)asn1_chunksSet.get_Renamed(index);
                    chunks[index] = ((Asn1Integer)asn1_eachSeq.get_Renamed(0)).intValue();
                }

                //Construct a temporary StringBuffer and append chunksSize, each size
                //element in chunks array and actual data of eDirectoty Object
                System.Text.StringBuilder tempBuffer = new System.Text.StringBuilder();
                tempBuffer.Append(chunksSize);
                tempBuffer.Append(";");
                int i = 0;

                for (; i < (chunksSize - 1); i++)
                {
                    tempBuffer.Append(chunks[i]);
                    tempBuffer.Append(";");
                }

                tempBuffer.Append(chunks[i]);

                //Assign tempBuffer to parsedString to be returned to Application
                chunkSizesString = tempBuffer.ToString();
            }
            else
            {
                //Intialize all these if getResultCode() != LdapException.SUCCESS
                bufferLength     = 0;
                stateInfo        = null;
                chunkSizesString = null;
                returnedBuffer   = null;
            }
        }
コード例 #8
0
        protected void ProcessMessage(sbyte[] returnedValue)
        {
            LBERDecoder  decoder  = new LBERDecoder();
            Asn1Sequence sequence = (Asn1Sequence)decoder.decode(returnedValue);

            event_type        = (EdirEventType)(((Asn1Integer)sequence.get_Renamed(0)).intValue());
            event_result_type = (EdirEventResultType)(((Asn1Integer)sequence.get_Renamed(1)).intValue());

            if (sequence.size() > 2)
            {
                Asn1Tagged objTagged = (Asn1Tagged)sequence.get_Renamed(2);

                switch ((EdirEventDataType)(objTagged.getIdentifier().Tag))
                {
                case EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA:
                    event_response_data = new EntryEventData(EdirEventDataType.EDIR_TAG_ENTRY_EVENT_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA:
                    event_response_data = new ValueEventData(EdirEventDataType.EDIR_TAG_VALUE_EVENT_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA:
                    event_response_data = new DebugEventData(EdirEventDataType.EDIR_TAG_DEBUG_EVENT_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA:
                    event_response_data = new GeneralDSEventData(EdirEventDataType.EDIR_TAG_GENERAL_EVENT_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_SKULK_DATA:
                    event_response_data = null;
                    break;

                case EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA:
                    event_response_data = new BinderyObjectEventData(EdirEventDataType.EDIR_TAG_BINDERY_EVENT_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_DSESEV_INFO:
                    event_response_data = new SecurityEquivalenceEventData(EdirEventDataType.EDIR_TAG_DSESEV_INFO, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA:
                    event_response_data = new ModuleStateEventData(EdirEventDataType.EDIR_TAG_MODULE_STATE_DATA, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS:
                    event_response_data = new NetworkAddressEventData(EdirEventDataType.EDIR_TAG_NETWORK_ADDRESS, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_CONNECTION_STATE:
                    event_response_data = new ConnectionStateEventData(EdirEventDataType.EDIR_TAG_CONNECTION_STATE, objTagged.taggedValue());
                    break;

                case EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS:
                    event_response_data = new ChangeAddressEventData(EdirEventDataType.EDIR_TAG_CHANGE_SERVER_ADDRESS, objTagged.taggedValue());
                    break;

                /*
                 *    case EdirEventDataType.EDIR_TAG_CHANGE_CONFIG_PARAM :
                 *        responsedata =
                 *            new ChangeConfigEventData(
                 *                taggedobject.taggedValue());
                 *
                 *        break;
                 *
                 *    case EdirEventDataType.EDIR_TAG_STATUS_LOG :
                 *        responsedata =
                 *            new StatusLogEventData(taggedobject.taggedValue());
                 *
                 *        break;
                 */
                case EdirEventDataType.EDIR_TAG_NO_DATA:
                    event_response_data = null;
                    break;

                default:
                    //unhandled data.
                    throw new IOException();
                }
            }
            else
            {
                //NO DATA
                event_response_data = null;
            }
        }
        /// <summary> Constructs an object from the responseValue which contains the replication
        /// filter.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///  SEQUENCE of SEQUENCE {
        ///  classname  OCTET STRING
        ///  SEQUENCE of ATTRIBUTES
        /// }
        /// where
        /// ATTRIBUTES:: OCTET STRING
        ///
        /// </summary>
        /// <exception> IOException The responseValue could not be decoded.
        /// </exception>
        public GetReplicationFilterResponse(RfcLdapMessage rfcMessage) : base(rfcMessage)
        {
            if (ResultCode != LdapException.SUCCESS)
            {
                returnedFilter = new System.String[0][];
                for (int i = 0; i < 0; i++)
                {
                    returnedFilter[i] = new System.String[0];
                }
            }
            else
            {
                // parse the contents of the reply
                sbyte[] returnedValue = this.Value;
                if (returnedValue == null)
                {
                    throw new System.IO.IOException("No returned value");
                }

                // Create a decoder object
                LBERDecoder decoder = new LBERDecoder();
                if (decoder == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                // We should get back a sequence
                Asn1Sequence returnedSequence = (Asn1Sequence)decoder.decode(returnedValue);

                if (returnedSequence == null)
                {
                    throw new System.IO.IOException("Decoding error");
                }

                // How many sequences in this list
                int numberOfSequences = returnedSequence.size();
                returnedFilter = new System.String[numberOfSequences][];

                // Parse each returned sequence object
                for (int classNumber = 0; classNumber < numberOfSequences; classNumber++)
                {
                    // Get the next Asn1Sequence
                    Asn1Sequence asn1_innerSequence = (Asn1Sequence)returnedSequence.get_Renamed(classNumber);
                    if (asn1_innerSequence == null)
                    {
                        throw new System.IO.IOException("Decoding error");
                    }

                    // Get the asn1 encoded classname
                    Asn1OctetString asn1_className = (Asn1OctetString)asn1_innerSequence.get_Renamed(0);
                    if (asn1_className == null)
                    {
                        return;
                    }

                    // Get the attribute List
                    Asn1Sequence asn1_attributeList = (Asn1Sequence)asn1_innerSequence.get_Renamed(1);
                    if (asn1_attributeList == null)
                    {
                        throw new System.IO.IOException("Decoding error");
                    }

                    int numberOfAttributes = asn1_attributeList.size();
                    returnedFilter[classNumber] = new System.String[numberOfAttributes + 1];

                    // Get the classname
                    returnedFilter[classNumber][0] = asn1_className.stringValue();
                    if ((System.Object)returnedFilter[classNumber][0] == null)
                    {
                        throw new System.IO.IOException("Decoding error");
                    }

                    for (int attributeNumber = 0; attributeNumber < numberOfAttributes; attributeNumber++)
                    {
                        // Get the asn1 encoded attribute name
                        Asn1OctetString asn1_attributeName = (Asn1OctetString)asn1_attributeList.get_Renamed(attributeNumber);
                        if (asn1_attributeName == null)
                        {
                            throw new System.IO.IOException("Decoding error");
                        }

                        // Get attributename string
                        returnedFilter[classNumber][attributeNumber + 1] = asn1_attributeName.stringValue();
                        if ((System.Object)returnedFilter[classNumber][attributeNumber + 1] == null)
                        {
                            throw new System.IO.IOException("Decoding error");
                        }
                    }
                }
            }
        }
コード例 #10
0
        public LdapVirtualListResponse(System.String oid, bool critical, sbyte[] values) : base(oid, critical, values)
        {
            /* Create a decoder object */
            LBERDecoder decoder = new LBERDecoder();

            if (decoder == null)
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* We should get back an ASN.1 Sequence object */
            Asn1Object asnObj = decoder.decode(values);

            if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* Else we got back a ASN.1 sequence - print it if running debug code */

            /* Get the 1st element which should be an integer containing the
             * targetPosition (firstPosition)
             */
            Asn1Object asn1firstPosition = ((Asn1Sequence)asnObj).get_Renamed(0);

            if ((asn1firstPosition != null) && (asn1firstPosition is Asn1Integer))
            {
                m_firstPosition = ((Asn1Integer)asn1firstPosition).intValue();
            }
            else
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* Get the 2nd element which should be an integer containing the
             * current estimate of the contentCount
             */
            Asn1Object asn1ContentCount = ((Asn1Sequence)asnObj).get_Renamed(1);

            if ((asn1ContentCount != null) && (asn1ContentCount is Asn1Integer))
            {
                m_ContentCount = ((Asn1Integer)asn1ContentCount).intValue();
            }
            else
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* The 3rd element is an enum containing the errorcode */
            Asn1Object asn1Enum = ((Asn1Sequence)asnObj).get_Renamed(2);

            if ((asn1Enum != null) && (asn1Enum is Asn1Enumerated))
            {
                m_resultCode = ((Asn1Enumerated)asn1Enum).intValue();
            }
            else
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* Optional 4th element could be the context string that the server
             * wants the client to send back with each subsequent VLV request
             */
            if (((Asn1Sequence)asnObj).size() > 3)
            {
                Asn1Object asn1String = ((Asn1Sequence)asnObj).get_Renamed(3);
                if ((asn1String != null) && (asn1String is Asn1OctetString))
                {
                    m_context = ((Asn1OctetString)asn1String).stringValue();
                }
            }
            return;
        }
コード例 #11
0
        public LdapPagedResultsResponse(string oid, bool critical, sbyte[] values)
            : base(oid, critical, values)
        {
            /* Create a decoder object */
            var decoder = new LBERDecoder();

            if (decoder == null)
            {
                throw new System.IO.IOException("Decoding error");
            }

            /* We should get back an ASN.1 Sequence object */
            var asnObj = decoder.decode(values);

            if ((asnObj == null) || (!(asnObj is Asn1Sequence)))
            {
                throw new System.IO.IOException("Decoding error");
            }

            /*
             * Get the 1st element which should be an integer containing the
             * size (RFC 2696).
             */
            var asn1Size = ((Asn1Sequence)asnObj).get_Renamed(0);

            if ((asn1Size != null) && (asn1Size is Asn1Integer))
            {
                m_size = ((Asn1Integer)asn1Size).intValue();
            }
            else
            {
                throw new System.IO.IOException("Decoding error");
            }

            /*
             * Get the 2nd element which should be an octet string containing the
             * cookie (RFC 2696).
             */
            var asn1Cookie = ((Asn1Sequence)asnObj).get_Renamed(1);

            if ((asn1Cookie != null) && (asn1Cookie is Asn1OctetString))
            {
                var t = ((Asn1OctetString)asn1Cookie).byteValue();

                /*byte[] bytes = Array.ConvertAll(t, b => unchecked((byte)b));
                 *
                 * var s = "";
                 * foreach (byte b in bytes)
                 *  s += (char)b;*/

                //var utf8bytes = Encoding.UTF8.GetBytes(t);

                /*var encoder = Encoding.GetEncoding("utf-8");
                 * var dchar = encoder.GetChars(SupportClass.ToByteArray(t));
                 * s = new string(dchar);*/

                m_cookie = t;
            }
            else
            {
                throw new System.IO.IOException("Decoding error");
            }
        }