-
Notifications
You must be signed in to change notification settings - Fork 557
/
SspiSecurityTokenProvider.cs
50 lines (42 loc) · 1.85 KB
/
SspiSecurityTokenProvider.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
// 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.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel.Security.Tokens;
using System.Net;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Runtime;
namespace System.ServiceModel.Security
{
public class SspiSecurityTokenProvider : SecurityTokenProvider
{
internal const bool DefaultAllowNtlm = true;
internal const bool DefaultExtractWindowsGroupClaims = true;
internal const bool DefaultAllowUnauthenticatedCallers = false;
private readonly SspiSecurityToken _token;
// client side ctor
public SspiSecurityTokenProvider(NetworkCredential credential, bool allowNtlm, TokenImpersonationLevel impersonationLevel)
{
_token = new SspiSecurityToken(impersonationLevel, allowNtlm, credential);
}
// service side ctor
public SspiSecurityTokenProvider(NetworkCredential credential, bool extractGroupsForWindowsAccounts, bool allowUnauthenticatedCallers)
{
_token = new SspiSecurityToken(credential, extractGroupsForWindowsAccounts, allowUnauthenticatedCallers);
}
protected override SecurityToken GetTokenCore(TimeSpan timeout)
{
return _token;
}
protected override IAsyncResult BeginGetTokenCore(TimeSpan timeout, AsyncCallback callback, object state)
{
return new CompletedAsyncResult<SecurityToken>(GetTokenCore(timeout), callback, state);
}
protected override SecurityToken EndGetTokenCore(IAsyncResult result)
{
return CompletedAsyncResult<SecurityToken>.End(result);
}
}
}