forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAntiForgeryToken.cs
More file actions
61 lines (54 loc) · 1.57 KB
/
Copy pathAntiForgeryToken.cs
File metadata and controls
61 lines (54 loc) · 1.57 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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace System.Web.Helpers.AntiXsrf
{
// Represents the security token for the Anti-XSRF system.
// The token is a random 128-bit value that correlates the session with the request body.
internal sealed class AntiForgeryToken
{
internal const int SecurityTokenBitLength = 128;
internal const int ClaimUidBitLength = 256;
private string _additionalData;
private BinaryBlob _securityToken;
private string _username;
public string AdditionalData
{
get
{
return _additionalData ?? String.Empty;
}
set
{
_additionalData = value;
}
}
public BinaryBlob ClaimUid { get; set; }
public bool IsSessionToken { get; set; }
public BinaryBlob SecurityToken
{
get
{
if (_securityToken == null)
{
_securityToken = new BinaryBlob(SecurityTokenBitLength);
}
return _securityToken;
}
set
{
_securityToken = value;
}
}
public string Username
{
get
{
return _username ?? String.Empty;
}
set
{
_username = value;
}
}
}
}