/// <summary>
 /// Decodes the object by PER.
 /// </summary>
 /// <param name="buffer">A buffer that contains a PER encoding result.</param>
 /// <param name="aligned">Indicating whether the PER decoding is aligned.</param>
 /// <remarks>Length is included.</remarks>
 protected override void ValuePerDecode(IAsn1DecodingBuffer buffer, bool aligned = true)
 {
     ByteArrayValue = Asn1StandardProcedure.PerDecodeArray<byte>(buffer,
         decodingBuffer =>
         {
             Asn1Integer ai = new Asn1Integer(null, 0, 15);
             ai.PerDecode(buffer);
             if (Constraint == null || Constraint.PermittedCharSet == null)
             {
                 if (ai.Value == 0)
                 {
                     return (byte)' ';
                 }
                 else if (ai.Value >= 1 && ai.Value <= 10)
                 {
                     return (byte)((byte)'0' + ai.Value - 1);
                 }
                 else
                 {
                     throw new Asn1DecodingUnexpectedData(ExceptionMessages.DecodingUnexpectedData +
                                                          "Only 0~9 and SPACE are allowed in NumericString.");
                 }
             }
             else
             {
                 int index = (int)ai.Value;
                 return (byte)CharSetInArray[(int)ai.Value];
             }
         },
     Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null,
     true);
 }
Exemple #2
0
        /// <summary>
        /// Constructs a new extended operation object for changing a replica's type.
        ///
        /// </summary>
        /// <param name="dn">         The distinguished name of the replica's
        /// partition root.
        ///
        /// </param>
        /// <param name="serverDN">   The server on which the replica resides.
        ///
        ///
        /// </param>
        /// <param name="replicaType">   The new replica type. The replica types are defined
        /// in the ReplicationConstants class.
        ///
        /// </param>
        /// <param name="flags">  Specifies whether all servers in the replica ring must be up
        /// before proceeding. When set to zero, the status of the servers is
        /// not checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be
        /// up for the operation to proceed.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        ///
        /// </exception>
        /// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
        /// </seealso>
        public ChangeReplicaTypeRequest(string dn, string serverDN, int replicaType, int flags)
            : base(ReplicationConstants.CHANGE_REPLICA_TYPE_REQ, null)
        {
            try
            {
                if (dn == null || serverDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                Asn1Integer     asn1_flags       = new Asn1Integer(flags);
                Asn1Integer     asn1_replicaType = new Asn1Integer(replicaType);
                Asn1OctetString asn1_serverDN    = new Asn1OctetString(serverDN);
                Asn1OctetString asn1_dn          = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_replicaType.encode(encoder, encodedData);
                asn1_serverDN.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null);
            }
        }
Exemple #3
0
        public void WriteTest()
        {
            var node = new Asn1Integer(0);
            var data = node.GetBytes();

            Equal(_etalon, data);
        }
Exemple #4
0
        // *************************************************************************
        // Constructors for BindRequest
        // *************************************************************************

        /// <summary> </summary>
        public RfcBindRequest(Asn1Integer version, RfcLdapDn name, RfcAuthenticationChoice auth)
            : base(3)
        {
            Add(version);
            Add(name);
            Add(auth);
        }
Exemple #5
0
        private string GetSigningSerialNumber()
        {
            Asn1Node    asn1 = _contentInfo.Content;
            Asn1Integer x    = (Asn1Integer)asn1.Nodes[0].Nodes[4].Nodes[0].Nodes[1].Nodes[1]; // ASN.1 Path to signer serial number: /1/0/4/0/1/1

            return(x.Value.ToHexString().Substring(2).ToUpper());
        }
