//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OpenId { using System; using System.Collections.Generic; using System.Linq; using System.Text; using DotNetOpenAuth.Xrds; using Validation; /// /// Utility methods for working with XRDS documents. /// internal static class OpenIdXrdsHelper { /// /// Finds the Relying Party return_to receiving endpoints. /// /// The XrdsDocument instance to use in this process. /// A sequence of Relying Party descriptors for the return_to endpoints. /// /// This is useful for Providers to send unsolicited assertions to Relying Parties, /// or for Provider's to perform RP discovery/verification as part of authentication. /// internal static IEnumerable FindRelyingPartyReceivingEndpoints(this XrdsDocument xrds) { Requires.NotNull(xrds, "xrds"); return from service in xrds.FindReturnToServices() from uri in service.UriElements select new RelyingPartyEndpointDescription(uri.Uri, service.TypeElementUris); } /// /// Finds the icons the relying party wants an OP to display as part of authentication, /// per the UI extension spec. /// /// The XrdsDocument to search. /// A sequence of the icon URLs in preferred order. internal static IEnumerable FindRelyingPartyIcons(this XrdsDocument xrds) { Requires.NotNull(xrds, "xrds"); return from xrd in xrds.XrdElements from service in xrd.OpenIdRelyingPartyIcons from uri in service.UriElements select uri.Uri; } /// /// Enumerates the XRDS service elements that describe OpenID Relying Party return_to URLs /// that can receive authentication assertions. /// /// The XrdsDocument instance to use in this process. /// A sequence of service elements. private static IEnumerable FindReturnToServices(this XrdsDocument xrds) { Requires.NotNull(xrds, "xrds"); return from xrd in xrds.XrdElements from service in xrd.OpenIdRelyingPartyReturnToServices select service; } } }