Inheritance: System.Object, System.ICloneable
コード例 #1
0
 public Asn1Tagged(Asn1Decoder dec, Stream in_Renamed, int len, Asn1Identifier identifier) : base(identifier)
 {
     // If we are decoding an implicit tag, there is no way to know at this
     // low level what the base type really is. We can place the content
     // into an Asn1OctetString type and pass it back to the application who
     // will be able to create the appropriate ASN.1 type for this tag.
     content = new Asn1OctetString(dec, in_Renamed, len);
 }
コード例 #2
0
        public override string ToString()
        {
            string[] classTypes = new string[] { "[UNIVERSAL ", "[APPLICATION ", "[", "[PRIVATE " };

            StringBuilder  sb = new StringBuilder();
            Asn1Identifier id = getIdentifier(); // could be overridden.

            sb.Append(classTypes[id.Asn1Class]).Append(id.Tag).Append("] ");

            return(sb.ToString());
        }
コード例 #3
0
        /// <summary> Constructs an Asn1Tagged object.</summary>
        public Asn1Tagged(Asn1Identifier identifier, Asn1Object objectRenamed, bool explicitRenamed)
            : base(identifier)
        {
            _content = objectRenamed;
            Explicit = explicitRenamed;

            if (!explicitRenamed && _content != null)
            {
                // replace object's id with new tag.
                _content.SetIdentifier(identifier);
            }
        }
コード例 #4
0
        /// <summary> Constructs an Asn1Tagged object.</summary>
        public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed, bool explicit_Renamed)
            : base(identifier)
        {
            this.content          = object_Renamed;
            this.explicit_Renamed = explicit_Renamed;

            if (!explicit_Renamed && content != null)
            {
                // replace object's id with new tag.
                content.setIdentifier(identifier);
            }
        }
コード例 #5
0
ファイル: Asn1Tagged.cs プロジェクト: EventStore/csharp-ldap
        /// <summary> Constructs an Asn1Tagged object.</summary>
        public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed, bool explicit_Renamed)
            : base(identifier)
        {
            this.content = object_Renamed;
            this.explicit_Renamed = explicit_Renamed;

            if (!explicit_Renamed && content != null)
            {
                // replace object's id with new tag.
                content.setIdentifier(identifier);
            }
            return ;
        }
コード例 #6
0
        /* Encoders for ASN.1 useful types
         */
        /* Encoder for ASN.1 Identifier
         */

        /// <summary> Encode an Asn1Identifier directly into the specified outputstream.</summary>
        public void encode(Asn1Identifier id, Stream out_Renamed)
        {
            var c   = id.Asn1Class;
            var t   = id.Tag;
            var ccf = (sbyte)((c << 6) | (id.Constructed ? 0x20 : 0));

            if (t < 30)
            {
                /* single octet */
                out_Renamed.WriteByte((byte)(ccf | t));
            }
            else
            {
                /* multiple octet */
                out_Renamed.WriteByte((byte)(ccf | 0x1F));
                encodeTagInteger(t, out_Renamed);
            }
        }
コード例 #7
0
        /* Encoders for ASN.1 useful types
         */
        /* Encoder for ASN.1 Identifier
         */

        /// <summary> Encode an Asn1Identifier directly into the specified outputstream.</summary>
        public void  encode(Asn1Identifier id, System.IO.Stream out_Renamed)
        {
            int   c   = id.Asn1Class;
            int   t   = id.Tag;
            sbyte ccf = (sbyte)((c << 6) | (id.Constructed?0x20:0));

            if (t < 30)
            {
                /* single octet */
                out_Renamed.WriteByte((System.Byte)(ccf | t));
            }
            else
            {
                /* multiple octet */
                out_Renamed.WriteByte((System.Byte)(ccf | 0x1F));
                encodeTagInteger(t, out_Renamed);
            }
            return;
        }
コード例 #8
0
 /// <summary>
 ///     Sets the identifier for this Asn1Object. This is helpful when
 ///     creating implicit Asn1Tagged types.
 /// </summary>
 /// <param name="id">
 ///     An Asn1Identifier object representing the CLASS,
 ///     FORM and TAG).
 /// </param>
 public virtual void SetIdentifier(Asn1Identifier id)
 {
     _id = id;
 }
