summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId.RelyingParty
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-09-18 07:40:02 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-09-18 07:40:02 -0700
commitcfe8dac81872ed4ba425864d550d66abcae581d2 (patch)
tree02908354efecbfb74caaf11538f6852148e74a53 /src/DotNetOpenAuth.OpenId.RelyingParty
parentd36e126e7daa6a0d106fa44692e931d489436bbf (diff)
downloadDotNetOpenAuth-cfe8dac81872ed4ba425864d550d66abcae581d2.zip
DotNetOpenAuth-cfe8dac81872ed4ba425864d550d66abcae581d2.tar.gz
DotNetOpenAuth-cfe8dac81872ed4ba425864d550d66abcae581d2.tar.bz2
All product assemblies build without ccrewrite.exe now.
Diffstat (limited to 'src/DotNetOpenAuth.OpenId.RelyingParty')
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ExtensionsBindingElementRelyingParty.cs4
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/OpenIdRelyingPartyChannel.cs10
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ReturnToNonceBindingElement.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/ExtensionsInteropRelyingPartyHelper.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/UI/UIUtilities.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/HostMetaDiscoveryService.cs42
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/AuthenticationResponseShim.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/ClaimsResponseShim.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateRequestRelyingParty.cs12
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateSuccessfulResponseRelyingPartyContract.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs14
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs6
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs18
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs12
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs52
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs2
-rw-r--r--src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs2
22 files changed, 104 insertions, 104 deletions
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ExtensionsBindingElementRelyingParty.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ExtensionsBindingElementRelyingParty.cs
index 20fc886..099573d 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ExtensionsBindingElementRelyingParty.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ExtensionsBindingElementRelyingParty.cs
@@ -29,8 +29,8 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="securitySettings">The security settings.</param>
internal ExtensionsBindingElementRelyingParty(IOpenIdExtensionFactory extensionFactory, RelyingPartySecuritySettings securitySettings)
: base(extensionFactory, securitySettings, !securitySettings.IgnoreUnsignedExtensions) {
- Contract.Requires<ArgumentNullException>(extensionFactory != null);
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(extensionFactory, "extensionFactory");
+ Requires.NotNull(securitySettings, "securitySettings");
this.relyingPartySecuritySettings = securitySettings;
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/OpenIdRelyingPartyChannel.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/OpenIdRelyingPartyChannel.cs
index 03266ec..4739d84 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/OpenIdRelyingPartyChannel.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/OpenIdRelyingPartyChannel.cs
@@ -27,7 +27,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="securitySettings">The security settings to apply.</param>
internal OpenIdRelyingPartyChannel(ICryptoKeyStore cryptoKeyStore, INonceStore nonceStore, RelyingPartySecuritySettings securitySettings)
: this(cryptoKeyStore, nonceStore, new OpenIdRelyingPartyMessageFactory(), securitySettings, false) {
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(securitySettings, "securitySettings");
}
/// <summary>
@@ -40,9 +40,9 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="nonVerifying">A value indicating whether the channel is set up with no functional security binding elements.</param>
private OpenIdRelyingPartyChannel(ICryptoKeyStore cryptoKeyStore, INonceStore nonceStore, IMessageFactory messageTypeProvider, RelyingPartySecuritySettings securitySettings, bool nonVerifying) :
base(messageTypeProvider, InitializeBindingElements(cryptoKeyStore, nonceStore, securitySettings, nonVerifying)) {
- Contract.Requires<ArgumentNullException>(messageTypeProvider != null);
- Contract.Requires<ArgumentNullException>(securitySettings != null);
- Contract.Requires<ArgumentException>(!nonVerifying || securitySettings is RelyingPartySecuritySettings);
+ Requires.NotNull(messageTypeProvider, "messageTypeProvider");
+ Requires.NotNull(securitySettings, "securitySettings");
+ Requires.True(!nonVerifying || securitySettings is RelyingPartySecuritySettings);
}
/// <summary>
@@ -74,7 +74,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// An array of binding elements which may be used to construct the channel.
/// </returns>
private static IChannelBindingElement[] InitializeBindingElements(ICryptoKeyStore cryptoKeyStore, INonceStore nonceStore, RelyingPartySecuritySettings securitySettings, bool nonVerifying) {
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(securitySettings, "securitySettings");
SigningBindingElement signingElement;
signingElement = nonVerifying ? null : new RelyingPartySigningBindingElement(new CryptoKeyStoreAsRelyingPartyAssociationStore(cryptoKeyStore ?? new MemoryCryptoKeyStore()));
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ReturnToNonceBindingElement.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ReturnToNonceBindingElement.cs
index 3649543..46cd103 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ReturnToNonceBindingElement.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/ChannelElements/ReturnToNonceBindingElement.cs
@@ -83,8 +83,8 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="nonceStore">The nonce store to use.</param>
/// <param name="securitySettings">The security settings of the RP.</param>
internal ReturnToNonceBindingElement(INonceStore nonceStore, RelyingPartySecuritySettings securitySettings) {
- Contract.Requires<ArgumentNullException>(nonceStore != null);
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(nonceStore, "nonceStore");
+ Requires.NotNull(securitySettings, "securitySettings");
this.nonceStore = nonceStore;
this.securitySettings = securitySettings;
@@ -264,7 +264,7 @@ namespace DotNetOpenAuth.OpenId.ChannelElements {
/// <param name="value">The base64-encoded value of the nonce.</param>
/// <returns>The instantiated and initialized nonce.</returns>
internal static CustomNonce Deserialize(string value) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(value));
+ Requires.NotNullOrEmpty(value, "value");
byte[] nonce = MessagingUtilities.FromBase64WebSafeString(value);
Contract.Assume(nonce != null);
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/ExtensionsInteropRelyingPartyHelper.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/ExtensionsInteropRelyingPartyHelper.cs
index 87eca8c..134aa16 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/ExtensionsInteropRelyingPartyHelper.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/ExtensionsInteropRelyingPartyHelper.cs
@@ -37,7 +37,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// </remarks>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sreg", Justification = "Abbreviation")]
public static void SpreadSregToAX(this RelyingParty.IAuthenticationRequest request, AXAttributeFormats attributeFormats) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
var req = (RelyingParty.AuthenticationRequest)request;
var sreg = req.AppliedExtensions.OfType<ClaimsRequest>().SingleOrDefault();
@@ -93,7 +93,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// Never <c>null</c>.</returns>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sreg", Justification = "Abbreviation")]
public static ClaimsResponse UnifyExtensionsAsSreg(this RelyingParty.IAuthenticationResponse response, bool allowUnsigned) {
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(response, "response");
var resp = (RelyingParty.IAuthenticationResponse)response;
var sreg = allowUnsigned ? resp.GetUntrustedExtension<ClaimsResponse>() : resp.GetExtension<ClaimsResponse>();
@@ -143,7 +143,7 @@ namespace DotNetOpenAuth.OpenId.Extensions {
/// <param name="attributeFormat">The attribute formats the RP will try if this discovery fails.</param>
/// <returns>The AX format(s) to use based on the Provider's advertised AX support.</returns>
private static bool TryDetectOPAttributeFormat(RelyingParty.IAuthenticationRequest request, out AXAttributeFormats attributeFormat) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
attributeFormat = ExtensionsInteropHelper.DetectAXFormat(request.DiscoveryResult.Capabilities);
return attributeFormat != AXAttributeFormats.None;
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/UI/UIUtilities.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/UI/UIUtilities.cs
index cee6882..a24aaba 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/UI/UIUtilities.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Extensions/UI/UIUtilities.cs
@@ -34,9 +34,9 @@ namespace DotNetOpenAuth.OpenId.Extensions.UI {
/// <param name="windowName">The name to assign to the popup window.</param>
/// <returns>A string starting with 'window.open' and forming just that one method call.</returns>
internal static string GetWindowPopupScript(OpenIdRelyingParty relyingParty, IAuthenticationRequest request, string windowName) {
- Contract.Requires<ArgumentNullException>(relyingParty != null);
- Contract.Requires<ArgumentNullException>(request != null);
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(windowName));
+ Requires.NotNull(relyingParty, "relyingParty");
+ Requires.NotNull(request, "request");
+ Requires.NotNullOrEmpty(windowName, "windowName");
Uri popupUrl = request.RedirectingResponse.GetDirectUriRequest(relyingParty.Channel);
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/HostMetaDiscoveryService.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/HostMetaDiscoveryService.cs
index 215ea24..6d60030 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/HostMetaDiscoveryService.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/HostMetaDiscoveryService.cs
@@ -158,7 +158,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="xrds">The XRDs to search.</param>
/// <returns>A sequence of services.</returns>
private static IEnumerable<ServiceElement> GetDescribedByServices(IEnumerable<XrdElement> xrds) {
- Contract.Requires<ArgumentNullException>(xrds != null);
+ Requires.NotNull(xrds, "xrds");
Contract.Ensures(Contract.Result<IEnumerable<ServiceElement>>() != null);
var describedBy = from xrd in xrds
@@ -175,9 +175,9 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="requestHandler">The request handler.</param>
/// <returns>The discovered services.</returns>
private static IEnumerable<IdentifierDiscoveryResult> GetExternalServices(IEnumerable<XrdElement> xrds, UriIdentifier identifier, IDirectWebRequestHandler requestHandler) {
- Contract.Requires<ArgumentNullException>(xrds != null);
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(xrds, "xrds");
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
Contract.Ensures(Contract.Result<IEnumerable<IdentifierDiscoveryResult>>() != null);
var results = new List<IdentifierDiscoveryResult>();
@@ -214,9 +214,9 @@ namespace DotNetOpenAuth.OpenId {
/// <exception cref="ProtocolException">Thrown if the XRDS document has an invalid or a missing signature.</exception>
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "XmlDSig", Justification = "xml")]
private static void ValidateXmlDSig(XrdsDocument document, UriIdentifier identifier, IncomingWebResponse response, string signingHost) {
- Contract.Requires<ArgumentNullException>(document != null);
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(document, "document");
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(response, "response");
var signatureNode = document.Node.SelectSingleNode("/xrds:XRDS/ds:Signature", document.XmlNamespaceResolver);
ErrorUtilities.VerifyProtocol(signatureNode != null, OpenIdStrings.MissingElement, "Signature");
@@ -299,9 +299,9 @@ namespace DotNetOpenAuth.OpenId {
/// </returns>
/// <exception cref="ProtocolException">Thrown if the XRDS document could not be obtained.</exception>
private static IncomingWebResponse GetXrdsResponse(UriIdentifier identifier, IDirectWebRequestHandler requestHandler, Uri xrdsLocation) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
- Contract.Requires<ArgumentNullException>(xrdsLocation != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
+ Requires.NotNull(xrdsLocation, "xrdsLocation");
Contract.Ensures(Contract.Result<IncomingWebResponse>() != null);
var request = (HttpWebRequest)WebRequest.Create(xrdsLocation);
@@ -325,8 +325,8 @@ namespace DotNetOpenAuth.OpenId {
/// <returns>A HTTP response carrying an XRDS document, or <c>null</c> if one could not be obtained.</returns>
/// <exception cref="ProtocolException">Thrown if the XRDS document could not be obtained.</exception>
private IncomingWebResponse GetXrdsResponse(UriIdentifier identifier, IDirectWebRequestHandler requestHandler, out string signingHost) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
Uri xrdsLocation = this.GetXrdsLocation(identifier, requestHandler, out signingHost);
if (xrdsLocation == null) {
return null;
@@ -345,8 +345,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="signingHost">The host name on the certificate that should be used to verify the signature in the XRDS.</param>
/// <returns>An absolute URI, or <c>null</c> if one could not be determined.</returns>
private Uri GetXrdsLocation(UriIdentifier identifier, IDirectWebRequestHandler requestHandler, out string signingHost) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
using (var hostMetaResponse = this.GetHostMeta(identifier, requestHandler, out signingHost)) {
if (hostMetaResponse == null) {
return null;
@@ -377,8 +377,8 @@ namespace DotNetOpenAuth.OpenId {
/// The host-meta response, or <c>null</c> if no host-meta document could be obtained.
/// </returns>
private IncomingWebResponse GetHostMeta(UriIdentifier identifier, IDirectWebRequestHandler requestHandler, out string signingHost) {
- Contract.Requires<ArgumentNullException>(identifier != null);
- Contract.Requires<ArgumentNullException>(requestHandler != null);
+ Requires.NotNull(identifier, "identifier");
+ Requires.NotNull(requestHandler, "requestHandler");
foreach (var hostMetaProxy in this.GetHostMetaLocations(identifier)) {
var hostMetaLocation = hostMetaProxy.GetProxy(identifier);
var request = (HttpWebRequest)WebRequest.Create(hostMetaLocation);
@@ -413,7 +413,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="identifier">The identifier.</param>
/// <returns>A sequence of URIs that MAY provide the host-meta for a given identifier.</returns>
private IEnumerable<HostMetaProxy> GetHostMetaLocations(UriIdentifier identifier) {
- Contract.Requires<ArgumentNullException>(identifier != null);
+ Requires.NotNull(identifier, "identifier");
// First try the proxies, as they are considered more "secure" than the local
// host-meta for a domain since the domain may be defaced.
@@ -440,8 +440,8 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="proxyFormat">The proxy formatting string.</param>
/// <param name="signingHostFormat">The signing host formatting string.</param>
public HostMetaProxy(string proxyFormat, string signingHostFormat) {
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(proxyFormat));
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(signingHostFormat));
+ Requires.NotNullOrEmpty(proxyFormat, "proxyFormat");
+ Requires.NotNullOrEmpty(signingHostFormat, "signingHostFormat");
this.ProxyFormat = proxyFormat;
this.SigningHostFormat = signingHostFormat;
}
@@ -469,7 +469,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="identifier">The identifier being discovered.</param>
/// <returns>The an absolute URI.</returns>
public virtual Uri GetProxy(UriIdentifier identifier) {
- Contract.Requires<ArgumentNullException>(identifier != null);
+ Requires.NotNull(identifier, "identifier");
return new Uri(string.Format(CultureInfo.InvariantCulture, this.ProxyFormat, Uri.EscapeDataString(identifier.Uri.Host)));
}
@@ -479,7 +479,7 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="identifier">The identifier being discovered.</param>
/// <returns>A host name.</returns>
public virtual string GetSigningHost(UriIdentifier identifier) {
- Contract.Requires<ArgumentNullException>(identifier != null);
+ Requires.NotNull(identifier, "identifier");
return string.Format(CultureInfo.InvariantCulture, this.SigningHostFormat, identifier.Uri.Host, this.GetProxy(identifier).Host);
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/AuthenticationResponseShim.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/AuthenticationResponseShim.cs
index c0354ac..c0d2b35 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/AuthenticationResponseShim.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/AuthenticationResponseShim.cs
@@ -30,7 +30,7 @@ namespace DotNetOpenAuth.OpenId.Interop {
/// </summary>
/// <param name="response">The response.</param>
internal AuthenticationResponseShim(IAuthenticationResponse response) {
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(response, "response");
this.response = response;
var claimsResponse = this.response.GetExtension<ClaimsResponse>();
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/ClaimsResponseShim.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/ClaimsResponseShim.cs
index 689777b..fa3b874 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/ClaimsResponseShim.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Interop/ClaimsResponseShim.cs
@@ -31,7 +31,7 @@ namespace DotNetOpenAuth.OpenId.Interop {
/// <param name="response">The Simple Registration response to wrap.</param>
internal ClaimsResponseShim(ClaimsResponse response)
{
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(response, "response");
this.response = response;
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateRequestRelyingParty.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateRequestRelyingParty.cs
index 04b39e1..99f1a3e 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateRequestRelyingParty.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateRequestRelyingParty.cs
@@ -27,8 +27,8 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// and the provider OpenID version.
/// </returns>
internal static AssociateRequest Create(SecuritySettings securityRequirements, IProviderEndpoint provider) {
- Contract.Requires<ArgumentNullException>(securityRequirements != null);
- Contract.Requires<ArgumentNullException>(provider != null);
+ Requires.NotNull(securityRequirements, "securityRequirements");
+ Requires.NotNull(provider, "provider");
// Apply our knowledge of the endpoint's transport, OpenID version, and
// security requirements to decide the best association.
@@ -57,10 +57,10 @@ namespace DotNetOpenAuth.OpenId.Messages {
/// and the provider OpenID version.
/// </returns>
internal static AssociateRequest Create(SecuritySettings securityRequirements, IProviderEndpoint provider, string associationType, string sessionType) {
- Contract.Requires<ArgumentNullException>(securityRequirements != null);
- Contract.Requires<ArgumentNullException>(provider != null);
- Contract.Requires<ArgumentException>(!String.IsNullOrEmpty(associationType));
- Contract.Requires<ArgumentNullException>(sessionType != null);
+ Requires.NotNull(securityRequirements, "securityRequirements");
+ Requires.NotNull(provider, "provider");
+ Requires.NotNullOrEmpty(associationType, "associationType");
+ Requires.NotNull(sessionType, "sessionType");
bool unencryptedAllowed = provider.Uri.IsTransportSecure();
if (unencryptedAllowed) {
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateSuccessfulResponseRelyingPartyContract.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateSuccessfulResponseRelyingPartyContract.cs
index 35cb928..c8f8f17 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateSuccessfulResponseRelyingPartyContract.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/Messages/AssociateSuccessfulResponseRelyingPartyContract.cs
@@ -26,7 +26,7 @@ namespace DotNetOpenAuth {
/// The created association.
/// </returns>
Association IAssociateSuccessfulResponseRelyingParty.CreateAssociationAtRelyingParty(AssociateRequest request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs
index d8b8840..eb501c5 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AssociationManager.cs
@@ -42,8 +42,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="associationStore">The association store. May be null for dumb mode relying parties.</param>
/// <param name="securitySettings">The security settings.</param>
internal AssociationManager(Channel channel, IRelyingPartyAssociationStore associationStore, RelyingPartySecuritySettings securitySettings) {
- Contract.Requires<ArgumentNullException>(channel != null);
- Contract.Requires<ArgumentNullException>(securitySettings != null);
+ Requires.NotNull(channel, "channel");
+ Requires.NotNull(securitySettings, "securitySettings");
this.channel = channel;
this.associationStore = associationStore;
@@ -60,7 +60,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
set {
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNull(value, "value");
this.channel = value;
}
}
@@ -74,7 +74,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
set {
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNull(value, "value");
this.securitySettings = value;
}
}
@@ -104,7 +104,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="provider">The provider to create an association with.</param>
/// <returns>The association if one exists and has useful life remaining. Otherwise <c>null</c>.</returns>
internal Association GetExistingAssociation(IProviderEndpoint provider) {
- Contract.Requires<ArgumentNullException>(provider != null);
+ Requires.NotNull(provider, "provider");
// If the RP has no application store for associations, there's no point in creating one.
if (this.associationStore == null) {
@@ -149,7 +149,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// Any new association is automatically added to the <see cref="associationStore"/>.
/// </remarks>
private Association CreateNewAssociation(IProviderEndpoint provider) {
- Contract.Requires<ArgumentNullException>(provider != null);
+ Requires.NotNull(provider, "provider");
// If there is no association store, there is no point in creating an association.
if (this.associationStore == null) {
@@ -183,7 +183,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// the given Provider given the current security settings.
/// </returns>
private Association CreateNewAssociation(IProviderEndpoint provider, AssociateRequest associateRequest, int retriesRemaining) {
- Contract.Requires<ArgumentNullException>(provider != null);
+ Requires.NotNull(provider, "provider");
if (associateRequest == null || retriesRemaining < 0) {
// this can happen if security requirements and protocol conflict
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs
index b171bec..e65750f 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/Associations.cs
@@ -60,7 +60,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="association">The association to add to the collection.</param>
public void Set(Association association) {
- Contract.Requires<ArgumentNullException>(association != null);
+ Requires.NotNull(association, "association");
Contract.Ensures(this.Get(association.Handle) == association);
lock (this.associations) {
this.associations.Remove(association.Handle); // just in case one already exists.
@@ -77,7 +77,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <returns>The desired association, or null if none with the given handle could be found.</returns>
[Pure]
public Association Get(string handle) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(handle));
+ Requires.NotNullOrEmpty(handle, "handle");
lock (this.associations) {
if (this.associations.Contains(handle)) {
@@ -94,7 +94,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="handle">The handle to the required association.</param>
/// <returns>Whether an <see cref="Association"/> with the given handle was in the collection for removal.</returns>
public bool Remove(string handle) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(handle));
+ Requires.NotNullOrEmpty(handle, "handle");
lock (this.associations) {
return this.associations.Remove(handle);
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs
index d79038c..f742a3d 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/AuthenticationRequest.cs
@@ -69,10 +69,10 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="returnToUrl">The base return_to URL that the Provider should return the user to to complete authentication. This should not include callback parameters as these should be added using the <see cref="AddCallbackArguments(string, string)"/> method.</param>
/// <param name="relyingParty">The relying party that created this instance.</param>
private AuthenticationRequest(IdentifierDiscoveryResult discoveryResult, Realm realm, Uri returnToUrl, OpenIdRelyingParty relyingParty) {
- Contract.Requires<ArgumentNullException>(discoveryResult != null);
- Contract.Requires<ArgumentNullException>(realm != null);
- Contract.Requires<ArgumentNullException>(returnToUrl != null);
- Contract.Requires<ArgumentNullException>(relyingParty != null);
+ Requires.NotNull(discoveryResult, "discoveryResult");
+ Requires.NotNull(realm, "realm");
+ Requires.NotNull(returnToUrl, "returnToUrl");
+ Requires.NotNull(relyingParty, "relyingParty");
this.DiscoveryResult = discoveryResult;
this.RelyingParty = relyingParty;
@@ -319,9 +319,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// Never null, but may be empty.
/// </returns>
internal static IEnumerable<AuthenticationRequest> Create(Identifier userSuppliedIdentifier, OpenIdRelyingParty relyingParty, Realm realm, Uri returnToUrl, bool createNewAssociationsAsNeeded) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<ArgumentNullException>(relyingParty != null);
- Contract.Requires<ArgumentNullException>(realm != null);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.NotNull(relyingParty, "relyingParty");
+ Requires.NotNull(realm, "realm");
Contract.Ensures(Contract.Result<IEnumerable<AuthenticationRequest>>() != null);
// Normalize the portion of the return_to path that correlates to the realm for capitalization.
@@ -496,8 +496,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="relyingParty">The relying party.</param>
/// <returns>A filtered and sorted list of endpoints; may be empty if the input was empty or the filter removed all endpoints.</returns>
private static List<IdentifierDiscoveryResult> FilterAndSortEndpoints(IEnumerable<IdentifierDiscoveryResult> endpoints, OpenIdRelyingParty relyingParty) {
- Contract.Requires<ArgumentNullException>(endpoints != null);
- Contract.Requires<ArgumentNullException>(relyingParty != null);
+ Requires.NotNull(endpoints, "endpoints");
+ Requires.NotNull(relyingParty, "relyingParty");
bool anyFilteredOut = false;
var filteredEndpoints = new List<IdentifierDiscoveryResult>();
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs
index 02ed3b0..1614145 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/CryptoKeyStoreAsRelyingPartyAssociationStore.cs
@@ -24,7 +24,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="keyStore">The key store.</param>
internal CryptoKeyStoreAsRelyingPartyAssociationStore(ICryptoKeyStore keyStore) {
- Contract.Requires<ArgumentNullException>(keyStore != null);
+ Requires.NotNull(keyStore, "keyStore");
Contract.Ensures(this.keyStore == keyStore);
this.keyStore = keyStore;
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs
index 682e3ff..b9266d3 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/FailedAuthenticationResponse.cs
@@ -28,7 +28,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="exception">The exception that resulted in the failed authentication.</param>
internal FailedAuthenticationResponse(Exception exception) {
- Contract.Requires<ArgumentNullException>(exception != null);
+ Requires.NotNull(exception, "exception");
this.Exception = exception;
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs
index 21a2c53..52e828c 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/IRelyingPartyAssociationStore.cs
@@ -88,8 +88,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// TODO: what should implementations do on association handle conflict?
/// </remarks>
void IRelyingPartyAssociationStore.StoreAssociation(Uri providerEndpoint, Association association) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentNullException>(association != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNull(association, "association");
throw new NotImplementedException();
}
@@ -111,8 +111,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// ignored and a new association created.
/// </remarks>
Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, SecuritySettings securityRequirements) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
- Contract.Requires<ArgumentNullException>(securityRequirements != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
+ Requires.NotNull(securityRequirements, "securityRequirements");
throw new NotImplementedException();
}
@@ -125,7 +125,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// The requested association, or null if no unexpired <see cref="Association"/>s exist for the given key and handle.
/// </returns>
Association IRelyingPartyAssociationStore.GetAssociation(Uri providerEndpoint, string handle) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
Contract.Requires(!String.IsNullOrEmpty(handle));
throw new NotImplementedException();
}
@@ -143,7 +143,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// before this call.
/// </remarks>
bool IRelyingPartyAssociationStore.RemoveAssociation(Uri providerEndpoint, string handle) {
- Contract.Requires<ArgumentNullException>(providerEndpoint != null);
+ Requires.NotNull(providerEndpoint, "providerEndpoint");
Contract.Requires(!String.IsNullOrEmpty(handle));
throw new NotImplementedException();
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs
index cfbccef..2942c9d 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/ISetupRequiredAuthenticationResponse.cs
@@ -41,7 +41,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
Identifier ISetupRequiredAuthenticationResponse.UserSuppliedIdentifier {
get {
- Contract.Requires<InvalidOperationException>(((IAuthenticationResponse)this).Status == AuthenticationStatus.SetupRequired, OpenIdStrings.OperationOnlyValidForSetupRequiredState);
+ Requires.ValidState(((IAuthenticationResponse)this).Status == AuthenticationStatus.SetupRequired, OpenIdStrings.OperationOnlyValidForSetupRequiredState);
throw new System.NotImplementedException();
}
}
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
index 9e3824d..e6b84f5 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/NegativeAuthenticationResponse.cs
@@ -29,7 +29,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="response">The negative assertion response received by the Relying Party.</param>
internal NegativeAuthenticationResponse(NegativeAssertionResponse response) {
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(response, "response");
this.response = response;
Reporting.RecordEventOccurrence(this, string.Empty);
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs
index d39d2ca..20382b3 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/OpenIdRelyingParty.cs
@@ -114,7 +114,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
// If we are a smart-mode RP (supporting associations), then we MUST also be
// capable of storing nonces to prevent replay attacks.
// If we're a dumb-mode RP, then 2.0 OPs are responsible for preventing replays.
- Contract.Requires<ArgumentException>(cryptoKeyStore == null || nonceStore != null, OpenIdStrings.AssociationStoreRequiresNonceStore);
+ Requires.True(cryptoKeyStore == null || nonceStore != null, null, OpenIdStrings.AssociationStoreRequiresNonceStore);
this.securitySettings = OpenIdElement.Configuration.RelyingParty.SecuritySettings.CreateSecuritySettings();
@@ -195,7 +195,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
set {
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNull(value, "value");
this.channel = value;
this.AssociationManager.Channel = value;
}
@@ -211,7 +211,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
internal set {
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNull(value, "value");
this.securitySettings = value;
this.AssociationManager.SecuritySettings = value;
}
@@ -244,7 +244,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
}
set {
- Contract.Requires<ArgumentNullException>(value != null);
+ Requires.NotNull(value, "value");
this.endpointOrder = value;
}
}
@@ -335,9 +335,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </returns>
/// <exception cref="ProtocolException">Thrown if no OpenID endpoint could be found.</exception>
public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<ArgumentNullException>(realm != null);
- Contract.Requires<ArgumentNullException>(returnToUrl != null);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.NotNull(realm, "realm");
+ Requires.NotNull(returnToUrl, "returnToUrl");
Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null);
try {
return this.CreateRequests(userSuppliedIdentifier, realm, returnToUrl).First();
@@ -368,8 +368,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <exception cref="ProtocolException">Thrown if no OpenID endpoint could be found.</exception>
/// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception>
public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<ArgumentNullException>(realm != null);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.NotNull(realm, "realm");
Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null);
try {
var result = this.CreateRequests(userSuppliedIdentifier, realm).First();
@@ -397,7 +397,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <exception cref="ProtocolException">Thrown if no OpenID endpoint could be found.</exception>
/// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception>
public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
Contract.Ensures(Contract.Result<IAuthenticationRequest>() != null);
try {
return this.CreateRequests(userSuppliedIdentifier).First();
@@ -434,9 +434,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// An empty enumerable is returned instead.</para>
/// </remarks>
public virtual IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<ArgumentNullException>(realm != null);
- Contract.Requires<ArgumentNullException>(returnToUrl != null);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.NotNull(realm, "realm");
+ Requires.NotNull(returnToUrl, "returnToUrl");
Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null);
return AuthenticationRequest.Create(userSuppliedIdentifier, this, realm, returnToUrl, true).Cast<IAuthenticationRequest>().CacheGeneratedResults();
@@ -468,9 +468,9 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </remarks>
/// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception>
public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier, Realm realm) {
- Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<ArgumentNullException>(realm != null);
+ Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.NotNull(realm, "realm");
Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null);
// This next code contract is a BAD idea, because it causes each authentication request to be generated
@@ -516,8 +516,8 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </remarks>
/// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception>
public IEnumerable<IAuthenticationRequest> CreateRequests(Identifier userSuppliedIdentifier) {
- Contract.Requires<ArgumentNullException>(userSuppliedIdentifier != null);
- Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
+ Requires.NotNull(userSuppliedIdentifier, "userSuppliedIdentifier");
+ Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
Contract.Ensures(Contract.Result<IEnumerable<IAuthenticationRequest>>() != null);
return this.CreateRequests(userSuppliedIdentifier, Realm.AutoDetect);
@@ -531,7 +531,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para>
/// </remarks>
public IAuthenticationResponse GetResponse() {
- Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
+ Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
return this.GetResponse(this.Channel.GetRequestFromContext());
}
@@ -541,7 +541,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="httpRequestInfo">The HTTP request that may be carrying an authentication response from the Provider.</param>
/// <returns>The processed authentication response if there is any; <c>null</c> otherwise.</returns>
public IAuthenticationResponse GetResponse(HttpRequestInfo httpRequestInfo) {
- Contract.Requires<ArgumentNullException>(httpRequestInfo != null);
+ Requires.NotNull(httpRequestInfo, "httpRequestInfo");
try {
var message = this.Channel.ReadFromRequest(httpRequestInfo);
PositiveAssertionResponse positiveAssertion;
@@ -584,7 +584,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para>
/// </remarks>
public OutgoingWebResponse ProcessResponseFromPopup() {
- Contract.Requires<InvalidOperationException>(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
+ Requires.ValidState(HttpContext.Current != null && HttpContext.Current.Request != null, MessagingStrings.HttpContextRequired);
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
return this.ProcessResponseFromPopup(this.Channel.GetRequestFromContext());
@@ -596,7 +596,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="request">The incoming HTTP request that is expected to carry an OpenID authentication response.</param>
/// <returns>The HTTP response to send to this HTTP request.</returns>
public OutgoingWebResponse ProcessResponseFromPopup(HttpRequestInfo request) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
return this.ProcessResponseFromPopup(request, null);
@@ -614,7 +614,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </remarks>
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "By design")]
public void RegisterClientScriptExtension<T>(string propertyName) where T : IClientScriptExtensionResponse {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(propertyName));
+ Requires.NotNullOrEmpty(propertyName, "propertyName");
ErrorUtilities.VerifyArgumentNamed(!this.clientScriptExtensions.ContainsValue(propertyName), "propertyName", OpenIdStrings.ClientScriptExtensionPropertyNameCollision, propertyName);
foreach (var ext in this.clientScriptExtensions.Keys) {
ErrorUtilities.VerifyArgument(ext != typeof(T), OpenIdStrings.ClientScriptExtensionTypeCollision, typeof(T).FullName);
@@ -683,7 +683,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </returns>
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "OpenID", Justification = "real word"), SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "iframe", Justification = "Code contracts")]
internal OutgoingWebResponse ProcessResponseFromPopup(HttpRequestInfo request, Action<AuthenticationStatus> callback) {
- Contract.Requires<ArgumentNullException>(request != null);
+ Requires.NotNull(request, "request");
Contract.Ensures(Contract.Result<OutgoingWebResponse>() != null);
string extensionsJson = null;
@@ -740,7 +740,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="identifier">The identifier to discover services for.</param>
/// <returns>A non-null sequence of services discovered for the identifier.</returns>
internal IEnumerable<IdentifierDiscoveryResult> Discover(Identifier identifier) {
- Contract.Requires<ArgumentNullException>(identifier != null);
+ Requires.NotNull(identifier, "identifier");
Contract.Ensures(Contract.Result<IEnumerable<IdentifierDiscoveryResult>>() != null);
IEnumerable<IdentifierDiscoveryResult> results = Enumerable.Empty<IdentifierDiscoveryResult>();
@@ -828,7 +828,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// parameters. (i.e. "callback('arg1', 2)"). No escaping is done by this method.</param>
/// <returns>The entire HTTP response to send to the popup window or iframe to perform the invocation.</returns>
private static OutgoingWebResponse InvokeParentPageScript(string methodCall) {
- Contract.Requires<ArgumentException>(!string.IsNullOrEmpty(methodCall));
+ Requires.NotNullOrEmpty(methodCall, "methodCall");
Logger.OpenId.DebugFormat("Sending Javascript callback: {0}", methodCall);
StringBuilder builder = new StringBuilder();
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs
index fc334b0..de82bed 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAnonymousResponse.cs
@@ -33,7 +33,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="response">The response message.</param>
protected internal PositiveAnonymousResponse(IndirectSignedResponse response) {
- Contract.Requires<ArgumentNullException>(response != null);
+ Requires.NotNull(response, "response");
this.response = response;
if (response.ProviderEndpoint != null && response.Version != null) {
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
index 3e2298c..1123912 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponse.cs
@@ -26,7 +26,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// <param name="relyingParty">The relying party.</param>
internal PositiveAuthenticationResponse(PositiveAssertionResponse response, OpenIdRelyingParty relyingParty)
: base(response) {
- Contract.Requires<ArgumentNullException>(relyingParty != null);
+ Requires.NotNull(relyingParty, "relyingParty");
this.Endpoint = IdentifierDiscoveryResult.CreateForClaimedIdentifier(
this.Response.ClaimedIdentifier,
diff --git a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs
index 80b424a..141b4f7 100644
--- a/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs
+++ b/src/DotNetOpenAuth.OpenId.RelyingParty/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs
@@ -33,7 +33,7 @@ namespace DotNetOpenAuth.OpenId.RelyingParty {
/// </summary>
/// <param name="copyFrom">The authentication response to copy from.</param>
internal PositiveAuthenticationResponseSnapshot(IAuthenticationResponse copyFrom) {
- Contract.Requires<ArgumentNullException>(copyFrom != null);
+ Requires.NotNull(copyFrom, "copyFrom");
this.ClaimedIdentifier = copyFrom.ClaimedIdentifier;
this.FriendlyIdentifierForDisplay = copyFrom.FriendlyIdentifierForDisplay;