Inheritance: Asn1Structured
Exemplo n.º 1
0
    } // end of static constructor

    public MonitorEventRequest(EdirEventSpecifier[] specifiers) :
      base(EventOids.NLDAP_MONITOR_EVENTS_REQUEST, null)
    {
      if ((specifiers == null)) 
      {
	throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
      }

      MemoryStream encodedData = new MemoryStream();
      LBEREncoder encoder = new LBEREncoder();

      Asn1Sequence asnSequence = new Asn1Sequence();
      try
      {
	asnSequence.add(new Asn1Integer(specifiers.Length));

	Asn1Set asnSet = new Asn1Set();
	bool bFiltered = false;
	for (int nIndex = 0; nIndex < specifiers.Length; nIndex++)
	{
	  Asn1Sequence specifierSequence = new Asn1Sequence();
	  specifierSequence.add(new Asn1Integer((int)(specifiers[nIndex].EventType)));
	  specifierSequence.add(new Asn1Enumerated((int)(specifiers[nIndex].EventResultType)));
	  if (0 == nIndex)
	  {
	    bFiltered = (null != specifiers[nIndex].EventFilter);
	    if (bFiltered)
	      setID(EventOids.NLDAP_FILTERED_MONITOR_EVENTS_REQUEST);
	  }
	  
	  if (bFiltered)
	  {
	    // A filter is expected
	    if (null == specifiers[nIndex].EventFilter)
	      throw new ArgumentException("Filter cannot be null,for Filter events");

	    specifierSequence.add(new Asn1OctetString(specifiers[nIndex].EventFilter));
	  }
	  else
	  {
	    // No filter is expected
	    if (null != specifiers[nIndex].EventFilter)
	      throw new ArgumentException("Filter cannot be specified for non Filter events");	 
	  }

	  asnSet.add(specifierSequence);
	}

	asnSequence.add(asnSet);
	asnSequence.encode(encoder, encodedData);
      }
      catch(Exception e)
      {
	throw new LdapException(ExceptionMessages.ENCODING_ERROR,
				LdapException.ENCODING_ERROR, 
				null);
      }

      setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
    } // end of the constructor MonitorEventRequest
Exemplo n.º 2
0
 /// <summary> A copy constructor that creates an Asn1SetOf from an instance of Asn1Set.
 /// 
 /// 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.
 /// </summary>
 public Asn1SetOf(Asn1Set set_Renamed)
     : base(ID, set_Renamed.toArray(), set_Renamed.size())
 {
     return ;
 }
Exemplo n.º 3
0
 /// <summary>
 ///     A copy constructor that creates an Asn1SetOf from an instance of Asn1Set.
 ///     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.
 /// </summary>
 public Asn1SetOf(Asn1Set set_Renamed) : base(ID, set_Renamed.toArray(), set_Renamed.size())
 {
 }
Exemplo n.º 4
0
        /**
        *
        * Constructs an extended operations object which contains the ber encoded
        * restore data.
        *
        * @param objectDN The object DN to restore
        * <br>
        * @param passwd 		The encrypted password required for the object to
        * be backed up
        * <br>
        * @param bufferLength The length of backed up data
        * <br>
        * @param chunkSizesString The String containing number of chunks and
        * each chunk elements representing chunk sizes
        * <br>
        * @param returnedBuffer The actual data in byte[]
        * <br><br>
        * @exception LdapException A general exception which includes an error
        *                          message and an LDAP error code.
        */
        public LdapRestoreRequest(String objectDN, byte[] passwd, 
            int bufferLength, String chunkSizesString, byte[] returnedBuffer)
            : base(BackupRestoreConstants.NLDAP_LDAP_RESTORE_REQUEST, null)
        {
            try
            {
                //Verify the validity of arguments
                if (objectDN == null || bufferLength == 0 ||
                    chunkSizesString == null || returnedBuffer == null)
                        throw new ArgumentException("PARAM_ERROR");

                //If encrypted password has null reference make it null String
                if(passwd == null)
                    passwd = System.Text.Encoding.UTF8.GetBytes("");

                /*
                 * From the input argument chunkSizesString get::
                 * chunkSize => Represents the number of chunks of data returned from server
                 * sizeOf each chunk => int represents the size of each chunk
                */
                int index;
                int chunkSize;
                int[] chunks = null;
                index = chunkSizesString.IndexOf(';');
                try
                {
                    chunkSize = int.Parse(chunkSizesString.Substring(0, index));
                }
                catch (FormatException e)
                {
                    throw new LdapLocalException(
                            "Invalid data buffer send in the request",
                            LdapException.ENCODING_ERROR);
                }
                //Return exception if chunkSize == 0
                if (chunkSize == 0)
                    throw new ArgumentException("PARAM_ERROR");

                chunkSizesString = chunkSizesString.Substring(index + 1);

                int chunkIndex;
                //Construct chunks array
                chunks = new int[chunkSize];
                /*
                * Iterate through each member in buffer and
                * assign to chunks array elements
                */
                for (int i = 0; i < chunkSize; i++)
                {
                    chunkIndex = chunkSizesString.IndexOf(';');
                    if(chunkIndex == -1)
                    {
                        chunks[i] = int.Parse(chunkSizesString);
                        break;
                    }
                    chunks[i] = int.Parse(chunkSizesString.Substring(0,
                                                            chunkIndex));
                    chunkSizesString = chunkSizesString.Substring(chunkIndex + 1);
                }

                MemoryStream encodedData = new MemoryStream();
                LBEREncoder encoder = new LBEREncoder();

                //Form objectDN, passwd, bufferLength, data byte[] as ASN1 Objects
                Asn1OctetString asn1_objectDN = new Asn1OctetString(objectDN);
                Asn1OctetString asn1_passwd = new Asn1OctetString(SupportClass.ToSByteArray(passwd));
                Asn1Integer asn1_bufferLength = new Asn1Integer(bufferLength);
                Asn1OctetString asn1_buffer = new Asn1OctetString(SupportClass.ToSByteArray(returnedBuffer));

                //Form the chunks sequence to be passed to Server
                Asn1Sequence asn1_chunksSeq = new Asn1Sequence();
                asn1_chunksSeq.add(new Asn1Integer(chunkSize));
                Asn1Set asn1_chunksSet = new Asn1Set();
                for (int i = 0; i < chunkSize; i++)
                {
                    Asn1Integer tmpChunk = new Asn1Integer(chunks[i]);
                    Asn1Sequence tmpSeq = new Asn1Sequence();
                    tmpSeq.add(tmpChunk);
                    asn1_chunksSet.add(tmpSeq);
                }
                asn1_chunksSeq.add(asn1_chunksSet);

                //Encode data to send to server
                asn1_objectDN.encode(encoder, encodedData);
                asn1_passwd.encode(encoder, encodedData);
                asn1_bufferLength.encode(encoder, encodedData);
                asn1_buffer.encode(encoder, encodedData);
                asn1_chunksSeq.encode(encoder, encodedData);

                // set the value of operation specific data
                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));

            }
            catch (IOException ioe)
            {
                throw new LdapException("ENCODING_ERROR", LdapException.ENCODING_ERROR, (String) null);
            }
        }
 /// <summary>
 ///     A copy constructor that creates an Asn1SetOf from an instance of Asn1Set.
 ///     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.
 /// </summary>
 public Asn1SetOf(Asn1Set setRenamed)
     : base(Id, setRenamed.ToArray(), setRenamed.Size())
 {
 }