blob: 496b14b95a9b6339ceacc10a49b9fc85b1fb0f4b (
plain)
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetOpenAuth.OpenId.Provider;
using DotNetOpenAuth.OpenId;
namespace DotNetOpenAuth.ApplicationBlock.Provider {
public static class AuthenticationRequestExtensions {
/// <summary>
/// Removes all personally identifiable information from the positive assertion.
/// </summary>
/// <remarks>
/// The openid.claimed_id and openid.identity values are hashed.
/// </remarks>
public static void ScrubPersonallyIdentifiableInformation(this IAuthenticationRequest request, Identifier localIdentifier, AnonymousIdentifierProviderBase anonymousIdentifierProvider, bool pairwiseUnique) {
if (request == null) {
throw new ArgumentNullException("request");
}
if (!request.IsDirectedIdentity) {
throw new InvalidOperationException("This operation is supported only under identifier select (directed identity) scenarios.");
}
if (anonymousIdentifierProvider == null) {
throw new ArgumentNullException("anonymousIdentifierProvider");
}
if (localIdentifier == null) {
throw new ArgumentNullException("localIdentifier");
}
// When generating the anonymous identifiers, the openid.identity and openid.claimed_id
// will always end up with matching values.
var anonymousIdentifier = anonymousIdentifierProvider.GetAnonymousIdentifier(localIdentifier, pairwiseUnique ? request.Realm : null);
request.ClaimedIdentifier = anonymousIdentifier;
request.LocalIdentifier = anonymousIdentifier;
}
}
}
|