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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
//-----------------------------------------------------------------------
// <copyright file="IDirectedIdentityIdentifierProvider.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.Provider {
using System;
using System.Diagnostics.Contracts;
/// <summary>
/// An interface to provide custom identifiers for users logging into specific relying parties.
/// </summary>
/// <remarks>
/// This interface would allow, for example, the Provider to offer PPIDs to their users,
/// allowing the users to log into RPs without leaving any clue as to their true identity,
/// and preventing multiple RPs from colluding to track user activity across realms.
/// </remarks>
[ContractClass(typeof(IDirectedIdentityIdentifierProviderContract))]
public interface IDirectedIdentityIdentifierProvider {
/// <summary>
/// Gets the Identifier to use for the Claimed Identifier and Local Identifier of
/// an outgoing positive assertion.
/// </summary>
/// <param name="localIdentifier">The OP local identifier for the authenticating user.</param>
/// <param name="relyingPartyRealm">The realm of the relying party receiving the assertion.</param>
/// <returns>
/// A valid, discoverable OpenID Identifier that should be used as the value for the
/// openid.claimed_id and openid.local_id parameters. Must not be null.
/// </returns>
Uri GetIdentifier(Identifier localIdentifier, Realm relyingPartyRealm);
/// <summary>
/// Determines whether a given identifier is the primary (non-PPID) local identifier for some user.
/// </summary>
/// <param name="identifier">The identifier in question.</param>
/// <returns>
/// <c>true</c> if the given identifier is the valid, unique identifier for some uesr (and NOT a PPID); otherwise, <c>false</c>.
/// </returns>
[Pure]
bool IsUserLocalIdentifier(Identifier identifier);
}
/// <summary>
/// Contract class for the <see cref="IDirectedIdentityIdentifierProvider"/> type.
/// </summary>
[ContractClassFor(typeof(IDirectedIdentityIdentifierProvider))]
internal abstract class IDirectedIdentityIdentifierProviderContract : IDirectedIdentityIdentifierProvider {
#region IDirectedIdentityIdentifierProvider Members
/// <summary>
/// Gets the Identifier to use for the Claimed Identifier and Local Identifier of
/// an outgoing positive assertion.
/// </summary>
/// <param name="localIdentifier">The OP local identifier for the authenticating user.</param>
/// <param name="relyingPartyRealm">The realm of the relying party receiving the assertion.</param>
/// <returns>
/// A valid, discoverable OpenID Identifier that should be used as the value for the
/// openid.claimed_id and openid.local_id parameters. Must not be null.
/// </returns>
Uri IDirectedIdentityIdentifierProvider.GetIdentifier(Identifier localIdentifier, Realm relyingPartyRealm) {
Requires.NotNull(localIdentifier, "localIdentifier");
Requires.NotNull(relyingPartyRealm, "relyingPartyRealm");
Requires.True(((IDirectedIdentityIdentifierProvider)this).IsUserLocalIdentifier(localIdentifier), "localIdentifier", OpenIdStrings.ArgumentIsPpidIdentifier);
throw new NotImplementedException();
}
/// <summary>
/// Determines whether a given identifier is the primary (non-PPID) local identifier for some user.
/// </summary>
/// <param name="identifier">The identifier in question.</param>
/// <returns>
/// <c>true</c> if the given identifier is the valid, unique identifier for some uesr (and NOT a PPID); otherwise, <c>false</c>.
/// </returns>
bool IDirectedIdentityIdentifierProvider.IsUserLocalIdentifier(Identifier identifier) {
Requires.NotNull(identifier, "identifier");
throw new NotImplementedException();
}
#endregion
}
}
|