コード例 #1
0
        /// <summary>
        /// Inherited from <see cref="SecurityTokenResolver"/>.
        /// </summary>
        protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key)
        {
            if (keyIdentifierClause == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
            }

            key = null;

            X509RawDataKeyIdentifierClause rawDataClause = keyIdentifierClause as X509RawDataKeyIdentifierClause;

            if (rawDataClause != null)
            {
                key = rawDataClause.CreateKey();
                return(true);
            }

            RsaKeyIdentifierClause rsaClause = keyIdentifierClause as RsaKeyIdentifierClause;

            if (rsaClause != null)
            {
                key = rsaClause.CreateKey();
                return(true);
            }

            if (_wrappedTokenResolver.TryResolveSecurityKey(keyIdentifierClause, out key))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            RsaKeyIdentifierClause that = keyIdentifierClause as RsaKeyIdentifierClause;

            // PreSharp
            #pragma warning suppress 56506
            return(ReferenceEquals(this, that) || (that != null && that.Matches(this.rsa)));
        }
コード例 #3
0
        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            RsaKeyIdentifierClause that = keyIdentifierClause as RsaKeyIdentifierClause;

            // PreSharp Bug: Parameter 'that' to this public method must be validated: A null-dereference can occur here.
            #pragma warning suppress 56506
            return(ReferenceEquals(this, that) || (that != null && that.Matches(this.rsa)));
        }
コード例 #4
0
        private static SecurityKeyIdentifierClause ReadRSAKeyValue(XmlReader reader)
        {
            string rsaXmlElement = reader.ReadInnerXml();

            var rsa = new RSACryptoServiceProvider(); // Do not dispose! Used later when creating key
            rsa.FromXmlString(rsaXmlElement);
            RsaKeyIdentifierClause clause = new RsaKeyIdentifierClause(rsa);

            return clause;
        }
コード例 #5
0
        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            if (keyIdentifierClause == null)
            {
                throw new ArgumentNullException("keyIdentifierClause");
            }
            RsaKeyIdentifierClause rkic =
                keyIdentifierClause as RsaKeyIdentifierClause;

            return(rkic != null && Matches(rkic.Rsa));
        }
コード例 #6
0
        public override bool MatchesKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            RsaKeyIdentifierClause rsaKeyIdentifierClause = keyIdentifierClause as RsaKeyIdentifierClause;

            if (rsaKeyIdentifierClause != null)
            {
                return(rsaKeyIdentifierClause.Matches(this.rsa));
            }

            return(false);
        }
コード例 #7
0
            public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
            {
                RsaKeyIdentifierClause rsaClause = keyIdentifierClause as RsaKeyIdentifierClause;

                writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.KeyValue, NamespaceUri);
                writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.RsaKeyValue, NamespaceUri);
                writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.Modulus, NamespaceUri);
                rsaClause.WriteModulusAsBase64(writer);
                writer.WriteEndElement();
                writer.WriteStartElement(XD.XmlSignatureDictionary.Prefix.Value, XD.XmlSignatureDictionary.Exponent, NamespaceUri);
                rsaClause.WriteExponentAsBase64(writer);
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
コード例 #8
0
        /// <summary>
        /// Inherited from <see cref="SecurityTokenResolver"/>.
        /// </summary>
        protected override bool TryResolveTokenCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityToken token)
        {
            if (keyIdentifierClause == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("keyIdentifierClause");
            }

            token = null;

            //
            // Try raw X509
            //
            X509RawDataKeyIdentifierClause rawDataClause = keyIdentifierClause as X509RawDataKeyIdentifierClause;

            if (rawDataClause != null)
            {
                token = new X509SecurityToken(new X509Certificate2(rawDataClause.GetX509RawData()));
                return(true);
            }

            //
            // Try RSA
            //
            RsaKeyIdentifierClause rsaClause = keyIdentifierClause as RsaKeyIdentifierClause;

            if (rsaClause != null)
            {
                token = new RsaSecurityToken(rsaClause.Rsa);
                return(true);
            }

            if (_wrappedTokenResolver.TryResolveToken(keyIdentifierClause, out token))
            {
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            RsaKeyIdentifierClause objB = keyIdentifierClause as RsaKeyIdentifierClause;

            return(object.ReferenceEquals(this, objB) || ((objB != null) && objB.Matches(this.rsa)));
        }
コード例 #10
0
        public override bool MatchesKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
        {
            RsaKeyIdentifierClause clause = keyIdentifierClause as RsaKeyIdentifierClause;

            return((clause != null) && clause.Matches(this.rsa));
        }