Ejemplo n.º 1
0
		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());
        }
Ejemplo n.º 3
0
        /**
         * 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());
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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				isExplicit)
        {
			Asn1Object o = obj.GetObject();

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

			return new DerT61String(Asn1OctetString.GetInstance(o).GetOctets());
        }
Ejemplo n.º 6
0
		/**
         * 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));
		}
Ejemplo n.º 7
0
		public CertStatus(
            Asn1TaggedObject choice)
        {
            this.tagNo = choice.TagNo;

			switch (choice.TagNo)
            {
				case 1:
					value = RevokedInfo.GetInstance(choice, false);
					break;
				case 0:
				case 2:
					value = DerNull.Instance;
					break;
            }
        }
Ejemplo n.º 8
0
        /**
         * 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());
        }
Ejemplo n.º 9
0
        /**
         * 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");
        }
Ejemplo n.º 10
0
		public static ResponderID GetInstance(
			Asn1TaggedObject	obj,
			bool				isExplicit)
		{
			return GetInstance(obj.GetObject()); // must be explicitly tagged
		}
Ejemplo n.º 11
0
 /**
  * return an EnvelopedData 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 object held by the
  *          tagged object cannot be converted.
  */
 public static EnvelopedData GetInstance(
     Asn1TaggedObject	obj,
     bool				explicitly)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
 }
Ejemplo n.º 12
0
		private KekRecipientInfo GetKekInfo(
			Asn1TaggedObject o)
		{
			// For compatibility with erroneous version, we don't always pass 'false' here
			return KekRecipientInfo.GetInstance(o, o.IsExplicit());
		}
Ejemplo n.º 13
0
		/**
         * return an OriginatorInfo 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 object held by the
         *          tagged object cannot be converted.
         */
        public static OriginatorInfo GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 14
0
		public static Gost28147Parameters GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 15
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());
 }
		private OriginatorIdentifierOrKey(
			Asn1TaggedObject id)
		{
			// TODO Add validation
			this.id = id;
		}
Ejemplo n.º 17
0
		public static CertificateList GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 18
0
		public static RsaPublicKeyStructure GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 19
0
		public static RevokedInfo GetInstance(
			Asn1TaggedObject	obj,
			bool				explicitly)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
		}
Ejemplo n.º 20
0
		public static SingleResponse GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 21
0
		public static AttCertValidityPeriod GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 22
0
		public static BasicConstraints GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 23
0
		public static ServiceLocator GetInstance(
			Asn1TaggedObject	obj,
			bool				explicitly)
		{
			return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
		}
Ejemplo n.º 24
0
		public static Time GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(obj.GetObject());
        }
Ejemplo n.º 25
0
		/**
         * return a KekIdentifier 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 object held by the
         *          tagged object cannot be converted.
         */
        public static KekIdentifier GetInstance(
            Asn1TaggedObject obj,
            bool explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 26
0
 public static ContentInfo GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
 }
Ejemplo n.º 27
0
 public static RsaPrivateKeyStructure GetInstance(Asn1TaggedObject obj, bool isExplicit)
 {
     return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
 }
Ejemplo n.º 28
0
 /**
  * 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());
 }
Ejemplo n.º 29
0
		/**
         * return a PasswordRecipientInfo 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 object held by the
         *          tagged object cannot be converted.
         */
        public static PasswordRecipientInfo GetInstance(
            Asn1TaggedObject	obj,
            bool				explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
        }
Ejemplo n.º 30
0
		/**
         * return a CompressedData object from a tagged object.
         *
         * @param ato 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 CompressedData GetInstance(
            Asn1TaggedObject ato,
            bool explicitly)
        {
            return GetInstance(Asn1Sequence.GetInstance(ato, explicitly));
        }
Ejemplo n.º 31
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()));
 }