Ejemplo n.º 1
0
    internal static OpenIdProvider CreateProviderForRequest(DotNetOpenId.RelyingParty.IAuthenticationRequest request)
    {
        IResponse relyingPartyAuthenticationRequest = request.RedirectingResponse;
        var       rpWebMessageToOP = (Response)relyingPartyAuthenticationRequest;
        var       rpMessageToOP    = (IndirectMessageRequest)rpWebMessageToOP.EncodableMessage;
        var       opEndpoint       = (ServiceEndpoint)request.Provider;
        var       provider         = new OpenIdProvider(ProviderStore, opEndpoint.ProviderEndpoint,
                                                        opEndpoint.ProviderEndpoint, rpMessageToOP.EncodedFields.ToNameValueCollection());

        return(provider);
    }
Ejemplo n.º 2
0
    internal static IAuthenticationResponse CreateRelyingPartyResponseThroughProvider(
        DotNetOpenId.RelyingParty.IAuthenticationRequest request,
        Action <DotNetOpenId.Provider.IAuthenticationRequest> providerAction)
    {
        var rpReq      = (AuthenticationRequest)request;
        var opResponse = CreateProviderResponseToRequest(rpReq, providerAction);
        // Be careful to use whatever store the original RP was using.
        var rp = CreateRelyingPartyResponse(rpReq.RelyingParty.Store, opResponse,
                                            ((AuthenticationRequest)request).RelyingParty.Settings.RequireSsl);

        Assert.IsNotNull(rp);
        return(rp);
    }
Ejemplo n.º 3
0
    internal static IResponse CreateProviderResponseToRequest(
        DotNetOpenId.RelyingParty.IAuthenticationRequest request,
        Action <DotNetOpenId.Provider.IAuthenticationRequest> prepareProviderResponse)
    {
        {
            // Sidetrack: Verify the return_to and realm URLs
            var      consumerToProviderQuery = HttpUtility.ParseQueryString(request.RedirectingResponse.ExtractUrl().Query);
            Protocol protocol = Protocol.Detect(consumerToProviderQuery.ToDictionary());
            Assert.IsTrue(consumerToProviderQuery[protocol.openid.return_to].StartsWith(request.ReturnToUrl.AbsoluteUri, StringComparison.Ordinal));
            Assert.AreEqual(request.Realm.ToString(), consumerToProviderQuery[protocol.openid.Realm]);
        }

        var op    = TestSupport.CreateProviderForRequest(request);
        var opReq = (DotNetOpenId.Provider.IAuthenticationRequest)op.Request;

        prepareProviderResponse(opReq);
        Assert.IsTrue(opReq.IsResponseReady);
        return(opReq.Response);
    }