当前位置: 首页>>代码示例>>C#>>正文


C# XmlDictionaryReader.ReadString方法代码示例

本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadString方法的具体用法?C# XmlDictionaryReader.ReadString怎么用?C# XmlDictionaryReader.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlDictionaryReader的用法示例。


在下文中一共展示了XmlDictionaryReader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadFrom

 public static TotalItemsCountEstimate ReadFrom(XmlDictionaryReader reader)
 {
    reader.ReadStartElement(ElementName, ManagementNamespaces.Namespace);
    int value = XmlConvert.ToInt32(reader.ReadString());
    TotalItemsCountEstimate result = new TotalItemsCountEstimate(value);
    reader.ReadEndElement();
    return result;
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:TotalItemsCountEstimate.cs

示例2: ReadAdditionalElements

 protected override void ReadAdditionalElements(XmlDictionaryReader reader)
 {
     if (reader.IsStartElement(System.ServiceModel.Security.ReferenceList.ElementName, EncryptedType.NamespaceUri))
     {
         this.referenceList = new System.ServiceModel.Security.ReferenceList();
         this.referenceList.ReadFrom(reader);
     }
     if (reader.IsStartElement(CarriedKeyElementName, EncryptedType.NamespaceUri))
     {
         reader.ReadStartElement(CarriedKeyElementName, EncryptedType.NamespaceUri);
         this.carriedKeyName = reader.ReadString();
         reader.ReadEndElement();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:EncryptedKey.cs

示例3: ReadKeyIdentifierClauseCore

 public override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlDictionaryReader reader)
 {
     string encryptionMethod = null;
     string carriedKeyName = null;
     SecurityKeyIdentifier encryptingKeyIdentifier = null;
     byte[] encryptedKey = null;
     reader.ReadStartElement(XD.XmlEncryptionDictionary.EncryptedKey, this.NamespaceUri);
     if (reader.IsStartElement(XD.XmlEncryptionDictionary.EncryptionMethod, this.NamespaceUri))
     {
         encryptionMethod = reader.GetAttribute(XD.XmlEncryptionDictionary.AlgorithmAttribute, null);
         bool isEmptyElement = reader.IsEmptyElement;
         reader.ReadStartElement();
         if (!isEmptyElement)
         {
             while (reader.IsStartElement())
             {
                 reader.Skip();
             }
             reader.ReadEndElement();
         }
     }
     if (this.tokenSerializer.CanReadKeyIdentifier(reader))
     {
         encryptingKeyIdentifier = this.tokenSerializer.ReadKeyIdentifier(reader);
     }
     reader.ReadStartElement(XD.XmlEncryptionDictionary.CipherData, this.NamespaceUri);
     reader.ReadStartElement(XD.XmlEncryptionDictionary.CipherValue, this.NamespaceUri);
     encryptedKey = reader.ReadContentAsBase64();
     reader.ReadEndElement();
     reader.ReadEndElement();
     if (reader.IsStartElement(XD.XmlEncryptionDictionary.CarriedKeyName, this.NamespaceUri))
     {
         reader.ReadStartElement();
         carriedKeyName = reader.ReadString();
         reader.ReadEndElement();
     }
     reader.ReadEndElement();
     return new EncryptedKeyIdentifierClause(encryptedKey, encryptionMethod, encryptingKeyIdentifier, carriedKeyName);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:39,代码来源:XmlEncApr2001.cs

示例4: ReadXml

 public override void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
 {
     if (reader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     reader.MoveToContent();
     reader.Read();
     while (reader.IsStartElement())
     {
         if (!reader.IsStartElement(samlDictionary.Audience, samlDictionary.Namespace))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLBadSchema", new object[] { samlDictionary.AudienceRestrictionCondition.Value })));
         }
         reader.MoveToContent();
         string str = reader.ReadString();
         if (string.IsNullOrEmpty(str))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAudienceRestrictionInvalidAudienceValueOnRead")));
         }
         this.audiences.Add(new Uri(str));
         reader.MoveToContent();
         reader.ReadEndElement();
     }
     if (this.audiences.Count == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAudienceRestrictionShouldHaveOneAudienceOnRead")));
     }
     reader.MoveToContent();
     reader.ReadEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:36,代码来源:SamlAudienceRestrictionCondition.cs

示例5: ReadXml

 public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
 {
     if (reader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     if (reader.IsStartElement(samlDictionary.Action, samlDictionary.Namespace))
     {
         this.ns = reader.GetAttribute(samlDictionary.ActionNamespaceAttribute, null);
         reader.MoveToContent();
         this.action = reader.ReadString();
         if (string.IsNullOrEmpty(this.action))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLActionNameRequiredOnRead")));
         }
         reader.MoveToContent();
         reader.ReadEndElement();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:SamlAction.cs

示例6: ReadXml

        public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            this.name = reader.GetAttribute(dictionary.AttributeName, null);
            if (string.IsNullOrEmpty(this.name))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAttributeMissingNameAttributeOnRead)));

            this.nameSpace = reader.GetAttribute(dictionary.AttributeNamespace, null);
            if (string.IsNullOrEmpty(this.nameSpace))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAttributeMissingNamespaceAttributeOnRead)));

            this.claimType = string.IsNullOrEmpty(this.nameSpace) ? this.name : this.nameSpace + "/" + this.name;

            reader.MoveToContent();
            reader.Read();
            while (reader.IsStartElement(dictionary.AttributeValue, dictionary.Namespace))
            {
                // We will load all Attributes as a string value by default.
                string attrValue = reader.ReadString();
                this.attributeValues.Add(attrValue);

                reader.MoveToContent();
                reader.ReadEndElement();
            }

            if (this.attributeValues.Count == 0)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAttributeShouldHaveOneValue)));

            reader.MoveToContent();
            reader.ReadEndElement();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:39,代码来源:SamlAttribute.cs

