forked from i8beef/SAML2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractEndpointHandler.cs
More file actions
72 lines (64 loc) · 2.54 KB
/
AbstractEndpointHandler.cs
File metadata and controls
72 lines (64 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.Reflection;
using System.Web;
using System.Web.SessionState;
using SAML2.Logging;
using SAML2.State;
namespace SAML2.Protocol
{
/// <summary>
/// A base class for all endpoint handlers.
/// </summary>
public abstract class AbstractEndpointHandler : IHttpHandler, IRequiresSessionState
{
/// <summary>
/// Logger instance.
/// </summary>
protected static readonly IInternalLogger Logger = LoggerProvider.LoggerFor(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// State Service instance
/// </summary>
protected static readonly IInternalStateService StateService = StateServiceProvider.StateServiceFor(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Gets or sets the redirect URL.
/// </summary>
/// <value>The redirect URL.</value>
public string RedirectUrl { get; set; }
#region IHttpHandler Members
/// <summary>
/// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler"/> instance.
/// </summary>
/// <value></value>
/// <returns>true if the <see cref="T:System.Web.IHttpHandler"/> instance is reusable; otherwise, false.</returns>
public bool IsReusable
{
get { return true; }
}
/// <summary>
/// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
/// </summary>
/// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
public abstract void ProcessRequest(HttpContext context);
#endregion
/// <summary>
/// Redirects the user.
/// </summary>
/// <param name="context">The context.</param>
public void DoRedirect(HttpContext context)
{
var redirectUrl = StateService.Get<string>("RedirectUrl");
if (!string.IsNullOrEmpty(redirectUrl))
{
StateService.Remove("RedirectUrl");
context.Response.Redirect(redirectUrl);
}
else if (string.IsNullOrEmpty(RedirectUrl))
{
context.Response.Redirect("~/");
}
else
{
context.Response.Redirect(RedirectUrl);
}
}
}
}