public virtual object ReadObject(XmlDictionaryReader reader)
 {
     return(ReadObjectHandleExceptions(new XmlReaderDelegator(reader), true /*verifyObjectName*/));
 }
 public abstract object ReadObject(XmlDictionaryReader reader, bool verifyObjectName);
Esempio n. 3
0
 protected override void ReadCipherData(XmlDictionaryReader reader)
 {
     _wrappedKey = reader.ReadContentAsBase64();
 }
 public virtual object ReadObject(Stream stream)
 {
     CheckNull(stream, "stream");
     return(ReadObject(XmlDictionaryReader.CreateTextReader(stream, XmlDictionaryReaderQuotas.Max)));
 }
Esempio n. 5
0
 public void ReadFrom(XmlDictionaryReader reader)
 {
     ReadFrom(reader, 0);
 }
Esempio n. 6
0
        public void ReadFrom(XmlDictionaryReader reader, long maxBufferSize)
        {
            ValidateReadState();
            reader.MoveToStartElement(OpeningElementName, NamespaceUri);
            Encoding = reader.GetAttribute(EncodingAttribute, null);
            Id       = reader.GetAttribute(XD.XmlEncryptionDictionary.Id, null) ?? SecurityUniqueId.Create().Value;
            WsuId    = reader.GetAttribute(XD.XmlEncryptionDictionary.Id, XD.UtilityDictionary.Namespace) ?? SecurityUniqueId.Create().Value;
            MimeType = reader.GetAttribute(MimeTypeAttribute, null);
            Type     = reader.GetAttribute(TypeAttribute, null);
            ReadAdditionalAttributes(reader);
            reader.Read();

            if (reader.IsStartElement(EncryptionMethodElement.ElementName, NamespaceUri))
            {
                _encryptionMethod.ReadFrom(reader);
            }

            if (_tokenSerializer.CanReadKeyIdentifier(reader))
            {
                XmlElement          xml = null;
                XmlDictionaryReader localReader;

                if (ShouldReadXmlReferenceKeyInfoClause)
                {
                    // We create the dom only when needed to not affect perf.
                    XmlDocument doc = new XmlDocument();
                    xml         = (doc.ReadNode(reader) as XmlElement);
                    localReader = XmlDictionaryReader.CreateDictionaryReader(new XmlNodeReader(xml));
                }
                else
                {
                    localReader = reader;
                }

                try
                {
                    KeyIdentifier = _tokenSerializer.ReadKeyIdentifier(localReader);
                }
                catch (Exception e)
                {
                    // In case when the issued token ( custom token) is used as an initiator token; we will fail
                    // to read the keyIdentifierClause using the plugged in default serializer. So We need to try to read it as an XmlReferencekeyIdentifierClause
                    // if it is the client side.

                    if (Fx.IsFatal(e) || !ShouldReadXmlReferenceKeyInfoClause)
                    {
                        throw;
                    }

                    KeyIdentifier = ReadGenericXmlSecurityKeyIdentifier(XmlDictionaryReader.CreateDictionaryReader(new XmlNodeReader(xml)), e);
                }
            }

            reader.ReadStartElement(CipherDataElementName, NamespaceUri);
            reader.ReadStartElement(CipherValueElementName, NamespaceUri);
            if (maxBufferSize == 0)
            {
                ReadCipherData(reader);
            }
            else
            {
                ReadCipherData(reader, maxBufferSize);
            }

            reader.ReadEndElement(); // CipherValue
            reader.ReadEndElement(); // CipherData

            ReadAdditionalElements(reader);
            reader.ReadEndElement(); // OpeningElementName
            State = EncryptionState.Read;
        }
Esempio n. 7
0
 public override bool CanReadTokenCore(XmlDictionaryReader reader)
 {
     return(false);
 }
 public virtual object ReadObject(XmlDictionaryReader reader);
Esempio n. 9
0
 public override bool IsStartObject(XmlDictionaryReader reader)
 {
     // No need to pass in DateTimeFormat to JsonReaderDelegator: no DateTimes will be read in IsStartObject
     return(IsStartObjectHandleExceptions(new JsonReaderDelegator(reader)));
 }
Esempio n. 10
0
 public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
 {
     return(ReadObjectHandleExceptions(new JsonReaderDelegator(reader, this.DateTimeFormat), verifyObjectName));
 }