Exemple #6
0
 public ExpectedEntryCountRequestValue(
     Asn1Integer searchEntriesMin,
     Asn1Integer searchEntriesMax)
 {
     this.searchEntriesMin = searchEntriesMin;
     this.searchEntriesMax = searchEntriesMax;
 }
        /// <summary>
        ///     Constructs an extended operation object for synchronizing the replicas
        ///     of a partition.
        /// </summary>
        /// <param name="serverName">
        ///     The distinquished name of server containing the
        ///     naming context.
        /// </param>
        /// <param name="partitionRoot">
        ///     The distinguished name of the naming context
        ///     to synchronize.
        /// </param>
        /// <param name="delay">
        ///     The time, in seconds, to delay before the synchronization
        ///     should start.
        /// </param>
        /// <exception>
        ///     LdapException A general exception which includes an error message
        ///     and an Ldap error code.
        /// </exception>
        public PartitionSyncRequest(string serverName, string partitionRoot, int delay)
            : base(ReplicationConstants.NAMING_CONTEXT_SYNC_REQ, null)
        {
            try
            {
                if ((object)serverName == null || (object)partitionRoot == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_serverName    = new Asn1OctetString(serverName);
                var asn1_partitionRoot = new Asn1OctetString(partitionRoot);
                var asn1_delay         = new Asn1Integer(delay);

                asn1_serverName.encode(encoder, encodedData);
                asn1_partitionRoot.encode(encoder, encodedData);
                asn1_delay.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
        /// <summary>
        /// Decodes the object by BER.
        /// </summary>
        /// <param name="buffer">A buffer that contains a BER encoding result.</param>
        /// <param name="explicitTag">Indicates whether the tags should be encoded explicitly. In our Test Suites, it will always be true.</param>
        /// <returns>The number of the bytes consumed in the buffer to decode this object.</returns>
        /// <exception cref="Asn1ConstraintsNotSatisfied">
        /// Thrown when the constraints are not satisfied after decoding.
        /// </exception>
        /// <exception cref="Asn1DecodingUnexpectedData">
        /// Thrown when the data in the buffer can not be properly decoded.
        /// </exception>
        /// <remarks>Override this method in a user-defined class only if the procedure is not applicable in some special scenarios.</remarks>
        public override int BerDecode(IAsn1DecodingBuffer buffer, bool explicitTag = true)
        {
            int     headLen = 0;
            Asn1Tag seqTag;

            headLen += TagBerDecode(buffer, out seqTag);
            int valueLen;

            headLen += LengthBerDecode(buffer, out valueLen);

            // Decode Request Name
            int valueLenDecode = 0;

            Asn1Tag nameTag;

            valueLenDecode += TagBerDecode(buffer, out nameTag);
            this.entryName  = new LDAPDN();
            valueLenDecode += this.entryName.BerDecodeWithoutUnisersalTag(buffer);

            // Decode Request Value
            Asn1Tag valueTag;

            valueLenDecode += TagBerDecode(buffer, out valueTag);
            this.requestTtl = new Asn1Integer();
            valueLenDecode += this.requestTtl.BerDecodeWithoutUnisersalTag(buffer);

            if (!VerifyConstraints())
            {
                throw new Asn1ConstraintsNotSatisfied(ExceptionMessages.ConstraintsNotSatisfied
                                                      + " Decode " + this.GetType().Name + ".");
            }

            return(headLen + valueLen);
        }
 /// <summary>
 /// This constructor allows primitive data to be passed for all
 /// primitive elements.  It will create new object wrappers for
 /// the primitive data and set other elements to references to
 /// the given objects
 /// </summary>
 public DirsyncExRep(long moreResults_, long unused_, byte[] cookieServer_)
     : base()
 {
     moreResults  = new Asn1Integer(moreResults_);
     unused       = new Asn1Integer(unused_);
     cookieServer = new Asn1OctetString(cookieServer_);
 }
Exemple #10
0
 public KERB_ERROR_DATA(
     Asn1Integer param0,
     Asn1OctetString param1)
 {
     this.data_type  = param0;
     this.data_value = param1;
 }
Exemple #11
0
 public StatsResponseValueV2(
     Asn1Integer threadCountTag,
     Asn1Integer threadCount,
     Asn1Integer callTimeTag,
     Asn1Integer callTime,
     Asn1Integer entriesReturnedTag,
     Asn1Integer entriesReturned,
     Asn1Integer entriesVisitedTag,
     Asn1Integer entriesVisited,
     Asn1Integer filterTag,
     Asn1OctetString filter,
     Asn1Integer indexTag,
     Asn1OctetString index)
 {
     this.threadCountTag     = threadCountTag;
     this.threadCount        = threadCount;
     this.callTimeTag        = callTimeTag;
     this.callTime           = callTime;
     this.entriesReturnedTag = entriesReturnedTag;
     this.entriesReturned    = entriesReturned;
     this.entriesVisitedTag  = entriesVisitedTag;
     this.entriesVisited     = entriesVisited;
     this.filterTag          = filterTag;
     this.filter             = filter;
     this.indexTag           = indexTag;
     this.index = index;
 }
Exemple #12
0
        /// <summary> Constructs an extended operation object for aborting a partition operation.
        ///
        /// </summary>
        /// <param name="partitionDN">The distinguished name of the replica's
        /// partition root.
        ///
        /// </param>
        /// <param name="flags">Determines whether all servers in the replica ring must
        /// be up before proceeding. When set to zero, the status of the
        /// servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
        /// all servers must be up for the operation to proceed.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        /// </exception>
        public AbortPartitionOperationRequest(String partitionDN, int flags) : base(ReplicationConstants.ABORT_NAMING_CONTEXT_OP_REQ, null)
        {
            try
            {
                if ((object)partitionDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder            encoder     = new LBEREncoder();


                Asn1Integer     asn1_flags       = new Asn1Integer(flags);
                Asn1OctetString asn1_partitionDN = new Asn1OctetString(partitionDN);

                asn1_flags.encode(encoder, encodedData);
                asn1_partitionDN.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (String)null);
            }
        }
 public StatsResponseValueV3()
 {
     this.threadCountTag     = null;
     this.threadCount        = null;
     this.callTimeTag        = null;
     this.callTime           = null;
     this.entriesReturnedTag = null;
     this.entriesReturned    = null;
     this.entriesVisitedTag  = null;
     this.entriesVisited     = null;
     this.filterTag          = null;
     this.filter             = null;
     this.indexTag           = null;
     this.index = null;
     this.pagesReferencedTag = null;
     this.pagesReferenced    = null;
     this.pagesReadTag       = null;
     this.pagesRead          = null;
     this.pagesPrereadTag    = null;
     this.pagesPreread       = null;
     this.pagesDirtiedTag    = null;
     this.pagesDirtied       = null;
     this.pagesRedirtiedTag  = null;
     this.pagesRedirtied     = null;
     this.logRecordCountTag  = null;
     this.logRecordCount     = null;
     this.logRecordBytesTag  = null;
     this.logRecordBytes     = null;
 }
 public ErectDomainRequest(
     Asn1Integer subHeight,
     Asn1Integer subInterval)
 {
     this.subHeight   = subHeight;
     this.subInterval = subInterval;
 }
        /// <summary>
        /// Constructs a new extended operation object for adding a replica to the
        /// specified server.
        ///
        /// </summary>
        /// <param name="dn">The distinguished name of the replica's partition root.
        ///
        /// </param>
        /// <param name="serverDN">The server on which the new replica will be added.
        ///
        /// </param>
        /// <param name="replicaType">The type of replica to add. The replica
        /// types are defined in the ReplicationConstants class.
        ///
        /// </param>
        /// <param name="flags">Specifies whether all servers in the replica ring must be up
        /// before proceeding. When set to zero, the status of the servers is not
        /// checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up for the
        /// operation to proceed.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        ///
        /// </exception>
        /// <seealso cref="ReplicationConstants.Ldap_RT_MASTER">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SECONDARY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_READONLY">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SUBREF">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_WRITE">
        /// </seealso>
        /// <seealso cref="ReplicationConstants.Ldap_RT_SPARSE_READ">
        /// </seealso>
        public AddReplicaRequest(System.String dn, System.String serverDN, int replicaType, int flags) : base(ReplicationConstants.ADD_REPLICA_REQ, null)
        {
            try
            {
                if (((System.Object)dn == null) || ((System.Object)serverDN == null))
                {
                    throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder            encoder     = new LBEREncoder();

                Asn1Integer     asn1_flags       = new Asn1Integer(flags);
                Asn1Integer     asn1_replicaType = new Asn1Integer(replicaType);
                Asn1OctetString asn1_serverDN    = new Asn1OctetString(serverDN);
                Asn1OctetString asn1_dn          = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_replicaType.encode(encoder, encodedData);
                asn1_serverDN.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String)null);
            }
        }
        /// <summary> Constructs an object from the responseValue which contains the effective
        /// privileges.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///   privileges  INTEGER
        ///
        /// </summary>
        /// <exception> IOException The responseValue could not be decoded.
        /// </exception>
        public GetEffectivePrivilegesResponse(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");
                }

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

                privileges = asn1_privileges.intValue();
            }
            else
            {
                privileges = 0;
            }
        }