示例7: ReadKeyIdentifierClauseCore

            public override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore( XmlDictionaryReader reader )
            {
                reader.ReadStartElement( XD.XmlSignatureDictionary.KeyValue, NamespaceUri );
                reader.ReadStartElement( XD.XmlSignatureDictionary.RsaKeyValue, NamespaceUri );
                reader.ReadStartElement( XD.XmlSignatureDictionary.Modulus, NamespaceUri );

                byte[] modulus = Convert.FromBase64String( reader.ReadString() );

                reader.ReadEndElement();
                reader.ReadStartElement( XD.XmlSignatureDictionary.Exponent, NamespaceUri );
                byte[] exponent = Convert.FromBase64String( reader.ReadString() );
                reader.ReadEndElement();
                reader.ReadEndElement();
                reader.ReadEndElement();

                RSA rsa = new RSACryptoServiceProvider();
                RSAParameters rsaParameters = new RSAParameters();
                rsaParameters.Modulus = modulus;
                rsaParameters.Exponent = exponent;
                rsa.ImportParameters( rsaParameters );

                return new RsaKeyIdentifierClause( rsa );
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:23,代码来源:XmlDsigSep2000.cs

示例8: ReadXml

 public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
 {
     if (reader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     reader.MoveToContent();
     reader.Read();
     while (reader.IsStartElement())
     {
         if (!reader.IsStartElement(samlDictionary.AssertionIdReference, samlDictionary.Namespace))
         {
             if (!reader.IsStartElement(samlDictionary.Assertion, samlDictionary.Namespace))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLBadSchema", new object[] { samlDictionary.Evidence.Value })));
             }
             SamlAssertion item = new SamlAssertion();
             item.ReadXml(reader, samlSerializer, keyInfoSerializer, outOfBandTokenResolver);
             this.assertions.Add(item);
         }
         else
         {
             reader.MoveToContent();
             this.assertionIdReferences.Add(reader.ReadString());
             reader.ReadEndElement();
             continue;
         }
     }
     if ((this.assertionIdReferences.Count == 0) && (this.assertions.Count == 0))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLEvidenceShouldHaveOneAssertionOnRead")));
     }
     reader.MoveToContent();
     reader.ReadEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:SamlEvidence.cs

示例9: ReadXml

 public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
 {
     if (reader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
     }
     if (samlSerializer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     this.name = reader.GetAttribute(samlDictionary.AttributeName, null);
     if (string.IsNullOrEmpty(this.name))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAttributeMissingNameAttributeOnRead")));
     }
     this.nameSpace = reader.GetAttribute(samlDictionary.AttributeNamespace, null);
     if (string.IsNullOrEmpty(this.nameSpace))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAttributeMissingNamespaceAttributeOnRead")));
     }
     this.claimType = string.IsNullOrEmpty(this.nameSpace) ? this.name : (this.nameSpace + "/" + this.name);
     reader.MoveToContent();
     reader.Read();
     while (reader.IsStartElement(samlDictionary.AttributeValue, samlDictionary.Namespace))
     {
         string item = reader.ReadString();
         this.attributeValues.Add(item);
         reader.MoveToContent();
         reader.ReadEndElement();
     }
     if (this.attributeValues.Count == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAttributeShouldHaveOneValue")));
     }
     reader.MoveToContent();
     reader.ReadEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:38,代码来源:SamlAttribute.cs

示例10: ReadExtensions

        public override void ReadExtensions( XmlDictionaryReader reader )
        {
            reader.MoveToContent();
            if ( reader.IsStartElement( XmlEncryptionConstants.Elements.ReferenceList, XmlEncryptionConstants.Namespace ) )
            {
                reader.ReadStartElement();

                // could have data or key references.  these are the only two possible elements sec 3.6 xml enc.
                // 3.6 The ReferenceList Element specifies there is a choice. Once one is chosen, it is fixed.
                if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                {
                    while ( reader.IsStartElement() )
                    {
                        if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                        {
                            string dataRef = reader.GetAttribute( XmlEncryptionConstants.Attributes.Uri );
                            if ( !string.IsNullOrEmpty( dataRef ) )
                            {
                                _dataReferences.Add( dataRef );
                            }
                            reader.Skip();
                        }
                        else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                        {
                            throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4189 ) );
                        }
                        else
                        {
                            string xml = reader.ReadOuterXml();
                            if ( DiagnosticUtility.ShouldTraceWarning )
                            {
                                TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8024, reader.Name, reader.NamespaceURI, xml ) );
                            }
                        }
                    }
                }
                else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                {
                    while ( reader.IsStartElement() )
                    {
                        if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                        {
                            string keyRef = reader.GetAttribute( XmlEncryptionConstants.Attributes.Uri );
                            if ( !string.IsNullOrEmpty( keyRef ) )
                            {
                                _keyReferences.Add( keyRef );
                            }
                            reader.Skip();
                        }
                        else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                        {
                            throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4190 ) );
                        }
                        else
                        {
                            string xml = reader.ReadOuterXml();
                            if ( DiagnosticUtility.ShouldTraceWarning )
                            {
                                TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8024, reader.Name, reader.NamespaceURI, xml ) );
                            }
                        }
                    }
                }
                else
                {
                    // there must be at least one reference.
                    throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4191 ) );
                }

                reader.MoveToContent();
                if ( reader.IsStartElement( XmlEncryptionConstants.Elements.CarriedKeyName, XmlEncryptionConstants.Namespace ) )
                {
                    reader.ReadStartElement();
                    _carriedName = reader.ReadString();
                    reader.ReadEndElement();
                }

                // </ReferenceList>
                reader.ReadEndElement();
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:81,代码来源:EncryptedKeyElement.cs

