GetObject() public méthode

public GetObject ( ) : Asn1Object
Résultat Asn1Object
        /**
         * return an Integer from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *               be converted.
         */
        public static DerInteger GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

			return GetInstance(obj.GetObject());
        }
        /**
         * return a Videotex String from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param explicit true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception IllegalArgumentException if the tagged object cannot
         *               be converted.
         * @return a DERVideotexString instance, or null.
         */
        public static DerVideotexString GetInstance(Asn1TaggedObject obj, bool isExplicit)
        {
			Asn1Object o = obj.GetObject();

            if (isExplicit || o is DerVideotexString)
			{
				return GetInstance(o);
			}

            return new DerVideotexString(((Asn1OctetString)o).GetOctets());
        }
		static public Asn1TaggedObject GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            if (explicitly)
            {
                return (Asn1TaggedObject) obj.GetObject();
            }

            throw new ArgumentException("implicitly tagged tagged object");
        }
        /**
         * return an OriginatorIdentifierOrKey object from a tagged object.
         *
         * @param o the tagged object holding the object we want.
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the object held by the
         *          tagged object cannot be converted.
         */
        public static OriginatorIdentifierOrKey GetInstance(
            Asn1TaggedObject	o,
            bool				explicitly)
        {
            if (!explicitly)
            {
                throw new ArgumentException(
                        "Can't implicitly tag OriginatorIdentifierOrKey");
            }

			return GetInstance(o.GetObject());
        }
		/**
         * return an Octet string from a tagged object.
         *
         * @param obj the tagged object holding the object we want.
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *              be converted.
         */
		public static Asn1OctetString GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			Asn1Object o = obj.GetObject();

			if (isExplicit || o is Asn1OctetString)
			{
				return GetInstance(o);
			}

			return BerOctetString.FromSequence(Asn1Sequence.GetInstance(o));
		}
		/**
         * return a Generalized Time object from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *               be converted.
         */
        public static DerGeneralizedTime GetInstance(
            Asn1TaggedObject	obj,
            bool				isExplicit)
        {
			Asn1Object o = obj.GetObject();

			if (isExplicit || o is DerGeneralizedTime)
			{
				return GetInstance(o);
			}

			return new DerGeneralizedTime(((Asn1OctetString)o).GetOctets());
        }
Exemple #7
0
        /**
         * return a Boolean from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *               be converted.
         */
        public static DerBoolean GetInstance(
            Asn1TaggedObject	obj,
            bool				isExplicit)
        {
            Asn1Object o = obj.GetObject();

            if (isExplicit || o is DerBoolean)
            {
                return GetInstance(o);
            }

            return FromOctetString(((Asn1OctetString)o).GetOctets());
        }
Exemple #8
0
        /**
         * Return an ASN1 set from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * set - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sets you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Set GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
			Asn1Object inner = obj.GetObject();

			if (explicitly)
            {
                if (!obj.IsExplicit())
                    throw new ArgumentException("object implicit - explicit expected.");

				return (Asn1Set) inner;
            }

			//
            // constructed object which appears to be explicitly tagged
            // and it's really implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                return new DerSet(inner);
            }

			if (inner is Asn1Set)
            {
                return (Asn1Set) inner;
            }

            //
            // in this case the parser returns a sequence, convert it
            // into a set.
            //
			if (inner is Asn1Sequence)
            {
				Asn1EncodableVector v = new Asn1EncodableVector();
				Asn1Sequence s = (Asn1Sequence) inner;

				foreach (Asn1Encodable ae in s)
				{
                    v.Add(ae);
                }

				// TODO Should be able to construct set directly from sequence?
				return new DerSet(v, false);
            }

			throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
		}
        /**
         * return an Integer from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param isExplicit true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *               be converted.
         */
        public static DerInteger GetInstance(
            Asn1TaggedObject	obj,
            bool				isExplicit)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

			Asn1Object o = obj.GetObject();

			if (isExplicit || o is DerInteger)
			{
				return GetInstance(o);
			}

			return new DerInteger(Asn1OctetString.GetInstance(o).GetOctets());
        }
		/**
         * Return an ASN1 sequence from a tagged object. There is a special
         * case here, if an object appears to have been explicitly tagged on
         * reading but we were expecting it to be implicitly tagged in the
         * normal course of events it indicates that we lost the surrounding
         * sequence - so we need to add it back (this will happen if the tagged
         * object is a sequence that contains other sequences). If you are
         * dealing with implicitly tagged sequences you really <b>should</b>
         * be using this method.
         *
         * @param obj the tagged object.
         * @param explicitly true if the object is meant to be explicitly tagged,
         *          false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *          be converted.
         */
        public static Asn1Sequence GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
			Asn1Object inner = obj.GetObject();

			if (explicitly)
            {
                if (!obj.IsExplicit())
                    throw new ArgumentException("object implicit - explicit expected.");

				return (Asn1Sequence) inner;
            }

			//
            // constructed object which appears to be explicitly tagged
            // when it should be implicit means we have to add the
            // surrounding sequence.
            //
            if (obj.IsExplicit())
            {
                if (obj is BerTaggedObject)
                {
                    return new BerSequence(inner);
                }

				return new DerSequence(inner);
            }

			if (inner is Asn1Sequence)
            {
                return (Asn1Sequence) inner;
            }

			throw new ArgumentException("Unknown object in GetInstance: " + obj.GetType().FullName, "obj");
		}
