コード例 #1
0
        /// <summary> Constructs an object from the responseValue which contains the list
        /// of replicas.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///   replicaList
        /// SEQUENCE OF OCTET STRINGS
        ///
        /// </summary>
        /// <exception> IOException  The responseValue could not be decoded.
        /// </exception>
        public ListReplicasResponse(RfcLdapMessage rfcMessage)
            : base(rfcMessage)
        {
            if (ResultCode != LdapException.SUCCESS)
            {
                replicaList = new string[0];
            }
            else
            {
                // 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");
                }

                // We should get back a sequence
                Asn1Sequence returnedSequence = (Asn1Sequence)decoder.decode(returnedValue);
                if (returnedSequence == null)
                {
                    throw new IOException("Decoding error");
                }

                // How many replicas were returned
                int len = returnedSequence.size();
                replicaList = new string[len];

                // Copy each one into our String array
                for (int i = 0; i < len; i++)
                {
                    // Get the next Asn1Octet String in the sequence
                    Asn1OctetString asn1_nextReplica = (Asn1OctetString)returnedSequence.get_Renamed(i);
                    if (asn1_nextReplica == null)
                    {
                        throw new IOException("Decoding error");
                    }

                    // Convert to a string
                    replicaList[i] = asn1_nextReplica.stringValue();
                    if (replicaList[i] == null)
                    {
                        throw new IOException("Decoding error");
                    }
                }
            }
        }
コード例 #2
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 = "";
            }
        }
コード例 #3
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;
            }
        }
        /// <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");
                        }
                    }
                }
            }
        }