コード例 #9
0
			/// <summary> This thread decodes and processes RfcLdapMessage's from the server.
			/// 
			/// Note: This thread needs a graceful shutdown implementation.
			/// </summary>
			public virtual void  Run()
			{
				
				System.String reason = "reader: thread stopping";
				InterThreadException notify = null;
				Message info = null;
				System.IO.IOException ioex = null;
				this.enclosingInstance.reader = SupportClass.ThreadClass.Current();				
//				Enclosing_Instance.reader = SupportClass.ThreadClass.Current();
//				Console.WriteLine("Inside run:" + this.enclosingInstance.reader.Name);
				try
				{
					for (; ; )
					{
						// -------------------------------------------------------
						// Decode an RfcLdapMessage directly from the socket.
						// -------------------------------------------------------
						Asn1Identifier asn1ID;
						System.IO.Stream myIn;
						/* get current value of in, keep value consistant
						* though the loop, i.e. even during shutdown
						*/
						myIn = this.enclosingInstance.in_Renamed;
						if (myIn == null)
						{
							break;
						}
						asn1ID = new Asn1Identifier(myIn);
						int tag = asn1ID.Tag;
						if (asn1ID.Tag != Asn1Sequence.TAG)
						{
							continue; // loop looking for an RfcLdapMessage identifier
						}
						
						// Turn the message into an RfcMessage class
						Asn1Length asn1Len = new Asn1Length(myIn);
						
						RfcLdapMessage msg = new RfcLdapMessage(this.enclosingInstance.decoder, myIn, asn1Len.Length);
						
						// ------------------------------------------------------------
						// Process the decoded RfcLdapMessage.
						// ------------------------------------------------------------
						int msgId = msg.MessageID;
						
						// Find the message which requested this response.
						// It is possible to receive a response for a request which
						// has been abandoned. If abandoned, throw it away
						try
						{
							info = this.enclosingInstance.messages.findMessageById(msgId);
							info.putReply(msg); // queue & wake up waiting thread
						}
						catch (System.FieldAccessException ex)
						{
							
							/*
							* We get the NoSuchFieldException when we could not find
							* a matching message id.  First check to see if this is
							* an unsolicited notification (msgID == 0). If it is not
							* we throw it away. If it is we call any unsolicited
							* listeners that might have been registered to listen for these
							* messages.
							*/
							
							
							/* Note the location of this code.  We could have required
							* that message ID 0 be just like other message ID's but
							* since message ID 0 has to be treated specially we have
							* a separate check for message ID 0.  Also note that
							* this test is after the regular message list has been
							* checked for.  We could have always checked the list
							* of messages after checking if this is an unsolicited
							* notification but that would have inefficient as
							* message ID 0 is a rare event (as of this time).
							*/
							if (msgId == 0)
							{
								
								
								// Notify any listeners that might have been registered
								this.enclosingInstance.notifyAllUnsolicitedListeners(msg);
								
								/*
								* Was this a server shutdown unsolicited notification.
								* IF so we quit. Actually calling the return will
								* first transfer control to the finally clause which
								* will do the necessary clean up.
								*/
								if (this.enclosingInstance.unsolSvrShutDnNotification)
								{
									notify = new InterThreadException(ExceptionMessages.SERVER_SHUTDOWN_REQ, new System.Object[]{this.enclosingInstance.host, this.enclosingInstance.port}, LdapException.CONNECT_ERROR, null, null);
									
									return ;
								}
							}
							else
							{
								
							}
						}
						if ((this.enclosingInstance.stopReaderMessageID == msgId) || (this.enclosingInstance.stopReaderMessageID == Novell.Directory.Ldap.Connection.STOP_READING))
						{
							// Stop the reader Thread.
							return ;
						}
					}
				}
				catch (System.IO.IOException ioe)
				{
					
					ioex = ioe;
					if ((this.enclosingInstance.stopReaderMessageID != Novell.Directory.Ldap.Connection.STOP_READING) && this.enclosingInstance.clientActive)
					{
						// Connection lost waiting for results from host:port
						notify = new InterThreadException(ExceptionMessages.CONNECTION_WAIT, new System.Object[]{this.enclosingInstance.host, this.enclosingInstance.port}, LdapException.CONNECT_ERROR, ioe, info);
					}
					// The connection is no good, don't use it any more
					this.enclosingInstance.in_Renamed = null;
					this.enclosingInstance.out_Renamed = null;
				}
				finally
				{
					/*
					* There can be four states that the reader can be in at this point:
					*  1) We are starting TLS and will be restarting the reader
					*     after we have negotiated TLS.
					*      - Indicated by whether stopReaderMessageID does not
					*        equal CONTINUE_READING.
					*      - Don't call Shutdown.
					*  2) We are stoping TLS and will be restarting after TLS is
					*     stopped.
					*      - Indicated by an IOException AND stopReaderMessageID equals
					*        STOP_READING - in which case notify will be null.
					*      - Don't call Shutdown
					*  3) We receive a Server Shutdown notification.
					*      - Indicated by messageID equal to 0.
					*      - call Shutdown.
					*  4) Another error occured
					*      - Indicated by an IOException AND notify is not NULL
					*      - call Shutdown.
					*/
					if ((!this.enclosingInstance.clientActive) || (notify != null))
					{
						//#3 & 4
						this.enclosingInstance.shutdown(reason, 0, notify);
					}
					else
					{
						this.enclosingInstance.stopReaderMessageID = Novell.Directory.Ldap.Connection.CONTINUE_READING;
					}
				}
				this.enclosingInstance.deadReaderException = ioex;
				this.enclosingInstance.deadReader = this.enclosingInstance.reader;
				this.enclosingInstance.reader = null;
				return ;
			}
