예제 #1
0
        public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            string str2;
            string str3;

            if (reader == null)
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
            }
            if (samlSerializer == null)
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
            }
            SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
            string         attribute      = reader.GetAttribute(samlDictionary.AuthorityKind, null);

            if (string.IsNullOrEmpty(attribute))
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingAuthorityKindOnRead")));
            }
            string[] strArray = attribute.Split(new char[] { ':' });
            if (strArray.Length > 2)
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingInvalidAuthorityKind")));
            }
            if (strArray.Length == 2)
            {
                str3 = strArray[0];
                str2 = strArray[1];
            }
            else
            {
                str3 = string.Empty;
                str2 = strArray[0];
            }
            string ns = reader.LookupNamespace(str3);

            this.authorityKind = new XmlQualifiedName(str2, ns);
            this.binding       = reader.GetAttribute(samlDictionary.Binding, null);
            if (string.IsNullOrEmpty(this.binding))
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingBindingOnRead")));
            }
            this.location = reader.GetAttribute(samlDictionary.Location, null);
            if (string.IsNullOrEmpty(this.location))
            {
                throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingLocationOnRead")));
            }
            if (reader.IsEmptyElement)
            {
                reader.MoveToContent();
                reader.Read();
            }
            else
            {
                reader.MoveToContent();
                reader.Read();
                reader.ReadEndElement();
            }
        }
예제 #2
0
        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;

            string authKind = reader.GetAttribute(dictionary.AuthorityKind, null);
            if (string.IsNullOrEmpty(authKind))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingAuthorityKindOnRead)));

            string[] authKindParts = authKind.Split(':');
            if (authKindParts.Length > 2)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingInvalidAuthorityKind)));

            string localName;
            string prefix;
            string nameSpace;
            if (authKindParts.Length == 2)
            {
                prefix = authKindParts[0];
                localName = authKindParts[1];
            }
            else
            {
                prefix = String.Empty;
                localName = authKindParts[0];
            }

            nameSpace = reader.LookupNamespace(prefix);

            this.authorityKind = new XmlQualifiedName(localName, nameSpace);

            this.binding = reader.GetAttribute(dictionary.Binding, null);
            if (string.IsNullOrEmpty(this.binding))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingBindingOnRead)));

            this.location = reader.GetAttribute(dictionary.Location, null);
            if (string.IsNullOrEmpty(this.location))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingLocationOnRead)));

            if (reader.IsEmptyElement)
            {
                reader.MoveToContent();
                reader.Read();
            }
            else
            {
                reader.MoveToContent();
                reader.Read();
                reader.ReadEndElement();
            }
        }
 public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager)
 {
     base.SendSide = false;
     if (reader.CanCanonicalize)
     {
         base.CanonicalStream = new MemoryStream();
         reader.StartCanonicalization(base.CanonicalStream, false, null);
     }
     reader.MoveToStartElement(dictionaryManager.XmlSignatureDictionary.SignedInfo, dictionaryManager.XmlSignatureDictionary.Namespace);
     this.prefix = reader.Prefix;
     base.Id     = reader.GetAttribute(dictionaryManager.UtilityDictionary.IdAttribute, null);
     reader.Read();
     base.ReadCanonicalizationMethod(reader, dictionaryManager);
     base.ReadSignatureMethod(reader, dictionaryManager);
     while (reader.IsStartElement(dictionaryManager.XmlSignatureDictionary.Reference, dictionaryManager.XmlSignatureDictionary.Namespace))
     {
         Reference reference = new Reference(dictionaryManager);
         reference.ReadFrom(reader, transformFactory, dictionaryManager);
         this.AddReference(reference);
     }
     reader.ReadEndElement();
     if (reader.CanCanonicalize)
     {
         reader.EndCanonicalization();
     }
     string[] inclusivePrefixes = base.GetInclusivePrefixes();
     if (inclusivePrefixes != null)
     {
         base.CanonicalStream = null;
         this.context         = new Dictionary <string, string>(inclusivePrefixes.Length);
         for (int i = 0; i < inclusivePrefixes.Length; i++)
         {
             this.context.Add(inclusivePrefixes[i], reader.LookupNamespace(inclusivePrefixes[i]));
         }
     }
 }
 public override string LookupNamespace(string prefix)
 {
     return(_reader.LookupNamespace(prefix));
 }