-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added DecryptionResponse.IsClientSideGenerated for decrypting tokens generated from Client Side Token Generation way. They are usually filled but can be null if the token decryption fails and we cannot determine the property. * Added DecryptionStatus.UserOptedOut when a Client Side Token Generated token is decrypted and it indicates the user actually has opted out previously so no valid raw UID2 can be used after this decrypt call. * Created the method interface "DecryptionResponse Decrypt(string token, string expectedDomainName)" for domain name check when decrypting UID2 token, to verify if the expectedDomainName param belongs to the UID2 creator's allowed domain name list (which needs to be registered with UID2 admins). If they don't match then it's a domain name check failure. * new DecryptionStatus.DomainNameCheckFailed status to indicate if domain name check failed * Refactored encryption tests to use a builder for advertiser token * Make it a 5.3.0 version --------- Co-authored-by: Sunny Wu <[email protected]> --------- Co-authored-by: Aleksandrs Ulme <[email protected]> Co-authored-by: mcollins-ttd <[email protected]>
- Loading branch information
1 parent
12ca430
commit c7f19e8
Showing
25 changed files
with
1,210 additions
and
527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
max_line_length=200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace UID2.Client | ||
{ | ||
public struct DecryptionResponse | ||
public readonly struct DecryptionResponse | ||
{ | ||
private readonly DecryptionStatus _status; | ||
private readonly string _uid; | ||
private readonly DateTime? _established; | ||
private readonly int? _siteId; | ||
private readonly int? _siteKeySiteId; | ||
|
||
public DecryptionResponse(DecryptionStatus status, string uid, DateTime? established, int? siteId, int? siteKeySiteId) | ||
public DecryptionResponse(DecryptionStatus status, string uid, DateTime? established, int? siteId, int? siteKeySiteId, bool? isClientSideGenerated = false) | ||
{ | ||
_status = status; | ||
_uid = uid; | ||
_established = established; | ||
_siteId = siteId; | ||
_siteKeySiteId = siteKeySiteId; | ||
Status = status; | ||
Uid = uid; | ||
Established = established; | ||
SiteId = siteId; | ||
SiteKeySiteId = siteKeySiteId; | ||
IsClientSideGenerated = isClientSideGenerated; | ||
} | ||
|
||
public static DecryptionResponse MakeError(DecryptionStatus status) | ||
{ | ||
return new DecryptionResponse(status, null, null, null, null); | ||
return new DecryptionResponse(status, null, null, null, null, null); | ||
} | ||
|
||
public bool Success => _status == DecryptionStatus.Success; | ||
public DecryptionStatus Status => _status; | ||
public string Uid => _uid; | ||
public DateTime? Established => _established; | ||
public int? SiteId => _siteId; | ||
public int? SiteKeySiteId => _siteKeySiteId; | ||
public bool Success => Status == DecryptionStatus.Success; | ||
public DecryptionStatus Status { get; } | ||
public string Uid { get; } | ||
public DateTime? Established { get; } | ||
public int? SiteId { get; } | ||
public int? SiteKeySiteId { get; } | ||
public bool? IsClientSideGenerated { get; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Collections; | ||
|
||
namespace UID2.Client | ||
{ | ||
internal class PrivacyBits | ||
{ | ||
// Bit 0 is legacy and is no longer in use | ||
private const int BitClientSideGenerated = 1; | ||
private const int BitOptedOut = 2; | ||
|
||
private readonly BitArray _bits; | ||
|
||
public PrivacyBits(int bitsAsInt) | ||
{ | ||
_bits = new BitArray(new [] {bitsAsInt}); | ||
} | ||
|
||
public bool IsClientSideGenerated => _bits.Get(BitClientSideGenerated); | ||
|
||
public bool IsOptedOut => _bits.Get(BitOptedOut); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace UID2.Client | ||
{ | ||
internal class Site | ||
{ | ||
private readonly HashSet<string> _domainNames; | ||
|
||
public Site(int id, IEnumerable<string> domainNames) | ||
{ | ||
Id = id; | ||
_domainNames = new HashSet<string>(domainNames, StringComparer.OrdinalIgnoreCase); | ||
} | ||
|
||
public int Id { get; } | ||
|
||
public bool AllowDomainName(string domainName) => _domainNames.Contains(domainName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.