GetInstance() 공개 정적인 메소드

public static GetInstance ( object o ) : MessageImprint
o object
리턴 MessageImprint
예제 #1
0
        private TimeStampReq(Asn1Sequence seq)
        {
            int count = seq.Count;
            int num   = 0;

            this.version        = DerInteger.GetInstance(seq[num++]);
            this.messageImprint = MessageImprint.GetInstance(seq[num++]);
            for (int i = num; i < count; i++)
            {
                if (seq[i] is DerObjectIdentifier)
                {
                    this.tsaPolicy = DerObjectIdentifier.GetInstance(seq[i]);
                }
                else if (seq[i] is DerInteger)
                {
                    this.nonce = DerInteger.GetInstance(seq[i]);
                }
                else if (seq[i] is DerBoolean)
                {
                    this.certReq = DerBoolean.GetInstance(seq[i]);
                }
                else if (seq[i] is Asn1TaggedObject)
                {
                    Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)seq[i];
                    if (asn1TaggedObject.TagNo == 0)
                    {
                        this.extensions = X509Extensions.GetInstance(asn1TaggedObject, false);
                    }
                }
            }
        }
예제 #2
0
        private TstInfo(Asn1Sequence seq)
        {
            IEnumerator enumerator = seq.GetEnumerator();

            enumerator.MoveNext();
            this.version = DerInteger.GetInstance(enumerator.Current);
            enumerator.MoveNext();
            this.tsaPolicyId = DerObjectIdentifier.GetInstance(enumerator.Current);
            enumerator.MoveNext();
            this.messageImprint = MessageImprint.GetInstance(enumerator.Current);
            enumerator.MoveNext();
            this.serialNumber = DerInteger.GetInstance(enumerator.Current);
            enumerator.MoveNext();
            this.genTime  = DerGeneralizedTime.GetInstance(enumerator.Current);
            this.ordering = DerBoolean.False;
            while (enumerator.MoveNext())
            {
                Asn1Object asn1Object = (Asn1Object)enumerator.Current;
                if (asn1Object is Asn1TaggedObject)
                {
                    DerTaggedObject derTaggedObject = (DerTaggedObject)asn1Object;
                    switch (derTaggedObject.TagNo)
                    {
                    case 0:
                        this.tsa = GeneralName.GetInstance(derTaggedObject, true);
                        break;

                    case 1:
                        this.extensions = X509Extensions.GetInstance(derTaggedObject, false);
                        break;

                    default:
                        throw new ArgumentException("Unknown tag value " + derTaggedObject.TagNo);
                    }
                }
                if (asn1Object is DerSequence)
                {
                    this.accuracy = Accuracy.GetInstance(asn1Object);
                }
                if (asn1Object is DerBoolean)
                {
                    this.ordering = DerBoolean.GetInstance(asn1Object);
                }
                if (asn1Object is DerInteger)
                {
                    this.nonce = DerInteger.GetInstance(asn1Object);
                }
            }
        }
예제 #3
0
        private TimeStampReq(
            Asn1Sequence seq)
        {
            int nbObjects = seq.Count;
            int seqStart  = 0;

            // version
            version = DerInteger.GetInstance(seq[seqStart++]);

            // messageImprint
            messageImprint = MessageImprint.GetInstance(seq[seqStart++]);

            for (int opt = seqStart; opt < nbObjects; opt++)
            {
                // tsaPolicy
                if (seq[opt] is DerObjectIdentifier)
                {
                    tsaPolicy = DerObjectIdentifier.GetInstance(seq[opt]);
                }
                // nonce
                else if (seq[opt] is DerInteger)
                {
                    nonce = DerInteger.GetInstance(seq[opt]);
                }
                // certReq
                else if (seq[opt] is DerBoolean)
                {
                    certReq = DerBoolean.GetInstance(seq[opt]);
                }
                // extensions
                else if (seq[opt] is Asn1TaggedObject)
                {
                    Asn1TaggedObject tagged = (Asn1TaggedObject)seq[opt];
                    if (tagged.TagNo == 0)
                    {
                        extensions = X509Extensions.GetInstance(tagged, false);
                    }
                }
            }
        }
예제 #4
0
        private TstInfo(
            Asn1Sequence seq)
        {
            IEnumerator e = seq.GetEnumerator();

            // version
            e.MoveNext();
            version = DerInteger.GetInstance(e.Current);

            // tsaPolicy
            e.MoveNext();
            tsaPolicyId = DerObjectIdentifier.GetInstance(e.Current);

            // messageImprint
            e.MoveNext();
            messageImprint = MessageImprint.GetInstance(e.Current);

            // serialNumber
            e.MoveNext();
            serialNumber = DerInteger.GetInstance(e.Current);

            // genTime
            e.MoveNext();
            genTime = DerGeneralizedTime.GetInstance(e.Current);

            // default for ordering
            ordering = DerBoolean.False;

            while (e.MoveNext())
            {
                Asn1Object o = (Asn1Object)e.Current;

                if (o is Asn1TaggedObject)
                {
                    DerTaggedObject tagged = (DerTaggedObject)o;

                    switch (tagged.TagNo)
                    {
                    case 0:
                        tsa = GeneralName.GetInstance(tagged, true);
                        break;

                    case 1:
                        extensions = X509Extensions.GetInstance(tagged, false);
                        break;

                    default:
                        throw new ArgumentException("Unknown tag value " + tagged.TagNo);
                    }
                }

                if (o is DerSequence)
                {
                    accuracy = Accuracy.GetInstance(o);
                }

                if (o is DerBoolean)
                {
                    ordering = DerBoolean.GetInstance(o);
                }

                if (o is DerInteger)
                {
                    nonce = DerInteger.GetInstance(o);
                }
            }
        }