Exemple #17
0
        /// <summary>
        ///     Constructs an extended operation object for splitting partition.
        /// </summary>
        /// <param name="dn">
        ///     The distinguished name of the container where the new
        ///     partition  root should be located.
        /// </param>
        /// <param name="flags">
        ///     Specifies whether all servers in the replica ring must be up before
        ///     proceeding. When set to zero, the status of the servers is not
        ///     checked. When set to Ldap_ENSURE_SERVERS_UP, all servers must be up
        ///     for the operation to proceed.
        /// </param>
        /// <exception>
        ///     LdapException A general exception which includes an error message
        ///     and an Ldap error code.
        /// </exception>
        public SplitPartitionRequest(string dn, int flags) : base(ReplicationConstants.CREATE_NAMING_CONTEXT_REQ, null)
        {
            try
            {
                if ((object)dn == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_flags = new Asn1Integer(flags);
                var asn1_dn    = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
Exemple #18
0
        /// <summary> Constructs an object from the responseValue which contains the
        /// entry count.
        ///
        /// The constructor parses the responseValue which has the following
        /// format:
        /// responseValue ::=
        ///   count  INTEGER
        ///
        /// </summary>
        /// <exception> IOException  The response value could not be decoded.
        /// </exception>
        public PartitionEntryCountResponse(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");
                }

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

                count = asn1_count.intValue();
            }
            else
            {
                count = -1;
            }
        }
        //BER encoding/decoding are implemented in base class Asn1ByteString.

        #region PER

        /// <summary>
        /// Encodes the content of the object by PER.
        /// </summary>
        /// <param name="buffer">A buffer to which the encoding result will be written.</param>
        /// <remarks>Length is included.</remarks>
        protected override void ValuePerEncode(IAsn1PerEncodingBuffer buffer)
        {
            Asn1StandardProcedure.PerEncodeArray(buffer, Value.ToCharArray(),
                                                 (encodingBuffer, b) =>
            {
                int val;
                if (Constraint == null || Constraint.PermittedCharSet == null)
                {
                    if (b == ' ')     //SPACE->0000, '0'->0001, ..., '9'->1010
                    {
                        val = 0;
                    }
                    else
                    {
                        val = 1 + b - '0';
                    }
                }
                else
                {
                    for (val = 0; val != CharSetInArray.Length && b != CharSetInArray[val]; val++)
                    {
                    }
                }
                Asn1Integer ai = new Asn1Integer(val, 0, 15);
                ai.PerEncode(buffer);
            }
                                                 , Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null,
                                                 true);
        }
 /// <summary>
 /// Decodes the object by PER.
 /// </summary>
 /// <param name="buffer">A buffer that contains a PER encoding result.</param>
 /// <param name="aligned">Indicating whether the PER decoding is aligned.</param>
 /// <remarks>Length is included.</remarks>
 protected override void ValuePerDecode(IAsn1DecodingBuffer buffer, bool aligned = true)
 {
     ByteArrayValue = Asn1StandardProcedure.PerDecodeArray <byte>(buffer,
                                                                  decodingBuffer =>
     {
         Asn1Integer ai = new Asn1Integer(null, 0, 15);
         ai.PerDecode(buffer);
         if (Constraint == null || Constraint.PermittedCharSet == null)
         {
             if (ai.Value == 0)
             {
                 return((byte)' ');
             }
             else if (ai.Value >= 1 && ai.Value <= 10)
             {
                 return((byte)((byte)'0' + ai.Value - 1));
             }
             else
             {
                 throw new Asn1DecodingUnexpectedData(ExceptionMessages.DecodingUnexpectedData +
                                                      "Only 0~9 and SPACE are allowed in NumericString.");
             }
         }
         else
         {
             int index = (int)ai.Value;
             return((byte)CharSetInArray[(int)ai.Value]);
         }
     },
                                                                  Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null,
                                                                  true);
 }
Exemple #21
0
        //*************************************************************************
        // Constructors for BindRequest
        //*************************************************************************

        /// <summary> </summary>
        public RfcBindRequest(Asn1Integer version, RfcLdapDN name, RfcAuthenticationChoice auth) : base(3)
        {
            add(version);
            add(name);
            add(auth);
            return;
        }
Exemple #22
0
        /// <summary>  Constructs an extended operation object for synchronizing the schema.
        ///
        /// </summary>
        /// <param name="serverName">    The distinguished name of the server which will start
        /// the synchronization.
        ///
        /// </param>
        /// <param name="delay">         The time, in seconds, to delay before the synchronization
        /// should start.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error message
        /// and an Ldap error code.
        /// </exception>
        public SchemaSyncRequest(String serverName, int delay) : base(ReplicationConstants.SCHEMA_SYNC_REQ, null)
        {
            try
            {
                if ((object)serverName == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder            encoder     = new LBEREncoder();

                Asn1OctetString asn1_serverName = new Asn1OctetString(serverName);
                Asn1Integer     asn1_delay      = new Asn1Integer(delay);

                asn1_serverName.encode(encoder, encodedData);
                asn1_delay.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (String)null);
            }
        }
        /// <summary> Constructs an extended operation object for merging partitions.
        ///
        /// </summary>
        /// <param name="dn">       The distinguished name of the child partition's root.
        ///
        /// </param>
        /// <param name="flags">    Determines whether all servers in the replica ring must
        /// be up before proceeding. When set to zero, the status of
        /// the servers is not checked. When set to
        /// Ldap_ENSURE_SERVERS_UP, all servers must be up for the
        /// operation to proceed.
        ///
        /// </param>
        /// <exception> LdapException A general exception which includes an error
        /// message and an Ldap error code.
        /// </exception>

        public MergePartitionsRequest(System.String dn, int flags) : base(ReplicationConstants.MERGE_NAMING_CONTEXT_REQ, null)
        {
            try
            {
                if ((System.Object)dn == null)
                {
                    throw new System.ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

                System.IO.MemoryStream encodedData = new System.IO.MemoryStream();
                LBEREncoder            encoder     = new LBEREncoder();

                Asn1Integer     asn1_flags = new Asn1Integer(flags);
                Asn1OctetString asn1_dn    = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (System.IO.IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, (System.String)null);
            }
        }
Exemple #24
0
 public VerifyNameRequestValue(
     Asn1Integer Flags,
     Asn1OctetString ServerName)
 {
     this.Flags      = Flags;
     this.ServerName = ServerName;
 }
Exemple #25
0
        public static byte[] FromRSA(RSA rsa)
        {
            var prms = rsa.ExportParameters(false);

            var modulus  = new Asn1Integer((new byte[] { 0x00 }.Concat(prms.Modulus)).ToArray());
            var exponent = new Asn1Integer(prms.Exponent);

            var oidheader = new Asn1Sequence();

            oidheader.Nodes.Add(new Asn1ObjectIdentifier("1.2.840.113549.1.1.1"));
            oidheader.Nodes.Add(new Asn1Null());

            var rsaSequence = new Asn1Sequence();

            rsaSequence.Nodes.Add(modulus);
            rsaSequence.Nodes.Add(exponent);

            var bitString = new Asn1BitString(rsaSequence.GetBytes());

            var result = new Asn1Sequence();

            result.Nodes.Add(oidheader);
            result.Nodes.Add(bitString);

            return(result.GetBytes());
        }
        /// <summary>
        ///     Constructs an extended operation object for removing a replica.
        /// </summary>
        /// <param name="dn">
        ///     The distinguished name of the replica's
        ///     partition root.
        /// </param>
        /// <param name="serverDN">
        ///     The distinguished name of server from which the replica
        ///     will be removed.
        /// </param>
        /// <param name="flags">
        ///     Determines whether all servers in the replica ring must
        ///     be up before proceeding. When set to zero, the status of the
        ///     servers is not checked. When set to Ldap_ENSURE_SERVERS_UP,
        ///     all servers must be up for the operation to proceed.
        /// </param>
        /// <exception>
        ///     LdapException A general exception which includes an error message
        ///     and an Ldap error code.
        /// </exception>
        public RemoveReplicaRequest(string dn, string serverDN, int flags)
            : base(ReplicationConstants.DELETE_REPLICA_REQ, null)
        {
            try
            {
                if ((object)dn == null || (object)serverDN == null)
                {
                    throw new ArgumentException(ExceptionMessages.PARAM_ERROR);
                }

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

                var asn1_flags    = new Asn1Integer(flags);
                var asn1_serverDN = new Asn1OctetString(serverDN);
                var asn1_dn       = new Asn1OctetString(dn);

                asn1_flags.encode(encoder, encodedData);
                asn1_serverDN.encode(encoder, encodedData);
                asn1_dn.encode(encoder, encodedData);

                setValue(SupportClass.ToSByteArray(encodedData.ToArray()));
            }
            catch (IOException ioe)
            {
                throw new LdapException(ExceptionMessages.ENCODING_ERROR, LdapException.ENCODING_ERROR, null, ioe);
            }
        }
Exemple #27
0
 public KRB_ERROR(
     Asn1Integer param0,
     Asn1Integer param1,
     KerberosTime param2,
     Microseconds param3,
     KerberosTime param4,
     Microseconds param5,
     KerbInt32 param6,
     Realm param7,
     PrincipalName param8,
     Realm param9,
     PrincipalName param10,
     KerberosString param11,
     Asn1OctetString param12)
 {
     this.pvno       = param0;
     this.msg_type   = param1;
     this.ctime      = param2;
     this.cusec      = param3;
     this.stime      = param4;
     this.susec      = param5;
     this.error_code = param6;
     this.crealm     = param7;
     this.cname      = param8;
     this.realm      = param9;
     this.sname      = param10;
     this.e_text     = param11;
     this.e_data     = param12;
 }
Exemple #28
0
 public BindRequest(
     Asn1Integer version,
     LDAPDN name,
     AuthenticationChoice authentication)
 {
     this.version        = version;
     this.name           = name;
     this.authentication = authentication;
 }
Exemple #29
0
 public KRB_PRIV(
     Asn1Integer param0,
     Asn1Integer param1,
     EncryptedData param2)
 {
     this.pvno     = param0;
     this.msg_type = param1;
     this.enc_part = param2;
 }
 public KDC_PROXY_MESSAGE(
     Asn1OctetString param0,
     KerberosString param1,
     Asn1Integer param2)
 {
     this.kerb_message   = param0;
     this.target_domain  = param1;
     this.dclocator_hint = param2;
 }
 public DirSyncRequestValue(
     Asn1Integer Flags,
     Asn1Integer MaxBytes,
     Asn1OctetString Cookie)
 {
     this.Flags    = Flags;
     this.MaxBytes = MaxBytes;
     this.Cookie   = Cookie;
 }
 /// <summary>
 /// Encodes the content of the object by PER.
 /// </summary>
 /// <param name="buffer">A buffer to which the encoding result will be written.</param>
 /// <remarks>Length is included.</remarks>
 protected override void ValuePerEncode(IAsn1PerEncodingBuffer buffer)
 {
     Asn1StandardProcedure.PerEncodeArray(buffer, Value.ToCharArray(),
         (encodingBuffer, b) =>
         {
             int val;
             if (Constraint == null || Constraint.PermittedCharSet == null)
             {
                 if (b == ' ') //SPACE->0000, '0'->0001, ..., '9'->1010
                 {
                     val = 0;
                 }
                 else
                 {
                     val = 1 + b - '0';
                 }
             }
             else
             {
                 for (val = 0; val != CharSetInArray.Length && b != CharSetInArray[val]; val++)
                 {
                 }
             }
             Asn1Integer ai = new Asn1Integer(val, 0, 15);
             ai.PerEncode(buffer);
         }
     , Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null,
     true);
 }