コード例 #10
0
 protected Asn1Object(Asn1Identifier id)
 {
     _id = id;
 }
コード例 #11
0
 internal Asn1Numeric(Asn1Identifier id, int value_Renamed) : base(id)
 {
     content = value_Renamed;
 }
コード例 #12
0
 /// <summary>
 ///     Sets the identifier of the contained Asn1Object. We
 ///     override the parent method as the identifier of
 ///     an Asn1Choice depends on the type of the object
 ///     encoded by this Asn1Choice.
 /// </summary>
 public override void SetIdentifier(Asn1Identifier id)
 {
     ChoiceValue.SetIdentifier(id);
 }
コード例 #13
0
ファイル: LBERDecoder.cs プロジェクト: nickchal/pash
		private void  InitBlock()
		{
			asn1ID = new Asn1Identifier();
			asn1Len = new Asn1Length();
		}
コード例 #14
0
        /*
         * Create a an Asn1 structured type with default size of 10
         *
         * @param id the Asn1Identifier containing the tag for this structured type
         *
         * @param content an array containing the content
         *
         * @param size the number of items of content in the array
         */

        protected internal Asn1Structured(Asn1Identifier id, Asn1Object[] newContent, int size) : base(id)
        {
            content      = newContent;
            contentIndex = size;
        }
コード例 #15
0
ファイル: Asn1Numeric.cs プロジェクト: REALTOBIZ/mono
		internal Asn1Numeric(Asn1Identifier id, long value_Renamed):base(id)
		{
			content = (System.Int64) value_Renamed;
			return ;
		}
コード例 #16
0
        /*
         * Create a an Asn1 structured type with the designated size
         *
         * @param id the Asn1Identifier containing the tag for this structured type
         *
         * @param size the size to allocate
         */

        protected internal Asn1Structured(Asn1Identifier id, int size)
            : base(id)
        {
            _content = new List <Asn1Object>(size);
        }
コード例 #17
0
        /*
         * Create a an Asn1 structured type with default size of 10
         *
         * @param id the Asn1Identifier containing the tag for this structured type
         *
         * @param content an array containing the content
         *
         * @param size the number of items of content in the array
         */

        protected internal Asn1Structured(Asn1Identifier id, IList <Asn1Object> newContent)
            : base(id)
        {
            _content = new List <Asn1Object>(newContent);
        }
コード例 #18
0
 internal Asn1Numeric(Asn1Identifier id, long value_Renamed)
     : base(id)
 {
     content = (long)value_Renamed;
 }
コード例 #19
0
 /*
 * Create a an Asn1 structured type with default size of 10
 *
 * @param id the Asn1Identifier containing the tag for this structured type
 *
 * @param content an array containing the content
 *
 * @param size the number of items of content in the array
 */
 protected internal Asn1Structured(Asn1Identifier id, Asn1Object[] newContent, int size)
     : base(id)
 {
     content = newContent;
     contentIndex = size;
     return ;
 }
コード例 #20
0
 /*
 * Create a an Asn1 structured type with the designated size
 *
 * @param id the Asn1Identifier containing the tag for this structured type
 *
 * @param size the size to allocate
 */
 protected internal Asn1Structured(Asn1Identifier id, int size)
     : base(id)
 {
     content = new Asn1Object[size];
     return ;
 }
コード例 #21
0
 /*
 * Create a an Asn1 structured type with default size of 10
 *
 * @param the Asn1Identifier containing the tag for this structured type
 */
 protected internal Asn1Structured(Asn1Identifier id)
     : this(id, 10)
 {
     return ;
 }
コード例 #22
0
        /* Constructors for Asn1Tagged
         */

        /// <summary> Constructs an Asn1Tagged object using the provided
        /// AN1Identifier and the Asn1Object.
        ///
        /// The explicit flag defaults to true as per the spec.
        /// </summary>
        public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed)
            : this(identifier, object_Renamed, true)
        {
        }
コード例 #23
0
        /*
         * Create a an Asn1 structured type with default size of 10
         *
         * @param the Asn1Identifier containing the tag for this structured type
         */

        protected internal Asn1Structured(Asn1Identifier id) : this(id, 10)
        {
        }