示例11: ReadFrom

 public void ReadFrom(XmlDictionaryReader reader, DictionaryManager dictionaryManager)
 {
     reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.DigestValue, dictionaryManager.XmlSignatureDictionary.Namespace);
     this.prefix = reader.Prefix;
     reader.Read();
     reader.MoveToContent();
     this.digestText = reader.ReadString();
     this.digestValue = Convert.FromBase64String(this.digestText.Trim());
     reader.MoveToContent();
     reader.ReadEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:Reference.cs

示例12: ReadDerivedKeyTokenParameters

            // xml format
            //<DerivedKeyToken wsu:Id="..." wsse:Algorithm="..."> id required, alg optional (curr disallowed)
            //  <SecurityTokenReference>...</SecurityTokenReference> - required
            //  <Properties>...</Properties> - disallowed (optional in spec, but we disallow it)
            // choice begin - (schema requires a choice - we allow neither on read - we always write one)
            //  <Generation>...</Generation> - optional
            //  <Offset>...</Offset> - optional
            // choice end
            //  <Length>...</Length> - optional - default 32 on read (default specified in spec, not in schema - we always write it)
            //  <Label>...</Label> - optional
            //  <Nonce>...</Nonce> - required (optional in spec, but we require it)
            //</DerivedKeyToken>
            public virtual void ReadDerivedKeyTokenParameters(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver, out string id, out string derivationAlgorithm, out string label, out int length, out byte[] nonce, out int offset, out int generation, out SecurityKeyIdentifierClause tokenToDeriveIdentifier, out SecurityToken tokenToDerive)
            {
                if (tokenResolver == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenResolver");
                }

                id = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);

                derivationAlgorithm = reader.GetAttribute(XD.XmlSignatureDictionary.Algorithm, null);
                if (derivationAlgorithm == null)
                {
                    derivationAlgorithm = parent.DerivationAlgorithm;
                }

                reader.ReadStartElement();

                tokenToDeriveIdentifier = null;
                tokenToDerive = null;

                if (reader.IsStartElement(XD.SecurityJan2004Dictionary.SecurityTokenReference, XD.SecurityJan2004Dictionary.Namespace))
                {
                    tokenToDeriveIdentifier = parent.WSSecurityTokenSerializer.ReadKeyIdentifierClause(reader);
                    tokenResolver.TryResolveToken(tokenToDeriveIdentifier, out tokenToDerive);
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyTokenRequiresTokenReference)));
                }

                // no support for properties

                generation = -1;
                if (reader.IsStartElement(parent.SerializerDictionary.Generation, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    generation = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                    if (generation < 0)
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyInvalidGenerationSpecified, generation)));
                }

                offset = -1;
                if (reader.IsStartElement(parent.SerializerDictionary.Offset, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    offset = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                    if (offset < 0)
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.DerivedKeyInvalidOffsetSpecified, offset)));
                }

                length = DerivedKeySecurityToken.DefaultDerivedKeyLength;
                if (reader.IsStartElement(parent.SerializerDictionary.Length, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    length = reader.ReadContentAsInt();
                    reader.ReadEndElement();
                }

                if ((offset == -1) && (generation == -1))
                    offset = 0;

                // verify that the offset is not larger than the max allowed
                DerivedKeySecurityToken.EnsureAcceptableOffset(offset, generation, length, this.maxKeyDerivationOffset);

                label = null;
                if (reader.IsStartElement(parent.SerializerDictionary.Label, parent.SerializerDictionary.Namespace))
                {
                    reader.ReadStartElement();
                    label = reader.ReadString();
                    reader.ReadEndElement();
                }
                if (label != null && label.Length > this.maxKeyDerivationLabelLength)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new MessageSecurityException(SR.GetString(SR.DerivedKeyTokenLabelTooLong, label.Length, this.maxKeyDerivationLabelLength)));
                }

                nonce = null;
                reader.ReadStartElement(parent.SerializerDictionary.Nonce, parent.SerializerDictionary.Namespace);
                nonce = reader.ReadContentAsBase64();
                reader.ReadEndElement();

                if (nonce != null && nonce.Length > this.maxKeyDerivationNonceLength)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new MessageSecurityException(SR.GetString(SR.DerivedKeyTokenNonceTooLong, nonce.Length, this.maxKeyDerivationNonceLength)));
                }

