-
Notifications
You must be signed in to change notification settings - Fork 557
/
UpnEndpointIdentity.cs
52 lines (44 loc) · 1.7 KB
/
UpnEndpointIdentity.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Security.Principal;
using System.IdentityModel.Claims;
using System.Runtime;
using System.ServiceModel.Diagnostics;
using System.Xml;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace System.ServiceModel
{
public class UpnEndpointIdentity : EndpointIdentity
{
public UpnEndpointIdentity(string upnName)
{
if (upnName == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(upnName));
}
Initialize(Claim.CreateUpnClaim(upnName));
}
internal UpnEndpointIdentity(Claim identity)
{
if (identity == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(identity));
}
if (!identity.ClaimType.Equals(ClaimTypes.Upn))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SRP.Format(SRP.UnrecognizedClaimTypeForIdentity, identity.ClaimType, ClaimTypes.Upn));
}
Initialize(identity);
}
internal override void WriteContentsTo(XmlDictionaryWriter writer)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writer));
}
writer.WriteElementString(XD.AddressingDictionary.Upn, XD.AddressingDictionary.IdentityExtensionNamespace, (string)IdentityClaim.Resource);
}
}
}