**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Microsoft.Web.Services.Timestamp / TimestampInputFilter.cs
blob2d8d4261dff490bf2daccbd0ed3d06545f30d501
1 //
2 // TimestampInputFilter.cs: Timestamp SOAP Input Filter
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
9 // Licensed under MIT X11 (see LICENSE) with this specific addition:
11 // “This source code may incorporate intellectual property owned by Microsoft
12 // Corporation. Our provision of this source code does not include any licenses
13 // or any other rights to you under any Microsoft intellectual property. If you
14 // would like a license from Microsoft (e.g. rebrand, redistribute), you need
15 // to contact Microsoft directly.”
18 using System;
19 using System.Xml;
21 namespace Microsoft.Web.Services.Timestamp {
23 // Reference:
24 // 1. Inside the Web Services Enhancements Pipeline
25 // http://msdn.microsoft.com/library/en-us/dnwebsrv/html/insidewsepipe.asp
27 public class TimestampInputFilter : SoapInputFilter {
29 public TimestampInputFilter () {}
31 public override void ProcessMessage (SoapEnvelope envelope)
33 if (envelope == null)
34 throw new ArgumentNullException ("envelope");
36 if (envelope.Header != null) {
37 XmlNodeList xnl = envelope.Header.GetElementsByTagName (WSTimestamp.ElementNames.Timestamp, WSTimestamp.NamespaceURI);
38 if ((xnl != null) && (xnl.Count > 0)) {
39 XmlElement xel = (XmlElement) xnl [0];
40 envelope.Context.Timestamp.LoadXml (xel);
41 if (envelope.Context.Timestamp.Expires < DateTime.UtcNow)
42 throw new TimestampFault ("Message Expired", null);
43 envelope.Header.RemoveChild (xel);