//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:WSSecureConversation.cs

示例13: ReadXml

        public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("samlSerializer");

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            reader.MoveToContent();
            reader.Read();
            if (reader.IsStartElement(dictionary.NameIdentifier, dictionary.Namespace))
            {
                this.nameFormat = reader.GetAttribute(dictionary.NameIdentifierFormat, null);
                this.nameQualifier = reader.GetAttribute(dictionary.NameIdentifierNameQualifier, null);

                reader.MoveToContent();
                this.name = reader.ReadString();

                if (this.name == null)
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLNameIdentifierMissingIdentifierValueOnRead)));

                reader.MoveToContent();
                reader.ReadEndElement();
            }

            if (reader.IsStartElement(dictionary.SubjectConfirmation, dictionary.Namespace))
            {
                reader.MoveToContent();
                reader.Read();

                while (reader.IsStartElement(dictionary.SubjectConfirmationMethod, dictionary.Namespace))
                {
                    string method = reader.ReadString();
                    if (string.IsNullOrEmpty(method))
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLBadSchema, dictionary.SubjectConfirmationMethod.Value)));

                    this.confirmationMethods.Add(method);
                    reader.MoveToContent();
                    reader.ReadEndElement();
                }

                if (this.confirmationMethods.Count == 0)
                {
                    // A SubjectConfirmaton clause should specify at least one 
                    // ConfirmationMethod.
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLSubjectConfirmationClauseMissingConfirmationMethodOnRead)));
                }

                if (reader.IsStartElement(dictionary.SubjectConfirmationData, dictionary.Namespace))
                {
                    reader.MoveToContent();
                    // An Authentication protocol specified in the confirmation method might need this
                    // data. Just store this content value as string.
                    this.confirmationData = reader.ReadString();
                    reader.MoveToContent();
                    reader.ReadEndElement();
                }

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
                if (reader.IsStartElement(samlSerializer.DictionaryManager.XmlSignatureDictionary.KeyInfo, samlSerializer.DictionaryManager.XmlSignatureDictionary.Namespace))
                {
                    XmlDictionaryReader dictionaryReader = XmlDictionaryReader.CreateDictionaryReader(reader);
                    this.securityKeyIdentifier = SamlSerializer.ReadSecurityKeyIdentifier(dictionaryReader, keyInfoSerializer);
                    this.crypto = SamlSerializer.ResolveSecurityKey(this.securityKeyIdentifier, outOfBandTokenResolver);
                    if (this.crypto == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SamlUnableToExtractSubjectKey)));
                    }
                    this.subjectToken = SamlSerializer.ResolveSecurityToken(this.securityKeyIdentifier, outOfBandTokenResolver);
                }


                if ((this.confirmationMethods.Count == 0) && (string.IsNullOrEmpty(name)))
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLSubjectRequiresNameIdentifierOrConfirmationMethodOnRead)));

                reader.MoveToContent();
                reader.ReadEndElement();
            }

            reader.MoveToContent();
            reader.ReadEndElement();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:85,代码来源:SamlSubject.cs

