//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenId.RelyingParty {
using System;
using System.Diagnostics.Contracts;
///
/// Stores s for lookup by their handle, keeping
/// associations separated by a given OP Endpoint.
///
///
/// Expired associations should be periodically cleared out of an association store.
/// This should be done frequently enough to avoid a memory leak, but sparingly enough
/// to not be a performance drain. Because this balance can vary by host, it is the
/// responsibility of the host to initiate this cleaning.
///
[ContractClass(typeof(IRelyingPartyAssociationStoreContract))]
public interface IRelyingPartyAssociationStore {
///
/// Saves an for later recall.
///
/// The OP Endpoint with which the association is established.
/// The association to store.
///
/// If the new association conflicts (in OP endpoint and association handle) with an existing association,
/// (which should never happen by the way) implementations may overwrite the previously saved association.
///
void StoreAssociation(Uri providerEndpoint, Association association);
///
/// Gets the best association (the one with the longest remaining life) for a given key.
///
/// The OP Endpoint with which the association is established.
/// The security requirements that the returned association must meet.
///
/// The requested association, or null if no unexpired s exist for the given key.
///
///
/// In the event that multiple associations exist for the given
/// , it is important for the
/// implementation for this method to use the
/// to pick the best (highest grade or longest living as the host's policy may dictate)
/// association that fits the security requirements.
/// Associations that are returned that do not meet the security requirements will be
/// ignored and a new association created.
///
Association GetAssociation(Uri providerEndpoint, SecuritySettings securityRequirements);
///
/// Gets the association for a given key and handle.
///
/// The OP Endpoint with which the association is established.
/// The handle of the specific association that must be recalled.
/// The requested association, or null if no unexpired s exist for the given key and handle.
Association GetAssociation(Uri providerEndpoint, string handle);
/// Removes a specified handle that may exist in the store.
/// The OP Endpoint with which the association is established.
/// The handle of the specific association that must be deleted.
///
/// Deprecated. The return value is insignificant.
/// Previously: True if the association existed in this store previous to this call.
///
///
/// No exception should be thrown if the association does not exist in the store
/// before this call.
///
bool RemoveAssociation(Uri providerEndpoint, string handle);
}
///
/// Code Contract for the class.
///
[ContractClassFor(typeof(IRelyingPartyAssociationStore))]
internal abstract class IRelyingPartyAssociationStoreContract : IRelyingPartyAssociationStore {
#region IAssociationStore Members
///
/// Saves an for later recall.
///
/// The Uri (for relying parties) or Smart/Dumb (for providers).
/// The association to store.
///
/// TODO: what should implementations do on association handle conflict?
///
void IRelyingPartyAssociationStore.StoreAssociation(Uri providerEndpoint, Association association) {
Requires.NotNull(providerEndpoint, "providerEndpoint");
Requires.NotNull(association, "association");
throw new NotImplementedException();
}
///
/// Gets the best association (the one with the longest remaining life) for a given key.
///
/// The Uri (for relying parties) or Smart/Dumb (for Providers).
/// The security requirements that the returned association must meet.
///
/// The requested association, or null if no unexpired s exist for the given key.
///
///
/// In the event that multiple associations exist for the given
/// , it is important for the
/// implementation for this method to use the
/// to pick the best (highest grade or longest living as the host's policy may dictate)
/// association that fits the security requirements.
/// Associations that are returned that do not meet the security requirements will be
/// ignored and a new association created.
///
Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, SecuritySettings securityRequirements) {
Requires.NotNull(providerEndpoint, "providerEndpoint");
Requires.NotNull(securityRequirements, "securityRequirements");
throw new NotImplementedException();
}
///
/// Gets the association for a given key and handle.
///
/// The Uri (for relying parties) or Smart/Dumb (for Providers).
/// The handle of the specific association that must be recalled.
///
/// The requested association, or null if no unexpired s exist for the given key and handle.
///
Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, string handle) {
Requires.NotNull(providerEndpoint, "providerEndpoint");
Contract.Requires(!string.IsNullOrEmpty(handle));
throw new NotImplementedException();
}
///
/// Removes a specified handle that may exist in the store.
///
/// The Uri (for relying parties) or Smart/Dumb (for Providers).
/// The handle of the specific association that must be deleted.
///
/// True if the association existed in this store previous to this call.
///
///
/// No exception should be thrown if the association does not exist in the store
/// before this call.
///
bool IRelyingPartyAssociationStore.RemoveAssociation(Uri providerEndpoint, string handle) {
Requires.NotNull(providerEndpoint, "providerEndpoint");
Contract.Requires(!string.IsNullOrEmpty(handle));
throw new NotImplementedException();
}
#endregion
}
}