Esempio n. 11
0
 public override bool IsStartObject(XmlDictionaryReader reader)
 {
     return(_serializer.IsStartObject(reader));
 }
Esempio n. 12
0
 public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
 {
     return(_serializer.ReadObject(reader, verifyObjectName));
 }
Esempio n. 13
0
 public override object ReadObject(XmlDictionaryReader reader)
 {
     return(_serializer.ReadObject(reader));
 }
 public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName);
Esempio n. 15
0
 public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)
 {
     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
 }
 protected virtual void WriteTextNode(XmlDictionaryReader reader, bool isAttribute);
Esempio n. 17
0
 private Task ReadItemAsync(XmlReaderWrapper reader)
 {
     SetItem(CreateItemInstance());
     return(_feedSerializer.ReadItemFromAsync(XmlReaderWrapper.CreateFromReader(XmlDictionaryReader.CreateDictionaryReader(reader)), this.Item));
 }
Esempio n. 18
0
        protected FaultException CreateFaultException(MessageFault messageFault, string action,
                                                      object detailObj, Type detailType, XmlDictionaryReader detailReader)
        {
            if (!detailReader.EOF)
            {
                detailReader.MoveToContent();
                if (detailReader.NodeType != XmlNodeType.EndElement && !detailReader.EOF)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.ExtraContentIsPresentInFaultDetail));
                }
            }
            bool isDetailObjectValid;

            if (detailObj == null)
            {
                isDetailObjectValid = !detailType.GetTypeInfo().IsValueType;
            }
            else
            {
                isDetailObjectValid = detailType.IsAssignableFrom(detailObj.GetType());
            }
            if (isDetailObjectValid)
            {
                Type knownFaultType = typeof(FaultException <>).MakeGenericType(detailType);
                return((FaultException)Activator.CreateInstance(knownFaultType,
                                                                detailObj,
                                                                messageFault.Reason,
                                                                messageFault.Code,
                                                                action));
            }
            return(null);
        }
Esempio n. 19
0
        protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest)
        {
            MessageInfo messageInfo = isRequest ? requestMessageInfo : replyMessageInfo;

            if (!messageInfo.AnyHeaders)
            {
                return;
            }

            MessageHeaders headers = message.Headers;

            KeyValuePair <Type, ArrayList>[] multipleHeaderValues = null;
            ArrayList elementList = null;

            if (messageInfo.UnknownHeaderDescription != null)
            {
                elementList = new ArrayList();
            }

            for (int i = 0; i < headers.Count; i++)
            {
                MessageHeaderInfo        header            = headers[i];
                MessageHeaderDescription headerDescription = messageInfo.HeaderDescriptionTable.Get(header.Name, header.Namespace);
                if (headerDescription != null)
                {
                    if (header.MustUnderstand)
                    {
                        headers.UnderstoodHeaders.Add(header);
                    }

                    object item = null;
                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i);
                    try
                    {
                        object dataValue = DeserializeHeaderContents(headerReader, messageDescription, headerDescription);
                        if (headerDescription.TypedHeader)
                        {
                            item = TypedHeaderManager.Create(headerDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }
                        else
                        {
                            item = dataValue;
                        }
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }

                    if (headerDescription.Multiple)
                    {
                        if (multipleHeaderValues == null)
                        {
                            multipleHeaderValues = new KeyValuePair <Type, ArrayList> [parameters.Length];
                        }

                        if (multipleHeaderValues[headerDescription.Index].Key == null)
                        {
                            multipleHeaderValues[headerDescription.Index] = new KeyValuePair <Type, ArrayList>(headerDescription.TypedHeader ? TypedHeaderManager.GetMessageHeaderType(headerDescription.Type) : headerDescription.Type, new ArrayList());
                        }
                        multipleHeaderValues[headerDescription.Index].Value.Add(item);
                    }
                    else
                    {
                        parameters[headerDescription.Index] = item;
                    }
                }
                else if (messageInfo.UnknownHeaderDescription != null)
                {
                    MessageHeaderDescription unknownHeaderDescription = messageInfo.UnknownHeaderDescription;
                    XmlDictionaryReader      headerReader             = headers.GetReaderAtHeader(i);
                    try
                    {
                        XmlDocument doc       = new XmlDocument();
                        object      dataValue = doc.ReadNode(headerReader);
                        if (dataValue != null && unknownHeaderDescription.TypedHeader)
                        {
                            dataValue = TypedHeaderManager.Create(unknownHeaderDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }

                        elementList.Add(dataValue);
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }
                }
            }
            if (multipleHeaderValues != null)
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (multipleHeaderValues[i].Key != null)
                    {
                        parameters[i] = multipleHeaderValues[i].Value.ToArray(multipleHeaderValues[i].Key);
                    }
                }
            }
        }
