public void AttachAuthorizationResponse(IHostProcessedRequest openIdAuthenticationRequest, string scope)
        {
            Requires.NotNull(openIdAuthenticationRequest, "openIdAuthenticationRequest");
            RequiresEx.ValidState(this.TokenManager is ICombinedOpenIdProviderTokenManager);

            var openidTokenManager = this.TokenManager as ICombinedOpenIdProviderTokenManager;
            IOpenIdMessageExtension response;

            if (scope != null)
            {
                // Generate an authorized request token to return to the relying party.
                string consumerKey      = openidTokenManager.GetConsumerKey(openIdAuthenticationRequest.Realm);
                var    approvedResponse = new AuthorizationApprovedResponse {
                    RequestToken = this.TokenGenerator.GenerateRequestToken(consumerKey),
                    Scope        = scope,
                };
                openidTokenManager.StoreOpenIdAuthorizedRequestToken(consumerKey, approvedResponse);
                response = approvedResponse;
            }
            else
            {
                response = new AuthorizationDeclinedResponse();
            }

            openIdAuthenticationRequest.AddResponseExtension(response);
        }
        private void BuildResponse(IHostProcessedRequest pendingRequest)
        {
            // Look for a Simple Registration request.  When the AXFetchAsSregTransform behavior is turned on
            // in the web.config file as it is in this sample, AX requests will come in as SReg requests.
            var claimsRequest = pendingRequest.GetExtension <ClaimsRequest>();

            if (claimsRequest != null)
            {
                var claimsResponse = claimsRequest.CreateResponse();

                // This simple respond to a request check may be enhanced to only respond to an individual attribute
                // request if the user consents to it explicitly, in which case this response extension creation can take
                // place in the confirmation page action rather than here.
                if (claimsRequest.Email != DemandLevel.NoRequest)
                {
                    claimsResponse.Email = this.User.Identity.Name + "@dotnetopenauth.net";
                }

                pendingRequest.AddResponseExtension(claimsResponse);
            }

            // Look for PAPE requests.
            var papeRequest = pendingRequest.GetExtension <PolicyRequest>();

            if (papeRequest == null)
            {
                return;
            }

            var papeResponse = new PolicyResponse();

            if (papeRequest.MaximumAuthenticationAge.HasValue)
            {
                papeResponse.AuthenticationTimeUtc = this.FormsAuth.SignedInTimestampUtc;
            }

            pendingRequest.AddResponseExtension(papeResponse);
        }
		public void AttachAuthorizationResponse(IHostProcessedRequest openIdAuthenticationRequest, string scope) {
			Requires.NotNull(openIdAuthenticationRequest, "openIdAuthenticationRequest");
			RequiresEx.ValidState(this.TokenManager is ICombinedOpenIdProviderTokenManager);

			var openidTokenManager = this.TokenManager as ICombinedOpenIdProviderTokenManager;
			IOpenIdMessageExtension response;
			if (scope != null) {
				// Generate an authorized request token to return to the relying party.
				string consumerKey = openidTokenManager.GetConsumerKey(openIdAuthenticationRequest.Realm);
				var approvedResponse = new AuthorizationApprovedResponse {
					RequestToken = this.TokenGenerator.GenerateRequestToken(consumerKey),
					Scope = scope,
				};
				openidTokenManager.StoreOpenIdAuthorizedRequestToken(consumerKey, approvedResponse);
				response = approvedResponse;
			} else {
				response = new AuthorizationDeclinedResponse();
			}

			openIdAuthenticationRequest.AddResponseExtension(response);
		}
        public void AttachAuthorizationResponse(IHostProcessedRequest openIdAuthenticationRequest, string scope)
        {
            Contract.Requires(openIdAuthenticationRequest != null);
            Contract.Requires(this.TokenManager is IOpenIdOAuthTokenManager);
            ErrorUtilities.VerifyArgumentNotNull(openIdAuthenticationRequest, "openIdAuthenticationRequest");
            var openidTokenManager = this.TokenManager as ICombinedOpenIdProviderTokenManager;
            ErrorUtilities.VerifyOperation(openidTokenManager != null, OAuthStrings.OpenIdOAuthExtensionRequiresSpecialTokenManagerInterface, typeof(ICombinedOpenIdProviderTokenManager).FullName);

            IOpenIdMessageExtension response;
            if (scope != null) {
                // Generate an authorized request token to return to the relying party.
                string consumerKey = openidTokenManager.GetConsumerKey(openIdAuthenticationRequest.Realm);
                var approvedResponse = new AuthorizationApprovedResponse {
                    RequestToken = this.TokenGenerator.GenerateRequestToken(consumerKey),
                    Scope = scope,
                };
                openidTokenManager.StoreOpenIdAuthorizedRequestToken(consumerKey, approvedResponse);
                response = approvedResponse;
            } else {
                response = new AuthorizationDeclinedResponse();
            }

            openIdAuthenticationRequest.AddResponseExtension(response);
        }