| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Collections.Specialized; |
| | | 7 | | using System.Net; |
| | | 8 | | using System.Net.WebSockets; |
| | | 9 | | using System.Security.Principal; |
| | | 10 | | using CoreWCF.Runtime; |
| | | 11 | | |
| | | 12 | | namespace CoreWCF.Channels |
| | | 13 | | { |
| | | 14 | | internal class ServiceWebSocketContext : WebSocketContext |
| | | 15 | | { |
| | | 16 | | private readonly WebSocketContext _context; |
| | | 17 | | private readonly IPrincipal _user; |
| | | 18 | | |
| | 11 | 19 | | public ServiceWebSocketContext(WebSocketContext context, IPrincipal user) |
| | | 20 | | { |
| | | 21 | | Fx.Assert(context != null, "context should not be null."); |
| | 11 | 22 | | _context = context; |
| | 11 | 23 | | _user = user; |
| | 11 | 24 | | } |
| | | 25 | | |
| | | 26 | | public override CookieCollection CookieCollection |
| | | 27 | | { |
| | 0 | 28 | | get { return _context.CookieCollection; } |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | public override NameValueCollection Headers |
| | | 32 | | { |
| | 0 | 33 | | get { return _context.Headers; } |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | public override bool IsAuthenticated |
| | | 37 | | { |
| | 0 | 38 | | get { return _user != null ? _user.Identity != null && _user.Identity.IsAuthenticated : _context.IsAuthentic |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | public override bool IsLocal |
| | | 42 | | { |
| | 0 | 43 | | get { return _context.IsLocal; } |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | public override bool IsSecureConnection |
| | | 47 | | { |
| | 0 | 48 | | get { return _context.IsSecureConnection; } |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | public override Uri RequestUri |
| | | 52 | | { |
| | 0 | 53 | | get { return _context.RequestUri; } |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | public override string SecWebSocketKey |
| | | 57 | | { |
| | 0 | 58 | | get { return _context.SecWebSocketKey; } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | public override string Origin |
| | | 62 | | { |
| | 0 | 63 | | get { return _context.Origin; } |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | public override IEnumerable<string> SecWebSocketProtocols |
| | | 67 | | { |
| | 0 | 68 | | get { return _context.SecWebSocketProtocols; } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | public override string SecWebSocketVersion |
| | | 72 | | { |
| | 0 | 73 | | get { return _context.SecWebSocketVersion; } |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | public override IPrincipal User |
| | | 77 | | { |
| | 0 | 78 | | get { return _user ?? _context.User; } |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | public override WebSocket WebSocket |
| | | 82 | | { |
| | 0 | 83 | | get { throw Fx.Exception.AsError(new InvalidOperationException(SR.WebSocketContextWebSocketCannotBeAccessedE |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | } |