public static EncodableResponse CreateAssertion(CheckIdRequest request) { if (request == null) { throw new ArgumentNullException("request"); } if (!request.IsAuthenticated.HasValue) { throw new InvalidOperationException(); } EncodableResponse response = EncodableResponse.PrepareIndirectMessage( request.Protocol, request.ReturnTo, request.AssociationHandle); if (request.IsAuthenticated.Value) { AssertionMessage.CreatePositiveAssertion(response, request.Provider, request.LocalIdentifier, request.ClaimedIdentifier); Logger.InfoFormat("Created positive assertion for {0}.", request.ClaimedIdentifier); } else { AssertionMessage.CreateNegativeAssertion(response, request); Logger.InfoFormat("Created negative assertion for {0}.", request.ClaimedIdentifier); } return(response); }
/// <summary> /// Creates a message that can be sent to a user agent to redirect them to a /// relying party web site complete with authentication information to /// automatically log them into that web site. /// </summary> public static IResponse CreateUnsolicitedAssertion(OpenIdProvider provider, Realm relyingParty, Identifier claimedIdentifier, Identifier localIdentifier) { if (relyingParty == null) { throw new ArgumentNullException("relyingParty"); } if (claimedIdentifier == null) { throw new ArgumentNullException("claimedIdentifier"); } if (localIdentifier == null) { throw new ArgumentNullException("localIdentifier"); } var discoveredEndpoints = new List <RelyingPartyReceivingEndpoint>(relyingParty.Discover(true)); if (discoveredEndpoints.Count == 0) { throw new OpenIdException( string.Format(CultureInfo.CurrentCulture, Strings.NoRelyingPartyEndpointDiscovered, relyingParty.NoWildcardUri)); } var selectedEndpoint = discoveredEndpoints[0]; EncodableResponse message = EncodableResponse.PrepareIndirectMessage( selectedEndpoint.Protocol, selectedEndpoint.RelyingPartyEndpoint, null); CreatePositiveAssertion(message, provider, localIdentifier, claimedIdentifier); return(provider.Encoder.Encode(message)); }