示例#1
0
		XrdsDocument downloadXrds() {
			var xrdsResponse = UntrustedWebRequest.Request(XrdsUrl);
			XrdsDocument doc = new XrdsDocument(XmlReader.Create(xrdsResponse.ResponseStream));
			if (!doc.IsXrdResolutionSuccessful) {
				throw new OpenIdException(Strings.XriResolutionFailed);
			}
			return doc;
		}
示例#2
0
 public XrdElement(XPathNavigator xrdElement, XrdsDocument parent) :
     base(xrdElement, parent)
 {
 }
示例#3
0
 public XrdElement(XPathNavigator xrdElement, XrdsDocument parent)
     : base(xrdElement, parent)
 {
 }
示例#4
0
 internal override IEnumerable<ServiceEndpoint> Discover()
 {
     List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
     // Attempt YADIS discovery
     DiscoveryResult yadisResult = Yadis.Yadis.Discover(this, IsDiscoverySecureEndToEnd);
     if (yadisResult != null) {
         if (yadisResult.IsXrds) {
             XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
             var xrdsEndpoints = xrds.CreateServiceEndpoints(yadisResult.NormalizedUri);
             // Filter out insecure endpoints if high security is required.
             if (IsDiscoverySecureEndToEnd) {
                 xrdsEndpoints = Util.Where(xrdsEndpoints, se => se.IsSecure);
             }
             endpoints.AddRange(xrdsEndpoints);
         }
         // Failing YADIS discovery of an XRDS document, we try HTML discovery.
         if (endpoints.Count == 0) {
             ServiceEndpoint ep = DiscoverFromHtml(yadisResult.NormalizedUri, yadisResult.ResponseText);
             if (ep != null && (!IsDiscoverySecureEndToEnd || ep.IsSecure)) {
                 endpoints.Add(ep);
             }
         }
     }
     return endpoints;
 }
示例#5
0
文件: Realm.cs 项目: tt/dotnetopenid
 /// <summary>
 /// Searches for an XRDS document at the realm URL, and if found, searches
 /// for a description of a relying party endpoints (OpenId login pages).
 /// </summary>
 /// <param name="allowRedirects">
 /// Whether redirects may be followed when discovering the Realm.
 /// This may be true when creating an unsolicited assertion, but must be
 /// false when performing return URL verification per 2.0 spec section 9.2.1.
 /// </param>
 /// <returns>The details of the endpoints if found, otherwise null.</returns>
 internal IEnumerable<DotNetOpenId.Provider.RelyingPartyReceivingEndpoint> Discover(bool allowRedirects)
 {
     // Attempt YADIS discovery
     DiscoveryResult yadisResult = Yadis.Yadis.Discover(UriWithWildcardChangedToWww, false);
     if (yadisResult != null) {
         if (!allowRedirects && yadisResult.NormalizedUri != yadisResult.RequestUri) {
             // Redirect occurred when it was not allowed.
             throw new OpenIdException(string.Format(CultureInfo.CurrentCulture,
                 Strings.RealmCausedRedirectUponDiscovery, yadisResult.RequestUri));
         }
         if (yadisResult.IsXrds) {
             try {
                 XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
                 return xrds.FindRelyingPartyReceivingEndpoints();
             } catch (XmlException ex) {
                 throw new OpenIdException(Strings.InvalidXRDSDocument, ex);
             }
         }
     }
     return new RelyingPartyReceivingEndpoint[0];
 }
示例#6
0
		internal override IEnumerable<ServiceEndpoint> Discover() {
			List<ServiceEndpoint> endpoints = new List<ServiceEndpoint>();
			// Attempt YADIS discovery
			DiscoveryResult yadisResult = Yadis.Yadis.Discover(this, IsDiscoverySecureEndToEnd);
			if (yadisResult != null) {
				if (yadisResult.IsXrds) {
					XrdsDocument xrds = new XrdsDocument(yadisResult.ResponseText);
					var xrdsEndpoints = xrds.CreateServiceEndpoints(yadisResult.NormalizedUri);
					// Filter out insecure endpoints if high security is required.
					if (IsDiscoverySecureEndToEnd) {
						xrdsEndpoints = Util.Where(xrdsEndpoints, se => se.IsSecure);
					}
					endpoints.AddRange(xrdsEndpoints);
				}
				// Failing YADIS discovery of an XRDS document, we try HTML discovery.
				if (endpoints.Count == 0) {
					ServiceEndpoint ep = DiscoverFromHtml(yadisResult.NormalizedUri, yadisResult.ResponseText);
					if (ep != null) {
						Logger.Debug("HTML discovery found a service endpoint.");
						Logger.Debug(ep);
						if (!IsDiscoverySecureEndToEnd || ep.IsSecure) {
							endpoints.Add(ep);
						} else {
							Logger.Info("Skipping HTML discovered endpoint because it is not secure.");
						}
					} else {
						Logger.Debug("HTML discovery failed to find any endpoints.");
					}
				} else {
					Logger.Debug("Skipping HTML discovery because XRDS contained service endpoints.");
				}
			}
			return endpoints;
		}