示例14: ReadXml

        public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            // SAML Advice is an optional element and all its child elements are optional 
            // too. So we may have an empty saml:Advice element in the saml token.
            if (reader.IsEmptyElement)
            {
                // Just issue a read for the empty element.
                reader.MoveToContent();
                reader.Read();
                return;
            }

            reader.MoveToContent();
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement(dictionary.AssertionIdReference, dictionary.Namespace))
                {
                    reader.MoveToContent();
                    this.assertionIdReferences.Add(reader.ReadString());
                    reader.MoveToContent();
                    reader.ReadEndElement();
                }
                else if (reader.IsStartElement(dictionary.Assertion, dictionary.Namespace))
                {
                    SamlAssertion assertion = new SamlAssertion();
                    assertion.ReadXml(reader, samlSerializer, keyInfoSerializer, outOfBandTokenResolver);
                    this.assertions.Add(assertion);
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLBadSchema, dictionary.Advice.Value)));
                }
            }

            reader.MoveToContent();
            reader.ReadEndElement();
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:47,代码来源:SamlAdvice.cs

示例15: ReadXml

        public override void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            reader.MoveToContent();
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement(dictionary.Audience, dictionary.Namespace))
                {
                    reader.MoveToContent();
                    string audience = reader.ReadString();
                    if (string.IsNullOrEmpty(audience))
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAudienceRestrictionInvalidAudienceValueOnRead)));

                    this.audiences.Add(new Uri(audience));
                    reader.MoveToContent();
                    reader.ReadEndElement();
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLBadSchema, dictionary.AudienceRestrictionCondition.Value)));
                }
            }

            if (this.audiences.Count == 0)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAudienceRestrictionShouldHaveOneAudienceOnRead)));

            reader.MoveToContent();
            reader.ReadEndElement();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:38,代码来源:SamlAudienceRestrictionCondition.cs


注:本文中的System.Xml.XmlDictionaryReader.ReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。