//-----------------------------------------------------------------------
//
// 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.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.Extensions.UI;
using DotNetOpenAuth.OpenId.Messages;
using DotNetOpenAuth.OpenId.Provider;
using DotNetOpenAuth.Xrds;
///
/// 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 web request handler to use for discovery.
/// Usually available via OpenIdProvider.Channel.WebRequestHandler.
///
/// 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 IEnumerable GetRelyingPartyIconUrls(Realm realm, IDirectWebRequestHandler webRequestHandler) {
Contract.Requires(realm != null);
Contract.Requires(webRequestHandler != null);
ErrorUtilities.VerifyArgumentNotNull(realm, "realm");
ErrorUtilities.VerifyArgumentNotNull(webRequestHandler, "webRequestHandler");
XrdsDocument xrds = realm.Discover(webRequestHandler, false);
if (xrds == null) {
return Enumerable.Empty();
} else {
return xrds.FindRelyingPartyIcons();
}
}
}
}