//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OpenId.Provider { using System; using System.Diagnostics.Contracts; /// /// An interface to provide custom identifiers for users logging into specific relying parties. /// /// /// 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. /// [ContractClass(typeof(IDirectedIdentityIdentifierProviderContract))] public interface IDirectedIdentityIdentifierProvider { /// /// Gets the Identifier to use for the Claimed Identifier and Local Identifier of /// an outgoing positive assertion. /// /// The OP local identifier for the authenticating user. /// The realm of the relying party receiving the assertion. /// /// 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. /// Uri GetIdentifier(Identifier localIdentifier, Realm relyingPartyRealm); /// /// Determines whether a given identifier is the primary (non-PPID) local identifier for some user. /// /// The identifier in question. /// /// true if the given identifier is the valid, unique identifier for some uesr (and NOT a PPID); otherwise, false. /// [Pure] bool IsUserLocalIdentifier(Identifier identifier); } /// /// Contract class for the type. /// [ContractClassFor(typeof(IDirectedIdentityIdentifierProvider))] internal abstract class IDirectedIdentityIdentifierProviderContract : IDirectedIdentityIdentifierProvider { #region IDirectedIdentityIdentifierProvider Members /// /// Gets the Identifier to use for the Claimed Identifier and Local Identifier of /// an outgoing positive assertion. /// /// The OP local identifier for the authenticating user. /// The realm of the relying party receiving the assertion. /// /// 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. /// 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(); } /// /// Determines whether a given identifier is the primary (non-PPID) local identifier for some user. /// /// The identifier in question. /// /// true if the given identifier is the valid, unique identifier for some uesr (and NOT a PPID); otherwise, false. /// bool IDirectedIdentityIdentifierProvider.IsUserLocalIdentifier(Identifier identifier) { Requires.NotNull(identifier, "identifier"); throw new NotImplementedException(); } #endregion } }