//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OpenId.Provider.Extensions.UI { using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OpenId.Extensions.UI; using DotNetOpenAuth.OpenId.Messages; using DotNetOpenAuth.OpenId.Provider; using DotNetOpenAuth.Xrds; using Validation; /// /// OpenID User Interface extension 1.0 request message. /// /// /// Implements the extension described by: http://wiki.openid.net/f/openid_ui_extension_draft01.html /// This extension only applies to checkid_setup requests, since checkid_immediate requests display /// no UI to the user. /// For rules about how the popup window should be displayed, please see the documentation of /// . /// An RP may determine whether an arbitrary OP supports this extension (and thereby determine /// whether to use a standard full window redirect or a popup) via the /// method. /// public static class UIRequestTools { /// /// Gets the URL of the RP icon for the OP to display. /// /// The realm of the RP where the authentication request originated. /// The host factories. /// The cancellation token. /// /// A sequence of the RP's icons it has available for the Provider to display, in decreasing preferred order. /// /// The icon URL. /// /// This property is automatically set for the OP with the result of RP discovery. /// RPs should set this value by including an entry such as this in their XRDS document. /// /// <Service xmlns="xri://$xrd*($v*2.0)"> /// <Type>http://specs.openid.net/extensions/ui/icon</Type> /// <URI>http://consumer.example.com/images/image.jpg</URI> /// </Service> /// /// public static async Task> GetRelyingPartyIconUrlsAsync(Realm realm, IHostFactories hostFactories, CancellationToken cancellationToken) { Requires.NotNull(realm, "realm"); Requires.NotNull(hostFactories, "hostFactories"); XrdsDocument xrds = await realm.DiscoverAsync(hostFactories, false, cancellationToken); if (xrds == null) { return Enumerable.Empty(); } else { return xrds.FindRelyingPartyIcons(); } } } }