public virtual object ReadObject(XmlDictionaryReader reader) { return(ReadObjectHandleExceptions(new XmlReaderDelegator(reader), true /*verifyObjectName*/)); }
public abstract object ReadObject(XmlDictionaryReader reader, bool verifyObjectName);
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))); }
public void ReadFrom(XmlDictionaryReader reader) { ReadFrom(reader, 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; }
public override bool CanReadTokenCore(XmlDictionaryReader reader) { return(false); }
public virtual object ReadObject(XmlDictionaryReader reader);
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))); }
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { return(ReadObjectHandleExceptions(new JsonReaderDelegator(reader, this.DateTimeFormat), verifyObjectName)); }
public override bool IsStartObject(XmlDictionaryReader reader) { return(_serializer.IsStartObject(reader)); }
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { return(_serializer.ReadObject(reader, verifyObjectName)); }
public override object ReadObject(XmlDictionaryReader reader) { return(_serializer.ReadObject(reader)); }
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName);
public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); }
protected virtual void WriteTextNode(XmlDictionaryReader reader, bool isAttribute);
private Task ReadItemAsync(XmlReaderWrapper reader) { SetItem(CreateItemInstance()); return(_feedSerializer.ReadItemFromAsync(XmlReaderWrapper.CreateFromReader(XmlDictionaryReader.CreateDictionaryReader(reader)), this.Item)); }
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); }
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); } } } }
public void ReadFrom(XmlReader reader, long maxBufferSize) { ReadFrom(XmlDictionaryReader.CreateDictionaryReader(reader), maxBufferSize); }
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); }
protected override void ReadAdditionalAttributes(XmlDictionaryReader reader) { Recipient = reader.GetAttribute(RecipientAttribute, null); }
public object ReadObject(XmlDictionaryReader reader) { return(ReadObject(reader, Serializer)); }
protected override void ReadCipherData(XmlDictionaryReader reader, long maxBufferSize) { _wrappedKey = SecurityUtils.ReadContentAsBase64(reader, maxBufferSize); }
public override bool IsStartObject(XmlDictionaryReader reader) { throw new NotImplementedException(); }
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(); }
public virtual object ReadObject(XmlReader reader, bool verifyObjectName) { CheckNull(reader, "reader"); return(ReadObject(XmlDictionaryReader.CreateDictionaryReader(reader), verifyObjectName)); }
protected virtual void ReadAdditionalAttributes(XmlDictionaryReader reader) { }
public override bool IsStartObject(XmlDictionaryReader reader);
protected virtual void ReadAdditionalElements(XmlDictionaryReader reader) { }
public virtual void WriteNode(XmlDictionaryReader reader, bool defattr);
protected abstract void ReadCipherData(XmlDictionaryReader reader);
public abstract bool IsStartObject(XmlDictionaryReader reader);
protected abstract void ReadCipherData(XmlDictionaryReader reader, long maxBufferSize);
public XmlReaderBodyWriter(XmlDictionaryReader reader) : base(false) { reader.MoveToContent(); this.reader = reader; }