コード例 #24
0
		/// <summary> Sets the identifier for this Asn1Object. This is helpful when 
		/// creating implicit Asn1Tagged types.
		/// 
		/// </summary>
		/// <param name="id">An Asn1Identifier object representing the CLASS, 
		/// FORM and TAG)
		/// </param>
		public virtual void  setIdentifier(Asn1Identifier id)
		{
			this.id = id;
			return ;
		}
コード例 #25
0
 internal Asn1Numeric(Asn1Identifier id, long value_Renamed) : base(id)
 {
     content = (System.Int64)value_Renamed;
     return;
 }
コード例 #26
0
		public Asn1Tagged(Asn1Decoder dec, System.IO.Stream in_Renamed, int len, Asn1Identifier identifier):base(identifier)
		{
			
			// If we are decoding an implicit tag, there is no way to know at this
			// low level what the base type really is. We can place the content
			// into an Asn1OctetString type and pass it back to the application who
			// will be able to create the appropriate ASN.1 type for this tag.
			content = new Asn1OctetString(dec, in_Renamed, len);
			return ;
		}
コード例 #27
0
 internal Asn1Numeric(Asn1Identifier id, long valueRenamed)
     : base(id)
 {
     _content = valueRenamed;
 }
コード例 #28
0
		public Asn1Object(Asn1Identifier id)
		{
			this.id = id;
			return ;
		}
コード例 #29
0
 private void InitBlock()
 {
     asn1ID  = new Asn1Identifier();
     asn1Len = new Asn1Length();
 }
コード例 #30
0
ファイル: Asn1Choice.cs プロジェクト: nickchal/pash
		/// <summary> Sets the identifier of the contained Asn1Object. We
		/// override the parent method as the identifier of 
		/// an Asn1Choice depends on the type of the object 
		/// encoded by this Asn1Choice.
		/// </summary>
		public override void  setIdentifier(Asn1Identifier id)
		{
			content.setIdentifier(id);
			return ;
		}
コード例 #31
0
ファイル: LBEREncoder.cs プロジェクト: REALTOBIZ/mono
		/* Encoders for ASN.1 useful types
		*/
		/* Encoder for ASN.1 Identifier
		*/
		
		/// <summary> Encode an Asn1Identifier directly into the specified outputstream.</summary>
		public void  encode(Asn1Identifier id, System.IO.Stream out_Renamed)
		{
			int c = id.Asn1Class;
			int t = id.Tag;
			sbyte ccf = (sbyte) ((c << 6) | (id.Constructed?0x20:0));
			
			if (t < 30)
			{
				/* single octet */
				out_Renamed.WriteByte((System.Byte) (ccf | t));
			}
			else
			{
				/* multiple octet */
				out_Renamed.WriteByte((System.Byte) (ccf | 0x1F));
				encodeTagInteger(t, out_Renamed);
			}
			return ;
		}
コード例 #32
0
		/* Constructors for Asn1Tagged
		*/
		
		/// <summary> Constructs an Asn1Tagged object using the provided 
		/// AN1Identifier and the Asn1Object.
		/// 
		/// The explicit flag defaults to true as per the spec.
		/// </summary>
		public Asn1Tagged(Asn1Identifier identifier, Asn1Object object_Renamed):this(identifier, object_Renamed, true)
		{
			return ;
		}
コード例 #33
0
 public Asn1Object(Asn1Identifier id)
 {
     this.id = id;
 }
コード例 #34
0
        /*
         * Create a an Asn1 structured type with the designated size
         *
         * @param id the Asn1Identifier containing the tag for this structured type
         *
         * @param size the size to allocate
         */

        protected internal Asn1Structured(Asn1Identifier id, int size) : base(id)
        {
            content = new Asn1Object[size];
        }
コード例 #35
0
 /// <summary> Sets the identifier for this Asn1Object. This is helpful when
 /// creating implicit Asn1Tagged types.
 ///
 /// </summary>
 /// <param name="id">An Asn1Identifier object representing the CLASS,
 /// FORM and TAG)
 /// </param>
 public virtual void setIdentifier(Asn1Identifier id)
 {
     this.id = id;
 }
コード例 #36
0
 /// <summary> Sets the identifier of the contained Asn1Object. We
 /// override the parent method as the identifier of
 /// an Asn1Choice depends on the type of the object
 /// encoded by this Asn1Choice.
 /// </summary>
 public override void  setIdentifier(Asn1Identifier id)
 {
     content.setIdentifier(id);
     return;
 }
コード例 #37
0
 internal Asn1Numeric(Asn1Identifier id, int value_Renamed) : base(id)
 {
     content = (Int64)value_Renamed;
     return;
 }