Exemple #11
0
		/**
         * return an object Identifier from a tagged object.
         *
         * @param obj the tagged object holding the object we want
         * @param explicitly true if the object is meant to be explicitly
         *              tagged false otherwise.
         * @exception ArgumentException if the tagged object cannot
         *               be converted.
         */
        public static DerObjectIdentifier GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(obj.GetObject());
        }
Exemple #12
0
		public static Time GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(obj.GetObject());
        }
Exemple #13
0
 /**
  * return an Enumerated from a tagged object.
  *
  * @param obj the tagged object holding the object we want
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *               be converted.
  */
 public static DerEnumerated GetInstance(
     Asn1TaggedObject obj,
     bool          explicitly)
 {
     return GetInstance(obj.GetObject());
 }
 /**
  * return a Generalized Time object from a tagged object.
  *
  * @param obj the tagged object holding the object we want
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *               be converted.
  */
 public static DerGeneralizedTime GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(obj.GetObject()));
 }
 /**
  * return an Enumerated from a tagged object.
  *
  * @param obj the tagged object holding the object we want
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *               be converted.
  */
 public static DerEnumerated GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(obj.GetObject()));
 }
Exemple #16
0
		public static ResponderID GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			return GetInstance(obj.GetObject()); // must be explicitly tagged
		}
		public static AttCertIssuer GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			return GetInstance(obj.GetObject()); // must be explictly tagged
		}
Exemple #18
0
 public static DerObjectIdentifier GetInstance(Asn1TaggedObject obj, bool explicitly) =>
 GetInstance(obj.GetObject());
 /**
  * return a Visible string from a tagged object.
  *
  * @param obj the tagged object holding the object we want
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *               be converted.
  */
 public static DerVisibleString GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(obj.GetObject()));
 }
 /**
  * return an Octet string from a tagged object.
  *
  * @param obj the tagged object holding the object we want.
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *              be converted.
  */
 public static Asn1OctetString GetInstance(
     Asn1TaggedObject obj,
     bool explicitly)
 {
     return(GetInstance(obj.GetObject()));
 }
Exemple #21
0
 /**
  * return an T61 string from a tagged object.
  *
  * @param obj the tagged object holding the object we want
  * @param explicitly true if the object is meant to be explicitly
  *              tagged false otherwise.
  * @exception ArgumentException if the tagged object cannot
  *               be converted.
  */
 public static DerT61String GetInstance(
     Asn1TaggedObject	obj,
     bool				explicitly)
 {
     return GetInstance(obj.GetObject());
 }
        protected override bool Asn1Equals(Asn1Object asn1Object)
        {
            Asn1TaggedObject obj2 = asn1Object as Asn1TaggedObject;

            if (obj2 == null)
            {
                return(false);
            }
            return(((this.tagNo == obj2.tagNo) && (this.explicitly == obj2.explicitly)) && object.Equals(this.GetObject(), obj2.GetObject()));
        }