Exemplo n.º 1
0
        /**
         * Return the first SignerInformation object that matches the
         * passed in selector. Null if there are no matches.
         *
         * @param selector to identify a signer
         * @return a single SignerInformation object. Null if none matches.
         */
        public SignerInformation GetFirstSigner(
            SignerID selector)
        {
            IList list = (IList)table[selector];

            return(list == null ? null : (SignerInformation)list[0]);
        }
Exemplo n.º 2
0
        /**
         * Return possible empty collection with signers matching the passed in SignerID
         *
         * @param selector a signer id to select against.
         * @return a collection of SignerInformation objects.
         */
        public ICollection GetSigners(
            SignerID selector)
        {
            IList list = (IList)table[selector];

            return(list == null?Platform.CreateArrayList() : Platform.CreateArrayList(list));
        }
Exemplo n.º 3
0
        private readonly IDictionary table = Platform.CreateHashtable(); // Hashtable[SignerID, ArrayList[SignerInformation]]

        public SignerInformationStore(
            ICollection signerInfos)
        {
            foreach (SignerInformation signer in signerInfos)
            {
                SignerID sid  = signer.SignerID;
                IList    list = (IList)table[sid];

                if (list == null)
                {
                    table[sid] = list = Platform.CreateArrayList(1);
                }

                list.Add(signer);
            }

            this.all = Platform.CreateArrayList(signerInfos);
        }
Exemplo n.º 4
0
        internal SignerInformation(
            SignerInfo info,
            DerObjectIdentifier contentType,
            CmsProcessable content,
            IDigestCalculator digestCalculator)
        {
            this.info               = info;
            this.sid                = new SignerID();
            this.contentType        = contentType;
            this.isCounterSignature = contentType == null;

            try
            {
                SignerIdentifier s = info.SignerID;

                if (s.IsTagged)
                {
                    Asn1OctetString octs = Asn1OctetString.GetInstance(s.ID);

                    sid.SubjectKeyIdentifier = octs.GetEncoded();
                }
                else
                {
                    Asn1.Cms.IssuerAndSerialNumber iAnds =
                        Asn1.Cms.IssuerAndSerialNumber.GetInstance(s.ID);

                    sid.Issuer       = iAnds.Name;
                    sid.SerialNumber = iAnds.SerialNumber.Value;
                }
            }
            catch (IOException)
            {
                throw new ArgumentException("invalid sid in SignerInfo");
            }

            this.digestAlgorithm      = info.DigestAlgorithm;
            this.signedAttributeSet   = info.AuthenticatedAttributes;
            this.unsignedAttributeSet = info.UnauthenticatedAttributes;
            this.encryptionAlgorithm  = info.DigestEncryptionAlgorithm;
            this.signature            = info.EncryptedDigest.GetOctets();

            this.content          = content;
            this.digestCalculator = digestCalculator;
        }
Exemplo n.º 5
0
        public override bool Equals(
            object obj)
        {
            if (obj == this)
            {
                return(false);
            }

            SignerID id = obj as SignerID;

            if (id == null)
            {
                return(false);
            }

            return(Arrays.AreEqual(SubjectKeyIdentifier, id.SubjectKeyIdentifier) &&
                   Platform.Equals(SerialNumber, id.SerialNumber) &&
                   IssuersMatch(Issuer, id.Issuer));
        }