Exemplo n.º 1
0
        public sbyte[] getValue()
        {
            Asn1OctetString tempString =
                ((RfcIntermediateResponse)message.Response).getResponse();

            if (tempString == null)
            {
                return(null);
            }
            return(tempString.byteValue());
        }
Exemplo n.º 2
0
        public virtual sbyte[] getValue()
        {
            sbyte[]         result = null;
            Asn1OctetString val    = control.ControlValue;

            if (val != null)
            {
                result = val.byteValue();
            }
            return(result);
        }
Exemplo n.º 3
0
        /**
         * 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;
            }
        }