Esempio n. 20
0
 public void ReadFrom(XmlReader reader, long maxBufferSize)
 {
     ReadFrom(XmlDictionaryReader.CreateDictionaryReader(reader), maxBufferSize);
 }
Esempio n. 21
0
        protected override object DeserializeBody(XmlDictionaryReader reader, MessageVersion version, string action, MessageDescription messageDescription, object[] parameters, bool isRequest)
        {
            if (reader == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(reader)));
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(parameters)));
            }

            MessageInfo messageInfo;

            if (isRequest)
            {
                messageInfo = requestMessageInfo;
            }
            else
            {
                messageInfo = replyMessageInfo;
            }

            if (messageInfo.WrapperName != null)
            {
                if (!reader.IsStartElement(messageInfo.WrapperName, messageInfo.WrapperNamespace))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.Format(SR.SFxInvalidMessageBody, messageInfo.WrapperName, messageInfo.WrapperNamespace, reader.NodeType, reader.Name, reader.NamespaceURI)));
                }

                bool isEmptyElement = reader.IsEmptyElement;
                reader.Read();
                if (isEmptyElement)
                {
                    return(null);
                }
            }
            object returnValue = null;

            if (messageInfo.ReturnPart != null)
            {
                while (true)
                {
                    PartInfo part = messageInfo.ReturnPart;
                    if (part.Serializer.IsStartObject(reader))
                    {
                        returnValue = DeserializeParameter(reader, part, isRequest);
                        break;
                    }
                    if (!reader.IsStartElement())
                    {
                        break;
                    }

                    OperationFormatter.TraceAndSkipElement(reader);
                }
            }
            DeserializeParameters(reader, messageInfo.BodyParts, parameters, isRequest);
            if (messageInfo.WrapperName != null)
            {
                reader.ReadEndElement();
            }

            return(returnValue);
        }
Esempio n. 22
0
 protected override void ReadAdditionalAttributes(XmlDictionaryReader reader)
 {
     Recipient = reader.GetAttribute(RecipientAttribute, null);
 }
Esempio n. 23
0
 public object ReadObject(XmlDictionaryReader reader)
 {
     return(ReadObject(reader, Serializer));
 }
Esempio n. 24
0
 protected override void ReadCipherData(XmlDictionaryReader reader, long maxBufferSize)
 {
     _wrappedKey = SecurityUtils.ReadContentAsBase64(reader, maxBufferSize);
 }
 public override bool IsStartObject(XmlDictionaryReader reader)
 {
     throw new NotImplementedException();
 }
Esempio n. 26
0
 public virtual object ReadObject(XmlReader reader)
 {
     CheckNull(reader, "reader");
     return(ReadObject(XmlDictionaryReader.CreateDictionaryReader(reader)));
 }
 public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
 {
     throw new NotImplementedException();
 }
Esempio n. 28
0
 public virtual object ReadObject(XmlReader reader, bool verifyObjectName)
 {
     CheckNull(reader, "reader");
     return(ReadObject(XmlDictionaryReader.CreateDictionaryReader(reader), verifyObjectName));
 }
Esempio n. 29
0
 protected virtual void ReadAdditionalAttributes(XmlDictionaryReader reader)
 {
 }
 public override bool IsStartObject(XmlDictionaryReader reader);
Esempio n. 31
0
 protected virtual void ReadAdditionalElements(XmlDictionaryReader reader)
 {
 }
 public virtual void WriteNode(XmlDictionaryReader reader, bool defattr);
Esempio n. 33
0
 protected abstract void ReadCipherData(XmlDictionaryReader reader);
 public abstract bool IsStartObject(XmlDictionaryReader reader);
Esempio n. 35
0
 protected abstract void ReadCipherData(XmlDictionaryReader reader, long maxBufferSize);
 public abstract object ReadObject(XmlDictionaryReader reader, bool verifyObjectName);
Esempio n. 37
0
 public XmlReaderBodyWriter(XmlDictionaryReader reader)
     : base(false)
 {
     reader.MoveToContent();
     this.reader = reader;
 }