コード例 #1
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?BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList() : BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(list));
        }
コード例 #2
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]);
        }
コード例 #3
0
        private readonly IDictionary table = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateHashtable(); // Hashtable[SignerID, ArrayList[SignerInformation]]

        /**
         * Create a store containing a single SignerInformation object.
         *
         * @param signerInfo the signer information to contain.
         */
        public SignerInformationStore(
            SignerInformation signerInfo)
        {
            this.all = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(1);
            this.all.Add(signerInfo);

            SignerID sid = signerInfo.SignerID;

            table[sid] = all;
        }
コード例 #4
0
 /**
  * Protected constructor. In some cases clients have their own idea about how to encode
  * the signed attributes and calculate the signature. This constructor is to allow developers
  * to deal with that by extending off the class and overridng methods like getSignedAttributes().
  *
  * @param baseInfo the SignerInformation to base this one on.
  */
 protected SignerInformation(SignerInformation baseInfo)
 {
     this.info               = baseInfo.info;
     this.contentType        = baseInfo.contentType;
     this.isCounterSignature = baseInfo.IsCounterSignature;
     this.sid                    = baseInfo.SignerID;
     this.digestAlgorithm        = info.DigestAlgorithm;
     this.signedAttributeSet     = info.AuthenticatedAttributes;
     this.unsignedAttributeSet   = info.UnauthenticatedAttributes;
     this.encryptionAlgorithm    = info.DigestEncryptionAlgorithm;
     this.signature              = info.EncryptedDigest.GetOctets();
     this.content                = baseInfo.content;
     this.resultDigest           = baseInfo.resultDigest;
     this.signedAttributeTable   = baseInfo.signedAttributeTable;
     this.unsignedAttributeTable = baseInfo.unsignedAttributeTable;
 }
コード例 #5
0
        /**
         * Create a store containing a collection of SignerInformation objects.
         *
         * @param signerInfos a collection signer information objects to contain.
         */
        public SignerInformationStore(
            ICollection signerInfos)
        {
            foreach (SignerInformation signer in signerInfos)
            {
                SignerID sid  = signer.SignerID;
                IList    list = (IList)table[sid];

                if (list == null)
                {
                    table[sid] = list = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(1);
                }

                list.Add(signer);
            }

            this.all = BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.CreateArrayList(signerInfos);
        }
コード例 #6
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;
        }
コード例 #7
0
ファイル: SignerId.cs プロジェクト: mustelidae1/utilities
        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) &&
                   BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Platform.Equals(SerialNumber, id.SerialNumber) &&
                   IssuersMatch(Issuer, id.Issuer));
        }