//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OpenId.RelyingParty.Behaviors { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Behaviors; using DotNetOpenAuth.OpenId.Extensions; using DotNetOpenAuth.OpenId.Extensions.AttributeExchange; using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; using DotNetOpenAuth.OpenId.RelyingParty; using DotNetOpenAuth.OpenId.RelyingParty.Extensions; /// /// An Attribute Exchange and Simple Registration filter to make all incoming attribute /// requests look like Simple Registration requests, and to convert the response /// to the originally requested extension and format. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sreg", Justification = "Abbreviation")] public sealed class AXFetchAsSregTransform : AXFetchAsSregTransformBase, IRelyingPartyBehavior { /// /// Initializes a new instance of the class. /// public AXFetchAsSregTransform() { } #region IRelyingPartyBehavior Members /// /// Applies a well known set of security requirements to a default set of security settings. /// /// The security settings to enhance with the requirements of this profile. /// /// Care should be taken to never decrease security when applying a profile. /// Profiles should only enhance security requirements to avoid being /// incompatible with each other. /// void IRelyingPartyBehavior.ApplySecuritySettings(RelyingPartySecuritySettings securitySettings) { } /// /// Called when an authentication request is about to be sent. /// /// The request. /// /// Implementations should be prepared to be called multiple times on the same outgoing message /// without malfunctioning. /// void IRelyingPartyBehavior.OnOutgoingAuthenticationRequest(RelyingParty.IAuthenticationRequest request) { // Don't create AX extensions for OpenID 1.x messages, since AX requires OpenID 2.0. if (request.Provider.Version.Major >= 2) { request.SpreadSregToAX(this.AXFormats); } } /// /// Called when an incoming positive assertion is received. /// /// The positive assertion. void IRelyingPartyBehavior.OnIncomingPositiveAssertion(IAuthenticationResponse assertion) { if (assertion.GetExtension() == null) { ClaimsResponse sreg = assertion.UnifyExtensionsAsSreg(true); ((PositiveAnonymousResponse)assertion).Response.Extensions.Add(sreg); } } #endregion } }