diff options
author | Jeff Ames | 2008-08-28 14:41:54 +0000 |
---|---|---|
committer | Jeff Ames | 2008-08-28 14:41:54 +0000 |
commit | 3bf88587277b83c0b6f058fabba7d46a3b5a6a00 (patch) | |
tree | ed4ad9dc27e649a6f52661665fb681984251f480 /OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs | |
parent | Thannk you, Ralphos, for a patch the corrects an improper cast in (diff) | |
download | opensim-SC-3bf88587277b83c0b6f058fabba7d46a3b5a6a00.zip opensim-SC-3bf88587277b83c0b6f058fabba7d46a3b5a6a00.tar.gz opensim-SC-3bf88587277b83c0b6f058fabba7d46a3b5a6a00.tar.bz2 opensim-SC-3bf88587277b83c0b6f058fabba7d46a3b5a6a00.tar.xz |
Update svn properties, formatting cleanup.
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs | 147 |
1 files changed, 73 insertions, 74 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs index 6742402..24e5ada 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RequestData.cs | |||
@@ -23,7 +23,6 @@ | |||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | ||
27 | */ | 26 | */ |
28 | 27 | ||
29 | using System; | 28 | using System; |
@@ -44,14 +43,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
44 | 43 | ||
45 | /// <summary> | 44 | /// <summary> |
46 | /// This class represents the current REST request. It | 45 | /// This class represents the current REST request. It |
47 | /// encapsulates the request/response state and takes care | 46 | /// encapsulates the request/response state and takes care |
48 | /// of response generation without exposing the REST handler | 47 | /// of response generation without exposing the REST handler |
49 | /// to the actual mechanisms involved. | 48 | /// to the actual mechanisms involved. |
50 | /// | 49 | /// |
51 | /// This structure is created on entry to the Handler | 50 | /// This structure is created on entry to the Handler |
52 | /// method and is disposed of upon return. It is part of | 51 | /// method and is disposed of upon return. It is part of |
53 | /// the plug-in infrastructure, rather than the functionally | 52 | /// the plug-in infrastructure, rather than the functionally |
54 | /// specific REST handler, and fundamental changes to | 53 | /// specific REST handler, and fundamental changes to |
55 | /// this should be reflected in the Rest HandlerVersion. The | 54 | /// this should be reflected in the Rest HandlerVersion. The |
56 | /// object is instantiated, and may be extended by, any | 55 | /// object is instantiated, and may be extended by, any |
57 | /// given handler. See the inventory handler for an example | 56 | /// given handler. See the inventory handler for an example |
@@ -84,7 +83,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
84 | // Storing information in body will suppress the return of | 83 | // Storing information in body will suppress the return of |
85 | // statusBody which is only intended to report status on | 84 | // statusBody which is only intended to report status on |
86 | // requests which do not themselves ordinarily generate | 85 | // requests which do not themselves ordinarily generate |
87 | // an informational response. All of this is handled in | 86 | // an informational response. All of this is handled in |
88 | // Respond(). | 87 | // Respond(). |
89 | 88 | ||
90 | internal byte[] buffer = null; | 89 | internal byte[] buffer = null; |
@@ -92,8 +91,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
92 | internal string bodyType = "text/html"; | 91 | internal string bodyType = "text/html"; |
93 | 92 | ||
94 | // The encoding in effect is set to a server default. It may | 93 | // The encoding in effect is set to a server default. It may |
95 | // subsequently be overridden by a Content header. This | 94 | // subsequently be overridden by a Content header. This |
96 | // value is established during construction and is used | 95 | // value is established during construction and is used |
97 | // wherever encoding services are needed. | 96 | // wherever encoding services are needed. |
98 | 97 | ||
99 | internal Encoding encoding = Rest.Encoding; | 98 | internal Encoding encoding = Rest.Encoding; |
@@ -110,7 +109,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
110 | 109 | ||
111 | // The path part of the URI is decomposed. pathNodes | 110 | // The path part of the URI is decomposed. pathNodes |
112 | // is an array of every element in the URI. Parameters | 111 | // is an array of every element in the URI. Parameters |
113 | // is an array that contains only those nodes that | 112 | // is an array that contains only those nodes that |
114 | // are not a part of the authority prefix | 113 | // are not a part of the authority prefix |
115 | 114 | ||
116 | private string[] pathNodes = null; | 115 | private string[] pathNodes = null; |
@@ -118,7 +117,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
118 | private static readonly string[] EmptyPath = { String.Empty }; | 117 | private static readonly string[] EmptyPath = { String.Empty }; |
119 | 118 | ||
120 | // The status code gets set during the course of processing | 119 | // The status code gets set during the course of processing |
121 | // and is the HTTP completion code. The status body is | 120 | // and is the HTTP completion code. The status body is |
122 | // initialized during construction, is appended to during the | 121 | // initialized during construction, is appended to during the |
123 | // course of execution, and is finalized during Respond | 122 | // course of execution, and is finalized during Respond |
124 | // processing. | 123 | // processing. |
@@ -166,7 +165,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
166 | // force selection of a particular authentication model | 165 | // force selection of a particular authentication model |
167 | // (choosing from amongst those supported of course) | 166 | // (choosing from amongst those supported of course) |
168 | // | 167 | // |
169 | 168 | ||
170 | internal bool authenticated = false; | 169 | internal bool authenticated = false; |
171 | internal string scheme = null; | 170 | internal string scheme = null; |
172 | internal string realm = Rest.Realm; | 171 | internal string realm = Rest.Realm; |
@@ -183,7 +182,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
183 | internal string userPass = String.Empty; | 182 | internal string userPass = String.Empty; |
184 | 183 | ||
185 | // Session related tables. These are only needed if QOP is set to "auth-sess" | 184 | // Session related tables. These are only needed if QOP is set to "auth-sess" |
186 | // and for now at least, it is not. Session related authentication is of | 185 | // and for now at least, it is not. Session related authentication is of |
187 | // questionable merit in the context of REST anyway, but it is, arguably, more | 186 | // questionable merit in the context of REST anyway, but it is, arguably, more |
188 | // secure. | 187 | // secure. |
189 | 188 | ||
@@ -199,23 +198,23 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
199 | 198 | ||
200 | private static Regex schema = new Regex("^\\s*(?<scheme>\\w+)\\s*.*", | 199 | private static Regex schema = new Regex("^\\s*(?<scheme>\\w+)\\s*.*", |
201 | RegexOptions.Compiled | RegexOptions.IgnoreCase); | 200 | RegexOptions.Compiled | RegexOptions.IgnoreCase); |
202 | 201 | ||
203 | private static Regex basicParms = new Regex("^\\s*(?:\\w+)\\s+(?<pval>\\S+)\\s*", | 202 | private static Regex basicParms = new Regex("^\\s*(?:\\w+)\\s+(?<pval>\\S+)\\s*", |
204 | RegexOptions.Compiled | RegexOptions.IgnoreCase); | 203 | RegexOptions.Compiled | RegexOptions.IgnoreCase); |
205 | 204 | ||
206 | private static Regex digestParm1 = new Regex("\\s*(?<parm>\\w+)\\s*=\\s*\"(?<pval>[^\"]+)\"", | 205 | private static Regex digestParm1 = new Regex("\\s*(?<parm>\\w+)\\s*=\\s*\"(?<pval>[^\"]+)\"", |
207 | RegexOptions.Compiled | RegexOptions.IgnoreCase); | 206 | RegexOptions.Compiled | RegexOptions.IgnoreCase); |
208 | 207 | ||
209 | private static Regex digestParm2 = new Regex("\\s*(?<parm>\\w+)\\s*=\\s*(?<pval>[^\\p{P}\\s]+)", | 208 | private static Regex digestParm2 = new Regex("\\s*(?<parm>\\w+)\\s*=\\s*(?<pval>[^\\p{P}\\s]+)", |
210 | RegexOptions.Compiled | RegexOptions.IgnoreCase); | 209 | RegexOptions.Compiled | RegexOptions.IgnoreCase); |
211 | 210 | ||
212 | private static Regex reuserPass = new Regex("(?<user>[^:]+):(?<pass>[\\S\\s]*)", | 211 | private static Regex reuserPass = new Regex("(?<user>[^:]+):(?<pass>[\\S\\s]*)", |
213 | RegexOptions.Compiled | RegexOptions.IgnoreCase); | 212 | RegexOptions.Compiled | RegexOptions.IgnoreCase); |
214 | 213 | ||
215 | // For efficiency, we create static instances of these objects | 214 | // For efficiency, we create static instances of these objects |
216 | 215 | ||
217 | private static MD5 md5hash = MD5.Create(); | 216 | private static MD5 md5hash = MD5.Create(); |
218 | 217 | ||
219 | private static StringComparer sc = StringComparer.OrdinalIgnoreCase; | 218 | private static StringComparer sc = StringComparer.OrdinalIgnoreCase; |
220 | 219 | ||
221 | #region properties | 220 | #region properties |
@@ -228,15 +227,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
228 | } | 227 | } |
229 | 228 | ||
230 | /// <summary> | 229 | /// <summary> |
231 | /// Return a boolean indication of whether or no an authenticated user is | 230 | /// Return a boolean indication of whether or no an authenticated user is |
232 | /// associated with this request. This could be wholly integrated, but | 231 | /// associated with this request. This could be wholly integrated, but |
233 | /// that would make authentication mandatory. | 232 | /// that would make authentication mandatory. |
234 | /// </summary> | 233 | /// </summary> |
235 | 234 | ||
236 | internal bool IsAuthenticated | 235 | internal bool IsAuthenticated |
237 | { | 236 | { |
238 | get | 237 | get |
239 | { | 238 | { |
240 | if (Rest.Authenticate) | 239 | if (Rest.Authenticate) |
241 | { | 240 | { |
242 | if (!authenticated) | 241 | if (!authenticated) |
@@ -258,31 +257,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
258 | internal string[] PathNodes | 257 | internal string[] PathNodes |
259 | { | 258 | { |
260 | get | 259 | get |
261 | { | 260 | { |
262 | return pathNodes; | 261 | return pathNodes; |
263 | } | 262 | } |
264 | } | 263 | } |
265 | 264 | ||
266 | /// <summary> | 265 | /// <summary> |
267 | /// Access to all non-prefix 'nodes' in the supplied URI as an | 266 | /// Access to all non-prefix 'nodes' in the supplied URI as an |
268 | /// array of strings. These identify a specific resource that | 267 | /// array of strings. These identify a specific resource that |
269 | /// is managed by the authority (the prefix). | 268 | /// is managed by the authority (the prefix). |
270 | /// </summary> | 269 | /// </summary> |
271 | 270 | ||
272 | internal string[] Parameters | 271 | internal string[] Parameters |
273 | { | 272 | { |
274 | get | 273 | get |
275 | { | 274 | { |
276 | return parameters; | 275 | return parameters; |
277 | } | 276 | } |
278 | } | 277 | } |
279 | 278 | ||
280 | #endregion properties | 279 | #endregion properties |
281 | 280 | ||
282 | #region constructors | 281 | #region constructors |
283 | 282 | ||
284 | // Constructor | 283 | // Constructor |
285 | 284 | ||
286 | internal RequestData(OSHttpRequest p_request, OSHttpResponse p_response, string p_qprefix) | 285 | internal RequestData(OSHttpRequest p_request, OSHttpResponse p_response, string p_qprefix) |
287 | { | 286 | { |
288 | 287 | ||
@@ -315,7 +314,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
315 | /// Realm, domain, etc. | 314 | /// Realm, domain, etc. |
316 | /// | 315 | /// |
317 | /// This method checks to see if the current request is already | 316 | /// This method checks to see if the current request is already |
318 | /// authenticated for this domain. If it is, then it returns | 317 | /// authenticated for this domain. If it is, then it returns |
319 | /// true. If it is not, then it issues a challenge to the client | 318 | /// true. If it is not, then it issues a challenge to the client |
320 | /// and responds negatively to the request. | 319 | /// and responds negatively to the request. |
321 | /// | 320 | /// |
@@ -339,7 +338,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
339 | Rest.Log.DebugFormat("{0} Challenge reason: No authorization data", MsgId); | 338 | Rest.Log.DebugFormat("{0} Challenge reason: No authorization data", MsgId); |
340 | DoChallenge(); | 339 | DoChallenge(); |
341 | } | 340 | } |
342 | 341 | ||
343 | // So, we have authentication data, now we have to check to | 342 | // So, we have authentication data, now we have to check to |
344 | // see what we got and whether or not it is valid for the | 343 | // see what we got and whether or not it is valid for the |
345 | // current domain. To do this we need to interpret the data | 344 | // current domain. To do this we need to interpret the data |
@@ -438,7 +437,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
438 | 437 | ||
439 | // The service provider can force a particular scheme by | 438 | // The service provider can force a particular scheme by |
440 | // assigning a value to scheme. | 439 | // assigning a value to scheme. |
441 | 440 | ||
442 | // Basic authentication is pretty simple. | 441 | // Basic authentication is pretty simple. |
443 | // Just specify the realm in question. | 442 | // Just specify the realm in question. |
444 | 443 | ||
@@ -468,8 +467,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
468 | sbuilder.Append(" "); | 467 | sbuilder.Append(" "); |
469 | 468 | ||
470 | // Specify the effective realm. This should | 469 | // Specify the effective realm. This should |
471 | // never be null if we are uthenticating, as it is required for all | 470 | // never be null if we are uthenticating, as it is required for all |
472 | // authentication schemes. It defines, in conjunction with the | 471 | // authentication schemes. It defines, in conjunction with the |
473 | // absolute URI information, the domain to which the authentication | 472 | // absolute URI information, the domain to which the authentication |
474 | // applies. It is an arbitrary string. I *believe* this allows an | 473 | // applies. It is an arbitrary string. I *believe* this allows an |
475 | // authentication to apply to disjoint resources within the same | 474 | // authentication to apply to disjoint resources within the same |
@@ -485,7 +484,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
485 | } | 484 | } |
486 | 485 | ||
487 | // Share our nonce. This is *uniquely* generated each time a 401 is | 486 | // Share our nonce. This is *uniquely* generated each time a 401 is |
488 | // returned. We do not generate a very sophisticated nonce at the | 487 | // returned. We do not generate a very sophisticated nonce at the |
489 | // moment (it's simply a base64 encoded UUID). | 488 | // moment (it's simply a base64 encoded UUID). |
490 | 489 | ||
491 | if (nonce != null) | 490 | if (nonce != null) |
@@ -532,7 +531,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
532 | sbuilder.Append(Rest.CS_COMMA); | 531 | sbuilder.Append(Rest.CS_COMMA); |
533 | } | 532 | } |
534 | 533 | ||
535 | // Theoretically QOP is optional, but it is required by a compliant | 534 | // Theoretically QOP is optional, but it is required by a compliant |
536 | // with current versions of the scheme. In fact IE requires that QOP | 535 | // with current versions of the scheme. In fact IE requires that QOP |
537 | // be specified and will refuse to authenticate otherwise. | 536 | // be specified and will refuse to authenticate otherwise. |
538 | 537 | ||
@@ -555,7 +554,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
555 | } | 554 | } |
556 | 555 | ||
557 | // We don't know the userid that will be used | 556 | // We don't know the userid that will be used |
558 | // so we cannot make any authentication domain | 557 | // so we cannot make any authentication domain |
559 | // assumptions. So the prefix will determine | 558 | // assumptions. So the prefix will determine |
560 | // this. | 559 | // this. |
561 | 560 | ||
@@ -582,7 +581,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
582 | /// understand this and also expect it to be the first one | 581 | /// understand this and also expect it to be the first one |
583 | /// offered. So we do. | 582 | /// offered. So we do. |
584 | /// OpenSim also needs this, as it is the only scheme that allows | 583 | /// OpenSim also needs this, as it is the only scheme that allows |
585 | /// authentication using the hashed passwords stored in the | 584 | /// authentication using the hashed passwords stored in the |
586 | /// user database. | 585 | /// user database. |
587 | /// </summary> | 586 | /// </summary> |
588 | 587 | ||
@@ -599,7 +598,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
599 | foreach (Match m in matches) | 598 | foreach (Match m in matches) |
600 | { | 599 | { |
601 | authparms.Add("response",m.Groups["pval"].Value); | 600 | authparms.Add("response",m.Groups["pval"].Value); |
602 | Rest.Log.DebugFormat("{0} Parameter matched : {1} = {2}", | 601 | Rest.Log.DebugFormat("{0} Parameter matched : {1} = {2}", |
603 | MsgId, "response", m.Groups["pval"].Value); | 602 | MsgId, "response", m.Groups["pval"].Value); |
604 | } | 603 | } |
605 | 604 | ||
@@ -623,7 +622,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
623 | } | 622 | } |
624 | 623 | ||
625 | /// <summary> | 624 | /// <summary> |
626 | /// This method provides validation in support of the BASIC | 625 | /// This method provides validation in support of the BASIC |
627 | /// authentication method. This is not normaly expected to be | 626 | /// authentication method. This is not normaly expected to be |
628 | /// used, but is included for completeness (and because I tried | 627 | /// used, but is included for completeness (and because I tried |
629 | /// it first). | 628 | /// it first). |
@@ -664,12 +663,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
664 | string last; | 663 | string last; |
665 | 664 | ||
666 | // Distinguish the parts, if necessary | 665 | // Distinguish the parts, if necessary |
667 | 666 | ||
668 | if ((x=user.IndexOf(Rest.C_SPACE)) != -1) | 667 | if ((x=user.IndexOf(Rest.C_SPACE)) != -1) |
669 | { | 668 | { |
670 | first = user.Substring(0,x); | 669 | first = user.Substring(0,x); |
671 | last = user.Substring(x+1); | 670 | last = user.Substring(x+1); |
672 | } | 671 | } |
673 | else | 672 | else |
674 | { | 673 | { |
675 | first = user; | 674 | first = user; |
@@ -685,9 +684,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
685 | 684 | ||
686 | HA1 = HashToString(pass); | 685 | HA1 = HashToString(pass); |
687 | HA1 = HashToString(String.Format("{0}:{1}",HA1,udata.PasswordSalt)); | 686 | HA1 = HashToString(String.Format("{0}:{1}",HA1,udata.PasswordSalt)); |
688 | 687 | ||
689 | return (0 == sc.Compare(HA1, udata.PasswordHash)); | 688 | return (0 == sc.Compare(HA1, udata.PasswordHash)); |
690 | 689 | ||
691 | } | 690 | } |
692 | 691 | ||
693 | #endregion authentication_basic | 692 | #endregion authentication_basic |
@@ -712,7 +711,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
712 | foreach (Match m in matches) | 711 | foreach (Match m in matches) |
713 | { | 712 | { |
714 | authparms.Add(m.Groups["parm"].Value,m.Groups["pval"].Value); | 713 | authparms.Add(m.Groups["parm"].Value,m.Groups["pval"].Value); |
715 | Rest.Log.DebugFormat("{0} String Parameter matched : {1} = {2}", | 714 | Rest.Log.DebugFormat("{0} String Parameter matched : {1} = {2}", |
716 | MsgId, m.Groups["parm"].Value,m.Groups["pval"].Value); | 715 | MsgId, m.Groups["parm"].Value,m.Groups["pval"].Value); |
717 | } | 716 | } |
718 | 717 | ||
@@ -723,7 +722,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
723 | foreach (Match m in matches) | 722 | foreach (Match m in matches) |
724 | { | 723 | { |
725 | authparms.Add(m.Groups["parm"].Value,m.Groups["pval"].Value); | 724 | authparms.Add(m.Groups["parm"].Value,m.Groups["pval"].Value); |
726 | Rest.Log.DebugFormat("{0} Tokenized Parameter matched : {1} = {2}", | 725 | Rest.Log.DebugFormat("{0} Tokenized Parameter matched : {1} = {2}", |
727 | MsgId, m.Groups["parm"].Value,m.Groups["pval"].Value); | 726 | MsgId, m.Groups["parm"].Value,m.Groups["pval"].Value); |
728 | } | 727 | } |
729 | 728 | ||
@@ -760,7 +759,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
760 | 759 | ||
761 | if (!authparms.TryGetValue("nonce", out nonce) || nonce == null) | 760 | if (!authparms.TryGetValue("nonce", out nonce) || nonce == null) |
762 | { | 761 | { |
763 | Rest.Log.WarnFormat("{0} Authentication failed: nonce missing", MsgId); | 762 | Rest.Log.WarnFormat("{0} Authentication failed: nonce missing", MsgId); |
764 | break; | 763 | break; |
765 | } | 764 | } |
766 | 765 | ||
@@ -771,7 +770,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
771 | { | 770 | { |
772 | if (temp != opaque) | 771 | if (temp != opaque) |
773 | { | 772 | { |
774 | Rest.Log.WarnFormat("{0} Authentication failed: bad opaque value", MsgId); | 773 | Rest.Log.WarnFormat("{0} Authentication failed: bad opaque value", MsgId); |
775 | break; | 774 | break; |
776 | } | 775 | } |
777 | } | 776 | } |
@@ -783,7 +782,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
783 | { | 782 | { |
784 | if (temp != algorithm) | 783 | if (temp != algorithm) |
785 | { | 784 | { |
786 | Rest.Log.WarnFormat("{0} Authentication failed: bad algorithm value", MsgId); | 785 | Rest.Log.WarnFormat("{0} Authentication failed: bad algorithm value", MsgId); |
787 | break; | 786 | break; |
788 | } | 787 | } |
789 | } | 788 | } |
@@ -800,7 +799,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
800 | 799 | ||
801 | if (!authparms.ContainsKey("cnonce")) | 800 | if (!authparms.ContainsKey("cnonce")) |
802 | { | 801 | { |
803 | Rest.Log.WarnFormat("{0} Authentication failed: cnonce missing", MsgId); | 802 | Rest.Log.WarnFormat("{0} Authentication failed: cnonce missing", MsgId); |
804 | break; | 803 | break; |
805 | } | 804 | } |
806 | 805 | ||
@@ -808,7 +807,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
808 | 807 | ||
809 | if (!authparms.TryGetValue("nc", out nck) || nck == null) | 808 | if (!authparms.TryGetValue("nc", out nck) || nck == null) |
810 | { | 809 | { |
811 | Rest.Log.WarnFormat("{0} Authentication failed: cnonce counter missing", MsgId); | 810 | Rest.Log.WarnFormat("{0} Authentication failed: cnonce counter missing", MsgId); |
812 | break; | 811 | break; |
813 | } | 812 | } |
814 | 813 | ||
@@ -820,7 +819,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
820 | 819 | ||
821 | if (Rest.Hex2Int(ncl) >= Rest.Hex2Int(nck)) | 820 | if (Rest.Hex2Int(ncl) >= Rest.Hex2Int(nck)) |
822 | { | 821 | { |
823 | Rest.Log.WarnFormat("{0} Authentication failed: bad cnonce counter", MsgId); | 822 | Rest.Log.WarnFormat("{0} Authentication failed: bad cnonce counter", MsgId); |
824 | break; | 823 | break; |
825 | } | 824 | } |
826 | cntable[nonce] = nck; | 825 | cntable[nonce] = nck; |
@@ -840,12 +839,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
840 | // these MUST NOT be present. | 839 | // these MUST NOT be present. |
841 | if (authparms.ContainsKey("cnonce")) | 840 | if (authparms.ContainsKey("cnonce")) |
842 | { | 841 | { |
843 | Rest.Log.WarnFormat("{0} Authentication failed: invalid cnonce", MsgId); | 842 | Rest.Log.WarnFormat("{0} Authentication failed: invalid cnonce", MsgId); |
844 | break; | 843 | break; |
845 | } | 844 | } |
846 | if (authparms.ContainsKey("nc")) | 845 | if (authparms.ContainsKey("nc")) |
847 | { | 846 | { |
848 | Rest.Log.WarnFormat("{0} Authentication failed: invalid cnonce counter[2]", MsgId); | 847 | Rest.Log.WarnFormat("{0} Authentication failed: invalid cnonce counter[2]", MsgId); |
849 | break; | 848 | break; |
850 | } | 849 | } |
851 | } | 850 | } |
@@ -854,7 +853,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
854 | 853 | ||
855 | authenticated = ValidateDigest(userName, nonce, cnonce, nck, authPrefix, response); | 854 | authenticated = ValidateDigest(userName, nonce, cnonce, nck, authPrefix, response); |
856 | 855 | ||
857 | } | 856 | } |
858 | while (false); | 857 | while (false); |
859 | 858 | ||
860 | } | 859 | } |
@@ -864,10 +863,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
864 | /// <summary> | 863 | /// <summary> |
865 | /// This mechanism is used by the digest authentication mechanism | 864 | /// This mechanism is used by the digest authentication mechanism |
866 | /// to return the user's password. In fact, because the OpenSim | 865 | /// to return the user's password. In fact, because the OpenSim |
867 | /// user's passwords are already hashed, and the HTTP mechanism | 866 | /// user's passwords are already hashed, and the HTTP mechanism |
868 | /// does not supply an open password, the hashed passwords cannot | 867 | /// does not supply an open password, the hashed passwords cannot |
869 | /// be used unless the client has used the same salting mechanism | 868 | /// be used unless the client has used the same salting mechanism |
870 | /// to has the password before using it in the authentication | 869 | /// to has the password before using it in the authentication |
871 | /// algorithn. This is not inconceivable... | 870 | /// algorithn. This is not inconceivable... |
872 | /// </summary> | 871 | /// </summary> |
873 | 872 | ||
@@ -879,12 +878,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
879 | string last; | 878 | string last; |
880 | 879 | ||
881 | // Distinguish the parts, if necessary | 880 | // Distinguish the parts, if necessary |
882 | 881 | ||
883 | if ((x=user.IndexOf(Rest.C_SPACE)) != -1) | 882 | if ((x=user.IndexOf(Rest.C_SPACE)) != -1) |
884 | { | 883 | { |
885 | first = user.Substring(0,x); | 884 | first = user.Substring(0,x); |
886 | last = user.Substring(x+1); | 885 | last = user.Substring(x+1); |
887 | } | 886 | } |
888 | else | 887 | else |
889 | { | 888 | { |
890 | first = user; | 889 | first = user; |
@@ -955,7 +954,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
955 | HA2 = HashToString(patt); | 954 | HA2 = HashToString(patt); |
956 | 955 | ||
957 | // Generate Digest | 956 | // Generate Digest |
958 | 957 | ||
959 | if (qop != String.Empty) | 958 | if (qop != String.Empty) |
960 | { | 959 | { |
961 | patt = String.Format("{0}:{1}:{2}:{3}:{4}:{5}", HA1, nonce, nck, cnonce, qop, HA2); | 960 | patt = String.Format("{0}:{1}:{2}:{3}:{4}:{5}", HA1, nonce, nck, cnonce, qop, HA2); |
@@ -1011,7 +1010,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1011 | } | 1010 | } |
1012 | 1011 | ||
1013 | /// <summary> | 1012 | /// <summary> |
1014 | /// Indicate a functionally-dependent conclusion to the | 1013 | /// Indicate a functionally-dependent conclusion to the |
1015 | /// request. See Rest.cs for a list of possible values. | 1014 | /// request. See Rest.cs for a list of possible values. |
1016 | /// </summary> | 1015 | /// </summary> |
1017 | 1016 | ||
@@ -1023,7 +1022,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1023 | /// <summary> | 1022 | /// <summary> |
1024 | /// Indicate that a request should be redirected, using | 1023 | /// Indicate that a request should be redirected, using |
1025 | /// the HTTP completion codes. Permanent and temporary | 1024 | /// the HTTP completion codes. Permanent and temporary |
1026 | /// redirections may be indicated. The supplied URL is | 1025 | /// redirections may be indicated. The supplied URL is |
1027 | /// the new location of the resource. | 1026 | /// the new location of the resource. |
1028 | /// </summary> | 1027 | /// </summary> |
1029 | 1028 | ||
@@ -1057,7 +1056,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1057 | } | 1056 | } |
1058 | 1057 | ||
1059 | /// <summary> | 1058 | /// <summary> |
1060 | /// For the more adventurous. This failure also includes a | 1059 | /// For the more adventurous. This failure also includes a |
1061 | /// specified entity to be appended to the code-related | 1060 | /// specified entity to be appended to the code-related |
1062 | /// status string. | 1061 | /// status string. |
1063 | /// </summary> | 1062 | /// </summary> |
@@ -1101,12 +1100,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1101 | 1100 | ||
1102 | fail = true; | 1101 | fail = true; |
1103 | 1102 | ||
1104 | // Respond to the client's request, tag the response (for the | 1103 | // Respond to the client's request, tag the response (for the |
1105 | // benefit of trace) to indicate the reason. | 1104 | // benefit of trace) to indicate the reason. |
1106 | 1105 | ||
1107 | Respond(String.Format("Failure response: ({0}) : {1}", | 1106 | Respond(String.Format("Failure response: ({0}) : {1}", |
1108 | code, Rest.HttpStatusDesc[code])); | 1107 | code, Rest.HttpStatusDesc[code])); |
1109 | 1108 | ||
1110 | // Finally initialize and the throw a RestException. All of the | 1109 | // Finally initialize and the throw a RestException. All of the |
1111 | // handler's infrastructure knows that this is a "normal" | 1110 | // handler's infrastructure knows that this is a "normal" |
1112 | // completion from a code point-of-view. | 1111 | // completion from a code point-of-view. |
@@ -1129,7 +1128,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1129 | Fail(Rest.HttpStatusCodeNotImplemented, "request rejected (not implemented)"); | 1128 | Fail(Rest.HttpStatusCodeNotImplemented, "request rejected (not implemented)"); |
1130 | } | 1129 | } |
1131 | 1130 | ||
1132 | // This MUST be called by an agent handler before it returns | 1131 | // This MUST be called by an agent handler before it returns |
1133 | // control to Handle, otherwise the request will be ignored. | 1132 | // control to Handle, otherwise the request will be ignored. |
1134 | // This is called implciitly for the REST stream handlers and | 1133 | // This is called implciitly for the REST stream handlers and |
1135 | // is harmless if it is called twice. | 1134 | // is harmless if it is called twice. |
@@ -1222,7 +1221,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1222 | 1221 | ||
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | // Set the status code & description. If nothing has been stored, | 1224 | // Set the status code & description. If nothing has been stored, |
1226 | // we consider that a success. | 1225 | // we consider that a success. |
1227 | 1226 | ||
1228 | if (statusCode == 0) | 1227 | if (statusCode == 0) |
@@ -1236,7 +1235,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1236 | 1235 | ||
1237 | // For a redirect we need to set the relocation header accordingly | 1236 | // For a redirect we need to set the relocation header accordingly |
1238 | 1237 | ||
1239 | if (response.StatusCode == (int) Rest.HttpStatusCodeTemporaryRedirect || | 1238 | if (response.StatusCode == (int) Rest.HttpStatusCodeTemporaryRedirect || |
1240 | response.StatusCode == (int) Rest.HttpStatusCodePermanentRedirect) | 1239 | response.StatusCode == (int) Rest.HttpStatusCodePermanentRedirect) |
1241 | { | 1240 | { |
1242 | Rest.Log.DebugFormat("{0} Re-direct location is {1}", MsgId, redirectLocation); | 1241 | Rest.Log.DebugFormat("{0} Re-direct location is {1}", MsgId, redirectLocation); |
@@ -1252,7 +1251,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1252 | // We've left the setting of handled' until the | 1251 | // We've left the setting of handled' until the |
1253 | // last minute because the header settings included | 1252 | // last minute because the header settings included |
1254 | // above are pretty harmless. But everything from | 1253 | // above are pretty harmless. But everything from |
1255 | // here on down probably leaves the response | 1254 | // here on down probably leaves the response |
1256 | // element unusable by anyone else. | 1255 | // element unusable by anyone else. |
1257 | 1256 | ||
1258 | handled = true; | 1257 | handled = true; |
@@ -1267,7 +1266,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1267 | 1266 | ||
1268 | if (buffer != null && buffer.Length != 0) | 1267 | if (buffer != null && buffer.Length != 0) |
1269 | { | 1268 | { |
1270 | Rest.Log.DebugFormat("{0} Entity buffer, length = {1} : <{2}>", | 1269 | Rest.Log.DebugFormat("{0} Entity buffer, length = {1} : <{2}>", |
1271 | MsgId, buffer.Length, encoding.GetString(buffer)); | 1270 | MsgId, buffer.Length, encoding.GetString(buffer)); |
1272 | response.OutputStream.Write(buffer, 0, buffer.Length); | 1271 | response.OutputStream.Write(buffer, 0, buffer.Length); |
1273 | } | 1272 | } |
@@ -1295,11 +1294,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1295 | { | 1294 | { |
1296 | if (Rest.DEBUG) | 1295 | if (Rest.DEBUG) |
1297 | { | 1296 | { |
1298 | Rest.Log.DebugFormat("{0} Adding header: <{1}: {2}>", | 1297 | Rest.Log.DebugFormat("{0} Adding header: <{1}: {2}>", |
1299 | MsgId, hdr, data); | 1298 | MsgId, hdr, data); |
1300 | if (response.Headers.Get(hdr) != null) | 1299 | if (response.Headers.Get(hdr) != null) |
1301 | { | 1300 | { |
1302 | Rest.Log.DebugFormat("{0} Multipe {1} headers will be generated>", | 1301 | Rest.Log.DebugFormat("{0} Multipe {1} headers will be generated>", |
1303 | MsgId, hdr); | 1302 | MsgId, hdr); |
1304 | } | 1303 | } |
1305 | } | 1304 | } |
@@ -1313,7 +1312,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1313 | Rest.Log.DebugFormat("{0} Removing header: <{1}>", MsgId, hdr); | 1312 | Rest.Log.DebugFormat("{0} Removing header: <{1}>", MsgId, hdr); |
1314 | if (response.Headers.Get(hdr) == null) | 1313 | if (response.Headers.Get(hdr) == null) |
1315 | { | 1314 | { |
1316 | Rest.Log.DebugFormat("{0} No such header existed", | 1315 | Rest.Log.DebugFormat("{0} No such header existed", |
1317 | MsgId, hdr); | 1316 | MsgId, hdr); |
1318 | } | 1317 | } |
1319 | } | 1318 | } |
@@ -1326,7 +1325,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1326 | { | 1325 | { |
1327 | for (int i=0;i<response.Headers.Count;i++) | 1326 | for (int i=0;i<response.Headers.Count;i++) |
1328 | { | 1327 | { |
1329 | Rest.Log.DebugFormat("{0} Header[{1}] : {2}", MsgId, i, | 1328 | Rest.Log.DebugFormat("{0} Header[{1}] : {2}", MsgId, i, |
1330 | response.Headers.Get(i)); | 1329 | response.Headers.Get(i)); |
1331 | } | 1330 | } |
1332 | } | 1331 | } |
@@ -1404,7 +1403,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1404 | // If we succeeded in getting a path, perform any | 1403 | // If we succeeded in getting a path, perform any |
1405 | // additional pre-processing required. | 1404 | // additional pre-processing required. |
1406 | 1405 | ||
1407 | if (path != null) | 1406 | if (path != null) |
1408 | { | 1407 | { |
1409 | if (Rest.ExtendedEscape) | 1408 | if (Rest.ExtendedEscape) |
1410 | { | 1409 | { |
@@ -1442,14 +1441,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1442 | { | 1441 | { |
1443 | parameters = new string[0]; | 1442 | parameters = new string[0]; |
1444 | } | 1443 | } |
1445 | 1444 | ||
1446 | // Generate a debug list of the decoded parameters | 1445 | // Generate a debug list of the decoded parameters |
1447 | 1446 | ||
1448 | if (Rest.DEBUG && prfxlen < path.Length-1) | 1447 | if (Rest.DEBUG && prfxlen < path.Length-1) |
1449 | { | 1448 | { |
1450 | Rest.Log.DebugFormat("{0} URI: Parameters: {1}", MsgId, path.Substring(prfxlen)); | 1449 | Rest.Log.DebugFormat("{0} URI: Parameters: {1}", MsgId, path.Substring(prfxlen)); |
1451 | for (int i = 0; i < parameters.Length; i++) | 1450 | for (int i = 0; i < parameters.Length; i++) |
1452 | { | 1451 | { |
1453 | Rest.Log.DebugFormat("{0} Parameter[{1}]: {2}", MsgId, i, parameters[i]); | 1452 | Rest.Log.DebugFormat("{0} Parameter[{1}]: {2}", MsgId, i, parameters[i]); |
1454 | } | 1453 | } |
1455 | } | 1454 | } |