forked from Sustainsys/Saml2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUrlResolver.cs
75 lines (67 loc) · 2.02 KB
/
UrlResolver.cs
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
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Kentor.AuthServices.StubIdp
{
public static class UrlResolver
{
private static Uri GetCombinedUrl(string path)
{
var applicationPathSegmentsCount = new Uri(HttpContext.Current.Request.Url, HttpContext.Current.Request.ApplicationPath).Segments.Length;
var namedIdpSegment = HttpContext.Current.Request.Url.Segments.Skip(applicationPathSegmentsCount).FirstOrDefault(); // find guid part if any
if (!string.IsNullOrEmpty(namedIdpSegment) && !namedIdpSegment.EndsWith("/"))
{
namedIdpSegment = namedIdpSegment + "/";
}
Guid parsedGuid;
if (!string.IsNullOrEmpty(namedIdpSegment) && Guid.TryParse(namedIdpSegment.TrimEnd('/'), out parsedGuid))
{
return new Uri(HttpContext.Current.Request.Url, HttpContext.Current.Request.ApplicationPath + namedIdpSegment + path);
}
return new Uri(HttpContext.Current.Request.Url, HttpContext.Current.Request.ApplicationPath + path);
}
public static Uri RootUrl
{
get
{
return GetCombinedUrl("");
}
}
public static Uri SsoServiceUrl
{
get
{
return RootUrl;
}
}
public static Uri MetadataUrl
{
get
{
return GetCombinedUrl("Metadata");
}
}
public static Uri ManageUrl
{
get
{
return GetCombinedUrl("Manage");
}
}
public static Uri ArtifactServiceUrl
{
get
{
return GetCombinedUrl("ArtifactResolve");
}
}
public static Uri LogoutServiceUrl
{
get
{
return GetCombinedUrl("Logout");
}
}
}
}